码迷,mamicode.com
首页 > 其他好文 > 详细

踏着前人的脚印学Hadoop——RPC源码

时间:2015-01-01 10:07:15      阅读:164      评论:0      收藏:0      [点我收藏+]

标签:

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源码

标签:

原文地址:http://www.cnblogs.com/shunliu-java/p/4197047.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!