Introduction to the RPC framework of hadoop

Source: Internet
Author: User

Why does RPC be introduced:

RPC adopts the Client/Server mode. A request is a client, and a service provider is a server. When we discuss HDFS, communication may occur in:

  • Client-namenode, where namenode is a server
  • Between client-datanode, where datanode is the server
  • Datanode-namenode, where namenode is a server
  • Datanode-datenode, where one datenode is the server and the other is the client

If we consider hadoop's map/reduce, the communication between these systems will be more complicated. To solve these problemsCommunication between clients and serversHadoop introducesRPC framework.

Features of hadoop RPC:

RPC is an application instance of the C/S model in distributed computing. For hadoop, it has the following features:

  • Transparency
  • High Performance
  • Controllability:

Overall hadoop RPC architecture:

Hadoop RPC consists of the serialization layer, function call layer, network transmission layer, and server processing framework.

  • Serialization Layer
    • Serialization is mainly used to convert a structured object into a byte stream for transmission over the network or writing to persistent storage. In the RPC framework, it is mainly usedParametersOrResponseConvertByte streamFor cross-host transmission.
  • Function call Layer
    • The main function of the function call layer is to locate the function to be called and execute the function. hadoop uses the Java reflection mechanism and dynamic proxy to call the function.
  • Network Transmission Layer
    • The Network Transmission Layer describes the message transmission mode between the client and the server. hadoop uses a socket Mechanism Based on TCP/IP.
  • Server Processing Framework
    • The server processing framework can be abstracted as a network I/O processing model. She describes how the client interacts with the server. Her design directly determines the concurrent processing capability of the server. Common network I/O models include blocking I/O, non-blocking I/O, and event-driven I/O, hadoop adopts the event-driven I/O model based on the reactor design model.

How to Use hadooprpc:

Hadooprpc mainly provides two interfaces

  • Public static <t> T getproxy/waitforproxy (class <t> protocol, long clientversion, inetsocketaddress ADDR, configuration Conf, socketfactory factory) throws ioexception;

Used to construct a client proxy object (which implements a Protocol) and send RPC requests to the server.

  • Public static <t> server RPC. Builder (configuration). Build ();

Constructs a Server Object for a protocol (Java Interface) instance for the client to process the sent request.

Generally, hadoop RPC can be divided into four steps:

  1. Define the RPC protocol
  2. Implement RPC
  3. Construct and start the RPC server
  4. Construct an RPC client to send RPC requests concurrently

After the above four steps, we have used hadoop to build a very efficient C/S network model.

Hadoop RPC:

Hadoop RPC consists of RPC, client, and server, which correspond to external programming interfaces, client implementations, and Server implementations respectively.

  1. IPC. RPC analysis.

Main class diagram:

 

  1. IPC. Client analysis.

Send Remote Procedure Call information and receive execution results.

  1. IPC. Server analysis.

 

Introduction to the RPC framework of hadoop

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.