踏着前人的脚印学hadoop——ipc中的Server

时间:2022-03-22 02:51:45

1、An abstract IPC service.  IPC calls take a single {@link Writable} as a parameter, and return a {@link Writable} as their value.  A service runs on a port and is defined by a parameter class and a value class.

2、共有5个内部类ExceptionsHandler,Call,Listener,Responder,Connection,Handler

他需要有一个线程 (Listener)来 accept socket,同时需要一些 Reader线程 来进行 socket 的 read,还有一个 Responder 来进行 socket 的 write,另外,还有若干个 handler线程 来进行业务处理。

3、很多内部属性,位置比较散乱

private final boolean authorize;
private boolean isSecurityEnabled;
private ExceptionsHandler exceptionsHandler = new ExceptionsHandler();

private String bindAddress;
  private int port;                               // port we listen on
  private int handlerCount;                       // number of handler threads
  private int readThreads;                        // number of read threads
  private Class<? extends Writable> paramClass;   // class of call parameters
  private int maxIdleTime;                        // the maximum idle time after  which a client may be disconnected
  private int thresholdIdleConnections;           // the number of idle connections after which we will start cleaning up idle   connections
  int maxConnectionsToNuke;                       // the max number of connections to nuke during a cleanup
  protected RpcInstrumentation rpcMetrics;
  private Configuration conf;
  private SecretManager<TokenIdentifier> secretManager;

private int maxQueueSize;
  private final int maxRespSize;
  private int socketSendBufferSize;
  private final boolean tcpNoDelay; // if T then disable Nagle's Algorithm

volatile private boolean running = true;         // true while server runs
  private BlockingQueue<Call> callQueue; // queued calls

private List<Connection> connectionList =
    Collections.synchronizedList(new LinkedList<Connection>());
  //maintain a list of client connections
  private Listener listener = null;
  private Responder responder = null;
  private int numConnections = 0;
  private Handler[] handlers = null;

4、这个Call和Client里边的Call是不一样的,

A call queued for handling.

private Writable param;                       // the parameter passed
private Connection connection;                // connection to client
private long timestamp;     // the time received when response is null ; the time served when response is not null
private ByteBuffer response;                      // the response for this call

5、Connection

Reads calls from a connection and queues them for handling.

private boolean rpcHeaderRead = false; // if initial rpc header is read
  private boolean headerRead = false;  //if the connection header that follows version is read.

private SocketChannel channel;
  private ByteBuffer data;
  private ByteBuffer dataLengthBuffer;
  private LinkedList<Call> responseQueue;
  private volatile int rpcCount = 0; // number of outstanding rpcs
  private long lastContact;
  private int dataLength;
  private Socket socket;// Cache the remote host & port info so that even if the socket is disconnected, we can say where it used to connect to.
  private String hostAddress;
  private int remotePort;
  private InetAddress addr;
  ConnectionHeader header = new ConnectionHeader();
  Class<?> protocol;
  boolean useSasl;
  SaslServer saslServer;
  private AuthMethod authMethod;
  private boolean saslContextEstablished;
  private boolean skipInitialSaslHandshake;
  private ByteBuffer rpcHeaderBuffer;
  private ByteBuffer unwrappedData;
  private ByteBuffer unwrappedDataLengthBuffer;
 
  UserGroupInformation user = null;
  public UserGroupInformation attemptingUser = null; // user name before auth

// Fake 'call' for failed authorization response
  private final int AUTHROIZATION_FAILED_CALLID = -1;
  private final Call authFailedCall =
    new Call(AUTHROIZATION_FAILED_CALLID, null, this);
  private ByteArrayOutputStream authFailedResponse = new ByteArrayOutputStream();
  // Fake 'call' for SASL context setup
  private static final int SASL_CALLID = -33;
  private final Call saslCall = new Call(SASL_CALLID, null, this);
  private final ByteArrayOutputStream saslResponse = new ByteArrayOutputStream();
 
  private boolean useWrap = false;

6、ExceptionsHandler manages Exception groups for special handling e.g., terse exception group for concise logging messages

7、Handles queued calls .

8、Listens on the socket. Creates jobs for the handler threads

Listener里边有一个内部类,Reader

相应的属性有

private ServerSocketChannel acceptChannel = null; //the accept channel
private Selector selector = null; //the selector that we use for the server
private Reader[] readers = null;
private int currentReader = 0;
private InetSocketAddress address; //the address we bind at
private Random rand = new Random();
private long lastCleanupRunTime = 0; //the last time when a cleanup connec-
                                     //-tion (for idle connections) ran
private long cleanupInterval = 10000; //the minimum interval between
                                      //two cleanup runs
private int backlogLength = conf.getInt("ipc.server.listen.queue.size", 128);
private ExecutorService readPool;

9、Responder

Sends responses of RPC back to clients

相应的属性有

private Selector writeSelector;
    private int pending;         // connections waiting to register
   
    final static int PURGE_INTERVAL = 900000; // 15mins

http://www.cnblogs.com/echomyecho/p/3272238.html

踏着前人的脚印学hadoop——ipc中的Server的更多相关文章

  1. 踏着前人的脚印学hadoop&mdash&semi;&mdash&semi;ipc中的Client

    1.Client有五个内部类,分别是Call,ParallelCall,ParallelResult,Connetion,ConnectionId 其实这五个类就是去完成两件事情的,一件事情是连接,另 ...

  2. 踏着前人的脚印学Hadoop&mdash&semi;&mdash&semi;RPC源码

    A simple RPC mechanism.A protocol  is a Java interface.  All parameters and return types must be one ...

  3. 踏着前人的脚印学Hadoop&mdash&semi;&mdash&semi;结构、重点

    HDFS作为一个分布式文件系统,是所有这些项目的基础.分析好HDFS,有利于了解其他系统.由于Hadoop的HDFS和MapReduce是同一个项目,我们就把他们放在一块,进行分析. 如果把整个had ...

  4. 踏着前人的脚印学Hadoop&mdash&semi;&mdash&semi;序列化,Writerable

    package org.apache.hadoop.io; import java.io.DataOutput;import java.io.DataInput;import java.io.IOEx ...

  5. org&period;apache&period;hadoop&period;ipc&period;RemoteException&lpar;java&period;io&period;IOException&rpar;

    昨晚突然之间mr跑步起来了 jps查看 进程都在的,但是在reduce任务跑了85%的时候会抛异常 异常情况如下: 2016-09-21 21:32:28,538 INFO [org.apache.h ...

  6. Hadoop IPC的代码结构分析

    与IPC相关的代码在org.apache.hadoop.ipc包下.共七个文件,其中4个辅助类: RemoteException Status VersionedProtocol Connection ...

  7. 一张图解释Hadoop IPC

    基于hadoop2.6.2.... 一张图Server启动,Client访问..... RPC是IPC的一种,IPC还有另外一种LPC,相关请看参考中的3 使用hadoop ipc步骤: 1.定义RP ...

  8. 运行基准测试hadoop集群中的问题:org&period;apache&period;hadoop&period;ipc&period;RemoteException&colon; java&period;io&period;IOException&colon; File &sol;benchmarks&sol;TestDFSIO&sol;io&lowbar;data&sol;test&lowbar;

    在master(即:host2)中执行 hadoop jar hadoop-test-1.1.2.jar DFSCIOTest -write -nrFiles 12 -fileSize 10240 - ...

  9. hive运行query语句时提示错误:org&period;apache&period;hadoop&period;ipc&period;RemoteException&colon; java&period;io&period;IOException&colon; java&period;io&period;IOException&colon;

    hive> select product_id, track_time from trackinfo limit 5; Total MapReduce jobs = 1 Launching Jo ...

随机推荐

  1. 关于HTML5的拖拽

    不介绍具体情况,先看API,注意看后面括号的说明 dragstart:拖拽开始(应用于被拖拽对象) drag:拖拽中(应用于被拖拽对象) dragenter:拖拽到指定位置(应用于拖拽目标) drag ...

  2. Scrum不是万能药,要在时机成熟时推行

    敏捷很火热,大家都在谈敏捷:但不是所有团队都适合敏捷! 需要等待时机,时机成熟了,才推! 什么时候算时机成熟呢? 我们的经验是需要两点: 一.团队有三名或以上的研发工程师 : 二. 团队内有一名合适的 ...

  3. List-ApI及详解

    1.API : add(Object o) remove(Object o) clear() indexOf(Object o) get(int i) size() iterator() isEmpt ...

  4. android应用的界面编程----View与ViewGroup的概念

    1 UI OverView Android中所有的UI元素都是通过View与ViewGroup来构建的,View是指屏幕中一块可与用户进行交互的空白,类似于java界面编程中的JPanel.为了界面布 ...

  5. POPTEST老李分享session&comma;cookie的安全性以及区别 2

    四,session和cookie谁更安全 就个人而言,我觉得session更安全一点,我以下几点看法. 1,如果session和cookie一样安全的话,二者就没有并要同时存在了,只要cookie就好 ...

  6. ES6 let const 声明变量 块级作用域

    ES6 中除了使用 var 定义变量,还有let.const,定义变量. function getValue(condition){ console.log(typeof value2); // un ...

  7. 【Java入门提高篇】Day30 Java容器类详解(十二)TreeMap详解

    今天来看看Map家族的另一名大将——TreeMap.前面已经介绍过Map家族的两名大将,分别是HashMap,LinkedHashMap.HashMap可以高效查找和存储元素,LinkedHashMa ...

  8. 【剑指Offer学习】【面试题3 :二维数组中的查找】

    package 二维数组查找; public class Test03 { /** * 在一个二维数组中,每一行都按 package 二维数组查找; public class Test03 { /** ...

  9. Gitlab权限管理

    使用管理员登陆gitlab(版本为8.9)创建一个组 给用户授权 创建新用户 再创建两个dev1和dev2 然后再到项目界面授权给pm授权master 创建库(事先先建一个java组) 设置权限 创建 ...

  10. 配置quartz数据源的三种方式

    如果是使用了JDBC JobStore或JobStoreCMT获得持久的Job时,就要配置相关的数据源了. 方式一:使用quartz.properties文件,这时只需要在property文件中增加如 ...