结合网络上一些牛人的解析文章和0.23.0源码,学习HDFS通信协议。
首先来看基类接口VersionedProtocol。该接口只需要实现一个方法:
public ProtocolSignature getProtocolSignature(String protocol, long clientVersion,int clientMethodsHash) throws IOException;
public class ProtocolSignature implements Writable {
private long version;
private int[] methods = null; // an array of method hash codes
Protocol是对版本号和支持方法HashCode的一个封装。
下面分别看各个协议接口的实现:
1、ClientProtocol