RPC主要分为3个部分:(1)交互协议(2)客户端(3)服务端
(1)交互协议
协议:把某些接口和接口中的方法称为协议,客户端和服务端只要实现这些接口中的方法就可以进行通信了
Hadoop RPC中VersionedProtocol是所有协议的父类,只定义了两个方法。
package org.apache.hadoop.ipc; import java.io.IOException; /** * Superclass of all protocols that use Hadoop RPC. * Subclasses of this interface are also supposed to have * a static final long versionID field. */ public interface VersionedProtocol { /** * Return protocol version corresponding to protocol interface. * @param protocol The classname of the protocol interface * @param clientVersion The version of the protocol that the client speaks * @return the version that the server will speak * @throws IOException if any IO error occurs */ public long getProtocolVersion(String protocol, long clientVersion) throws IOException; /** * Return protocol version corresponding to protocol interface. * @param protocol The classname of the protocol interface * @param clientVersion The version of the protocol that the client speaks * @param clientMethodsHash the hashcode of client protocol methods * @return the server protocol signature containing its version and * a list of its supported methods * @see ProtocolSignature#getProtocolSignature(VersionedProtocol, String, * long, int) for a default implementation */ public ProtocolSignature getProtocolSignature(String protocol, long clientVersion, int clientMethodsHash) throws IOException; }
Hadoop RPC中的几个重要的协议
HDFS相关:
ClientDatanodeProtocol :一个客户端和datanode之间的协议接口,用于数据块恢复 ClientProtocol :client与Namenode交互的接口,所有控制流的请求均在这里,如:创建文件、删除文件等; DatanodeProtocol : Datanode与Namenode交互的接口,如心跳、blockreport等; NamenodeProtocol :SecondaryNode与Namenode交互的接口。
MapReduce相关:
InterDatanodeProtocol :Datanode内部交互的接口,用来更新block的元数据; InnerTrackerProtocol :TaskTracker与JobTracker交互的接口,功能与DatanodeProtocol相似;//在hadoop2.6中找不到 JobSubmissionProtocol :JobClient与JobTracker交互的接口,用来提交Job、获得Job等与Job相关的操作;//在hadoop2.6中找不到 TaskUmbilicalProtocol :Task中子进程与母进程交互的接口,子进程即map、reduce等操作,母进程即TaskTracker,该接口可以回报子进程的运行状态(词汇扫盲: umbilical 脐带的, 关系亲密的) 。
时间: 2024-11-25 19:21:41