Implementing Remote Procedure Calls
RPC的概念很简单, 就跟普通procedure call差不多,只不过callee是remote machine而已. 其他的behavior和local procedure call是一样的.
- Caller Machine
- User (user application code module)
- User-Stub
- Caller instance of RPCRuntime (RPC communications package)
- Callee Machine
- Server (server code module)
- Server-stub
- Callee instance of RPCRuntime
- User => Normal procedure call to the corresponding procedure in the user-stub.
- User-stub => Place target specification + procedure arguments in a packet or more and ask RPCRuntime to transmit them.
- RPCRuntime =>Responsible for retransmission, acknowledgments, packet routing, and encryption.
- Server => Contain the server-side modules
- Server-stub => unpack call-packets and prepare ack + results packets and asks RPCRuntime to transmit them.
-
naming(服务类型) : Which interface the caller expect the callee to implement.
-
Service Name (e.g Mail-server)
-
locating(实例, 哪台机器帮我做) : Which particular implementer of an abstract interface is desired.
-
Machine Address (e.g Specific mail-server address)
有时候我们不想实先决定选哪台机器(比如有时候我们甚至还不知道哪些机器可以提供这些服务,很多情况是这样的,所以需要动态请求)
Grapevine Database�我感觉和CA差不多,就是有一个trusted的third party,可以告诉我谁谁谁值得信赖啥的. 你请求某个service(邮件服务), Grapevine Database会告诉你哪台机器提供了这个服务. 做你们的协调者.
- ExportInterface=> is given interface name(type, instance) and a procedure (dispatcher)
- Dispatcher => implemented in the server-stub to handle incoming calls for the interface.
- ExportInterface => calls Grapevine database and ensures that instance is one of the type members, and the connect-site of the instance is the address of the exporting machine
- RPCRuntime Table => Interface name, Dispatcher procedure from server-stub, Unique Identifier, and table index
- Unique Identifier => Has a successive counter, initiated to 1-second-realtime clock, and guaranteed to be less than the current value of that clock
- user code call user-stub
- user-stub calls ImportInterface(Interface type and instance) procedure, in RPCRuntime
- RPCRuntime asks Grapevine database for the interface exporter’s connect-site (NT Address)
- Importer machine’s RPCRuntime makes a remote procedure call to RPCRuntime on the exporter machine. Asking for binding information.
- The table maintained by the Exporter’s RPCRuntime yields the corresponding UID,TableIndex,
- Then the exporter NT address, UID, and TableIndex remembered by the user-stub
- Google RPC
- Protocal Buffers
- JSON-RPC
- XML-RPC
- SOAP
- 还有Apache Thrift(Hbase中就用了Thrift提供远程调用的接口)