BaseRpc Class Reference

#include <BaseRpc.h>

Inheritance diagram for BaseRpc:

RpcListener BaseApp BaseOverlay BootstrapList DHT DHTTestApp GIASearchApp I3 KBRTestApp P2pns RealWorldTestApp Scribe SimMud SimpleGameClient TierDummy XmlRpcInterface BasePastry Broose Gia Kademlia OverlayDummy oversim::Chord PubSubLobby PubSubMMOG QuonP QuonPR Vast

List of all members.


Detailed Description

Base class for RPCs.

Base class for RPCs.

Author:
Sebastian Mies

Ingmar Baumgart

Bernhard Heep

Gregoire Menuel

Definition at line 52 of file BaseRpc.h.


Public Member Functions

 BaseRpc ()
const NodeHandle & getThisNode ()
 Returns the NodeHandle of this node.

Protected Member Functions

virtual bool internalHandleRpc (BaseCallMessage *msg)
 Handles internal rpc requests.
virtual bool 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 corresponsing 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, bool overrideCache=true)
 ping a node by its TransportAddress
virtual bool handleRpc (BaseCallMessage *msg)
 Processes Remote-Procedure-Call invokation 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)

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
int numPingSent
int bytesPingSent
int numPingResponseSent
int bytesPingResponseSent

Private Types

typedef UNORDERED_MAP< int,
RpcState > 
RpcStates

Private Member Functions

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 pingRpc (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
double rpcUdpTimeout
double rpcKeyTimeout
bool rpcExponentialBackoff

Classes

class  RpcState

Member Typedef Documentation

typedef UNORDERED_MAP<int,RpcState> BaseRpc::RpcStates [private]

Definition at line 529 of file BaseRpc.h.


Constructor & Destructor Documentation

BaseRpc::BaseRpc (  ) 

Definition at line 54 of file BaseRpc.cc.

00055 {
00056     defaultRpcListener = NULL;
00057 }


Member Function Documentation

const NodeHandle& BaseRpc::getThisNode (  )  [inline]

Returns the NodeHandle of this node.

Returns:
the NodeHandle of this node.

Definition at line 64 of file BaseRpc.h.

Referenced by Scribe::addChildToGroup(), BaseApp::callRoute(), Scribe::checkGroupEmpty(), RealWorldTestApp::deliver(), KBRTestApp::deliver(), Scribe::deliverALMDataToGroup(), Scribe::forward(), KBRTestApp::forward(), BootstrapList::getBootstrapNode(), Kademlia::handleBucketRefreshTimerExpired(), BaseApp::handleCommonAPIMessage(), Scribe::handleJoinMessage(), Scribe::handleJoinResponse(), KBRTestApp::handleLookupResponse(), DHT::handleLookupResponse(), BootstrapList::handleLookupResponse(), GIASearchApp::handleLowerMessage(), XmlRpcInterface::handleMessage(), BaseApp::handleMessage(), SimMud::handleMove(), SimMud::handleOtherPlayerMove(), Scribe::handlePublishCall(), Scribe::handlePublishResponse(), DHT::handlePutRequest(), IterativePathLookup::handleResponse(), Scribe::handleRpcResponse(), KBRTestApp::handleRpcResponse(), BootstrapList::handleRpcResponse(), SimpleGameClient::handleTimerEvent(), Scribe::handleTimerEvent(), GIASearchApp::handleTimerEvent(), DHT::handleTimerEvent(), Scribe::handleUpperMessage(), SimpleGameClient::initializeApp(), BootstrapList::initializeApp(), BaseOverlay::isMalicious(), XmlRpcInterface::localLookup(), IterativeLookup::lookup(), P2pns::p2pnsRegisterRpc(), BootstrapList::pingResponse(), BootstrapList::pingTimeout(), Kademlia::routingAdd(), Kademlia::routingBucketIndex(), BaseApp::sendMessageToUDP(), sendRpcCall(), sendRpcResponse(), BaseOverlay::setOverlayReady(), IterativeLookup::start(), Scribe::subscribeToGroup(), Scribe::update(), and DHT::update().

00064 { return thisNode; };

bool BaseRpc::internalHandleRpc ( BaseCallMessage *  msg  )  [protected, virtual]

Handles internal rpc requests.


This method is used to implement basic functionionality in the BaseRpc.

Parameters:
msg The call message
Returns:
bool true, if call has been handled.

Reimplemented in BaseApp, and BaseOverlay.

Definition at line 383 of file BaseRpc.cc.

Referenced by BaseOverlay::internalHandleRpc(), BaseApp::internalHandleRpc(), and internalHandleRpcMessage().

00384 {
00385     RPC_SWITCH_START( msg );
00386     RPC_DELEGATE( Ping, pingRpc );
00387     RPC_SWITCH_END( );
00388 
00389     return RPC_HANDLED;
00390 }

bool 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 functionionality in the BaseRpc.

Parameters:
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
Returns:
bool true, if call has been handled.

Reimplemented in BaseApp, and BaseOverlay.

Definition at line 392 of file BaseRpc.cc.

Referenced by internalHandleRpcMessage(), BaseOverlay::internalHandleRpcResponse(), and BaseApp::internalHandleRpcResponse().

00395 {
00396     // call rpc stubs
00397     RPC_SWITCH_START( msg );
00398     RPC_ON_RESPONSE( Ping ) {
00399         pingRpcResponse(_PingResponse, context, rpcId, rtt);
00400     }
00401     RPC_SWITCH_END( );
00402 
00403     return RPC_HANDLED; //TODO always false
00404 }

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.

Parameters:
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
Returns:
bool true, if call has been handled.
Todo:
return bool?

Reimplemented in BaseOverlay.

Definition at line 406 of file BaseRpc.cc.

Referenced by internalHandleRpcMessage(), and BaseOverlay::internalHandleRpcTimeout().

00410 {
00411     RPC_SWITCH_START( msg ) {
00412         RPC_ON_CALL( Ping ) {
00413             pingRpcTimeout(_PingCall, dest, context, rpcId);
00414         }
00415     }
00416     RPC_SWITCH_END( )
00417 }

void BaseRpc::initRpcs (  )  [protected]

Initializes Remote-Procedure state.

Definition at line 60 of file BaseRpc.cc.

Referenced by BaseOverlay::initialize(), BaseApp::initialize(), and DHTTestApp::initializeApp().

00061 {
00062     // set friend modules
00063     globalStatistics = GlobalStatisticsAccess().get();
00064 
00065     rpcUdpTimeout = par("rpcUdpTimeout");
00066     rpcKeyTimeout = par("rpcKeyTimeout");
00067     rpcExponentialBackoff = par("rpcExponentialBackoff");
00068 
00069     rpcsPending = 0;
00070     rpcStates.clear();
00071 
00072     defaultRpcListener = new RpcListener();
00073 
00074     //set ping cache
00075     numPingSent = 0;
00076     bytesPingSent = 0;
00077     numPingResponseSent = 0;
00078     bytesPingResponseSent = 0;
00079 
00080     WATCH(numPingSent);
00081     WATCH(bytesPingSent);
00082     WATCH(numPingResponseSent);
00083     WATCH(bytesPingResponseSent);
00084 
00085     // set overlay pointer
00086     overlay = OverlayAccess().get(this);
00087 
00088     // register component
00089     thisCompType = getThisCompType();
00090     overlay->registerComp(thisCompType, this);
00091 
00092     cModule *mod = getParentModule();
00093     neighborCache = NULL;
00094     while (neighborCache == NULL) {
00095         neighborCache = (NeighborCache*)mod->getSubmodule("neighborCache");
00096         mod = mod->getParentModule();
00097         if (!mod)
00098             opp_error ("BaseRpc::initRpc: Module type contains no ping cache!");
00099     }
00100 }

void BaseRpc::finishRpcs (  )  [protected]

Deinitializes Remote-Procedure state.

Definition at line 103 of file BaseRpc.cc.

Referenced by BaseApp::~BaseApp(), and BaseOverlay::~BaseOverlay().

00104 {
00105     cancelAllRpcs();
00106 
00107     // delete default rpc listener
00108     if (defaultRpcListener != NULL) {
00109         delete defaultRpcListener;
00110         defaultRpcListener = NULL;
00111     }
00112 }

void BaseRpc::internalHandleRpcMessage ( BaseRpcMessage *  msg  )  [protected, virtual]

Handles incoming rpc messages and delegates them to the corresponsing listeners or handlers.

Parameters:
msg The message to handle.

Definition at line 235 of file BaseRpc.cc.

Referenced by BaseOverlay::handleBaseOverlayMessage(), BaseApp::handleCommonAPIMessage(), XmlRpcInterface::handleMessage(), BaseOverlay::handleMessage(), and BaseApp::handleMessage().

00236 {
00237     // check if this is a rpc call message
00238     BaseCallMessage* rpCall = dynamic_cast<BaseCallMessage*>(msg);
00239     if (rpCall != NULL) {
00240         bool rpcHandled = true;
00241         if (!handleRpc(rpCall)) rpcHandled = internalHandleRpc(rpCall);
00242         if (!rpcHandled) {
00243             EV << "[BaseRpc::internalHandleRpcMessage() @ " << thisNode.ip
00244                << " (" << thisNode.key.toString(16) << ")]\n"
00245                << "    Error: RPC '" << msg->getFullName()<< "' was not handled"
00246                << endl;
00247             delete msg;
00248         }
00249         return;
00250     }
00251 
00252     // get nonce
00253     int nonce = msg->getNonce();
00254 
00255     // nonce known? no -> delete message and return
00256     if (rpcStates.count(nonce)==0) {
00257         EV << "[BaseRpc::internalHandleRpcMessage() @ " << thisNode.ip
00258            << " " << thisNode.key.toString(16) << ")]\n"
00259            << "    RPC: Nonce Unknown"
00260            << endl;
00261         delete msg;
00262         return;
00263     }
00264 
00265     // get state and remove from map
00266     RpcState state = rpcStates[nonce];
00267     rpcStates.erase(nonce);
00268 
00269     // is timeout message?
00270     if (msg->isSelfMessage() &&
00271         (dynamic_cast<RpcTimeoutMessage*>(msg) != NULL)) {
00272         // yes-> inform listener
00273 
00274         // retry?
00275         state.retries--;
00276         if (state.retries>=0) {
00277             //TODO
00278             std::vector<TransportAddress> sourceRoute;
00279             sourceRoute.push_back(*state.dest);
00280             sendRpcMessageWithTransport(state.transportType, state.destComp,
00281                                         state.routingType,
00282                                         sourceRoute,
00283                                         state.destKey,
00284                                         dynamic_cast<BaseCallMessage*>
00285                                         (state.callMsg->dup()));
00286 
00287             if (rpcExponentialBackoff) {
00288                 state.rto *= 2;
00289             }
00290 
00291             if (state.rto!=0)
00292                 scheduleAt(simTime() + state.rto, msg);
00293 
00294             state.timeSent = simTime();
00295             rpcStates[nonce] = state;
00296             return;
00297         }
00298         // inform listener
00299         if (state.listener != NULL)
00300             state.listener->handleRpcTimeout(state.callMsg, *state.dest,
00301                                              state.context, state.id,
00302                                              state.destKey);
00303 
00304         // inform overlay
00305         internalHandleRpcTimeout(state.callMsg, *state.dest, state.context,
00306                                  state.id, state.destKey);
00307         handleRpcTimeout(state.callMsg, *state.dest, state.context,
00308                          state.id, state.destKey);
00309 
00310     } else { // no-> handle rpc response
00311 
00312         // drop responses with wrong source key
00313         if (state.destKey.isUnspecified()) {
00314             const NodeHandle* stateHandle =
00315                 dynamic_cast<const NodeHandle*>(state.dest);
00316                 if (stateHandle != NULL &&
00317                     stateHandle->key != msg->getSrcNode().key) {
00318 
00319                     EV << "[BaseRpc::internalHandleRpcMessage() @ "
00320                        << thisNode.ip
00321                        << " " << thisNode.key.toString(16) << ")]\n"
00322                        << "    Dropping RPC: Invalid source key"
00323                        << endl;
00324 
00325                     // restore state to trigger timeout message
00326                     rpcStates[nonce] = state;
00327                     delete msg;
00328                     return;
00329                 }
00330         }
00331 
00332         // get parameters
00333         simtime_t rtt = simTime() - state.timeSent;
00334         BaseResponseMessage* response
00335             = dynamic_cast<BaseResponseMessage*>(msg);
00336 
00337         //if (state.transportType == UDP_TRANSPORT)
00338         //    globalStatistics->recordOutVector("BaseRpc: UDP Round Trip Time",
00339         //                                      rtt);
00340 
00341         // inform listener
00342         if (state.listener != NULL)
00343             state.listener->handleRpcResponse(response, state.context,
00344                                               state.id, rtt);
00345 
00346         // neighborCache/vivaldi stuff
00347         if (state.transportType == UDP_TRANSPORT) {
00348             if (neighborCache->vivaldiEnabled()) {
00349                 // vivaldi: get coordinates/error estimation from message
00350                 std::vector<double> nodeCoords;
00351                 nodeCoords.resize(response->getCoordsArraySize());
00352                 for (uint32_t i = 0; i < response->getCoordsArraySize(); i++)
00353                     nodeCoords[i] = response->getCoords(i);
00354                 neighborCache->updateNode(response->getSrcNode(), rtt,
00355                                           nodeCoords, response->getError());
00356             } else {
00357                 neighborCache->updateNode(response->getSrcNode(), rtt);
00358             }
00359         }
00360 
00361         // inform overlay
00362         internalHandleRpcResponse(response, state.context, state.id, rtt);
00363         handleRpcResponse(response, state.context, state.id, rtt);
00364 
00365         // delete response
00366         delete response->removeControlInfo();
00367         delete response;
00368     }
00369 
00370     // delete messages
00371     delete state.callMsg;
00372     cancelAndDelete(state.timeoutMsg);
00373     delete state.dest;
00374 
00375     // clean up pointers
00376     state.dest = NULL;
00377     state.context = NULL;
00378     state.callMsg = NULL;
00379     state.timeoutMsg = NULL;
00380 }

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.

Parameters:
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
retries How often we try to resent rpc call, if it gets lost
rpcId RPC id
rpcListener RPC Listener
Returns:
The nonce of the RPC

Definition at line 172 of file BaseRpc.h.

Referenced by Scribe::deliverALMDataToRoot(), oversim::Koorde::handleDeBruijnTimerExpired(), oversim::Chord::handleFixFingersTimerExpired(), DHT::handleGetResponse(), Scribe::handleJoinMessage(), oversim::Chord::handleJoinTimerExpired(), Broose::handleJoinTimerExpired(), DHT::handleLookupResponse(), DHT::handleRpcTimeout(), Scribe::handleTimerEvent(), oversim::Chord::joinForeignPartition(), RecursiveLookup::lookup(), pingNode(), Scribe::subscribeToGroup(), Scribe::update(), and DHT::update().

00182     {
00183         if (dest.isUnspecified() && destKey.isUnspecified())
00184             opp_error("BaseRpc::sendRouteRpcCall() with both key and "
00185                       "transportAddress unspecified!");
00186         return sendRpcCall(ROUTE_TRANSPORT, destComp, dest, destKey, msg,
00187                            context, routingType, timeout, retries,
00188                            rpcId, rpcListener);
00189     }

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.

Parameters:
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
retries How often we try to resent rpc call, if it gets lost
rpcId RPC id
rpcListener RPC Listener
Returns:
The nonce of the RPC

Definition at line 213 of file BaseRpc.h.

00222     {
00223         return sendRpcCall(ROUTE_TRANSPORT, destComp,
00224                            TransportAddress::UNSPECIFIED_NODE,
00225                            destKey, msg, context, routingType, timeout,
00226                            retries, rpcId, rpcListener);
00227     }

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.

Parameters:
destComp The destination component
dest Destination node handle
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
Returns:
The nonce of the RPC

Definition at line 252 of file BaseRpc.h.

00261     {
00262         return sendRpcCall(ROUTE_TRANSPORT, destComp, dest,
00263                            OverlayKey::UNSPECIFIED_KEY, msg, context,
00264                            routingType, timeout, retries, rpcId, rpcListener);
00265     }

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.

Parameters:
dest Destination node handle
msg RPC Call Message
context a pointer to an arbitrary cPolymorphic object, which can be used to store additional state
timeout RPC timeout
retries How often we try to resent rpc call, if it gets lost
rpcId RPC id
rpcListener RPC Listener
Returns:
The nonce of the RPC

Definition at line 287 of file BaseRpc.h.

Referenced by Broose::changeState(), PubSubMMOG::handleAppMessage(), PubSubMMOG::handleBackupCallTimeout(), Broose::handleBucketTimerExpired(), PubSubMMOG::handleHelpResponse(), PubSubMMOG::handleIntermediateResponse(), PubSubLobby::handleJoin(), PubSubMMOG::handleJoinResponse(), PubSubMMOG::handleMove(), oversim::Chord::handleNewSuccessorHint(), PubSubMMOG::handlePingCallTimeout(), PubSubLobby::handleRespCall(), PubSubMMOG::handleResponsibleNodeResponse(), oversim::Chord::handleRpcNotifyResponse(), oversim::Koorde::handleRpcStabilizeResponse(), oversim::Chord::handleRpcStabilizeResponse(), oversim::Chord::handleStabilizeTimerExpired(), PubSubMMOG::handleSubscriptionCall(), PubSubMMOG::handleSubscriptionCallTimeout(), IterativePathLookup::handleTimeout(), pingNode(), PubSubMMOG::sendMessageToChildren(), BaseOverlay::sendRouteMessage(), IterativeLookup::sendRpc(), PubSubMMOG::takeOverSubspace(), and PubSubMMOG::unsubscribeChild().

00293     {
00294         return sendRpcCall(UDP_TRANSPORT, INVALID_COMP, dest,
00295                            OverlayKey::UNSPECIFIED_KEY, msg, context,
00296                            NO_OVERLAY_ROUTING, timeout, retries, rpcId,
00297                            rpcListener);
00298     }

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.

Parameters:
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
retries How often we try to resent rpc call, if it gets lost
rpcId RPC id
rpcListener RPC Listener
Returns:
The nonce of the RPC

Definition at line 320 of file BaseRpc.h.

Referenced by P2pns::handleDHTgetCAPIResponse(), DHT::handleGetCAPIRequest(), DHT::handlePutCAPIRequest(), KBRTestApp::handleTimerEvent(), DHTTestApp::handleTimerEvent(), DHTTestApp::handleTraceMessage(), BootstrapList::locateBootstrapNode(), P2pns::p2pnsRegisterRpc(), P2pns::p2pnsResolveRpc(), XmlRpcInterface::sendInternalRpcWithTimeout(), and DHT::update().

00327     {
00328         return sendRpcCall(INTERNAL_TRANSPORT, destComp,
00329                            TransportAddress::UNSPECIFIED_NODE,
00330                            OverlayKey::UNSPECIFIED_KEY, msg, context,
00331                            NO_OVERLAY_ROUTING, timeout, retries, rpcId,
00332                            rpcListener);
00333     }

void BaseRpc::cancelRpcMessage ( uint32_t  nonce  )  [protected]

Cancels a Remote-Procedure-Call.

Parameters:
nonce The nonce of the RPC

Definition at line 220 of file BaseRpc.cc.

Referenced by RecursiveLookup::abortLookup(), XmlRpcInterface::resetConnectionState(), and IterativeLookup::stop().

00221 {
00222     if (rpcStates.count(nonce)==0)
00223         return;
00224     RpcState state = rpcStates[nonce];
00225     rpcStates.erase(nonce);
00226     cancelAndDelete(state.callMsg);
00227     cancelAndDelete(state.timeoutMsg);
00228     delete state.dest;
00229     state.dest = NULL;
00230     delete state.context;
00231     state.context = NULL;
00232 }

void BaseRpc::cancelAllRpcs (  )  [protected]

Cancels all RPCs.

Definition at line 114 of file BaseRpc.cc.

Referenced by Pastry::changeState(), and finishRpcs().

00115 {
00116     // stop all rpcs
00117     for (RpcStates::iterator i = rpcStates.begin();
00118         i != rpcStates.end(); i++) {
00119         cancelAndDelete(i->second.callMsg);
00120         cancelAndDelete(i->second.timeoutMsg);
00121         delete i->second.dest;
00122         i->second.dest = NULL;
00123         delete i->second.context;
00124         i->second.context = NULL;
00125     }
00126     rpcStates.clear();
00127 }

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.

Parameters:
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 reponse
response The response message

Definition at line 425 of file BaseRpc.cc.

Referenced by BaseOverlay::failedNodeRpc(), BaseOverlay::findNodeRpc(), PubSubMMOG::handleAdoptChildCall(), PubSubMMOG::handleBackupCall(), Broose::handleBroosePingRequestRpc(), Broose::handleBucketRequestRpc(), P2pns::handleDHTgetCAPIResponse(), P2pns::handleDHTputCAPIResponse(), DHT::handleDumpDhtRequest(), DHT::handleGetRequest(), DHT::handleGetResponse(), PubSubLobby::handleHelpCall(), PubSubMMOG::handleIntermediateCall(), PubSubLobby::handleJoin(), Scribe::handleJoinMessage(), P2pns::handleLookupResponse(), DHT::handleLookupResponse(), PubSubMMOG::handlePingCall(), Scribe::handlePublishCall(), DHT::handlePutRequest(), DHT::handlePutResponse(), PubSubLobby::handleRespCall(), oversim::Koorde::handleRpcDeBruijnRequest(), DHT::handleRpcTimeout(), PubSubMMOG::handleSubscriptionCall(), PubSubMMOG::handleTakeOver(), BaseOverlay::internalSendRpcResponse(), BaseApp::internalSendRpcResponse(), SendToKeyListener::lookupFinished(), BaseOverlay::nextHopRpc(), pingRpc(), PubSubLobby::replaceResponsibleNode(), oversim::Chord::rpcFixfingers(), oversim::Chord::rpcJoin(), oversim::Koorde::rpcNotify(), oversim::Chord::rpcNotify(), oversim::Chord::rpcStabilize(), and sendRpcResponse().

00431 {
00432     if (call == NULL || response == NULL) {
00433         throw cRuntimeError("call or response = NULL!");
00434     }
00435 
00436     // vivaldi: set coordinates and error estimation in response
00437     if (neighborCache->vivaldiEnabled()) { //TODO only for directly sent msgs
00438         const std::vector<double>& nodeCoord =
00439             neighborCache->getVivaldiAccess().getOwnCoordinates();
00440         response->setError(neighborCache->getVivaldiAccess().getOwnError());
00441         response->setCoordsArraySize(nodeCoord.size());
00442         for (uint32_t i = 0; i < nodeCoord.size(); i++) {
00443             response->setCoords(i, nodeCoord[i]);
00444         }
00445     }
00446 
00447     assert(transportType == INTERNAL_TRANSPORT ||
00448            !dest.isUnspecified() ||
00449            !destKey.isUnspecified());
00450 
00451     if (transportType == ROUTE_TRANSPORT)
00452         response->setSrcNode(overlay->getThisNode());
00453     else
00454         response->setSrcNode(thisNode);
00455     response->setType(RPC);
00456     response->setNonce(call->getNonce());
00457     response->setStatType(call->getStatType());
00458 
00459     RoutingType routingType = NO_OVERLAY_ROUTING;
00460     OverlayCtrlInfo* overlayCtrlInfo = NULL;
00461     if (dynamic_cast<OverlayCtrlInfo*>(call->getControlInfo()))
00462         overlayCtrlInfo =
00463             static_cast<OverlayCtrlInfo*>(call->removeControlInfo());
00464     else
00465         delete call->removeControlInfo();
00466 
00467     // source routing
00468     std::vector<TransportAddress> sourceRoute;
00469     if (overlayCtrlInfo && transportType == ROUTE_TRANSPORT) {
00470         routingType =
00471             static_cast<RoutingType>(overlayCtrlInfo->getRoutingType());
00472         for (uint32_t i = overlayCtrlInfo->getVisitedHopsArraySize(); i > 0; --i) {
00473             if (overlayCtrlInfo->getVisitedHops(i - 1) !=
00474                     overlay->getThisNode()) {
00475                 sourceRoute.push_back(overlayCtrlInfo->getVisitedHops(i - 1));
00476             }
00477         }
00478     }
00479     sourceRoute.push_back(dest);
00480 
00481     sendRpcMessageWithTransport(transportType, compType,
00482                                 routingType, sourceRoute,
00483                                 destKey, response);
00484     delete overlayCtrlInfo;
00485     delete call;
00486 }

void BaseRpc::sendRpcResponse ( BaseCallMessage *  call,
BaseResponseMessage *  response 
) [protected]

Send Remote-Procedure response message to UDP and deletes call message.

Parameters:
call The corresponding call message to the reponse
response The response message

Definition at line 489 of file BaseRpc.cc.

00491 {
00492     const TransportAddress* destNode = &(call->getSrcNode());
00493     const OverlayKey* destKey = &(call->getSrcNode().key);
00494 
00495     OverlayCtrlInfo* overlayCtrlInfo =
00496         dynamic_cast<OverlayCtrlInfo*>(call->getControlInfo());
00497 
00498     // "magic" transportType selection: internal
00499     if (overlayCtrlInfo &&
00500         overlayCtrlInfo->getTransportType() == INTERNAL_TRANSPORT) {
00501         sendRpcResponse(INTERNAL_TRANSPORT,
00502                         static_cast<CompType>(overlayCtrlInfo->getSrcComp()),
00503                         *destNode, *destKey, call, response);
00504     } else {
00505         internalSendRpcResponse(call, response);
00506     }
00507 }

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,
bool  overrideCache = true 
) [protected]

ping a node by its TransportAddress

Statistics are collected by this method.

Parameters:
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
overrideCache ignore ping cache

Definition at line 647 of file BaseRpc.cc.

Referenced by Pastry::changeState(), BootstrapList::handleBootstrapListTimerExpired(), oversim::Chord::handleRpcFixfingersResponse(), oversim::Chord::handleStabilizeTimerExpired(), Pastry::handleTimerEvent(), KBRTestApp::handleTimerEvent(), oversim::Chord::handleTimerEvent(), Pastry::handleUDPMessage(), Kademlia::joinOverlay(), BasePastry::pingNodes(), BasePastry::prePing(), BasePastry::recursiveRoutingHook(), and Kademlia::routingAdd().

00652 {
00653     simtime_t rtt;
00654     if (overrideCache || neighborCache->getNodeRtt(dest) ==
00655         NEIGHBORSTATE_UNKNOWN || neighborCache->getNodeRtt(dest) ==
00656         NEIGHBORSTATE_TIMEOUT) {
00657         // if unknown or overriding, send ping call as normal
00658         PingCall* call = new PingCall(caption);
00659         call->setBitLength(PINGCALL_L(call));
00660         RECORD_STATS(numPingSent++; bytesPingSent += call->getByteLength());
00661 
00662         if (transportType == UDP_TRANSPORT ||
00663             (transportType != ROUTE_TRANSPORT &&
00664              getThisCompType() == OVERLAY_COMP)) {
00665             sendUdpRpcCall(dest, call, context, timeout, retries, rpcId,
00666                            rpcListener);
00667         } else {
00668             sendRouteRpcCall(getThisCompType(), dest, call, context,
00669                              DEFAULT_ROUTING, timeout, retries, rpcId,
00670                              rpcListener);
00671         }
00672         neighborCache->insertNodeContext(dest, context, rpcListener, rpcId);
00673     } else if ((rtt = neighborCache->getNodeRtt(dest)) !=
00674                NEIGHBORSTATE_WAITING) {
00675         // if it's time-out or a known value, reply with fake ping response
00676         PingResponse *pr = new PingResponse();
00677         pr->setNonce(0);
00678         if (neighborCache->getNodeHandle(dest).isUnspecified())
00679             pr->setSrcNode(dest);
00680         else
00681             pr->setSrcNode(neighborCache->getNodeHandle(dest));
00682 
00683         // inform listener
00684         if (rpcListener != NULL)
00685             rpcListener->handleRpcResponse(pr, context, rpcId, rtt);
00686 
00687         pingResponse(pr, context, rpcId, rtt);
00688         handleRpcResponse(pr, context, rpcId, rtt);
00689 
00690         delete pr;
00691     } else {
00692         assert(neighborCache->getNodeRtt(dest) == NEIGHBORSTATE_WAITING);
00693         neighborCache->insertNodeContext(dest, context, rpcListener, rpcId);
00694     }
00695 }

bool BaseRpc::handleRpc ( BaseCallMessage *  msg  )  [protected, virtual]

Processes Remote-Procedure-Call invokation messages.


This method should be overloaded when the overlay provides RPC functionality.

Returns:
true, if rpc has been handled

Reimplemented in DHT, Scribe, Broose, oversim::Chord, Kademlia, oversim::Koorde, PubSubLobby, PubSubMMOG, P2pns, and SimMud.

Definition at line 420 of file BaseRpc.cc.

Referenced by internalHandleRpcMessage().

00421 {
00422     return false;
00423 }

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.

Returns:
the component type of this module

Implemented in BaseApp, BaseOverlay, and BootstrapList.

Referenced by initRpcs(), pingNode(), sendRpcCall(), and sendRpcMessageWithTransport().

virtual void BaseRpc::sendMessageToUDP ( const TransportAddress &  addr,
cPacket *  message 
) [inline, protected, virtual]

Reimplemented in BaseApp, and BaseOverlay.

Definition at line 424 of file BaseRpc.h.

Referenced by sendRpcMessageWithTransport().

00426     {
00427         throw cRuntimeError("sendMessageToUDP() not implemented");
00428     }

void BaseRpc::pingResponse ( PingResponse *  pingResponse,
cPolymorphic *  context,
int  rpcId,
simtime_t  rtt 
) [protected, virtual]

Reimplemented in KBRTestApp, BootstrapList, oversim::Chord, and BasePastry.

Definition at line 548 of file BaseRpc.cc.

Referenced by Broose::handleBroosePingRequestRpc(), pingNode(), and pingRpcResponse().

00550 {
00551 }

void BaseRpc::pingTimeout ( PingCall *  pingCall,
const TransportAddress &  dest,
cPolymorphic *  context,
int  rpcId 
) [protected, virtual]

Reimplemented in BootstrapList, oversim::Chord, and BasePastry.

Definition at line 553 of file BaseRpc.cc.

Referenced by pingRpcTimeout().

00555 {
00556 }

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. After a timeout the message gets retransmitted for at maximum retries times. The destKey attribute is kept untouched.

Parameters:
transportType The type of transport
destComp The destination component
dest Destination node handle
destKey route the RPC to the node that is responsible for destkey
msg RPC Call Message
rpcListener RPC Listener
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
Returns:
The nonce of the RPC

Definition at line 129 of file BaseRpc.cc.

Referenced by sendInternalRpcCall(), sendRouteRpcCall(), and sendUdpRpcCall().

00141 {
00142     // create nonce, timeout and set default parameters
00143     uint32_t nonce;
00144     do {
00145         nonce = intuniform(1, 2147483647);
00146     } while (rpcStates.count(nonce) > 0);
00147 
00148     if (timeout == -1) {
00149         switch (transportType) {
00150         case INTERNAL_TRANSPORT:
00151             timeout = 0;
00152             break;
00153         case UDP_TRANSPORT:
00154             timeout = rpcUdpTimeout;
00155             break;
00156         case ROUTE_TRANSPORT:
00157             timeout = (destKey.isUnspecified() ?
00158                        rpcUdpTimeout :
00159                        rpcKeyTimeout);
00160             break;
00161         default:
00162             throw cRuntimeError("BaseRpc::sendRpcMessage(): "
00163                                  "Unknown RpcTransportType!");
00164         }
00165     }
00166 
00167     if (rpcListener == NULL)
00168         rpcListener = defaultRpcListener;
00169 
00170     // create state
00171     RpcState state;
00172     state.id = rpcId;
00173     state.timeSent = simTime();
00174     state.dest = dest.dup();
00175     state.destKey = destKey;
00176     state.srcComp = getThisCompType();
00177     state.destComp = destComp;
00178     state.listener = rpcListener;
00179     state.timeoutMsg = new RpcTimeoutMessage();
00180     state.timeoutMsg->setNonce(nonce);
00181     state.retries = retries;
00182     state.rto = timeout;
00183     state.transportType = transportType;
00184     state.routingType = routingType;
00185     state.context = context;
00186 
00187     if (rpcStates.count(nonce) > 0)
00188         error("RPC nonce collision");
00189 
00190     // set message parameters
00191     msg->setNonce(nonce);
00192     if (transportType == ROUTE_TRANSPORT)
00193         msg->setSrcNode(overlay->getThisNode());
00194     else
00195         msg->setSrcNode(thisNode);
00196     msg->setType(RPC);
00197 
00198     // save copy of call message in RpcState
00199     state.callMsg = dynamic_cast<BaseCallMessage*>(msg->dup());
00200     assert(!msg->getEncapsulatedMsg() || !msg->getEncapsulatedMsg()->getControlInfo());
00201 
00202     // register state
00203     rpcStates[nonce] = state;
00204 
00205     // schedule timeout message
00206     if (state.rto != 0)
00207         scheduleAt(simTime() + state.rto, state.timeoutMsg);
00208 
00209     //TODO
00210     std::vector<TransportAddress> sourceRoute;
00211     sourceRoute.push_back(dest);
00212     sendRpcMessageWithTransport(transportType, destComp, routingType,
00213                                 sourceRoute, destKey, msg);
00214 
00215     return nonce;
00216 }

void BaseRpc::sendRpcMessageWithTransport ( TransportType  transportType,
CompType  destComp,
RoutingType  routingType,
const std::vector< TransportAddress > &  sourceRoute,
const OverlayKey &  destKey,
BaseRpcMessage *  message 
) [private]

Definition at line 509 of file BaseRpc.cc.

Referenced by internalHandleRpcMessage(), sendRpcCall(), and sendRpcResponse().

00515 {
00516     switch (transportType) {
00517     case UDP_TRANSPORT: {
00518         sendMessageToUDP(sourceRoute[0], message);
00519         break;
00520     }
00521     case ROUTE_TRANSPORT: {
00522         internalSendRouteRpc(message, destKey,
00523                              sourceRoute, routingType);
00524         break;
00525     }
00526     case INTERNAL_TRANSPORT: {
00527         cGate *destCompGate = overlay->getCompRpcGate(destComp);
00528         if (destCompGate == NULL) {
00529             opp_error("BaseRpc::sendRpcMessageWithTransport():"
00530                       " INTERNAL_RPC to unknown RpcCompType!");
00531         }
00532         OverlayCtrlInfo *overlayCtrlInfo = new OverlayCtrlInfo();
00533         overlayCtrlInfo->setSrcComp(getThisCompType());
00534         overlayCtrlInfo->setDestComp(destComp);
00535         overlayCtrlInfo->setTransportType(INTERNAL_TRANSPORT);
00536         message->setControlInfo(overlayCtrlInfo);
00537         sendDirect(message, destCompGate);
00538         break;
00539     }
00540     default:
00541         opp_error("BaseRpc::sendRpcMessageWithTransport: "
00542                   "invalid transportType!");
00543         break;
00544     }
00545 }

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().

void BaseRpc::pingRpc ( PingCall *  call  )  [private]

Definition at line 558 of file BaseRpc.cc.

Referenced by internalHandleRpc().

00559 {
00560     std::string pongName(call->getName());
00561     if (pongName == "PING")
00562         pongName = "PONG";
00563     else {
00564         pongName = "PONG: [ ";
00565         pongName += call->getName();
00566         pongName += " ]";
00567     }
00568 
00569     PingResponse* response = new PingResponse(pongName.c_str());
00570     response->setBitLength( PINGRESPONSE_L(response) );
00571     RECORD_STATS(numPingResponseSent++; bytesPingResponseSent +=
00572         response->getByteLength());
00573 
00574     sendRpcResponse(call, response );
00575 }

void BaseRpc::pingRpcResponse ( PingResponse *  response,
cPolymorphic *  context,
int  rpcId,
simtime_t  rtt 
) [private]

Definition at line 577 of file BaseRpc.cc.

Referenced by internalHandleRpcResponse().

00579 {
00580     NodeHandle& srcNode = response->getSrcNode();
00581     WaitingContexts* waitingContexts =
00582         neighborCache->getNodeContexts(srcNode);
00583 
00584     pingResponse(response, context, rpcId, rtt);
00585 
00586     if (waitingContexts && waitingContexts->size() > 0) {
00587         for (uint32_t i = 0; i < waitingContexts->pingListeners.size(); ++i) {
00588             PingResponse *pr = new PingResponse();
00589             pr->setNonce(0);
00590             if (neighborCache->getNodeHandle(srcNode).isUnspecified())
00591                 pr->setSrcNode(srcNode);
00592             else
00593                 pr->setSrcNode(neighborCache->getNodeHandle(srcNode));
00594 
00595             // inform listener
00596             if (waitingContexts->pingListeners[i] != NULL)
00597                 waitingContexts->pingListeners[i]
00598                     ->handleRpcResponse(pr, waitingContexts->pingContexts[i],
00599                                         waitingContexts->pingIds[i], rtt);
00600 
00601             handleRpcResponse(pr, waitingContexts->pingContexts[i],
00602                               waitingContexts->pingIds[i], rtt);
00603             pingResponse(pr, waitingContexts->pingContexts[i],
00604                          waitingContexts->pingIds[i], rtt);
00605 
00606             delete pr;
00607         }
00608     }
00609     delete waitingContexts;
00610 }

void BaseRpc::pingRpcTimeout ( PingCall *  pingCall,
const TransportAddress &  dest,
cPolymorphic *  context,
int  rpcId 
) [private]

Definition at line 612 of file BaseRpc.cc.

Referenced by internalHandleRpcTimeout().

00616 {
00617     neighborCache->setNodeTimeout(dest);
00618     WaitingContexts* waitingContexts =
00619         neighborCache->getNodeContexts(dest);
00620 
00621     pingTimeout(pingCall, dest, context, rpcId);
00622 
00623     if (waitingContexts && waitingContexts->size() > 0) {
00624         for (uint32_t i = 0; i < waitingContexts->pingListeners.size(); ++i) {
00625             PingCall* copy = static_cast<PingCall*>(pingCall->dup());
00626             copy->setNonce(0);
00627 
00628             // inform listener
00629             if (waitingContexts->pingListeners[i] != NULL)
00630                 waitingContexts->pingListeners[i]
00631                     ->handleRpcTimeout(copy, dest,
00632                                        waitingContexts->pingContexts[i],
00633                                        waitingContexts->pingIds[i],
00634                                        OverlayKey::UNSPECIFIED_KEY);
00635 
00636             handleRpcTimeout(copy, dest, waitingContexts->pingContexts[i],
00637                              waitingContexts->pingIds[i],
00638                              OverlayKey::UNSPECIFIED_KEY);
00639             pingTimeout(copy, dest, waitingContexts->pingContexts[i],
00640                         waitingContexts->pingIds[i]);
00641 
00642             delete copy;
00643         }
00644     }
00645     delete waitingContexts;
00646 }


Member Data Documentation

NodeHandle to this node.

Definition at line 64 of file BaseRpc.h.

Referenced by QuonPR::addSite(), QuonP::addSite(), BasePastry::baseChangeState(), BasePastry::baseInit(), BaseOverlay::bindToPort(), BaseApp::bindToPort(), BaseApp::callRoute(), BaseOverlay::callUpdate(), QuonPR::changeState(), QuonP::changeState(), Pastry::changeState(), Gia::changeState(), oversim::Chord::changeState(), Broose::changeState(), Bamboo::changeState(), Pastry::checkProxCache(), oversim::Chord::closestPreceedingNode(), QuonPR::deleteSite(), QuonP::deleteSite(), Broose::displayBucketState(), Pastry::doJoinUpdate(), BasePastry::doRoutingTableMaintenance(), Pastry::doSecondStage(), Pastry::endProcessingState(), oversim::Koorde::findDeBruijnHop(), oversim::Koorde::findNode(), Kademlia::findNode(), oversim::Chord::findNode(), Broose::findNode(), BasePastry::findNode(), BaseOverlay::findNodeRpc(), oversim::Chord::finishOverlay(), Broose::finishOverlay(), BasePastry::finishOverlay(), PubSubMMOG::handleAdoptChildCall(), PubSubMMOG::handleAdoptChildResponse(), QuonPR::handleAppMessage(), QuonP::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(), QuonPR::handleNodeLeaveNotification(), PubSubMMOG::handlePingCall(), SimpleGameClient::handleRealworldPacket(), BasePastry::handleRequestMessage(), oversim::Koorde::handleRpc(), oversim::Chord::handleRpc(), oversim::Koorde::handleRpcDeBruijnRequest(), oversim::Chord::handleRpcFixfingersResponse(), oversim::Chord::handleRpcJoinResponse(), oversim::Koorde::handleRpcNotifyResponse(), oversim::Chord::handleRpcNotifyResponse(), PubSubMMOG::handleRpcResponse(), oversim::Koorde::handleRpcResponse(), oversim::Chord::handleRpcResponse(), Broose::handleRpcResponse(), oversim::Koorde::handleRpcStabilizeResponse(), 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(), KBRTestApp::handleTimerEvent(), Bamboo::handleTimerEvent(), BaseOverlay::handleTransportAddressChangedNotification(), QuonPR::handleUDPMessage(), QuonP::handleUDPMessage(), Pastry::handleUDPMessage(), Bamboo::handleUDPMessage(), BaseOverlay::initialize(), BaseApp::initialize(), KBRTestApp::initializeApp(), I3::initializeApp(), oversim::Koorde::initializeFriendModules(), oversim::Chord::initializeFriendModules(), Vast::initializeOverlay(), QuonPR::initializeOverlay(), QuonP::initializeOverlay(), PubSubMMOG::initializeOverlay(), PubSubLobby::initializeOverlay(), oversim::Chord::initializeOverlay(), I3::insertTrigger(), internalHandleRpcMessage(), BaseOverlay::internalHandleRpcTimeout(), Kademlia::isSiblingFor(), oversim::Chord::isSiblingFor(), Broose::isSiblingFor(), BasePastry::isSiblingFor(), BaseOverlay::join(), oversim::Chord::joinForeignPartition(), Kademlia::joinOverlay(), SendToKeyListener::lookupFinished(), Pastry::mergeState(), BaseOverlay::neighborSet(), BasePastry::newLeafs(), BasePastry::pingNodes(), oversim::Chord::pingResponse(), BasePastry::pingResponse(), oversim::Chord::pingTimeout(), BasePastry::pingTimeout(), BasePastry::prePing(), QuonPR::purgeSites(), QuonP::purgeSites(), BasePastry::recursiveRoutingHook(), BaseOverlay::route(), Kademlia::routingInit(), oversim::Chord::rpcFixfingers(), oversim::Chord::rpcJoin(), oversim::Koorde::rpcNotify(), oversim::Chord::rpcNotify(), BasePastry::sendLeafset(), QuonPR::sendMessage(), QuonP::sendMessage(), BaseOverlay::sendMessageToUDP(), BaseApp::sendMessageToUDP(), I3::sendPacket(), I3::sendQueryReply(), BasePastry::sendRequest(), BaseOverlay::sendRouteMessage(), BasePastry::sendRoutingRow(), sendRpcCall(), sendRpcResponse(), BasePastry::sendStateTables(), QuonPR::sendToApp(), QuonP::sendToApp(), BaseOverlay::sendToKey(), Kademlia::setBucketUsage(), BaseOverlay::setOverlayReady(), BaseOverlay::setOwnNodeID(), PubSubMMOG::startTimer(), PubSubMMOG::takeOverSubspace(), SimpleGameClient::updateNeighbors(), QuonPR::updateThisSite(), QuonP::updateThisSite(), oversim::Koorde::updateTooltip(), Kademlia::updateTooltip(), Gia::updateTooltip(), oversim::Chord::updateTooltip(), Broose::updateTooltip(), and BasePastry::updateTooltip().

Definition at line 71 of file BaseRpc.h.

Referenced by Scribe::addChildToGroup(), BaseApp::BaseApp(), BaseApp::callLocalLookup(), BaseApp::callNeighborSet(), BaseApp::callRoute(), Scribe::checkGroupEmpty(), RealWorldTestApp::deliver(), KBRTestApp::deliver(), Scribe::deliverALMDataToGroup(), XmlRpcInterface::dumpDht(), Scribe::forward(), KBRTestApp::forward(), BaseApp::forwardResponse(), XmlRpcInterface::get(), BootstrapList::getBootstrapNode(), BaseApp::handleCommonAPIMessage(), Scribe::handleJoinMessage(), Scribe::handleJoinResponse(), KBRTestApp::handleLookupResponse(), DHT::handleLookupResponse(), BootstrapList::handleLookupResponse(), GIASearchApp::handleLowerMessage(), XmlRpcInterface::handleMessage(), BaseApp::handleMessage(), SimMud::handleMove(), SimMud::handleOtherPlayerMove(), Scribe::handlePublishCall(), Scribe::handlePublishResponse(), DHT::handlePutRequest(), Scribe::handleRpcResponse(), KBRTestApp::handleRpcResponse(), BootstrapList::handleRpcResponse(), SimpleGameClient::handleTimerEvent(), Scribe::handleTimerEvent(), KBRTestApp::handleTimerEvent(), GIASearchApp::handleTimerEvent(), DHT::handleTimerEvent(), Scribe::handleUpperMessage(), SimpleGameClient::initializeApp(), DHT::initializeApp(), BootstrapList::initializeApp(), initRpcs(), BaseApp::isSiblingFor(), XmlRpcInterface::joinOverlay(), XmlRpcInterface::localLookup(), BootstrapList::locateBootstrapNode(), XmlRpcInterface::lookup(), IterativeLookup::lookup(), SendToKeyListener::lookupFinished(), XmlRpcInterface::p2pnsRegister(), P2pns::p2pnsRegisterRpc(), XmlRpcInterface::p2pnsResolve(), BootstrapList::pingResponse(), BootstrapList::pingTimeout(), XmlRpcInterface::put(), BootstrapList::removeBootstrapNode(), BaseApp::sendMessageToUDP(), sendRpcCall(), sendRpcMessageWithTransport(), sendRpcResponse(), Scribe::subscribeToGroup(), Scribe::update(), DHT::update(), and SendToKeyListener::~SendToKeyListener().

bool BaseRpc::debugOutput [protected]

debug output ?

Reimplemented in BaseApp, BaseOverlay, and DHTTestApp.

Definition at line 74 of file BaseRpc.h.

CompType BaseRpc::thisCompType [protected]

Definition at line 422 of file BaseRpc.h.

Referenced by BaseApp::callRoute(), and initRpcs().

int BaseRpc::numPingSent [protected]

Definition at line 441 of file BaseRpc.h.

Referenced by BaseOverlay::finish(), initRpcs(), and pingNode().

int BaseRpc::bytesPingSent [protected]

Definition at line 442 of file BaseRpc.h.

Referenced by BaseOverlay::finish(), initRpcs(), and pingNode().

Definition at line 443 of file BaseRpc.h.

Referenced by BaseOverlay::finish(), initRpcs(), and pingRpc().

Definition at line 444 of file BaseRpc.h.

Referenced by BaseOverlay::finish(), initRpcs(), and pingRpc().

int BaseRpc::rpcsPending [private]

Definition at line 531 of file BaseRpc.h.

Referenced by initRpcs().

Definition at line 532 of file BaseRpc.h.

Referenced by BaseRpc(), finishRpcs(), initRpcs(), and sendRpcCall().

double BaseRpc::rpcUdpTimeout [private]

Definition at line 534 of file BaseRpc.h.

Referenced by initRpcs(), and sendRpcCall().

double BaseRpc::rpcKeyTimeout [private]

Definition at line 534 of file BaseRpc.h.

Referenced by initRpcs(), and sendRpcCall().

Definition at line 535 of file BaseRpc.h.

Referenced by initRpcs(), and internalHandleRpcMessage().


The documentation for this class was generated from the following files:

Generated on Wed Mar 25 16:32:52 2009 for OverSim by  doxygen 1.5.5