Base class for RPCs. More...
#include <BaseRpc.h>
Public Member Functions | |
BaseRpc () | |
const NodeHandle & | getThisNode () |
Returns the NodeHandle of this node. | |
simtime_t | getUdpTimeout () |
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. | |
int | 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 | optimizeTimeouts |
bool | rpcExponentialBackoff |
Base class for RPCs.
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 158 of file BaseRpc.cc.
Referenced by Pastry::changeState(), and finishRpcs().
00159 { 00160 // stop all rpcs 00161 for (RpcStates::iterator i = rpcStates.begin(); 00162 i != rpcStates.end(); i++) { 00163 cancelAndDelete(i->second.callMsg); 00164 cancelAndDelete(i->second.timeoutMsg); 00165 delete i->second.dest; 00166 i->second.dest = NULL; 00167 delete i->second.context; 00168 i->second.context = NULL; 00169 } 00170 rpcStates.clear(); 00171 }
void BaseRpc::cancelRpcMessage | ( | uint32_t | nonce | ) | [protected] |
Cancels a Remote-Procedure-Call.
nonce | The nonce of the RPC |
Definition at line 278 of file BaseRpc.cc.
Referenced by RecursiveLookup::abortLookup(), XmlRpcInterface::resetConnectionState(), and IterativeLookup::stop().
00279 { 00280 if (rpcStates.count(nonce)==0) 00281 return; 00282 RpcState state = rpcStates[nonce]; 00283 rpcStates.erase(nonce); 00284 cancelAndDelete(state.callMsg); 00285 cancelAndDelete(state.timeoutMsg); 00286 delete state.dest; 00287 state.dest = NULL; 00288 delete state.context; 00289 state.context = NULL; 00290 }
void BaseRpc::finishRpcs | ( | ) | [protected] |
Deinitializes Remote-Procedure state.
Definition at line 147 of file BaseRpc.cc.
Referenced by BaseApp::~BaseApp(), and BaseOverlay::~BaseOverlay().
00148 { 00149 cancelAllRpcs(); 00150 00151 // delete default rpc listener 00152 if (defaultRpcListener != NULL) { 00153 delete defaultRpcListener; 00154 defaultRpcListener = NULL; 00155 } 00156 }
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(), IterativeLookup::addSibling(), 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(), DHT::handleGetRequest(), CBRDHT::handleGetResponse(), Scribe::handleJoinMessage(), Scribe::handleJoinResponse(), KBRTestApp::handleLookupResponse(), DHT::handleLookupResponse(), CBRDHT::handleLookupResponse(), BootstrapList::handleLookupResponse(), GIASearchApp::handleLowerMessage(), XmlRpcInterface::handleMessage(), BaseOverlay::handleMessage(), BaseApp::handleMessage(), SimMud::handleMove(), Kademlia::handleNodeGracefulLeaveNotification(), SimMud::handleOtherPlayerMove(), Scribe::handlePublishCall(), Scribe::handlePublishResponse(), DHT::handlePutRequest(), CBRDHT::handlePutRequest(), XmlRpcInterface::handleReadyMessage(), P2pns::handleReadyMessage(), IterativePathLookup::handleResponse(), Scribe::handleRpcResponse(), KBRTestApp::handleRpcResponse(), Kademlia::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(), BaseOverlay::join(), BrooseBucket::keyInRange(), XmlRpcInterface::localLookup(), IterativeLookup::lookup(), PastryLeafSet::mergeNode(), BrooseBucket::output(), P2pns::p2pnsRegisterRpc(), BootstrapList::pingResponse(), BootstrapList::pingTimeout(), Kademlia::routingAdd(), Kademlia::routingBucketIndex(), BaseApp::sendMessageToUDP(), IterativePathLookup::sendRpc(), sendRpcCall(), sendRpcResponse(), BaseOverlay::setOverlayReady(), Nps::setOwnLayer(), IterativeLookup::start(), IterativeLookup::stop(), Scribe::subscribeToGroup(), Scribe::update(), DHT::update(), and CBRDHT::update().
00071 { return thisNode; };
simtime_t BaseRpc::getUdpTimeout | ( | ) | [inline] |
Definition at line 73 of file BaseRpc.h.
00073 { return rpcUdpTimeout; };
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, MyOverlay, PubSubLobby, PubSubMMOG, P2pns, and SimMud.
Definition at line 525 of file BaseRpc.cc.
Referenced by internalHandleRpcMessage().
void BaseRpc::handleTimerEvent | ( | cMessage * | msg | ) | [private, virtual] |
Reimplemented in ALMTest, DHT, GIASearchApp, I3, KBRTestApp, MyApplication, RealWorldTestApp, Scribe, SimpleGameClient, BootstrapList, CBRDHT, NeighborCache, Bamboo, Broose, oversim::Chord, Gia, Kademlia, oversim::Koorde, MyOverlay, oversim::Nice, Pastry, PubSubLobby, PubSubMMOG, Quon, Vast, DHTTestApp, P2pns, SimMud, and P2PNSTestApp.
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(), BaseApp::initialize(), and P2PNSTestApp::initializeApp().
00093 { 00094 // set friend modules 00095 globalStatistics = GlobalStatisticsAccess().get(); 00096 00097 rpcUdpTimeout = par("rpcUdpTimeout"); 00098 rpcKeyTimeout = par("rpcKeyTimeout"); 00099 optimizeTimeouts = par("optimizeTimeouts"); 00100 rpcExponentialBackoff = par("rpcExponentialBackoff"); 00101 00102 rpcsPending = 0; 00103 rpcStates.clear(); 00104 00105 defaultRpcListener = new RpcListener(); 00106 00107 //set ping cache 00108 numPingSent = 0; 00109 bytesPingSent = 0; 00110 numPingResponseSent = 0; 00111 bytesPingResponseSent = 0; 00112 00113 WATCH(numPingSent); 00114 WATCH(bytesPingSent); 00115 WATCH(numPingResponseSent); 00116 WATCH(bytesPingResponseSent); 00117 00118 // set overlay pointer 00119 overlay = OverlayAccess().get(this); 00120 00121 // register component 00122 thisCompType = getThisCompType(); 00123 overlay->registerComp(thisCompType, this); 00124 00125 // get pointer to the neighborCache 00126 cModule *mod = getParentModule(); 00127 while (neighborCache == NULL) { 00128 neighborCache = (NeighborCache*)mod->getSubmodule("neighborCache"); 00129 mod = mod->getParentModule(); 00130 if (!mod) 00131 throw cRuntimeError("BaseRpc::initRpc: " 00132 "Module type contains no NeighborCache!"); 00133 } 00134 00135 // get pointer to the cryptoModule 00136 mod = getParentModule(); 00137 cryptoModule = NULL; 00138 while (cryptoModule == NULL) { 00139 cryptoModule = (CryptoModule*)mod->getSubmodule("cryptoModule"); 00140 mod = mod->getParentModule(); 00141 if (!mod) 00142 throw cRuntimeError("BaseRpc::initRpc: CryptoModule not found!"); 00143 } 00144 }
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 490 of file BaseRpc.cc.
Referenced by internalHandleRpcMessage().
00491 { 00492 RPC_SWITCH_START( msg ); 00493 RPC_DELEGATE( Ping, pingRpcCall ); 00494 RPC_SWITCH_END( ); 00495 00496 return RPC_HANDLED; 00497 }
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 293 of file BaseRpc.cc.
Referenced by BaseOverlay::handleBaseOverlayMessage(), BaseApp::handleCommonAPIMessage(), XmlRpcInterface::handleMessage(), and internalHandleMessage().
00294 { 00295 // check if this is a rpc call message 00296 BaseCallMessage* rpCall = dynamic_cast<BaseCallMessage*>(msg); 00297 if (rpCall != NULL) { 00298 // verify the message signature 00299 //cryptoModule->verifyMessage(msg); 00300 00301 OverlayCtrlInfo* overlayCtrlInfo = 00302 dynamic_cast<OverlayCtrlInfo*>(msg->getControlInfo()); 00303 00304 if (overlayCtrlInfo && overlayCtrlInfo->getSrcRoute().isUnspecified() && 00305 (!overlayCtrlInfo->getLastHop().isUnspecified())) { 00306 overlayCtrlInfo->setSrcRoute(NodeHandle(msg->getSrcNode().getKey(), 00307 overlayCtrlInfo->getLastHop())); 00308 } 00309 00310 bool rpcHandled = true; 00311 if (!handleRpcCall(rpCall)) rpcHandled = internalHandleRpcCall(rpCall); 00312 if (!rpcHandled) { 00313 EV << "[BaseRpc::internalHandleRpcMessage() @ " << thisNode.getAddress() 00314 << " (" << thisNode.getKey().toString(16) << ")]\n" 00315 << " Error: RPC '" << msg->getFullName()<< "' was not handled" 00316 << endl; 00317 delete msg; 00318 } 00319 return; 00320 } 00321 00322 // get nonce 00323 int nonce = msg->getNonce(); 00324 00325 // nonce known? no -> delete message and return 00326 if (rpcStates.count(nonce)==0) { 00327 EV << "[BaseRpc::internalHandleRpcMessage() @ " << thisNode.getAddress() 00328 << " " << thisNode.getKey().toString(16) << ")]\n" 00329 << " RPC: Nonce Unknown" 00330 << endl; 00331 delete msg; 00332 return; 00333 } 00334 00335 // get state and remove from map 00336 RpcState state = rpcStates[nonce]; 00337 rpcStates.erase(nonce); 00338 00339 // is timeout message? 00340 if (msg->isSelfMessage() && 00341 (dynamic_cast<RpcTimeoutMessage*>(msg) != NULL)) { 00342 // yes-> inform listener 00343 00344 // retry? 00345 state.retries--; 00346 if (state.retries>=0) { 00347 // TODO: cleanup code to have only one type for source routes 00348 std::vector<TransportAddress> sourceRoute; 00349 sourceRoute.push_back(*state.dest); 00350 if (state.dest->getSourceRouteSize() > 0) { 00351 sourceRoute.insert(sourceRoute.begin(), 00352 state.dest->getSourceRoute().rend(), 00353 state.dest->getSourceRoute().rbegin()); 00354 // remove the original source route from the destination 00355 sourceRoute.back().clearSourceRoute(); 00356 } 00357 00358 sendRpcMessageWithTransport(state.transportType, state.destComp, 00359 state.routingType, 00360 sourceRoute, 00361 state.destKey, 00362 dynamic_cast<BaseCallMessage*> 00363 (state.callMsg->dup())); 00364 00365 if (rpcExponentialBackoff) { 00366 state.rto *= 2; 00367 } 00368 00369 if (state.rto!=0) 00370 scheduleAt(simTime() + state.rto, msg); 00371 00372 state.timeSent = simTime(); 00373 rpcStates[nonce] = state; 00374 return; 00375 } 00376 EV << "[BaseRpc::internalHandleRpcMessage() @ " << thisNode.getAddress() 00377 << " " << thisNode.getKey().toString(16) << ")]\n" 00378 << " RPC timeout (" << state.callMsg->getName() << ")" 00379 << endl; 00380 00381 // inform neighborcache 00382 if (state.transportType == UDP_TRANSPORT || 00383 (!state.dest->isUnspecified() && state.destKey.isUnspecified())) { 00384 neighborCache->setNodeTimeout(*state.dest); 00385 } 00386 00387 // inform listener 00388 if (state.listener != NULL) 00389 state.listener->handleRpcTimeout(state); 00390 00391 // inform overlay 00392 internalHandleRpcTimeout(state.callMsg, *state.dest, state.context, 00393 state.id, state.destKey); 00394 handleRpcTimeout(state); 00395 00396 } else { // no-> handle rpc response 00397 00398 // verify the message signature 00399 //cryptoModule->verifyMessage(msg); 00400 00401 OverlayCtrlInfo* overlayCtrlInfo = 00402 dynamic_cast<OverlayCtrlInfo*>(msg->getControlInfo()); 00403 00404 if (overlayCtrlInfo && overlayCtrlInfo->getSrcRoute().isUnspecified() && 00405 (!overlayCtrlInfo->getLastHop().isUnspecified())) { 00406 overlayCtrlInfo->setSrcRoute(NodeHandle(msg->getSrcNode().getKey(), 00407 overlayCtrlInfo->getLastHop())); 00408 } 00409 00410 // drop responses with wrong source key 00411 if (state.destKey.isUnspecified()) { 00412 const NodeHandle* stateHandle = 00413 dynamic_cast<const NodeHandle*>(state.dest); 00414 if (stateHandle != NULL && 00415 stateHandle->getKey() != msg->getSrcNode().getKey()) { 00416 00417 EV << "[BaseRpc::internalHandleRpcMessage() @ " 00418 << thisNode.getAddress() 00419 << " " << thisNode.getKey().toString(16) << ")]\n" 00420 << " Dropping RPC: Invalid source key" 00421 << endl; 00422 00423 // restore state to trigger timeout message 00424 rpcStates[nonce] = state; 00425 delete msg; 00426 return; 00427 } 00428 } 00429 00430 // get parameters 00431 simtime_t rtt = simTime() - state.timeSent; 00432 BaseResponseMessage* response 00433 = dynamic_cast<BaseResponseMessage*>(msg); 00434 00435 //if (state.transportType == UDP_TRANSPORT) 00436 // globalStatistics->recordOutVector("BaseRpc: UDP Round Trip Time", 00437 // rtt); 00438 00439 // neighborCache/vivaldi stuff 00440 if (state.transportType == UDP_TRANSPORT || 00441 (state.transportType != INTERNAL_TRANSPORT && 00442 response->getCallHopCount() == 1)) { //TODO 00443 if (neighborCache->adaptingNcs()) { 00444 std::vector<double> tempCoords(response->getNcsInfoArraySize()); 00445 for (uint8_t i = 0; i < response->getNcsInfoArraySize(); i++) { 00446 tempCoords[i] = response->getNcsInfo(i); 00447 } 00448 AbstractNcsNodeInfo* coords = 00449 neighborCache->getNcsAccess().createNcsInfo(tempCoords); 00450 00451 OverlayCtrlInfo* ctrlInfo = 00452 dynamic_cast<OverlayCtrlInfo*>(response->getControlInfo()); 00453 00454 neighborCache->updateNode(response->getSrcNode(), rtt, 00455 (ctrlInfo ? 00456 ctrlInfo->getSrcRoute() : 00457 NodeHandle::UNSPECIFIED_NODE), 00458 coords); 00459 } else { 00460 neighborCache->updateNode(response->getSrcNode(), rtt); 00461 } 00462 } 00463 00464 // inform listener 00465 if (state.listener != NULL) 00466 state.listener->handleRpcResponse(response, state, rtt); 00467 00468 // inform overlay 00469 internalHandleRpcResponse(response, state.context, state.id, rtt); 00470 handleRpcResponse(response, state, rtt); 00471 00472 // delete response 00473 delete response->removeControlInfo(); 00474 delete response; 00475 } 00476 00477 // delete messages 00478 delete state.callMsg; 00479 cancelAndDelete(state.timeoutMsg); 00480 delete state.dest; 00481 00482 // clean up pointers 00483 state.dest = NULL; 00484 state.context = NULL; 00485 state.callMsg = NULL; 00486 state.timeoutMsg = NULL; 00487 }
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 499 of file BaseRpc.cc.
Referenced by internalHandleRpcMessage().
00502 { 00503 // call rpc stubs 00504 RPC_SWITCH_START( msg ); 00505 RPC_ON_RESPONSE( Ping ) { 00506 pingRpcResponse(_PingResponse, context, rpcId, rtt); 00507 } 00508 RPC_SWITCH_END( ); 00509 }
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 511 of file BaseRpc.cc.
Referenced by internalHandleRpcMessage().
00515 { 00516 RPC_SWITCH_START( msg ) { 00517 RPC_ON_CALL( Ping ) { 00518 pingRpcTimeout(_PingCall, dest, context, rpcId); 00519 } 00520 } 00521 RPC_SWITCH_END( ) 00522 }
virtual void BaseRpc::internalSendRouteRpc | ( | BaseRpcMessage * | message, | |
const OverlayKey & | destKey, | |||
const std::vector< TransportAddress > & | sourceRoute, | |||
RoutingType | routingType | |||
) | [private, pure virtual] |
Implemented in BaseApp, and BaseOverlay.
Referenced by sendRpcMessageWithTransport().
virtual void BaseRpc::internalSendRpcResponse | ( | BaseCallMessage * | call, | |
BaseResponseMessage * | response | |||
) | [private, pure virtual] |
Implemented in BaseApp, and BaseOverlay.
Referenced by sendRpcResponse().
int 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 700 of file BaseRpc.cc.
Referenced by IterativeLookup::addSibling(), Pastry::changeState(), BootstrapList::handleBootstrapListTimerExpired(), Broose::handleBucketTimerExpired(), oversim::Chord::handleStabilizeTimerExpired(), P2pns::handleTimerEvent(), KBRTestApp::handleTimerEvent(), Kademlia::handleTimerEvent(), oversim::Chord::handleTimerEvent(), Pastry::handleUDPMessage(), Kademlia::joinOverlay(), NeighborCache::queryProx(), and Kademlia::routingAdd().
00704 { 00705 PingCall* call = new PingCall(caption); 00706 call->setBitLength(PINGCALL_L(call)); 00707 RECORD_STATS(numPingSent++; bytesPingSent += call->getByteLength()); 00708 00709 if (transportType == UDP_TRANSPORT || 00710 (transportType != ROUTE_TRANSPORT && 00711 getThisCompType() == OVERLAY_COMP)) { 00712 return sendUdpRpcCall(dest, call, context, timeout, retries, rpcId, 00713 rpcListener); 00714 } else { 00715 return sendRouteRpcCall(getThisCompType(), dest, call, context, 00716 DEFAULT_ROUTING, timeout, retries, rpcId, 00717 rpcListener); 00718 } 00719 }
void BaseRpc::pingResponse | ( | PingResponse * | pingResponse, | |
cPolymorphic * | context, | |||
int | rpcId, | |||
simtime_t | rtt | |||
) | [protected, virtual] |
Reimplemented in KBRTestApp, BootstrapList, Broose, oversim::Chord, BasePastry, and Pastry.
Definition at line 657 of file BaseRpc.cc.
Referenced by pingRpcResponse().
void BaseRpc::pingRpcCall | ( | PingCall * | call | ) | [private] |
Definition at line 667 of file BaseRpc.cc.
Referenced by internalHandleRpcCall().
00668 { 00669 std::string pongName(call->getName()); 00670 if (pongName == "PING") 00671 pongName = "PONG"; 00672 else { 00673 pongName = "PONG: [ "; 00674 pongName += call->getName(); 00675 pongName += " ]"; 00676 } 00677 00678 PingResponse* response = new PingResponse(pongName.c_str()); 00679 response->setBitLength(PINGRESPONSE_L(response)); 00680 RECORD_STATS(numPingResponseSent++; bytesPingResponseSent += 00681 response->getByteLength()); 00682 00683 sendRpcResponse(call, response ); 00684 }
void BaseRpc::pingRpcResponse | ( | PingResponse * | response, | |
cPolymorphic * | context, | |||
int | rpcId, | |||
simtime_t | rtt | |||
) | [private] |
Reimplemented in P2pns.
Definition at line 686 of file BaseRpc.cc.
Referenced by internalHandleRpcResponse().
00688 { 00689 pingResponse(response, context, rpcId, rtt); 00690 }
void BaseRpc::pingRpcTimeout | ( | PingCall * | pingCall, | |
const TransportAddress & | dest, | |||
cPolymorphic * | context, | |||
int | rpcId | |||
) | [private] |
Definition at line 692 of file BaseRpc.cc.
Referenced by internalHandleRpcTimeout().
00696 { 00697 pingTimeout(pingCall, dest, context, rpcId); 00698 }
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 662 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(), 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 429 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(), MyOverlay::getNeighbors(), 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(), DHT::sendMaintenancePutCall(), Scribe::subscribeToGroup(), Scribe::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 173 of file BaseRpc.cc.
Referenced by sendInternalRpcCall(), sendRouteRpcCall(), and sendUdpRpcCall().
00184 { 00185 // create nonce, timeout and set default parameters 00186 uint32_t nonce; 00187 do { 00188 nonce = intuniform(1, 2147483647); 00189 } while (rpcStates.count(nonce) > 0); 00190 00191 if (timeout == -1) { 00192 switch (transportType) { 00193 case INTERNAL_TRANSPORT: 00194 timeout = 0; 00195 break; 00196 case UDP_TRANSPORT: 00197 if (optimizeTimeouts) { 00198 timeout = neighborCache->getNodeTimeout(dest); 00199 if (timeout == -1) timeout = rpcUdpTimeout; 00200 } else timeout = rpcUdpTimeout; 00201 break; 00202 case ROUTE_TRANSPORT: 00203 timeout = (destKey.isUnspecified() ? 00204 rpcUdpTimeout : 00205 rpcKeyTimeout); 00206 break; 00207 default: 00208 throw cRuntimeError("BaseRpc::sendRpcMessage(): " 00209 "Unknown RpcTransportType!"); 00210 } 00211 } 00212 00213 if (rpcListener == NULL) 00214 rpcListener = defaultRpcListener; 00215 00216 // create state 00217 RpcState state; 00218 state.id = rpcId; 00219 state.timeSent = simTime(); 00220 state.dest = dest.dup(); 00221 state.destKey = destKey; 00222 state.srcComp = getThisCompType(); 00223 state.destComp = destComp; 00224 state.listener = rpcListener; 00225 state.timeoutMsg = new RpcTimeoutMessage(); 00226 state.timeoutMsg->setNonce(nonce); 00227 state.retries = retries; 00228 state.rto = timeout; 00229 state.transportType = transportType; 00230 //state.transportType = (destKey.isUnspecified() && (dest.getSourceRouteSize() == 0) 00231 // ? UDP_TRANSPORT : transportType); //test 00232 state.routingType = routingType; 00233 state.context = context; 00234 00235 if (rpcStates.count(nonce) > 0) 00236 throw cRuntimeError("RPC nonce collision"); 00237 00238 // set message parameters 00239 msg->setNonce(nonce); 00240 if (transportType == ROUTE_TRANSPORT) 00241 msg->setSrcNode(overlay->getThisNode()); 00242 else 00243 msg->setSrcNode(thisNode); 00244 msg->setType(RPC); 00245 00246 // sign the message 00247 // if (transportType != INTERNAL_TRANSPORT) cryptoModule->signMessage(msg); 00248 00249 // save copy of call message in RpcState 00250 state.callMsg = dynamic_cast<BaseCallMessage*>(msg->dup()); 00251 assert(!msg->getEncapsulatedPacket() || !msg->getEncapsulatedPacket()->getControlInfo()); 00252 00253 // register state 00254 rpcStates[nonce] = state; 00255 00256 // schedule timeout message 00257 if (state.rto != 0) 00258 scheduleAt(simTime() + state.rto, state.timeoutMsg); 00259 00260 // TODO: cleanup code to have only one type for source routes 00261 std::vector<TransportAddress> sourceRoute; 00262 sourceRoute.push_back(dest); 00263 if (dest.getSourceRouteSize() > 0) { 00264 state.transportType = transportType = ROUTE_TRANSPORT; 00265 sourceRoute.insert(sourceRoute.begin(), dest.getSourceRoute().rend(), 00266 dest.getSourceRoute().rbegin()); 00267 // remove the original source route from the destination 00268 sourceRoute.back().clearSourceRoute(); 00269 } 00270 sendRpcMessageWithTransport(transportType, destComp, routingType, 00271 sourceRoute, destKey, msg); 00272 00273 return nonce; 00274 }
void BaseRpc::sendRpcMessageWithTransport | ( | TransportType | transportType, | |
CompType | destComp, | |||
RoutingType | routingType, | |||
const std::vector< TransportAddress > & | sourceRoute, | |||
const OverlayKey & | destKey, | |||
BaseRpcMessage * | message | |||
) | [private] |
Definition at line 618 of file BaseRpc.cc.
Referenced by internalHandleRpcMessage(), sendRpcCall(), and sendRpcResponse().
00624 { 00625 switch (transportType) { 00626 case UDP_TRANSPORT: { 00627 sendMessageToUDP(sourceRoute[0], message); 00628 break; 00629 } 00630 case ROUTE_TRANSPORT: { 00631 internalSendRouteRpc(message, destKey, 00632 sourceRoute, routingType); 00633 break; 00634 } 00635 case INTERNAL_TRANSPORT: { 00636 cGate *destCompGate = overlay->getCompRpcGate(destComp); 00637 if (destCompGate == NULL) { 00638 throw cRuntimeError("BaseRpc::sendRpcMessageWithTransport():" 00639 " INTERNAL_RPC to unknown RpcCompType!"); 00640 } 00641 OverlayCtrlInfo *overlayCtrlInfo = new OverlayCtrlInfo(); 00642 overlayCtrlInfo->setSrcComp(getThisCompType()); 00643 overlayCtrlInfo->setDestComp(destComp); 00644 overlayCtrlInfo->setTransportType(INTERNAL_TRANSPORT); 00645 message->setControlInfo(overlayCtrlInfo); 00646 sendDirect(message, destCompGate); 00647 break; 00648 } 00649 default: 00650 throw cRuntimeError("BaseRpc::sendRpcMessageWithTransport: " 00651 "invalid transportType!"); 00652 break; 00653 } 00654 }
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 598 of file BaseRpc.cc.
00600 { 00601 const TransportAddress* destNode = &(call->getSrcNode()); 00602 const OverlayKey* destKey = &(call->getSrcNode().getKey()); 00603 00604 OverlayCtrlInfo* overlayCtrlInfo = 00605 dynamic_cast<OverlayCtrlInfo*>(call->getControlInfo()); 00606 00607 // "magic" transportType selection: internal 00608 if (overlayCtrlInfo && 00609 overlayCtrlInfo->getTransportType() == INTERNAL_TRANSPORT) { 00610 sendRpcResponse(INTERNAL_TRANSPORT, 00611 static_cast<CompType>(overlayCtrlInfo->getSrcComp()), 00612 *destNode, *destKey, call, response); 00613 } else { 00614 internalSendRpcResponse(call, response); 00615 } 00616 }
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 530 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(), MyOverlay::handleRpcCall(), 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().
00536 { 00537 if (call == NULL || response == NULL) { 00538 throw cRuntimeError("call or response = NULL!"); 00539 } 00540 00541 // vivaldi: set coordinates and error estimation in response 00542 if (neighborCache->adaptingNcs()) { //TODO only for directly sent msgs 00543 std::vector<double> nodeCoord = 00544 neighborCache->getNcsAccess().getOwnNcsInfo(); 00545 00546 response->setNcsInfoArraySize(nodeCoord.size()); 00547 for (uint32_t i = 0; i < nodeCoord.size(); i++) { 00548 response->setNcsInfo(i, nodeCoord[i]); 00549 } 00550 } 00551 00552 assert(transportType == INTERNAL_TRANSPORT || 00553 !dest.isUnspecified() || 00554 !destKey.isUnspecified()); 00555 00556 if (transportType == ROUTE_TRANSPORT) 00557 response->setSrcNode(overlay->getThisNode()); 00558 else 00559 response->setSrcNode(thisNode); 00560 response->setType(RPC); 00561 response->setNonce(call->getNonce()); 00562 response->setStatType(call->getStatType()); 00563 00564 RoutingType routingType = NO_OVERLAY_ROUTING; 00565 OverlayCtrlInfo* overlayCtrlInfo = NULL; 00566 if (dynamic_cast<OverlayCtrlInfo*>(call->getControlInfo())) { 00567 overlayCtrlInfo = 00568 static_cast<OverlayCtrlInfo*>(call->removeControlInfo()); 00569 response->setCallHopCount(overlayCtrlInfo->getHopCount()); 00570 } else { 00571 delete call->removeControlInfo(); 00572 response->setCallHopCount(1); // one udp hop (?) 00573 } 00574 00575 // source routing 00576 std::vector<TransportAddress> sourceRoute; 00577 if (overlayCtrlInfo && transportType == ROUTE_TRANSPORT) { 00578 routingType = 00579 static_cast<RoutingType>(overlayCtrlInfo->getRoutingType()); 00580 for (uint32_t i = overlayCtrlInfo->getVisitedHopsArraySize(); i > 0; --i) { 00581 sourceRoute.push_back(overlayCtrlInfo->getVisitedHops(i - 1)); 00582 } 00583 } 00584 00585 if (sourceRoute.size() == 0) { 00586 // empty visited hops list => direct response 00587 sourceRoute.push_back(dest); 00588 } 00589 00590 sendRpcMessageWithTransport(transportType, compType, 00591 routingType, sourceRoute, 00592 destKey, response); 00593 delete overlayCtrlInfo; 00594 delete call; 00595 }
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(), Kademlia::handleNodeGracefulLeaveNotification(), 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(), Kademlia::sendSiblingFindNodeCall(), 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 450 of file BaseRpc.h.
Referenced by BaseOverlay::finish(), initRpcs(), and pingRpcCall().
int BaseRpc::bytesPingSent [protected] |
Definition at line 448 of file BaseRpc.h.
Referenced by BaseOverlay::finish(), initRpcs(), and pingNode().
CryptoModule* BaseRpc::cryptoModule [protected] |
pointer to CryptoModule
Definition at line 445 of file BaseRpc.h.
Referenced by BaseRpc(), and initRpcs().
bool BaseRpc::debugOutput [protected] |
debug output ?
Reimplemented in BaseApp, BaseOverlay, DHTTestApp, and P2PNSTestApp.
RpcListener* BaseRpc::defaultRpcListener [private] |
Definition at line 522 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, DHTTestApp, and P2PNSTestApp.
Definition at line 86 of file BaseRpc.h.
Referenced by BaseOverlay::finish(), Vast::finishOverlay(), Quon::finishOverlay(), PubSubMMOG::finishOverlay(), PubSubLobby::finishOverlay(), MyOverlay::finishOverlay(), oversim::Koorde::finishOverlay(), Kademlia::finishOverlay(), Gia::finishOverlay(), oversim::Chord::finishOverlay(), Broose::finishOverlay(), BasePastry::finishOverlay(), Kademlia::handleBucketRefreshTimerExpired(), PubSubMMOG::handleMoveListMessage(), Vast::handleNodeMove(), Quon::handleNodeMove(), initRpcs(), and SendToKeyListener::SendToKeyListener().
NeighborCache* BaseRpc::neighborCache [protected] |
pointer to the neighbor cache
Reimplemented in CBRDHT, and NeighborCache.
Definition at line 444 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(), sendRpcCall(), and sendRpcResponse().
int BaseRpc::numPingResponseSent [protected] |
Definition at line 449 of file BaseRpc.h.
Referenced by BaseOverlay::finish(), initRpcs(), and pingRpcCall().
int BaseRpc::numPingSent [protected] |
Definition at line 447 of file BaseRpc.h.
Referenced by BaseOverlay::finish(), initRpcs(), and pingNode().
bool BaseRpc::optimizeTimeouts [private] |
Definition at line 525 of file BaseRpc.h.
Referenced by initRpcs(), and sendRpcCall().
BaseOverlay* BaseRpc::overlay [protected] |
Definition at line 80 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(), DHT::handleGetRequest(), 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(), Nps::init(), 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(), DHT::sendMaintenancePutCall(), BaseApp::sendMessageToUDP(), BaseApp::sendReadyMessage(), sendRpcCall(), sendRpcMessageWithTransport(), sendRpcResponse(), Nps::setOwnLayer(), Scribe::subscribeToGroup(), Scribe::update(), DHT::update(), and CBRDHT::update().
bool BaseRpc::rpcExponentialBackoff [private] |
Definition at line 526 of file BaseRpc.h.
Referenced by initRpcs(), and internalHandleRpcMessage().
simtime_t BaseRpc::rpcKeyTimeout [private] |
Definition at line 524 of file BaseRpc.h.
Referenced by initRpcs(), and sendRpcCall().
int BaseRpc::rpcsPending [private] |
Definition at line 521 of file BaseRpc.h.
Referenced by initRpcs().
RpcStates BaseRpc::rpcStates [private] |
Definition at line 523 of file BaseRpc.h.
Referenced by cancelAllRpcs(), cancelRpcMessage(), initRpcs(), internalHandleRpcMessage(), and sendRpcCall().
simtime_t BaseRpc::rpcUdpTimeout [private] |
Definition at line 524 of file BaseRpc.h.
Referenced by initRpcs(), and sendRpcCall().
CompType BaseRpc::thisCompType [protected] |
Definition at line 427 of file BaseRpc.h.
Referenced by BaseApp::callRoute(), and initRpcs().
NodeHandle BaseRpc::thisNode [protected] |
NodeHandle to this node.
Definition at line 73 of file BaseRpc.h.
Referenced by Quon::addSite(), BasePastry::baseChangeState(), BasePastry::baseInit(), BaseOverlay::bindToPort(), BaseApp::bindToPort(), MyOverlay::callbackNeighbors(), MyOverlay::callbackTimeout(), BaseApp::callRoute(), BaseOverlay::callUpdate(), Quon::changeState(), Pastry::changeState(), Gia::changeState(), oversim::Chord::changeState(), Broose::changeState(), Bamboo::changeState(), Pastry::checkProxCache(), oversim::Chord::closestPreceedingNode(), Nps::coordsReqRpcResponse(), Quon::deleteSite(), MyApplication::deliver(), Broose::displayBucketState(), Bamboo::doGlobalTuning(), Pastry::doJoinUpdate(), Bamboo::doLocalTuning(), Pastry::doRoutingTableMaintenance(), Pastry::doSecondStage(), Pastry::endProcessingState(), oversim::Koorde::findDeBruijnHop(), MyOverlay::findNode(), oversim::Koorde::findNode(), Kademlia::findNode(), oversim::Chord::findNode(), Broose::findNode(), BasePastry::findNode(), BaseOverlay::findNodeRpc(), oversim::Chord::finishOverlay(), BasePastry::finishOverlay(), MyOverlay::getNeighbors(), getThisNode(), PubSubMMOG::handleAdoptChildCall(), PubSubMMOG::handleAdoptChildResponse(), Quon::handleAppMessage(), BaseOverlay::handleBaseOverlayMessage(), BaseApp::handleCommonAPIMessage(), oversim::Koorde::handleDeBruijnTimerExpired(), Pastry::handleFailedNode(), oversim::Chord::handleFixFingersTimerExpired(), PubSubMMOG::handleHelpResponse(), PubSubMMOG::handleIntermediateResponse(), oversim::Chord::handleJoinTimerExpired(), Broose::handleJoinTimerExpired(), BaseOverlay::handleMessage(), BaseApp::handleMessage(), PubSubMMOG::handleMove(), PubSubMMOG::handleMoveMessage(), oversim::Chord::handleNewSuccessorHint(), PubSubMMOG::handlePingCall(), SimpleGameClient::handleRealworldPacket(), BasePastry::handleRequestMessage(), MyOverlay::handleRpcCall(), 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(), MyApplication::handleTimerEvent(), KBRTestApp::handleTimerEvent(), DHTTestApp::handleTimerEvent(), Bamboo::handleTimerEvent(), BaseOverlay::handleTransportAddressChangedNotification(), Quon::handleUDPMessage(), Pastry::handleUDPMessage(), MyApplication::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(), MyOverlay::initializeOverlay(), oversim::Chord::initializeOverlay(), I3::insertTrigger(), internalHandleRpcMessage(), BaseOverlay::internalHandleRpcTimeout(), MyOverlay::isSiblingFor(), Kademlia::isSiblingFor(), oversim::Chord::isSiblingFor(), Broose::isSiblingFor(), BasePastry::isSiblingFor(), BaseOverlay::join(), oversim::Chord::joinForeignPartition(), MyOverlay::joinOverlay(), Kademlia::joinOverlay(), SendToKeyListener::lookupFinished(), Bamboo::lookupFinished(), BaseOverlay::lookupRpc(), Pastry::mergeState(), BaseOverlay::neighborSet(), BasePastry::newLeafs(), BasePastry::pingNodes(), Pastry::pingResponse(), oversim::Chord::pingResponse(), BasePastry::pingResponse(), oversim::Chord::pingTimeout(), BasePastry::pingTimeout(), BasePastry::prePing(), BasePastry::proxCallback(), Quon::purgeSites(), oversim::Nice::Query(), Pastry::recursiveRoutingHook(), BaseOverlay::route(), Kademlia::routingInit(), oversim::Chord::rpcFixfingers(), oversim::Chord::rpcJoin(), oversim::Chord::rpcNotify(), BasePastry::sendLeafset(), Quon::sendMessage(), BaseOverlay::sendMessageToUDP(), BaseApp::sendMessageToUDP(), I3::sendPacket(), I3::sendQueryReply(), BasePastry::sendRequest(), BaseOverlay::sendRouteMessage(), BasePastry::sendRoutingRow(), sendRpcCall(), sendRpcResponse(), Kademlia::sendSiblingFindNodeCall(), BasePastry::sendStateTables(), Quon::sendToApp(), BaseOverlay::sendToKey(), Kademlia::setBucketUsage(), BaseOverlay::setOverlayReady(), MyOverlay::setOwnNodeID(), BaseOverlay::setOwnNodeID(), PubSubMMOG::startTimer(), PubSubMMOG::takeOverSubspace(), NeighborCache::updateNcsInfo(), SimpleGameClient::updateNeighbors(), NeighborCache::updateNode(), Quon::updateThisSite(), oversim::Koorde::updateTooltip(), Kademlia::updateTooltip(), Gia::updateTooltip(), oversim::Chord::updateTooltip(), Broose::updateTooltip(), and BasePastry::updateTooltip().