bamboo.lss
Class Rpc
java.lang.Object
bamboo.util.StandardStage
bamboo.lss.Rpc
- All Implemented Interfaces:
- EventHandlerIF, SingleThreadedEventHandlerIF
public class Rpc
- extends StandardStage
A simple mechanism for associating request and response messages, with
error checking. To use, receivers call register_request_cb(java.lang.Class, bamboo.lss.Rpc.RequestCB, java.lang.Object) to set
the function to be called when a request is received. A sender sends a
request using send_request(ostore.util.NodeId, ostore.util.QuickSerializable, long, java.lang.Class, bamboo.lss.Rpc.ResponseCB, java.lang.Object), which will later result in a call to
supplied callback. This stage will ensure that the response has the type
specified in the call to send_request(ostore.util.NodeId, ostore.util.QuickSerializable, long, java.lang.Class, bamboo.lss.Rpc.ResponseCB, java.lang.Object). To send a response, the
receiving node calls #send_response with the token passed to the
request callback.
|
Constructor Summary |
Rpc()
|
| Methods inherited from class bamboo.util.StandardStage |
BUG, BUG, BUG, config_get_boolean, config_get_double, config_get_int, config_get_string, configGetInt, destroy, dispatch, enqueue, handleEvents, init, lookup_stage, now_ms, timer_ms |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
instance
protected static Rpc instance
next_xact_id
protected long next_xact_id
handlers
protected HashMap handlers
inflight
protected HashMap inflight
known_types
protected HashSet known_types
request_timeout_cb
public ASyncCore.TimerCB request_timeout_cb
Rpc
public Rpc()
ensure_known
protected void ensure_known(Class clazz)
next_xact_id
protected long next_xact_id()
instance
public static Rpc instance()
register_request_cb
public void register_request_cb(Class req_class,
Rpc.RequestCB cb,
Object user_data)
send_request
public void send_request(ostore.util.NodeId dest,
ostore.util.QuickSerializable req,
long timeout_sec,
Class resp_class,
Rpc.ResponseCB cb,
Object user_data)
send_response
public void send_response(ostore.util.QuickSerializable resp,
Object token)
handleEvent
public void handleEvent(QueueElementIF item)
- Specified by:
handleEvent in interface EventHandlerIF- Overrides:
handleEvent in class StandardStage