To learn the client of HADOOP--IPC in the footsteps of his predecessors.

Source: Internet
Author: User
Tags pings

1, the client has five internal classes, respectively, is Call,parallelcall,parallelresult,connetion,connectionid

In fact, these five classes are to accomplish two things, one thing is connected, the other thing is called, and the connection is mainly through the connection to complete, ConnectionID is its auxiliary class. Calls, call-based, because it will be at the same time and Namenode and other datanode communication, so need a parallelcall to complete the matter, the call is finished there is always a return value it, so to have parallelresult this class.

2, first see ConnectionID

This class holds the address and the user ticket. The client connections to servers is uniquely identified by <remoteaddress, protocol, ticket> This is the source of the explanation,

Below there are 10 attributes, the core is Address,ticket,protocol, connection related to have Rpctimeout,serverprincipal,maxidletime,connectionretrypolicy, Tcpnodelay,pinginterval

The Nagle algorithm, named after his inventor John Nagle, is used to automatically connect many small buffer messages, a process called nagling that increases the efficiency of the network software system by reducing the number of packets that must be sent. The Nagle algorithm usually adds two lines of code to the TCP program, allowing the sender to send the data to the cache when unconfirmed data is sent. Any data is then continued until a significant data confirmation is obtained or until a certain amount of data has been saved to the contract.

    inetsocketaddress address;
     Usergroupinformation ticket;
     class<?> Protocol;
     private static final int PRIME = 16777619;//This guy just used a bit of hashcode inside.
      private int rpctimeout;
     private String serverprincipal;
     private int maxidletime;//connections'll be culled if it is idle for maxidletime MSECS
     private final Retrypolicy connectionretrypolicy;
     Private Boolean tcpnodelay;//If T then disable Nagle ' s algorithm
   & nbsp private int pinginterval; How often sends pings the server in Msecs
3, look again at connection,

Thread that reads responses and notifies callers.  Each connection owns a sockets connected to a remote address. Calls is multiplexed through this socket:responses is delivered out of order.

This guy inherits the thread. This class, mainly read the corresponding notification callers, each connection maintains a connection to the remote. Call-time multiplexing: response is not ordered?

Inside also contains an inner class Pinginputstream

This class sends a pings the remote side when timeout is on reading. If No failure is detected, it retries until at least a-byte is read.

If no failure is detected, it will persist to retry until the last byte is read
Private class Pinginputstream extends FilterInputStream {}

The following properties

Private inetsocketaddress server; Server Ip:port, this connectionid inside has
Private String Serverprincipal; Server ' s KRB5 Principal name Kerberos This is a secure authentication system, and if it fails it will be used SASL: Simple Authentication and security layer (easy authentication and secure layers), simple authentication and security layer, simple authentication and security layer?
Private Connectionheader header; Connection Header
Private final ConnectionID Remoteid; Connection ID
Private Authmethod Authmethod; Authentication method
Private Boolean USESASL;
Private token<? extends tokenidentifier> token;
Private Saslrpcclient saslrpcclient;

Private socket socket = NULL; Connected socket
Private DataInputStream in;
Private DataOutputStream out;

Here are a few connectionid inside
private int rpctimeout;
private int maxidletime; Connections'll be culled if it is idle for maxidletime msecs
Private final Retrypolicy Connectionretrypolicy;
Private Boolean Tcpnodelay; If T then disable Nagle ' s algorithm
private int pinginterval; How often sends pings to the server in msecs


Currently active calls, the concurrency of these few to note that they are not very familiar with, I have not seen before the exception defined as a property variable
Private Hashtable<integer, call> calls = new Hashtable<integer, call> ();
Private Atomiclong lastactivity = new Atomiclong ();//Last I/O activity time
Private Atomicboolean shouldcloseconnection = new Atomicboolean (); Indicate if the connection is closed
Private IOException closeexception; Close Reason

4, the top of the calls inside appeared call this class,

A call waiting for a value.

This simple, 5 attributes, respectively, ID, parameter, return value, exception, end flag bit, usually we a method call is just a parameter list, return value, exception, but this adds an ID and end flag bit done.

int id; Call ID
writable param; Parameter
writable value; Value, NULL if error
IOException error; exception, NULL if value
Boolean done; True when the call was done

5, look at this Parallelcall

Call implementation used for parallel calls.

This inside is two attributes, of course it inherits the property of call to temporarily ignore

Private parallelresults results;
private int index;
6, above the first attribute parallelresults, look at this inner class

Result collector for parallel calls.

Three properties, also very simple

Private writable[] values;//store the value
private int size;//if (count = = size) notify (); If all values is in and then notify waiting caller
private int count; Count it

HADOOP--IPC the client in the footsteps of his predecessors

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.