首页 > 代码库 > 踏着前人的脚印学Hadoop——RPC源码
踏着前人的脚印学Hadoop——RPC源码
A simple RPC mechanism.A protocol is a Java interface. All parameters and return types must be one of:a primitive type(这个注意是9个基本类型,包括void),a String ; or a Writable or an array of the above types All methods in the protocol should throw only IOException. No field data of the protocol instance is transmitted.
1、这个RPC有5个内部类。
分别是ClientCache,Invocation,Invoker,Server,VersionMismatch。
更奇葩的是它的构造器是私有的。
2、Invocation
A method invocation, including the method name and its parameters
private String methodName;
private Class[] parameterClasses;
private Object[] parameters;
private Configuration conf;
3、ClientCache
Cache a client using its socket factory as the hash key
private Map<SocketFactory, Client> clients =new HashMap<SocketFactory, Client>();
4、Invoker
private Client.ConnectionId remoteId;
private Client client;
private boolean isClosed = false;
5、VersionMismatch
private String interfaceName;the name of the protocol mismatch 不协调,不搭配
private long clientVersion; the client‘s version of the protocol
private long serverVersion;the server‘s version of the protocol
Get the client‘s preferred version
Get the server‘s agreed to version.
6、Server
An RPC Server.
public static class Server extends org.apache.hadoop.ipc.Server
private Object instance;
private boolean verbose;
踏着前人的脚印学Hadoop——RPC源码