...
- There is a separate class corresponding to each RPC, whose name derives naturally from the name of the corresponding method in RAMCloud::RamCloud. For example, there is a class
RAMCloud::CreateTableRpc
corresponding to thecreateTable
method. - To invoke an RPC asynchronously, construct the corresponding Rpc object such as
RAMCloud::CreateTableRpc
; the constructor arguments are the same as those for the arguments for the synchronous method such ascreateTable. C
onstructing the Rpc object initiates the RPC, but does not wait for it to complete. - Objects such as
RAMCloud::CreateTableRpc
support the following methods:wait
: waits synchronously for the RPC to completeisReady
: tests whether the RPC has completed, without blockingcancel
: aborts the RPC (deleting the object also has this effect)
- Note: RAMCloud RPCs are implemented using a polling approach. This means that asynchronous RPCs will not make progress or complete unless you occasionally invoke the RAMCloud polling mechanism. If you invoke a synchronous RPC, or if you call the
wait
method on an asynchronous Rpc object, the RAMCloud poller will automatically be invoked. However, if your program only callsisReady
to test for completion, then you must also occasionally invoke the RAMCloud poller. If you have created a RamCloud object namedrc
, the following statement will invoke the poller:rc.clientContext->dispatch->poll();
- In addition, you must call the
isReady
method on an Rpc object from time to time to ensure that the RPC "makes progress". Certain actions, such as retrying RPCs after server failures, are invoked only from withinisReady
. - Once
isReady
has returned true for an RPC, you should callwait
to complete the RPC. At this point,wait
is guaranteed not to block. There are two reasons for callingwait
. First, this is the only way to get any results returned by the RPC. Second, if the RPC completed with an error condition, this is the only way to find out about that error:wait
may throw exceptions, butisReady
never throws any exceptions.