Hadoop IPC分析 (基于v0.1.0)
Client类逻辑上为单例,仅可能由RPC.getProxy()或RPC.call()创建。
使用方法如下,Client被封装在getProxy()方法内部,对业务透明。
XXXProtocol xxx = (XXXProtocol) RPC.getProxy(XXXProtocol.class,
new InetSocketAddress(port), conf);
xxx.xxx();
RPC.getProxy()方法通过代理方式调用Client.call(),参见以下code。
Proxy.newProxyInstance(protocol.getClassLoader(),
new Class[] { protocol },
new Invoker(addr, conf));
public Object invoke(Object proxy, Method method, Object[] args)
throws Throwable {
ObjectWritable