#include <BaseRpc.h>

Public Member Functions | |
| BaseRpc () | |
| const NodeHandle & | getThisNode () |
| Returns the NodeHandle of this node. | |
Protected Member Functions | |
| virtual bool | internalHandleRpcCall (BaseCallMessage *msg) |
| Handles internal rpc requests. | |
| virtual void | internalHandleRpcResponse (BaseResponseMessage *msg, cPolymorphic *context, int rpcId, simtime_t rtt) |
| Handles rpc responses internal in base classes . | |
| virtual void | internalHandleRpcTimeout (BaseCallMessage *msg, const TransportAddress &dest, cPolymorphic *context, int rpcId, const OverlayKey &destKey) |
| Handles rpc timeouts internal in base classes . | |
| void | initRpcs () |
| Initializes Remote-Procedure state. | |
| void | finishRpcs () |
| Deinitializes Remote-Procedure state. | |
| virtual void | internalHandleRpcMessage (BaseRpcMessage *msg) |
| Handles incoming rpc messages and delegates them to the corresponding listeners or handlers. | |
| uint32_t | sendRouteRpcCall (CompType destComp, const TransportAddress &dest, const OverlayKey &destKey, BaseCallMessage *msg, cPolymorphic *context=NULL, RoutingType routingType=DEFAULT_ROUTING, simtime_t timeout=-1, int retries=0, int rpcId=-1, RpcListener *rpcListener=NULL) |
| Routes a Remote-Procedure-Call message to an OverlayKey. | |
| uint32_t | sendRouteRpcCall (CompType destComp, const OverlayKey &destKey, BaseCallMessage *msg, cPolymorphic *context=NULL, RoutingType routingType=DEFAULT_ROUTING, simtime_t timeout=-1, int retries=0, int rpcId=-1, RpcListener *rpcListener=NULL) |
| Routes a Remote-Procedure-Call message to an OverlayKey. | |
| uint32_t | sendRouteRpcCall (CompType destComp, const TransportAddress &dest, BaseCallMessage *msg, cPolymorphic *context=NULL, RoutingType routingType=DEFAULT_ROUTING, simtime_t timeout=-1, int retries=0, int rpcId=-1, RpcListener *rpcListener=NULL) |
| Sends a Remote-Procedure-Call message using the overlay's UDP port This replaces ROUTE_DIRECT calls! | |
| uint32_t | sendUdpRpcCall (const TransportAddress &dest, BaseCallMessage *msg, cPolymorphic *context=NULL, simtime_t timeout=-1, int retries=0, int rpcId=-1, RpcListener *rpcListener=NULL) |
| Sends a Remote-Procedure-Call message to the underlay . | |
| uint32_t | sendInternalRpcCall (CompType destComp, BaseCallMessage *msg, cPolymorphic *context=NULL, simtime_t timeout=-1, int retries=0, int rpcId=-1, RpcListener *rpcListener=NULL) |
| Sends an internal Remote-Procedure-Call between two tiers . | |
| void | cancelRpcMessage (uint32_t nonce) |
| Cancels a Remote-Procedure-Call. | |
| void | cancelAllRpcs () |
| Cancels all RPCs. | |
| void | sendRpcResponse (TransportType transportType, CompType destComp, const TransportAddress &dest, const OverlayKey &destKey, BaseCallMessage *call, BaseResponseMessage *response) |
| Send Remote-Procedure response message and deletes call message. | |
| void | sendRpcResponse (BaseCallMessage *call, BaseResponseMessage *response) |
| Send Remote-Procedure response message to UDP and deletes call message. | |
| void | pingNode (const TransportAddress &dest, simtime_t timeout=-1, int retries=0, cPolymorphic *context=NULL, const char *caption="PING", RpcListener *rpcListener=NULL, int rpcId=-1, TransportType transportType=INVALID_TRANSPORT) |
| ping a node by its TransportAddress | |
| virtual bool | handleRpcCall (BaseCallMessage *msg) |
| Processes Remote-Procedure-Call invocation messages. | |
| virtual CompType | getThisCompType ()=0 |
| Return the component type of this module. | |
| virtual void | sendMessageToUDP (const TransportAddress &addr, cPacket *message) |
| virtual void | pingResponse (PingResponse *pingResponse, cPolymorphic *context, int rpcId, simtime_t rtt) |
| virtual void | pingTimeout (PingCall *pingCall, const TransportAddress &dest, cPolymorphic *context, int rpcId) |
| bool | internalHandleMessage (cMessage *msg) |
Protected Attributes | |
| NodeHandle | thisNode |
| NodeHandle to this node. | |
| BaseOverlay * | overlay |
| bool | debugOutput |
| debug output ? | |
| GlobalStatistics * | globalStatistics |
| pointer to GlobalStatistics module in this node | |
| CompType | thisCompType |
| NeighborCache * | neighborCache |
| pointer to the neighbor cache | |
| CryptoModule * | cryptoModule |
| pointer to CryptoModule | |
| int | numPingSent |
| int | bytesPingSent |
| int | numPingResponseSent |
| int | bytesPingResponseSent |
Private Types | |
| typedef UNORDERED_MAP< int, RpcState > | RpcStates |
Private Member Functions | |
| virtual void | handleTimerEvent (cMessage *msg) |
| uint32_t | sendRpcCall (TransportType transportType, CompType destComp, const TransportAddress &dest, const OverlayKey &destKey, BaseCallMessage *msg, cPolymorphic *context, RoutingType routingType, simtime_t timeout, int retries, int rpcId, RpcListener *rpcListener) |
| Sends a Remote-Procedure-Call message to the underlay. | |
| void | sendRpcMessageWithTransport (TransportType transportType, CompType destComp, RoutingType routingType, const std::vector< TransportAddress > &sourceRoute, const OverlayKey &destKey, BaseRpcMessage *message) |
| virtual void | internalSendRouteRpc (BaseRpcMessage *message, const OverlayKey &destKey, const std::vector< TransportAddress > &sourceRoute, RoutingType routingType)=0 |
| virtual void | internalSendRpcResponse (BaseCallMessage *call, BaseResponseMessage *response)=0 |
| void | pingRpcCall (PingCall *call) |
| void | pingRpcResponse (PingResponse *response, cPolymorphic *context, int rpcId, simtime_t rtt) |
| void | pingRpcTimeout (PingCall *pingCall, const TransportAddress &dest, cPolymorphic *context, int rpcId) |
Private Attributes | |
| int | rpcsPending |
| RpcListener * | defaultRpcListener |
| RpcStates | rpcStates |
| simtime_t | rpcUdpTimeout |
| simtime_t | rpcKeyTimeout |
| bool | rpcExponentialBackoff |
Base class for RPCs.
Definition at line 59 of file BaseRpc.h.
typedef UNORDERED_MAP<int,RpcState> BaseRpc::RpcStates [private] |
| BaseRpc::BaseRpc | ( | ) |
Definition at line 52 of file BaseRpc.cc.
00053 { 00054 defaultRpcListener = NULL; 00055 neighborCache = NULL; 00056 cryptoModule = NULL; 00057 }
| void BaseRpc::cancelAllRpcs | ( | ) | [protected] |
Cancels all RPCs.
Definition at line 157 of file BaseRpc.cc.
Referenced by Pastry::changeState(), and finishRpcs().
00158 { 00159 // stop all rpcs 00160 for (RpcStates::iterator i = rpcStates.begin(); 00161 i != rpcStates.end(); i++) { 00162 cancelAndDelete(i->second.callMsg); 00163 cancelAndDelete(i->second.timeoutMsg); 00164 delete i->second.dest; 00165 i->second.dest = NULL; 00166 delete i->second.context; 00167 i->second.context = NULL; 00168 } 00169 rpcStates.clear(); 00170 }
| void BaseRpc::cancelRpcMessage | ( | uint32_t | nonce | ) | [protected] |
Cancels a Remote-Procedure-Call.
| nonce | The nonce of the RPC |
Definition at line 274 of file BaseRpc.cc.
Referenced by RecursiveLookup::abortLookup(), XmlRpcInterface::resetConnectionState(), and IterativeLookup::stop().
00275 { 00276 if (rpcStates.count(nonce)==0) 00277 return; 00278 RpcState state = rpcStates[nonce]; 00279 rpcStates.erase(nonce); 00280 cancelAndDelete(state.callMsg); 00281 cancelAndDelete(state.timeoutMsg); 00282 delete state.dest; 00283 state.dest = NULL; 00284 delete state.context; 00285 state.context = NULL; 00286 }
| void BaseRpc::finishRpcs | ( | ) | [protected] |
Deinitializes Remote-Procedure state.
Definition at line 146 of file BaseRpc.cc.
Referenced by BaseApp::~BaseApp(), and BaseOverlay::~BaseOverlay().
00147 { 00148 cancelAllRpcs(); 00149 00150 // delete default rpc listener 00151 if (defaultRpcListener != NULL) { 00152 delete defaultRpcListener; 00153 defaultRpcListener = NULL; 00154 } 00155 }
| virtual CompType BaseRpc::getThisCompType | ( | ) | [protected, pure virtual] |
Return the component type of this module.
This method is overloaded by BaseOverlay/BaseApp and returns the appropriate component type of this module.
Implemented in BaseApp, BaseOverlay, BootstrapList, and NeighborCache.
Referenced by initRpcs(), pingNode(), sendRpcCall(), and sendRpcMessageWithTransport().
| const NodeHandle& BaseRpc::getThisNode | ( | ) | [inline] |
Returns the NodeHandle of this node.
Reimplemented in SimpleGameClient.
Definition at line 71 of file BaseRpc.h.
Referenced by Scribe::addChildToGroup(), BaseApp::callRoute(), Scribe::checkGroupEmpty(), RealWorldTestApp::deliver(), KBRTestApp::deliver(), Scribe::deliverALMDataToGroup(), PastryLeafSet::failedNode(), Scribe::forward(), KBRTestApp::forward(), PastryLeafSet::getBiggestNode(), BootstrapList::getBootstrapNode(), NeighborCache::getProx(), PastryLeafSet::getSmallestNode(), Kademlia::handleBucketRefreshTimerExpired(), BaseApp::handleCommonAPIMessage(), CBRDHT::handleGetCAPIRequest(), CBRDHT::handleGetResponse(), Scribe::handleJoinMessage(), Scribe::handleJoinResponse(), KBRTestApp::handleLookupResponse(), DHT::handleLookupResponse(), CBRDHT::handleLookupResponse(), BootstrapList::handleLookupResponse(), GIASearchApp::handleLowerMessage(), XmlRpcInterface::handleMessage(), BaseApp::handleMessage(), SimMud::handleMove(), SimMud::handleOtherPlayerMove(), Scribe::handlePublishCall(), Scribe::handlePublishResponse(), DHT::handlePutRequest(), CBRDHT::handlePutRequest(), XmlRpcInterface::handleReadyMessage(), P2pns::handleReadyMessage(), IterativePathLookup::handleResponse(), Scribe::handleRpcResponse(), KBRTestApp::handleRpcResponse(), BootstrapList::handleRpcResponse(), SimpleGameClient::handleTimerEvent(), Scribe::handleTimerEvent(), P2pns::handleTimerEvent(), GIASearchApp::handleTimerEvent(), DHT::handleTimerEvent(), CBRDHT::handleTimerEvent(), Scribe::handleUpperMessage(), BaseOverlay::initialize(), SimpleGameClient::initializeApp(), Landmark::initializeApp(), BootstrapList::initializeApp(), BrooseBucket::initializeBucket(), PastryLeafSet::insertLeaf(), BaseOverlay::isMalicious(), BrooseBucket::keyInRange(), XmlRpcInterface::localLookup(), IterativeLookup::lookup(), PastryLeafSet::mergeNode(), BrooseBucket::output(), P2pns::p2pnsRegisterRpc(), BootstrapList::pingResponse(), BootstrapList::pingTimeout(), Kademlia::routingAdd(), Kademlia::routingBucketIndex(), BaseApp::sendMessageToUDP(), sendRpcCall(), sendRpcResponse(), BaseOverlay::setOverlayReady(), Nps::setOwnLayer(), IterativeLookup::start(), Scribe::subscribeToGroup(), Scribe::update(), DHT::update(), and CBRDHT::update().
00071 { return thisNode; };
| bool BaseRpc::handleRpcCall | ( | BaseCallMessage * | msg | ) | [protected, virtual] |
Processes Remote-Procedure-Call invocation messages.
This method should be overloaded when the overlay provides RPC functionality.
Reimplemented in DHT, KBRTestApp, Scribe, CBRDHT, NeighborCache, Broose, oversim::Chord, Kademlia, oversim::Koorde, PubSubLobby, PubSubMMOG, P2pns, and SimMud.
Definition at line 513 of file BaseRpc.cc.
Referenced by internalHandleRpcMessage().
| void BaseRpc::handleTimerEvent | ( | cMessage * | msg | ) | [private, virtual] |
Reimplemented in DHT, GIASearchApp, I3, KBRTestApp, RealWorldTestApp, Scribe, SimpleGameClient, BootstrapList, CBRDHT, NeighborCache, Bamboo, Broose, oversim::Chord, Gia, Kademlia, oversim::Koorde, oversim::Nice, Pastry, PubSubLobby, PubSubMMOG, Quon, Vast, DHTTestApp, P2pns, and SimMud.
Definition at line 86 of file BaseRpc.cc.
Referenced by internalHandleMessage().
| void BaseRpc::initRpcs | ( | ) | [protected] |
Initializes Remote-Procedure state.
Definition at line 92 of file BaseRpc.cc.
Referenced by BaseOverlay::initialize(), and BaseApp::initialize().
00093 { 00094 // set friend modules 00095 globalStatistics = GlobalStatisticsAccess().get(); 00096 00097 rpcUdpTimeout = par("rpcUdpTimeout"); 00098 rpcKeyTimeout = par("rpcKeyTimeout"); 00099 rpcExponentialBackoff = par("rpcExponentialBackoff"); 00100 00101 rpcsPending = 0; 00102 rpcStates.clear(); 00103 00104 defaultRpcListener = new RpcListener(); 00105 00106 //set ping cache 00107 numPingSent = 0; 00108 bytesPingSent = 0; 00109 numPingResponseSent = 0; 00110 bytesPingResponseSent = 0; 00111 00112 WATCH(numPingSent); 00113 WATCH(bytesPingSent); 00114 WATCH(numPingResponseSent); 00115 WATCH(bytesPingResponseSent); 00116 00117 // set overlay pointer 00118 overlay = OverlayAccess().get(this); 00119 00120 // register component 00121 thisCompType = getThisCompType(); 00122 overlay->registerComp(thisCompType, this); 00123 00124 // get pointer to the neighborCache 00125 cModule *mod = getParentModule(); 00126 while (neighborCache == NULL) { 00127 neighborCache = (NeighborCache*)mod->getSubmodule("neighborCache"); 00128 mod = mod->getParentModule(); 00129 if (!mod) 00130 throw cRuntimeError("BaseRpc::initRpc: " 00131 "Module type contains no ping cache!"); 00132 } 00133 00134 // get pointer to the cryptoModule 00135 mod = getParentModule(); 00136 cryptoModule = NULL; 00137 while (cryptoModule == NULL) { 00138 cryptoModule = (CryptoModule*)mod->getSubmodule("cryptoModule"); 00139 mod = mod->getParentModule(); 00140 if (!mod) 00141 throw cRuntimeError("BaseRpc::initRpc: CryptoModule not found!"); 00142 } 00143 }
| bool BaseRpc::internalHandleMessage | ( | cMessage * | msg | ) | [protected] |
Definition at line 59 of file BaseRpc.cc.
Referenced by BaseOverlay::handleMessage(), and BaseApp::handleMessage().
00060 { 00061 // process self-messages and RPC-timeouts 00062 if (msg->isSelfMessage()) { 00063 // process rpc self-messages 00064 BaseRpcMessage* rpcMessage = dynamic_cast<BaseRpcMessage*>(msg); 00065 if (rpcMessage != NULL) { 00066 internalHandleRpcMessage(rpcMessage); 00067 return true; 00068 } 00069 // process all other self-messages 00070 handleTimerEvent(msg); 00071 return true; 00072 } 00073 00074 // process RPC messages 00075 BaseRpcMessage* rpcMessage = dynamic_cast<BaseRpcMessage*>(msg); 00076 if (rpcMessage != NULL) { 00077 internalHandleRpcMessage(rpcMessage); 00078 return true; 00079 } 00080 00081 // other messages are processed by derived classes 00082 // (e.g. BaseOverlay / BaseApp) 00083 return false; 00084 }
| bool BaseRpc::internalHandleRpcCall | ( | BaseCallMessage * | msg | ) | [protected, virtual] |
Handles internal rpc requests.
This method is used to implement basic functionality in the BaseRpc.
| msg | The call message |
Reimplemented in BaseApp, and BaseOverlay.
Definition at line 478 of file BaseRpc.cc.
Referenced by internalHandleRpcMessage().
00479 { 00480 RPC_SWITCH_START( msg ); 00481 RPC_DELEGATE( Ping, pingRpcCall ); 00482 RPC_SWITCH_END( ); 00483 00484 return RPC_HANDLED; 00485 }
| void BaseRpc::internalHandleRpcMessage | ( | BaseRpcMessage * | msg | ) | [protected, virtual] |
Handles incoming rpc messages and delegates them to the corresponding listeners or handlers.
| msg | The message to handle. |
Definition at line 289 of file BaseRpc.cc.
Referenced by BaseOverlay::handleBaseOverlayMessage(), BaseApp::handleCommonAPIMessage(), XmlRpcInterface::handleMessage(), and internalHandleMessage().
00290 { 00291 // check if this is a rpc call message 00292 BaseCallMessage* rpCall = dynamic_cast<BaseCallMessage*>(msg); 00293 if (rpCall != NULL) { 00294 // verify the message signature 00295 //cryptoModule->verifyMessage(msg); 00296 00297 OverlayCtrlInfo* overlayCtrlInfo = 00298 check_and_cast<OverlayCtrlInfo*>(msg->getControlInfo()); 00299 00300 if (overlayCtrlInfo->getSrcRoute().isUnspecified() && 00301 (!overlayCtrlInfo->getLastHop().isUnspecified())) { 00302 overlayCtrlInfo->setSrcRoute(NodeHandle(msg->getSrcNode().getKey(), 00303 overlayCtrlInfo->getLastHop())); 00304 } 00305 00306 bool rpcHandled = true; 00307 if (!handleRpcCall(rpCall)) rpcHandled = internalHandleRpcCall(rpCall); 00308 if (!rpcHandled) { 00309 EV << "[BaseRpc::internalHandleRpcMessage() @ " << thisNode.getAddress() 00310 << " (" << thisNode.getKey().toString(16) << ")]\n" 00311 << " Error: RPC '" << msg->getFullName()<< "' was not handled" 00312 << endl; 00313 delete msg; 00314 } 00315 return; 00316 } 00317 00318 // get nonce 00319 int nonce = msg->getNonce(); 00320 00321 // nonce known? no -> delete message and return 00322 if (rpcStates.count(nonce)==0) { 00323 EV << "[BaseRpc::internalHandleRpcMessage() @ " << thisNode.getAddress() 00324 << " " << thisNode.getKey().toString(16) << ")]\n" 00325 << " RPC: Nonce Unknown" 00326 << endl; 00327 delete msg; 00328 return; 00329 } 00330 00331 // get state and remove from map 00332 RpcState state = rpcStates[nonce]; 00333 rpcStates.erase(nonce); 00334 00335 // is timeout message? 00336 if (msg->isSelfMessage() && 00337 (dynamic_cast<RpcTimeoutMessage*>(msg) != NULL)) { 00338 // yes-> inform listener 00339 00340 // retry? 00341 state.retries--; 00342 if (state.retries>=0) { 00343 // TODO: cleanup code to have only one type for source routes 00344 std::vector<TransportAddress> sourceRoute; 00345 sourceRoute.push_back(*state.dest); 00346 if (state.dest->getSourceRouteSize() > 0) { 00347 sourceRoute.insert(sourceRoute.begin(), 00348 state.dest->getSourceRoute().rend(), 00349 state.dest->getSourceRoute().rbegin()); 00350 // remove the original source route from the destination 00351 sourceRoute.back().clearSourceRoute(); 00352 } 00353 00354 sendRpcMessageWithTransport(state.transportType, state.destComp, 00355 state.routingType, 00356 sourceRoute, 00357 state.destKey, 00358 dynamic_cast<BaseCallMessage*> 00359 (state.callMsg->dup())); 00360 00361 if (rpcExponentialBackoff) { 00362 state.rto *= 2; 00363 } 00364 00365 if (state.rto!=0) 00366 scheduleAt(simTime() + state.rto, msg); 00367 00368 state.timeSent = simTime(); 00369 rpcStates[nonce] = state; 00370 return; 00371 } 00372 // inform neighborcache 00373 if (state.transportType == UDP_TRANSPORT || 00374 (!state.dest->isUnspecified() && state.destKey.isUnspecified())) { 00375 neighborCache->setNodeTimeout(*state.dest); 00376 } 00377 00378 // inform listener 00379 if (state.listener != NULL) 00380 state.listener->handleRpcTimeout(state); 00381 00382 // inform overlay 00383 internalHandleRpcTimeout(state.callMsg, *state.dest, state.context, 00384 state.id, state.destKey); 00385 handleRpcTimeout(state); 00386 00387 } else { // no-> handle rpc response 00388 00389 // verify the message signature 00390 //cryptoModule->verifyMessage(msg); 00391 00392 OverlayCtrlInfo* overlayCtrlInfo = 00393 check_and_cast<OverlayCtrlInfo*>(msg->getControlInfo()); 00394 00395 if (overlayCtrlInfo->getSrcRoute().isUnspecified() && 00396 (!overlayCtrlInfo->getLastHop().isUnspecified())) { 00397 overlayCtrlInfo->setSrcRoute(NodeHandle(msg->getSrcNode().getKey(), 00398 overlayCtrlInfo->getLastHop())); 00399 } 00400 00401 // drop responses with wrong source key 00402 if (state.destKey.isUnspecified()) { 00403 const NodeHandle* stateHandle = 00404 dynamic_cast<const NodeHandle*>(state.dest); 00405 if (stateHandle != NULL && 00406 stateHandle->getKey() != msg->getSrcNode().getKey()) { 00407 00408 EV << "[BaseRpc::internalHandleRpcMessage() @ " 00409 << thisNode.getAddress() 00410 << " " << thisNode.getKey().toString(16) << ")]\n" 00411 << " Dropping RPC: Invalid source key" 00412 << endl; 00413 00414 // restore state to trigger timeout message 00415 rpcStates[nonce] = state; 00416 delete msg; 00417 return; 00418 } 00419 } 00420 00421 // get parameters 00422 simtime_t rtt = simTime() - state.timeSent; 00423 BaseResponseMessage* response 00424 = dynamic_cast<BaseResponseMessage*>(msg); 00425 00426 //if (state.transportType == UDP_TRANSPORT) 00427 // globalStatistics->recordOutVector("BaseRpc: UDP Round Trip Time", 00428 // rtt); 00429 00430 // neighborCache/vivaldi stuff 00431 if (state.transportType == UDP_TRANSPORT || 00432 (state.transportType != INTERNAL_TRANSPORT && 00433 response->getCallHopCount() == 1)) { //TODO 00434 if (neighborCache->vivaldiEnabled()) { 00435 // vivaldi: get coordinates/error estimation from message 00436 std::vector<double> nodeCoords; 00437 nodeCoords.resize(response->getCoordsArraySize()); 00438 for (uint32_t i = 0; i < response->getCoordsArraySize(); i++) 00439 nodeCoords[i] = response->getCoords(i); 00440 OverlayCtrlInfo* ctrlInfo = 00441 dynamic_cast<OverlayCtrlInfo*>(response->getControlInfo()); 00442 neighborCache->updateNode(response->getSrcNode(), rtt, 00443 (ctrlInfo ? 00444 ctrlInfo->getSrcRoute() : 00445 NodeHandle::UNSPECIFIED_NODE), 00446 nodeCoords, response->getError()); 00447 } else { 00448 neighborCache->updateNode(response->getSrcNode(), rtt); 00449 } 00450 } 00451 00452 // inform listener 00453 if (state.listener != NULL) 00454 state.listener->handleRpcResponse(response, state, rtt); 00455 00456 // inform overlay 00457 internalHandleRpcResponse(response, state.context, state.id, rtt); 00458 handleRpcResponse(response, state, rtt); 00459 00460 // delete response 00461 delete response->removeControlInfo(); 00462 delete response; 00463 } 00464 00465 // delete messages 00466 delete state.callMsg; 00467 cancelAndDelete(state.timeoutMsg); 00468 delete state.dest; 00469 00470 // clean up pointers 00471 state.dest = NULL; 00472 state.context = NULL; 00473 state.callMsg = NULL; 00474 state.timeoutMsg = NULL; 00475 }
| void BaseRpc::internalHandleRpcResponse | ( | BaseResponseMessage * | msg, | |
| cPolymorphic * | context, | |||
| int | rpcId, | |||
| simtime_t | rtt | |||
| ) | [protected, virtual] |
Handles rpc responses internal in base classes
.
This method is used to implement basic functionality in the BaseRpc.
| msg | The call message | |
| context | Pointer to an optional state object. The object has to be handled/deleted by the internalHandleRpcResponse() code | |
| rpcId | The ID of the call | |
| rtt | the time between sending the call and receiving the response |
Reimplemented in BaseApp, and BaseOverlay.
Definition at line 487 of file BaseRpc.cc.
Referenced by internalHandleRpcMessage().
00490 { 00491 // call rpc stubs 00492 RPC_SWITCH_START( msg ); 00493 RPC_ON_RESPONSE( Ping ) { 00494 pingRpcResponse(_PingResponse, context, rpcId, rtt); 00495 } 00496 RPC_SWITCH_END( ); 00497 }
| void BaseRpc::internalHandleRpcTimeout | ( | BaseCallMessage * | msg, | |
| const TransportAddress & | dest, | |||
| cPolymorphic * | context, | |||
| int | rpcId, | |||
| const OverlayKey & | destKey | |||
| ) | [protected, virtual] |
Handles rpc timeouts internal in base classes
.
This method is used to implement basic functionality in the BaseRpc.
| msg | The call message | |
| dest | The node that did not response | |
| context | Pointer to an optional state object. The object has to be handled/deleted by the internalHandleRpcResponse() code | |
| rpcId | The ID of the call | |
| destKey | The key of the call if used |
Reimplemented in BaseOverlay.
Definition at line 499 of file BaseRpc.cc.
Referenced by internalHandleRpcMessage().
00503 { 00504 RPC_SWITCH_START( msg ) { 00505 RPC_ON_CALL( Ping ) { 00506 pingRpcTimeout(_PingCall, dest, context, rpcId); 00507 } 00508 } 00509 RPC_SWITCH_END( ) 00510 }
| virtual void BaseRpc::internalSendRouteRpc | ( | BaseRpcMessage * | message, | |
| const OverlayKey & | destKey, | |||
| const std::vector< TransportAddress > & | sourceRoute, | |||
| RoutingType | routingType | |||
| ) | [private, pure virtual] |
| virtual void BaseRpc::internalSendRpcResponse | ( | BaseCallMessage * | call, | |
| BaseResponseMessage * | response | |||
| ) | [private, pure virtual] |
| void BaseRpc::pingNode | ( | const TransportAddress & | dest, | |
| simtime_t | timeout = -1, |
|||
| int | retries = 0, |
|||
| cPolymorphic * | context = NULL, |
|||
| const char * | caption = "PING", |
|||
| RpcListener * | rpcListener = NULL, |
|||
| int | rpcId = -1, |
|||
| TransportType | transportType = INVALID_TRANSPORT | |||
| ) | [protected] |
ping a node by its TransportAddress
Statistics are collected by this method.
| dest | the node to ping | |
| timeout | RPC timeout | |
| retries | how often to retry after timeout | |
| context | a pointer to an arbitrary cPolymorphic object, which can be used to store additional state | |
| caption | special name for the ping call (instead of "PING") | |
| rpcListener | RPC Listener | |
| rpcId | RPC id | |
| transportType | The transport used for this RPC |
Definition at line 688 of file BaseRpc.cc.
Referenced by Pastry::changeState(), BootstrapList::handleBootstrapListTimerExpired(), Broose::handleBucketTimerExpired(), oversim::Chord::handleStabilizeTimerExpired(), Pastry::handleTimerEvent(), P2pns::handleTimerEvent(), KBRTestApp::handleTimerEvent(), oversim::Chord::handleTimerEvent(), Pastry::handleUDPMessage(), Kademlia::joinOverlay(), NeighborCache::queryProx(), BasePastry::recursiveRoutingHook(), and Kademlia::routingAdd().
00692 { 00693 //Rtt rtt(0.0, RTTSTATE_UNKNOWN); 00694 00695 PingCall* call = new PingCall(caption); 00696 call->setBitLength(PINGCALL_L(call)); 00697 RECORD_STATS(numPingSent++; bytesPingSent += call->getByteLength()); 00698 00699 if (transportType == UDP_TRANSPORT || 00700 (transportType != ROUTE_TRANSPORT && 00701 getThisCompType() == OVERLAY_COMP)) { 00702 sendUdpRpcCall(dest, call, context, timeout, retries, rpcId, 00703 rpcListener); 00704 } else { 00705 sendRouteRpcCall(getThisCompType(), dest, call, context, 00706 DEFAULT_ROUTING, timeout, retries, rpcId, 00707 rpcListener); 00708 } 00709 }
| void BaseRpc::pingResponse | ( | PingResponse * | pingResponse, | |
| cPolymorphic * | context, | |||
| int | rpcId, | |||
| simtime_t | rtt | |||
| ) | [protected, virtual] |
Reimplemented in KBRTestApp, BootstrapList, Broose, and BasePastry.
Definition at line 645 of file BaseRpc.cc.
Referenced by pingRpcResponse().
| void BaseRpc::pingRpcCall | ( | PingCall * | call | ) | [private] |
Definition at line 655 of file BaseRpc.cc.
Referenced by internalHandleRpcCall().
00656 { 00657 std::string pongName(call->getName()); 00658 if (pongName == "PING") 00659 pongName = "PONG"; 00660 else { 00661 pongName = "PONG: [ "; 00662 pongName += call->getName(); 00663 pongName += " ]"; 00664 } 00665 00666 PingResponse* response = new PingResponse(pongName.c_str()); 00667 response->setBitLength(PINGRESPONSE_L(response)); 00668 RECORD_STATS(numPingResponseSent++; bytesPingResponseSent += 00669 response->getByteLength()); 00670 00671 sendRpcResponse(call, response ); 00672 }
| void BaseRpc::pingRpcResponse | ( | PingResponse * | response, | |
| cPolymorphic * | context, | |||
| int | rpcId, | |||
| simtime_t | rtt | |||
| ) | [private] |
Reimplemented in P2pns.
Definition at line 674 of file BaseRpc.cc.
Referenced by internalHandleRpcResponse().
00676 { 00677 pingResponse(response, context, rpcId, rtt); 00678 }
| void BaseRpc::pingRpcTimeout | ( | PingCall * | pingCall, | |
| const TransportAddress & | dest, | |||
| cPolymorphic * | context, | |||
| int | rpcId | |||
| ) | [private] |
Definition at line 680 of file BaseRpc.cc.
Referenced by internalHandleRpcTimeout().
00684 { 00685 pingTimeout(pingCall, dest, context, rpcId); 00686 }
| void BaseRpc::pingTimeout | ( | PingCall * | pingCall, | |
| const TransportAddress & | dest, | |||
| cPolymorphic * | context, | |||
| int | rpcId | |||
| ) | [protected, virtual] |
Reimplemented in BootstrapList, Broose, oversim::Chord, BasePastry, and P2pns.
Definition at line 650 of file BaseRpc.cc.
Referenced by pingRpcTimeout().
| uint32_t BaseRpc::sendInternalRpcCall | ( | CompType | destComp, | |
| BaseCallMessage * | msg, | |||
| cPolymorphic * | context = NULL, |
|||
| simtime_t | timeout = -1, |
|||
| int | retries = 0, |
|||
| int | rpcId = -1, |
|||
| RpcListener * | rpcListener = NULL | |||
| ) | [inline, protected] |
Sends an internal Remote-Procedure-Call between two tiers
.
If no timeout is provided, a default value of globalParameters.rpcUdpTimeout for underlay and globalParameters.rpcKeyTimeout for a overlay rpc is used. After a timeout the message gets retransmitted for at maximum retries times. The destKey attribute is kept untouched.
| destComp | Destination component | |
| msg | RPC Call Message | |
| context | a pointer to an arbitrary cPolymorphic object, which can be used to store additional state | |
| timeout | RPC timeout in seconds (-1=use default value, 0=no timeout) | |
| retries | How often we try to resent rpc call, if it gets lost | |
| rpcId | RPC id | |
| rpcListener | RPC Listener |
Definition at line 326 of file BaseRpc.h.
Referenced by P2pns::handleDHTgetCAPIResponse(), DHT::handleGetCAPIRequest(), CBRDHT::handleGetCAPIRequest(), DHT::handlePutCAPIRequest(), CBRDHT::handlePutCAPIRequest(), P2pns::handleTimerEvent(), KBRTestApp::handleTimerEvent(), DHTTestApp::handleTimerEvent(), DHTTestApp::handleTraceMessage(), BootstrapList::locateBootstrapNode(), P2pns::p2pnsRegisterRpc(), P2pns::p2pnsResolveRpc(), P2pns::registerId(), XmlRpcInterface::sendInternalRpcWithTimeout(), P2pns::tunnel(), DHT::update(), and CBRDHT::update().
00333 { 00334 return sendRpcCall(INTERNAL_TRANSPORT, destComp, 00335 TransportAddress::UNSPECIFIED_NODE, 00336 OverlayKey::UNSPECIFIED_KEY, msg, context, 00337 NO_OVERLAY_ROUTING, timeout, retries, rpcId, 00338 rpcListener); 00339 }
| virtual void BaseRpc::sendMessageToUDP | ( | const TransportAddress & | addr, | |
| cPacket * | message | |||
| ) | [inline, protected, virtual] |
Reimplemented in BaseApp, and BaseOverlay.
Definition at line 428 of file BaseRpc.h.
Referenced by sendRpcMessageWithTransport().
| uint32_t BaseRpc::sendRouteRpcCall | ( | CompType | destComp, | |
| const TransportAddress & | dest, | |||
| BaseCallMessage * | msg, | |||
| cPolymorphic * | context = NULL, |
|||
| RoutingType | routingType = DEFAULT_ROUTING, |
|||
| simtime_t | timeout = -1, |
|||
| int | retries = 0, |
|||
| int | rpcId = -1, |
|||
| RpcListener * | rpcListener = NULL | |||
| ) | [inline, protected] |
Sends a Remote-Procedure-Call message using the overlay's UDP port
This replaces ROUTE_DIRECT calls!
If no timeout is provided, a default value of globalParameters.rpcUdpTimeout for underlay and globalParameters.rpcKeyTimeout for a overlay rpc is used. After a timeout the message gets retransmitted for at maximum retries times. The destKey attribute is kept untouched.
| destComp | The destination component | |
| dest | Destination node handle (may contain a source route) | |
| msg | RPC Call Message | |
| context | a pointer to an arbitrary cPolymorphic object, which can be used to store additional state | |
| routingType | KBR routing type | |
| timeout | RPC timeout | |
| retries | How often we try to resent rpc call, if it gets lost | |
| rpcId | RPC id | |
| rpcListener | RPC Listener |
Definition at line 258 of file BaseRpc.h.
00267 { 00268 return sendRpcCall(ROUTE_TRANSPORT, destComp, dest, 00269 OverlayKey::UNSPECIFIED_KEY, msg, context, 00270 routingType, timeout, retries, rpcId, rpcListener); 00271 }
| uint32_t BaseRpc::sendRouteRpcCall | ( | CompType | destComp, | |
| const OverlayKey & | destKey, | |||
| BaseCallMessage * | msg, | |||
| cPolymorphic * | context = NULL, |
|||
| RoutingType | routingType = DEFAULT_ROUTING, |
|||
| simtime_t | timeout = -1, |
|||
| int | retries = 0, |
|||
| int | rpcId = -1, |
|||
| RpcListener * | rpcListener = NULL | |||
| ) | [inline, protected] |
Routes a Remote-Procedure-Call message to an OverlayKey.
If no timeout is provided, a default value of globalParameters.rpcUdpTimeout for underlay and globalParameters.rpcKeyTimeout for a overlay rpc is used. After a timeout the message gets retransmitted for at maximum retries times. The destKey attribute is kept untouched.
| destComp | The destination component | |
| destKey | Destination OverlayKey | |
| msg | RPC Call Message | |
| context | a pointer to an arbitrary cPolymorphic object, which can be used to store additional state | |
| routingType | KBR routing type | |
| timeout | RPC timeout in seconds (-1=use default value, 0=no timeout) | |
| retries | How often we try to resent rpc call, if it gets lost | |
| rpcId | RPC id | |
| rpcListener | RPC Listener |
Definition at line 219 of file BaseRpc.h.
00228 { 00229 return sendRpcCall(ROUTE_TRANSPORT, destComp, 00230 TransportAddress::UNSPECIFIED_NODE, 00231 destKey, msg, context, routingType, timeout, 00232 retries, rpcId, rpcListener); 00233 }
| uint32_t BaseRpc::sendRouteRpcCall | ( | CompType | destComp, | |
| const TransportAddress & | dest, | |||
| const OverlayKey & | destKey, | |||
| BaseCallMessage * | msg, | |||
| cPolymorphic * | context = NULL, |
|||
| RoutingType | routingType = DEFAULT_ROUTING, |
|||
| simtime_t | timeout = -1, |
|||
| int | retries = 0, |
|||
| int | rpcId = -1, |
|||
| RpcListener * | rpcListener = NULL | |||
| ) | [inline, protected] |
Routes a Remote-Procedure-Call message to an OverlayKey.
If no timeout is provided, a default value of globalParameters.rpcUdpTimeout for underlay and globalParameters.rpcKeyTimeout for a overlay rpc is used. After a timeout the message gets retransmitted for at maximum retries times. The destKey attribute is kept untouched.
| destComp | The destination component | |
| dest | Destination node handle (if specified, used as first hop) | |
| destKey | Destination OverlayKey (if unspecified, the message will be sent to dest using the overlay's UDP port) | |
| msg | RPC Call Message | |
| context | a pointer to an arbitrary cPolymorphic object, which can be used to store additional state | |
| routingType | KBR routing type | |
| timeout | RPC timeout in seconds (-1=use default value, 0=no timeout) | |
| retries | How often we try to resent rpc call, if it gets lost | |
| rpcId | RPC id | |
| rpcListener | RPC Listener |
Definition at line 178 of file BaseRpc.h.
Referenced by Scribe::deliverALMDataToRoot(), oversim::Koorde::handleDeBruijnTimerExpired(), oversim::Chord::handleFixFingersTimerExpired(), CBRDHT::handleGetCAPIRequest(), DHT::handleGetResponse(), CBRDHT::handleGetResponse(), Scribe::handleJoinMessage(), oversim::Chord::handleJoinTimerExpired(), Broose::handleJoinTimerExpired(), DHT::handleLookupResponse(), CBRDHT::handleLookupResponse(), DHT::handleRpcTimeout(), CBRDHT::handleRpcTimeout(), Scribe::handleTimerEvent(), KBRTestApp::handleTimerEvent(), oversim::Chord::joinForeignPartition(), RecursiveLookup::lookup(), pingNode(), Nps::sendCoordsReqCall(), Scribe::subscribeToGroup(), Scribe::update(), DHT::update(), and CBRDHT::update().
00188 { 00189 if (dest.isUnspecified() && destKey.isUnspecified()) 00190 opp_error("BaseRpc::sendRouteRpcCall() with both key and " 00191 "transportAddress unspecified!"); 00192 return sendRpcCall(ROUTE_TRANSPORT, destComp, dest, destKey, msg, 00193 context, routingType, timeout, retries, 00194 rpcId, rpcListener); 00195 }
| uint32_t BaseRpc::sendRpcCall | ( | TransportType | transportType, | |
| CompType | destComp, | |||
| const TransportAddress & | dest, | |||
| const OverlayKey & | destKey, | |||
| BaseCallMessage * | msg, | |||
| cPolymorphic * | context, | |||
| RoutingType | routingType, | |||
| simtime_t | timeout, | |||
| int | retries, | |||
| int | rpcId, | |||
| RpcListener * | rpcListener | |||
| ) | [private] |
Sends a Remote-Procedure-Call message to the underlay.
USE ONE OF THE WRAPPER FUNCTIONS INSTEAD:
sendRouteRpcCall(), sendInternalRpcCall(), or sendUdpRpcCall()
If no timeout is provided, a default value of globalParameters.rpcUdpTimeout for underlay and globalParameters.rpcKeyTimeout for a overlay rpc is used. Internal RPCs don't have a default timeout. After a timeout the message gets retransmitted for at maximum retries times. The destKey attribute is kept untouched.
| transportType | The type of transport | |
| destComp | The destination component | |
| dest | Destination node handle (may contain a source route) | |
| destKey | route the RPC to the node that is responsible for destkey | |
| msg | RPC Call Message | |
| context | a pointer to an arbitrary cPolymorphic object, which can be used to store additional state | |
| routingType | KBR routing type | |
| timeout | RPC timeout in seconds (-1=use default value, 0=no timeout) | |
| retries | How often we try to resent rpc call, if it gets lost | |
| rpcId | RPC id | |
| rpcListener | RPC Listener (callback handler) |
Definition at line 172 of file BaseRpc.cc.
Referenced by sendInternalRpcCall(), sendRouteRpcCall(), and sendUdpRpcCall().
00183 { 00184 // create nonce, timeout and set default parameters 00185 uint32_t nonce; 00186 do { 00187 nonce = intuniform(1, 2147483647); 00188 } while (rpcStates.count(nonce) > 0); 00189 00190 if (timeout == -1) { 00191 switch (transportType) { 00192 case INTERNAL_TRANSPORT: 00193 timeout = 0; 00194 break; 00195 case UDP_TRANSPORT: 00196 timeout = rpcUdpTimeout; 00197 break; 00198 case ROUTE_TRANSPORT: 00199 timeout = (destKey.isUnspecified() ? 00200 rpcUdpTimeout : 00201 rpcKeyTimeout); 00202 break; 00203 default: 00204 throw cRuntimeError("BaseRpc::sendRpcMessage(): " 00205 "Unknown RpcTransportType!"); 00206 } 00207 } 00208 00209 if (rpcListener == NULL) 00210 rpcListener = defaultRpcListener; 00211 00212 // create state 00213 RpcState state; 00214 state.id = rpcId; 00215 state.timeSent = simTime(); 00216 state.dest = dest.dup(); 00217 state.destKey = destKey; 00218 state.srcComp = getThisCompType(); 00219 state.destComp = destComp; 00220 state.listener = rpcListener; 00221 state.timeoutMsg = new RpcTimeoutMessage(); 00222 state.timeoutMsg->setNonce(nonce); 00223 state.retries = retries; 00224 state.rto = timeout; 00225 state.transportType = transportType; 00226 //state.transportType = (destKey.isUnspecified() && (dest.getSourceRouteSize() == 0) 00227 // ? UDP_TRANSPORT : transportType); //test 00228 state.routingType = routingType; 00229 state.context = context; 00230 00231 if (rpcStates.count(nonce) > 0) 00232 throw cRuntimeError("RPC nonce collision"); 00233 00234 // set message parameters 00235 msg->setNonce(nonce); 00236 if (transportType == ROUTE_TRANSPORT) 00237 msg->setSrcNode(overlay->getThisNode()); 00238 else 00239 msg->setSrcNode(thisNode); 00240 msg->setType(RPC); 00241 00242 // sign the message 00243 // if (transportType != INTERNAL_TRANSPORT) cryptoModule->signMessage(msg); 00244 00245 // save copy of call message in RpcState 00246 state.callMsg = dynamic_cast<BaseCallMessage*>(msg->dup()); 00247 assert(!msg->getEncapsulatedMsg() || !msg->getEncapsulatedMsg()->getControlInfo()); 00248 00249 // register state 00250 rpcStates[nonce] = state; 00251 00252 // schedule timeout message 00253 if (state.rto != 0) 00254 scheduleAt(simTime() + state.rto, state.timeoutMsg); 00255 00256 // TODO: cleanup code to have only one type for source routes 00257 std::vector<TransportAddress> sourceRoute; 00258 sourceRoute.push_back(dest); 00259 if (dest.getSourceRouteSize() > 0) { 00260 state.transportType = transportType = ROUTE_TRANSPORT; 00261 sourceRoute.insert(sourceRoute.begin(), dest.getSourceRoute().rend(), 00262 dest.getSourceRoute().rbegin()); 00263 // remove the original source route from the destination 00264 sourceRoute.back().clearSourceRoute(); 00265 } 00266 sendRpcMessageWithTransport(transportType, destComp, routingType, 00267 sourceRoute, destKey, msg); 00268 00269 return nonce; 00270 }
| void BaseRpc::sendRpcMessageWithTransport | ( | TransportType | transportType, | |
| CompType | destComp, | |||
| RoutingType | routingType, | |||
| const std::vector< TransportAddress > & | sourceRoute, | |||
| const OverlayKey & | destKey, | |||
| BaseRpcMessage * | message | |||
| ) | [private] |
Definition at line 606 of file BaseRpc.cc.
Referenced by internalHandleRpcMessage(), sendRpcCall(), and sendRpcResponse().
00612 { 00613 switch (transportType) { 00614 case UDP_TRANSPORT: { 00615 sendMessageToUDP(sourceRoute[0], message); 00616 break; 00617 } 00618 case ROUTE_TRANSPORT: { 00619 internalSendRouteRpc(message, destKey, 00620 sourceRoute, routingType); 00621 break; 00622 } 00623 case INTERNAL_TRANSPORT: { 00624 cGate *destCompGate = overlay->getCompRpcGate(destComp); 00625 if (destCompGate == NULL) { 00626 throw cRuntimeError("BaseRpc::sendRpcMessageWithTransport():" 00627 " INTERNAL_RPC to unknown RpcCompType!"); 00628 } 00629 OverlayCtrlInfo *overlayCtrlInfo = new OverlayCtrlInfo(); 00630 overlayCtrlInfo->setSrcComp(getThisCompType()); 00631 overlayCtrlInfo->setDestComp(destComp); 00632 overlayCtrlInfo->setTransportType(INTERNAL_TRANSPORT); 00633 message->setControlInfo(overlayCtrlInfo); 00634 sendDirect(message, destCompGate); 00635 break; 00636 } 00637 default: 00638 throw cRuntimeError("BaseRpc::sendRpcMessageWithTransport: " 00639 "invalid transportType!"); 00640 break; 00641 } 00642 }
| void BaseRpc::sendRpcResponse | ( | BaseCallMessage * | call, | |
| BaseResponseMessage * | response | |||
| ) | [protected] |
Send Remote-Procedure response message to UDP and deletes call message.
| call | The corresponding call message to the response | |
| response | The response message |
Definition at line 586 of file BaseRpc.cc.
00588 { 00589 const TransportAddress* destNode = &(call->getSrcNode()); 00590 const OverlayKey* destKey = &(call->getSrcNode().getKey()); 00591 00592 OverlayCtrlInfo* overlayCtrlInfo = 00593 dynamic_cast<OverlayCtrlInfo*>(call->getControlInfo()); 00594 00595 // "magic" transportType selection: internal 00596 if (overlayCtrlInfo && 00597 overlayCtrlInfo->getTransportType() == INTERNAL_TRANSPORT) { 00598 sendRpcResponse(INTERNAL_TRANSPORT, 00599 static_cast<CompType>(overlayCtrlInfo->getSrcComp()), 00600 *destNode, *destKey, call, response); 00601 } else { 00602 internalSendRpcResponse(call, response); 00603 } 00604 }
| void BaseRpc::sendRpcResponse | ( | TransportType | transportType, | |
| CompType | destComp, | |||
| const TransportAddress & | dest, | |||
| const OverlayKey & | destKey, | |||
| BaseCallMessage * | call, | |||
| BaseResponseMessage * | response | |||
| ) | [protected] |
Send Remote-Procedure response message and deletes call message.
| transportType | The transport used for this RPC | |
| destComp | Destination component | |
| dest | The TransportAddress of the destination (hint for ROUTE_TRANSPORT) | |
| destKey | The destination key for a ROUTE_TRANSPORT | |
| call | The corresponding call message to the response | |
| response | The response message |
Definition at line 518 of file BaseRpc.cc.
Referenced by Nps::coordsReqRpc(), BaseOverlay::failedNodeRpc(), BaseOverlay::findNodeRpc(), PubSubMMOG::handleAdoptChildCall(), PubSubMMOG::handleBackupCall(), Broose::handleBucketRequestRpc(), P2pns::handleDHTgetCAPIResponse(), P2pns::handleDHTputCAPIResponse(), DHT::handleDumpDhtRequest(), CBRDHT::handleDumpDhtRequest(), DHT::handleGetRequest(), CBRDHT::handleGetRequest(), DHT::handleGetResponse(), CBRDHT::handleGetResponse(), PubSubLobby::handleHelpCall(), PubSubMMOG::handleIntermediateCall(), PubSubLobby::handleJoin(), Scribe::handleJoinMessage(), P2pns::handleLookupResponse(), DHT::handleLookupResponse(), CBRDHT::handleLookupResponse(), PubSubMMOG::handlePingCall(), Scribe::handlePublishCall(), DHT::handlePutRequest(), CBRDHT::handlePutRequest(), DHT::handlePutResponse(), CBRDHT::handlePutResponse(), PubSubLobby::handleRespCall(), oversim::Koorde::handleRpcDeBruijnRequest(), DHT::handleRpcTimeout(), CBRDHT::handleRpcTimeout(), PubSubMMOG::handleSubscriptionCall(), PubSubMMOG::handleTakeOver(), BaseOverlay::internalSendRpcResponse(), BaseApp::internalSendRpcResponse(), KBRTestApp::kbrTestCall(), SendToKeyListener::lookupFinished(), BaseOverlay::lookupRpc(), BaseOverlay::nextHopRpc(), pingRpcCall(), PubSubLobby::replaceResponsibleNode(), oversim::Chord::rpcFixfingers(), oversim::Chord::rpcJoin(), oversim::Chord::rpcNotify(), oversim::Chord::rpcStabilize(), and sendRpcResponse().
00524 { 00525 if (call == NULL || response == NULL) { 00526 throw cRuntimeError("call or response = NULL!"); 00527 } 00528 00529 // vivaldi: set coordinates and error estimation in response 00530 if (neighborCache->vivaldiEnabled()) { //TODO only for directly sent msgs 00531 const std::vector<double>& nodeCoord = 00532 neighborCache->getVivaldiAccess().getOwnCoordinates(); 00533 response->setError(neighborCache->getVivaldiAccess().getOwnError()); 00534 response->setCoordsArraySize(nodeCoord.size()); 00535 for (uint32_t i = 0; i < nodeCoord.size(); i++) { 00536 response->setCoords(i, nodeCoord[i]); 00537 } 00538 } 00539 00540 assert(transportType == INTERNAL_TRANSPORT || 00541 !dest.isUnspecified() || 00542 !destKey.isUnspecified()); 00543 00544 if (transportType == ROUTE_TRANSPORT) 00545 response->setSrcNode(overlay->getThisNode()); 00546 else 00547 response->setSrcNode(thisNode); 00548 response->setType(RPC); 00549 response->setNonce(call->getNonce()); 00550 response->setStatType(call->getStatType()); 00551 00552 RoutingType routingType = NO_OVERLAY_ROUTING; 00553 OverlayCtrlInfo* overlayCtrlInfo = NULL; 00554 if (dynamic_cast<OverlayCtrlInfo*>(call->getControlInfo())) { 00555 overlayCtrlInfo = 00556 static_cast<OverlayCtrlInfo*>(call->removeControlInfo()); 00557 response->setCallHopCount(overlayCtrlInfo->getHopCount()); 00558 } else { 00559 delete call->removeControlInfo(); 00560 response->setCallHopCount(1); // one udp hop (?) 00561 } 00562 00563 // source routing 00564 std::vector<TransportAddress> sourceRoute; 00565 if (overlayCtrlInfo && transportType == ROUTE_TRANSPORT) { 00566 routingType = 00567 static_cast<RoutingType>(overlayCtrlInfo->getRoutingType()); 00568 for (uint32_t i = overlayCtrlInfo->getVisitedHopsArraySize(); i > 0; --i) { 00569 sourceRoute.push_back(overlayCtrlInfo->getVisitedHops(i - 1)); 00570 } 00571 } 00572 00573 if (sourceRoute.size() == 0) { 00574 // empty visited hops list => direct response 00575 sourceRoute.push_back(dest); 00576 } 00577 00578 sendRpcMessageWithTransport(transportType, compType, 00579 routingType, sourceRoute, 00580 destKey, response); 00581 delete overlayCtrlInfo; 00582 delete call; 00583 }
| uint32_t BaseRpc::sendUdpRpcCall | ( | const TransportAddress & | dest, | |
| BaseCallMessage * | msg, | |||
| cPolymorphic * | context = NULL, |
|||
| simtime_t | timeout = -1, |
|||
| int | retries = 0, |
|||
| int | rpcId = -1, |
|||
| RpcListener * | rpcListener = NULL | |||
| ) | [inline, protected] |
Sends a Remote-Procedure-Call message to the underlay
.
If no timeout is provided, a default value of globalParameters.rpcUdpTimeout for underlay and globalParameters.rpcKeyTimeout for a overlay rpc is used. After a timeout the message gets retransmitted for at maximum retries times. The destKey attribute is kept untouched.
| dest | Destination node handle (may contain a source route) | |
| msg | RPC Call Message | |
| context | a pointer to an arbitrary cPolymorphic object, which can be used to store additional state | |
| timeout | RPC timeout in seconds (-1=use default value, 0=no timeout) | |
| retries | How often we try to resent rpc call, if it gets lost | |
| rpcId | RPC id | |
| rpcListener | RPC Listener |
Definition at line 293 of file BaseRpc.h.
Referenced by Broose::changeState(), PubSubMMOG::handleAppMessage(), PubSubMMOG::handleBackupCallTimeout(), PubSubMMOG::handleHelpResponse(), PubSubMMOG::handleIntermediateResponse(), PubSubLobby::handleJoin(), PubSubMMOG::handleJoinResponse(), PubSubMMOG::handleMove(), oversim::Chord::handleNewSuccessorHint(), PubSubMMOG::handlePingCallTimeout(), PubSubLobby::handleRespCall(), PubSubMMOG::handleResponsibleNodeResponse(), oversim::Chord::handleRpcNotifyResponse(), oversim::Chord::handleRpcStabilizeResponse(), oversim::Chord::handleStabilizeTimerExpired(), PubSubMMOG::handleSubscriptionCall(), PubSubMMOG::handleSubscriptionCallTimeout(), IterativePathLookup::handleTimeout(), pingNode(), PubSubMMOG::sendMessageToChildren(), BaseOverlay::sendRouteMessage(), IterativeLookup::sendRpc(), PubSubMMOG::takeOverSubspace(), and PubSubMMOG::unsubscribeChild().
00299 { 00300 return sendRpcCall(UDP_TRANSPORT, INVALID_COMP, dest, 00301 OverlayKey::UNSPECIFIED_KEY, msg, context, 00302 NO_OVERLAY_ROUTING, timeout, retries, rpcId, 00303 rpcListener); 00304 }
int BaseRpc::bytesPingResponseSent [protected] |
Definition at line 449 of file BaseRpc.h.
Referenced by BaseOverlay::finish(), initRpcs(), and pingRpcCall().
int BaseRpc::bytesPingSent [protected] |
Definition at line 447 of file BaseRpc.h.
Referenced by BaseOverlay::finish(), initRpcs(), and pingNode().
CryptoModule* BaseRpc::cryptoModule [protected] |
pointer to CryptoModule
Definition at line 444 of file BaseRpc.h.
Referenced by BaseRpc(), and initRpcs().
bool BaseRpc::debugOutput [protected] |
RpcListener* BaseRpc::defaultRpcListener [private] |
Definition at line 523 of file BaseRpc.h.
Referenced by BaseRpc(), finishRpcs(), initRpcs(), and sendRpcCall().
GlobalStatistics* BaseRpc::globalStatistics [protected] |
pointer to GlobalStatistics module in this node
Reimplemented in BaseApp, NeighborCache, and DHTTestApp.
Definition at line 84 of file BaseRpc.h.
Referenced by BaseOverlay::finish(), Vast::finishOverlay(), Quon::finishOverlay(), PubSubMMOG::finishOverlay(), PubSubLobby::finishOverlay(), oversim::Koorde::finishOverlay(), Kademlia::finishOverlay(), Gia::finishOverlay(), oversim::Chord::finishOverlay(), Broose::finishOverlay(), BasePastry::finishOverlay(), Kademlia::handleBucketRefreshTimerExpired(), PubSubMMOG::handleMoveListMessage(), Vast::handleNodeMove(), Quon::handleNodeMove(), oversim::Nice::handleTimerEvent(), oversim::Nice::handleUDPMessage(), BaseOverlay::initialize(), initRpcs(), oversim::Nice::maintenance(), and SendToKeyListener::SendToKeyListener().
NeighborCache* BaseRpc::neighborCache [protected] |
pointer to the neighbor cache
Reimplemented in CBRDHT, and NeighborCache.
Definition at line 443 of file BaseRpc.h.
Referenced by BasePastry::baseInit(), BaseRpc(), BasePastry::determineAliveTable(), Landmark::finishApp(), oversim::Chord::handleRpcFixfingersResponse(), Landmark::initializeApp(), initRpcs(), internalHandleRpcMessage(), Bamboo::lookupFinished(), BasePastry::pingNodes(), BasePastry::prePing(), and sendRpcResponse().
int BaseRpc::numPingResponseSent [protected] |
Definition at line 448 of file BaseRpc.h.
Referenced by BaseOverlay::finish(), initRpcs(), and pingRpcCall().
int BaseRpc::numPingSent [protected] |
Definition at line 446 of file BaseRpc.h.
Referenced by BaseOverlay::finish(), initRpcs(), and pingNode().
BaseOverlay* BaseRpc::overlay [protected] |
Definition at line 78 of file BaseRpc.h.
Referenced by Scribe::addChildToGroup(), BaseApp::BaseApp(), BaseApp::callLocalLookup(), BaseApp::callNeighborSet(), BaseApp::callRoute(), Scribe::checkGroupEmpty(), Nps::coordsReqRpcResponse(), RealWorldTestApp::deliver(), KBRTestApp::deliver(), Scribe::deliverALMDataToGroup(), XmlRpcInterface::dumpDht(), Scribe::forward(), KBRTestApp::forward(), BaseApp::forwardResponse(), XmlRpcInterface::get(), BootstrapList::getBootstrapNode(), NeighborCache::getProx(), BaseApp::handleCommonAPIMessage(), CBRDHT::handleGetCAPIRequest(), CBRDHT::handleGetResponse(), Scribe::handleJoinMessage(), Scribe::handleJoinResponse(), KBRTestApp::handleLookupResponse(), DHT::handleLookupResponse(), CBRDHT::handleLookupResponse(), BootstrapList::handleLookupResponse(), GIASearchApp::handleLowerMessage(), XmlRpcInterface::handleMessage(), BaseApp::handleMessage(), SimMud::handleMove(), SimMud::handleOtherPlayerMove(), Scribe::handlePublishCall(), Scribe::handlePublishResponse(), DHT::handlePutRequest(), CBRDHT::handlePutRequest(), XmlRpcInterface::handleReadyMessage(), P2pns::handleReadyMessage(), Scribe::handleRpcResponse(), KBRTestApp::handleRpcResponse(), BootstrapList::handleRpcResponse(), SimpleGameClient::handleTimerEvent(), Scribe::handleTimerEvent(), P2pns::handleTimerEvent(), KBRTestApp::handleTimerEvent(), GIASearchApp::handleTimerEvent(), DHT::handleTimerEvent(), CBRDHT::handleTimerEvent(), Scribe::handleUpperMessage(), XmlRpcInterface::initializeApp(), SimpleGameClient::initializeApp(), P2pns::initializeApp(), Landmark::initializeApp(), DHT::initializeApp(), CBRDHT::initializeApp(), BootstrapList::initializeApp(), initRpcs(), BaseApp::isSiblingFor(), XmlRpcInterface::joinOverlay(), XmlRpcInterface::localLookup(), BootstrapList::locateBootstrapNode(), XmlRpcInterface::lookup(), IterativeLookup::lookup(), BaseOverlay::lookupRpc(), XmlRpcInterface::p2pnsRegister(), P2pns::p2pnsRegisterRpc(), XmlRpcInterface::p2pnsResolve(), BootstrapList::pingResponse(), BootstrapList::pingTimeout(), XmlRpcInterface::put(), BootstrapList::removeBootstrapNode(), BaseOverlay::route(), BaseApp::sendMessageToUDP(), sendRpcCall(), sendRpcMessageWithTransport(), sendRpcResponse(), Nps::setOwnLayer(), Scribe::subscribeToGroup(), Scribe::update(), DHT::update(), and CBRDHT::update().
bool BaseRpc::rpcExponentialBackoff [private] |
simtime_t BaseRpc::rpcKeyTimeout [private] |
int BaseRpc::rpcsPending [private] |
RpcStates BaseRpc::rpcStates [private] |
Definition at line 524 of file BaseRpc.h.
Referenced by cancelAllRpcs(), cancelRpcMessage(), initRpcs(), internalHandleRpcMessage(), and sendRpcCall().
simtime_t BaseRpc::rpcUdpTimeout [private] |
CompType BaseRpc::thisCompType [protected] |
NodeHandle BaseRpc::thisNode [protected] |
NodeHandle to this node.
Definition at line 71 of file BaseRpc.h.
Referenced by Quon::addSite(), BasePastry::baseChangeState(), BasePastry::baseInit(), oversim::Nice::BasicJoinLayer(), oversim::Nice::becomeRendevouzPoint(), BaseOverlay::bindToPort(), BaseApp::bindToPort(), BaseApp::callRoute(), BaseOverlay::callUpdate(), Quon::changeState(), Pastry::changeState(), oversim::Nice::changeState(), Gia::changeState(), oversim::Chord::changeState(), Broose::changeState(), Bamboo::changeState(), Pastry::checkProxCache(), oversim::Chord::closestPreceedingNode(), oversim::Nice::ClusterMerge(), oversim::Nice::ClusterMergeRequest(), oversim::Nice::ClusterSplit(), Nps::coordsReqRpcResponse(), Quon::deleteSite(), Broose::displayBucketState(), Bamboo::doGlobalTuning(), Pastry::doJoinUpdate(), BasePastry::doRoutingTableMaintenance(), Pastry::doSecondStage(), Pastry::endProcessingState(), oversim::Nice::findClusterLeader(), oversim::Koorde::findDeBruijnHop(), oversim::Koorde::findNode(), Kademlia::findNode(), oversim::Chord::findNode(), Broose::findNode(), BasePastry::findNode(), BaseOverlay::findNodeRpc(), oversim::Chord::finishOverlay(), BasePastry::finishOverlay(), oversim::Nice::getHighestLayer(), oversim::Nice::getHighestLeaderLayer(), oversim::Nice::getMaxDistance(), oversim::Nice::getMeanDistance(), oversim::Nice::gracefulLeave(), PubSubMMOG::handleAdoptChildCall(), PubSubMMOG::handleAdoptChildResponse(), Quon::handleAppMessage(), oversim::Nice::handleAppMessage(), BaseOverlay::handleBaseOverlayMessage(), BaseApp::handleCommonAPIMessage(), oversim::Koorde::handleDeBruijnTimerExpired(), Pastry::handleFailedNode(), oversim::Chord::handleFixFingersTimerExpired(), oversim::Nice::handleHeartbeat(), PubSubMMOG::handleHelpResponse(), PubSubMMOG::handleIntermediateResponse(), oversim::Nice::handleJoinCluster(), oversim::Chord::handleJoinTimerExpired(), Broose::handleJoinTimerExpired(), BaseOverlay::handleMessage(), BaseApp::handleMessage(), PubSubMMOG::handleMove(), PubSubMMOG::handleMoveMessage(), oversim::Chord::handleNewSuccessorHint(), PubSubMMOG::handlePingCall(), oversim::Nice::handleQuery(), oversim::Nice::handleQueryResponse(), SimpleGameClient::handleRealworldPacket(), BasePastry::handleRequestMessage(), oversim::Koorde::handleRpcCall(), oversim::Chord::handleRpcCall(), oversim::Koorde::handleRpcDeBruijnRequest(), oversim::Chord::handleRpcFixfingersResponse(), oversim::Chord::handleRpcJoinResponse(), oversim::Chord::handleRpcNotifyResponse(), PubSubMMOG::handleRpcResponse(), oversim::Koorde::handleRpcResponse(), oversim::Chord::handleRpcResponse(), Broose::handleRpcResponse(), oversim::Chord::handleRpcStabilizeResponse(), PubSubMMOG::handleRpcTimeout(), PubSubLobby::handleRpcTimeout(), oversim::Koorde::handleRpcTimeout(), Kademlia::handleRpcTimeout(), oversim::Chord::handleRpcTimeout(), Broose::handleRpcTimeout(), oversim::Chord::handleStabilizeTimerExpired(), Pastry::handleStateMessage(), Bamboo::handleStateMessage(), PubSubMMOG::handleSubscriptionCall(), Pastry::handleTimerEvent(), oversim::Nice::handleTimerEvent(), KBRTestApp::handleTimerEvent(), DHTTestApp::handleTimerEvent(), Bamboo::handleTimerEvent(), BaseOverlay::handleTransportAddressChangedNotification(), Quon::handleUDPMessage(), Pastry::handleUDPMessage(), oversim::Nice::handleUDPMessage(), Bamboo::handleUDPMessage(), BaseOverlay::initialize(), BaseApp::initialize(), Landmark::initializeApp(), KBRTestApp::initializeApp(), I3::initializeApp(), oversim::Koorde::initializeFriendModules(), oversim::Chord::initializeFriendModules(), Vast::initializeOverlay(), Quon::initializeOverlay(), PubSubMMOG::initializeOverlay(), PubSubLobby::initializeOverlay(), oversim::Nice::initializeOverlay(), oversim::Chord::initializeOverlay(), I3::insertTrigger(), internalHandleRpcMessage(), BaseOverlay::internalHandleRpcTimeout(), Kademlia::isSiblingFor(), oversim::Chord::isSiblingFor(), Broose::isSiblingFor(), BasePastry::isSiblingFor(), BaseOverlay::join(), oversim::Nice::JoinCluster(), oversim::Chord::joinForeignPartition(), Kademlia::joinOverlay(), oversim::Nice::LeaderTransfer(), SendToKeyListener::lookupFinished(), Bamboo::lookupFinished(), BaseOverlay::lookupRpc(), oversim::Nice::maintenance(), Pastry::mergeState(), BaseOverlay::neighborSet(), BasePastry::newLeafs(), BasePastry::pingNodes(), BasePastry::pingResponse(), oversim::Chord::pingTimeout(), BasePastry::pingTimeout(), oversim::Nice::pollRP(), BasePastry::prePing(), BasePastry::proxCallback(), Quon::purgeSites(), oversim::Nice::Query(), BasePastry::recursiveRoutingHook(), oversim::Nice::Remove(), BaseOverlay::route(), Kademlia::routingInit(), oversim::Chord::rpcFixfingers(), oversim::Chord::rpcJoin(), oversim::Chord::rpcNotify(), oversim::Nice::sendDataToOverlay(), oversim::Nice::sendHeartbeats(), oversim::Nice::sendHeartbeatTo(), BasePastry::sendLeafset(), Quon::sendMessage(), BaseOverlay::sendMessageToUDP(), BaseApp::sendMessageToUDP(), I3::sendPacket(), I3::sendQueryReply(), BasePastry::sendRequest(), BaseOverlay::sendRouteMessage(), BasePastry::sendRoutingRow(), sendRpcCall(), sendRpcResponse(), BasePastry::sendStateTables(), Quon::sendToApp(), BaseOverlay::sendToKey(), Kademlia::setBucketUsage(), BaseOverlay::setOverlayReady(), BaseOverlay::setOwnNodeID(), Nps::showReceivedCoords(), PubSubMMOG::startTimer(), PubSubMMOG::takeOverSubspace(), SimpleGameClient::updateNeighbors(), NeighborCache::updateNode(), Quon::updateThisSite(), oversim::Koorde::updateTooltip(), Kademlia::updateTooltip(), Gia::updateTooltip(), oversim::Chord::updateTooltip(), Broose::updateTooltip(), BasePastry::updateTooltip(), and oversim::Nice::updateVisualization().
1.5.8