Hadoop RPC protocol description--转

原文地址:https://spotify.github.io/snakebite/hadoop_rpc.html

Snakebite currently implements the following protocol in snakebite.channel.SocketRpcChannel to communicate with the NameNode.

Connection

The Hadoop RPC protocol works as described below. On connection, headers are sent to setup a session. After that, multiple requests can be sent within the session.

Function Type Default
Header bytes “hrpc”
Version uint8 7
Auth method uint8 80 (Auth method SIMPLE)
Serialization type uint8 0 (protobuf)
IpcConnectionContextProto length uint32  
IpcConnectionContextProto bytes  

Sending messages

When sending a message, the following is sent to the sever:

Function Type
Length of the next two parts uint32
RpcPayloadHeaderProto length varint
RpcPayloadHeaderProto protobuf serialized message
HadoopRpcRequestProto length varint
HadoopRpcRequestProto protobuf serialized message

varint is a Protocol Buffer variable int.

Note

The Java protobuf implementation uses writeToDelimited to prepend the message with their lenght, but the python implementation doesn’t implement such a method (yet).

Next to an rpcKind (snakebites default is RPC_PROTOCOL_BUFFER), an rpcOp (snakebites default isRPC_FINAL_PAYLOAD), the RpcPayloadHeaderProto message defines a callId that is added in the RPC response (described below).

The HadoopRpcRequestProto contains a methodName field that defines what server method is called and a has a property request that contains the serialized actual request message.

Receiving messages

After a message is sent, the response can be read in the following way:

Function Type
Length of the RpcResponseHeaderProto varint
RpcResponseHeaderProto bytes
Length of the RPC response uint32
Serialized RPC response bytes

The RpcResponseHeaderProto contains the callId of the request and a status field. The status can beSUCCESSERROR or FAILURE. In case SUCCESS the rest of response is a complete protobuf response.

In case of ERROR, the response looks like follows:

Function Type
Length of the RpcResponseHeaderProto varint
RpcResponseHeaderProto bytes
Length of the RPC response uint32
Length of the Exeption class name uint32
Exception class name utf-8 string
Length of the stack trace uint32
Stack trace utf-8 string
时间: 2024-07-29 09:19:16

Hadoop RPC protocol description--转的相关文章

Hadoop基于Protocol Buffer的RPC实现代码分析-Server端--转载

原文地址:http://yanbohappy.sinaapp.com/?p=110 最新版本的Hadoop代码中已经默认了Protocol buffer(以下简称PB,http://code.google.com/p/protobuf/)作为RPC的默认实现,原来的WritableRpcEngine已经被淘汰了.来自cloudera的Aaron T. Myers在邮件中这样说的“since PB can provide support for evolving protocols in a co

Hadoop 自定义RPC protocol

RPC的全称为远程过程调用.由于Hadoop是一个分布式系统,因此底层的通信库也就必须实现RPC的基础功能.Hadoop RPC 在整个hadoop中扮演着底层通信模块的角色,举例而言NN和DN.AM和RM之间的通信和协调都是Hadoop RPC来完成的.熟悉使用Hadoop RPC可以加深我们对Hadoop各个模块之间通信过程的理解,也能让我们实现一些自己想要的分布式的小功能. 很多Hadoop相关书籍中都详细介绍了Hadoop RPC,其具体原理大家有兴趣的话可以去看源码加深理解.不过,我觉

Hadoop RPC简单例子

jdk中已经提供了一个RPC框架-RMI,但是该PRC框架过于重量级并且可控之处比较少,所以Hadoop RPC实现了自定义的PRC框架. 同其他RPC框架一样,Hadoop RPC分为四个部分: (1)序列化层:Clent与Server端通信传递的信息采用了Hadoop里提供的序列化类或自定义的Writable类型: (2)函数调用层:Hadoop RPC通过动态代理以及java反射实现函数调用: (3)网络传输层:Hadoop RPC采用了基于TCP/IP的socket机制: (4)服务器端

Hadoop RPC

第一部分:什么是RPC RPC (Remote Procedure Call Protocol) – 远程过程协议调用 .通过 RPC 我们可以从网络上的计算机请求服务,而不需要了 解底层网络协议. Hadoop 底层的交互都是通过 rpc 进行的.例 如: datanode 和 namenode . tasktracker 和 jobtracker . secondary namenode 和 namenode 之间的通信都是通过 rpc 实 现的. RPC 模式 RPC 采用客户机 / 服务

Hadoop RPC通信Client客户端的流程分析

Hadoop的RPC的通信与其他系统的RPC通信不太一样,作者针对Hadoop的使用特点,专门的设计了一套RPC框架,这套框架个人感觉还是有点小复杂的.所以我打算分成Client客户端和Server服务端2个模块做分析.如果你对RPC的整套流程已经非常了解的前提下,对于Hadoop的RPC,你也一定可以非常迅速的了解的.OK,下面切入正题. Hadoop的RPC的相关代码都在org.apache.hadoop.ipc的包下,首先RPC的通信必须遵守许多的协议,其中最最基本的协议即使如下: /**

Hadoop RPC远程过程调用源码解析及实例

什么是RPC? 1.RPC(Remote Procedure Call)远程过程调用,它允许一台计算机程序远程调用另外一台计算机的子程序,而不用去关心底层的网络通信细节,对我们来说是透明的.经常用于分布式网络通信中. 2.Hadoop的进程间交互都是通过RPC来进行的,比如Namenode与Datanode之间,Jobtracker与Tasktracker之间等. RPC协议假定某些传输协议的存在,如TCP或UDP,为通信程序之间携带信息数据.在OSI网络通信模型中, RPC跨越了传输层和应用层

每天收获一点点------Hadoop RPC机制的使用

一.RPC基础概念 1.1 RPC的基础概念 RPC,即Remote Procdure Call,中文名:远程过程调用: (1)它允许一台计算机程序远程调用另外一台计算机的子程序,而不用去关心底层的网络通信细节,对我们来说是透明的.因此,它经常用于分布式网络通信中. RPC协议假定某些传输协议的存在,如TCP或UDP,为通信程序之间携带信息数据.在OSI网络通信模型中,RPC跨越了传输层和应用层.RPC使得开发包括网络分布式多程序在内的应用程序更加容易. (2)Hadoop的进程间交互都是通过R

Hadoop RPC通信Server端的流程分析

前2天刚刚小小的分析下Client端的流程,走的还是比较通顺的,但是RPC的服务端就显然没有那么简单了,毕竟C-S这种模式的,压力和重点都是放在Server端的,所以我也只能做个大概的分析,因为里面细节的东西太多,我也不可能理清所有细节,但是我会集合源代码把主要的流程理理清.如果读者想进一步学习的话,可自行查阅源码. Server服务端和Client客户端在某些变量的定义上还是一致的,比如服务端也有Call,和Connection,这个很好理解,Call回调,和Connection连接是双向的.

Hadoop RPC框架

1.RPC框架概述 1.1 RPC(Remote Procedure Call Protocol)--远程过程调用协议,它是一种通过网络从远程计算机程序上请求服务,而不需要了解底层网络技术的协议.RPC协议假定某些传输协议的存在,如TCP或UDP,为通信程序之间携带信息数据.在OSI网络通信模型中,RPC跨越了传输层和应用层.RPC使得开发包括网络分布式多程序在内的应用程序更加容易. 1.2 RPC通常采用客户端服务器模型,其框架主要有以下几部分 通信模块:实现请求应该协议.主要分为同步方式和异