#include <BaseRpc.h>
Base class for RPCs.
Public Member Functions | |
BaseRpc () | |
Protected Member Functions | |
virtual bool | internalHandleRpc (BaseCallMessage *msg) |
Handles internal rpc requests. | |
virtual bool | internalHandleRpcResponse (BaseResponseMessage *msg, int rpcId, simtime_t rtt) |
Handles rpc responses internal in base classes . | |
virtual void | internalHandleRpcTimeout (BaseCallMessage *msg, const TransportAddress &dest, 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 | sendRpcMessage (const TransportAddress &dest, BaseCallMessage *msg, RpcListener *rpcListener=NULL, const OverlayKey &destKey=OverlayKey::UNSPECIFIED_KEY, int rpcId=-1, simtime_t timeout=-1, int retries=0) __attribute__((deprecated)) |
Sends a Remote-Procedure-Call message to the underlay. | |
uint32_t | sendRpcMessage (RpcAddrType destType, const TransportAddress &dest, BaseCallMessage *msg, RpcListener *rpcListener=NULL, const OverlayKey &destKey=OverlayKey::UNSPECIFIED_KEY, int rpcId=-1, simtime_t timeout=-1, int retries=0) __attribute__((deprecated)) |
Sends a Remote-Procedure-Call message to the underlay. | |
uint32_t | sendRouteRpcCall (CompType destComp, const TransportAddress &dest, const OverlayKey &destKey, BaseCallMessage *msg, 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, 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, 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, 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, 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 | sendRpcResponse (TransportType transportType, const TransportAddress &dest, const OverlayKey &destKey, BaseCallMessage *call, BaseResponseMessage *response) |
Send Remote-Procedure response message and deletes call message. | |
void | sendRpcResponse (int destType, BaseCallMessage *call, BaseResponseMessage *response) __attribute__((deprecated)) |
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 | sendInternalRpcResponse (BaseCallMessage *call, BaseResponseMessage *response) __attribute__((deprecated)) |
Send internal RPC response message and deletes call message. | |
void | pingNode (const TransportAddress &dest, simtime_t timeout=-1, int retries=0, const char *caption=NULL, RpcListener *rpcListener=NULL, int rpcId=-1, bool overrideCache=false) |
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 | sendRpcMessageWithTransport (TransportType transportType, CompType destComp, const TransportAddress &dest, const OverlayKey &destKey, BaseRpcMessage *message)=0 |
void | pingRpc (PingCall *call) |
PingResponse * | ping (PingCall *call) |
void | pingRpcResponse (PingResponse *response, int rpcId, simtime_t rtt) |
PingCall * | createPingCall (const char *caption) |
virtual void | pingResponse (PingResponse *pingResponse, int rpcId, simtime_t rtt) |
virtual void | pingTimeout (PingResponse *pingResponse, int rpcId) |
Protected Attributes | |
NodeHandle | thisNode |
Virtual destructor. | |
bool | debugOutput |
GlobalParameters * | globalParameters |
GlobalStatistics * | globalStatistics |
pointer to GlobalStatistics module in this node | |
int | numPingSent |
int | bytesPingSent |
int | numPingResponseSent |
int | bytesPingResponseSent |
PingCache * | pingCache |
Private Types | |
typedef hash_map < int, RpcState > | RpcStates |
Private Member Functions | |
uint32_t | sendRpcCall (TransportType transportType, CompType destComp, const TransportAddress &dest, const OverlayKey &destKey, BaseCallMessage *msg, simtime_t timeout, int retries, int rpcId, RpcListener *rpcListener) |
Sends a Remote-Procedure-Call message to the underlay. | |
Private Attributes | |
int | rpcsPending |
RpcListener * | defaultRpcListener |
RpcStates | rpcStates |
double | rpcUdpTimeout |
double | rpcKeyTimeout |
Classes | |
class | RpcState |
typedef hash_map<int,RpcState> BaseRpc::RpcStates [private] |
BaseRpc::BaseRpc | ( | ) |
bool BaseRpc::internalHandleRpc | ( | BaseCallMessage * | msg | ) | [protected, virtual] |
Handles internal rpc requests.
This method is used to implement basic functionionality in the BaseRpc.
msg | The call message |
Reimplemented in BaseApp, and BaseOverlay.
00358 { 00359 RPC_SWITCH_START( msg ); 00360 RPC_DELEGATE( Ping, pingRpc ); 00361 RPC_SWITCH_END( ); 00362 00363 return RPC_HANDLED; 00364 }
bool BaseRpc::internalHandleRpcResponse | ( | BaseResponseMessage * | msg, | |
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.
msg | The call message | |
rpcId | The ID of the call | |
rtt | the time between sending the call and receiving the response |
Reimplemented in BaseApp, and BaseOverlay.
00367 { 00368 // call rpc stubs 00369 RPC_SWITCH_START( msg ); 00370 RPC_ON_RESPONSE( Ping ) { 00371 pingRpcResponse(_PingResponse, rpcId, rtt); 00372 break; 00373 } 00374 RPC_SWITCH_END( ); 00375 00376 return RPC_HANDLED; 00377 }
void BaseRpc::internalHandleRpcTimeout | ( | BaseCallMessage * | msg, | |
const TransportAddress & | dest, | |||
int | rpcId, | |||
const OverlayKey & | destKey | |||
) | [protected, virtual] |
Handles rpc timeouts internal in base classes
.
This method is used to implement basic functionionality in the BaseRpc.
msg | The call message | |
dest | The node that did not response | |
rpcId | The ID of the call | |
destKey | The key of the call if used |
Reimplemented in BaseOverlay.
00382 { 00383 RPC_SWITCH_START( msg ) { 00384 RPC_ON_CALL( Ping ) { 00385 pingCache->addressTimeout(dest); 00386 } 00387 } 00388 RPC_SWITCH_END( ) 00389 }
void BaseRpc::initRpcs | ( | ) | [protected] |
Initializes Remote-Procedure state.
00054 { 00055 // set friend modules 00056 globalStatistics = GlobalStatisticsAccess().get(); 00057 globalParameters = GlobalParametersAccess().get(); 00058 00059 rpcsPending = 0; 00060 rpcStates.clear(); 00061 00062 defaultRpcListener = new RpcListener(); 00063 00064 //set ping cache 00065 numPingSent = 0; 00066 bytesPingSent = 0; 00067 numPingResponseSent = 0; 00068 bytesPingResponseSent = 0; 00069 00070 WATCH(numPingSent); 00071 WATCH(bytesPingSent); 00072 WATCH(numPingResponseSent); 00073 WATCH(bytesPingResponseSent); 00074 00075 cModule *mod = parentModule(); 00076 pingCache = NULL; 00077 while (pingCache == NULL) { 00078 pingCache = (PingCache*)mod->submodule("pingCache"); 00079 mod = mod->parentModule(); 00080 if (!mod) 00081 opp_error ("BaseRpc::initRpc: Module type contains no ping cache!"); 00082 } 00083 }
void BaseRpc::finishRpcs | ( | ) | [protected] |
Deinitializes Remote-Procedure state.
00087 { 00088 // stop all rpcs 00089 for (RpcStates::iterator i = rpcStates.begin(); 00090 i != rpcStates.end(); i++) { 00091 cancelAndDelete(i->second.callMsg); 00092 cancelAndDelete(i->second.timeoutMsg); 00093 } 00094 rpcStates.clear(); 00095 00096 // delete default rpc listener 00097 if (defaultRpcListener!=NULL) { 00098 delete defaultRpcListener; 00099 defaultRpcListener = NULL; 00100 } 00101 }
void BaseRpc::internalHandleRpcMessage | ( | BaseRpcMessage * | msg | ) | [protected, virtual] |
Handles incoming rpc messages and delegates them to the corresponsing listeners or handlers.
msg | The message to handle. |
00263 { 00264 // check if this is a rpc call message 00265 BaseCallMessage* rpCall = dynamic_cast<BaseCallMessage*>(msg); 00266 if (rpCall != NULL) { 00267 bool rpcHandled = true; 00268 if (!handleRpc(rpCall)) rpcHandled = internalHandleRpc(rpCall); 00269 if (!rpcHandled) { 00270 EV << "[BaseRpc::internalHandleRpcMessage() @ " << thisNode.ip 00271 << " (" << thisNode.key.toString(16) << ")]\n" 00272 << " Error: RPC '" << msg->fullName()<< "' was not handled" 00273 << endl; 00274 delete msg; 00275 } 00276 return; 00277 } 00278 00279 // get nonce 00280 int nonce = msg->getNonce(); 00281 00282 // nonce known? no -> delete message and return 00283 if (rpcStates.count(nonce)==0) { 00284 EV << "[BaseRpc::internalHandleRpcMessage() @ " << thisNode.ip 00285 << " " << thisNode.key.toString(16) << ")]\n" 00286 << " RPC: Nonce Unknown" 00287 << endl; 00288 delete msg; 00289 return; 00290 } 00291 00292 // get state and remove from map 00293 RpcState state = rpcStates[nonce]; 00294 rpcStates.erase(nonce); 00295 00296 // is timeout message? 00297 if (msg->isSelfMessage() && 00298 (dynamic_cast<RpcTimeoutMessage*>(msg) != NULL)) { 00299 // yes-> inform listener 00300 00301 // retry? 00302 state.retries--; 00303 simtime_t timeout = simulation.simTime() - state.timeSent; 00304 if (state.retries>=0) { 00305 sendRpcMessageWithTransport(state.transportType, state.destComp, 00306 state.dest, 00307 state.destKey, 00308 dynamic_cast<BaseCallMessage*> 00309 (state.callMsg->dup())); 00310 if (timeout!=0) 00311 scheduleAt( simulation.simTime() + timeout, msg ); 00312 00313 state.timeSent = simulation.simTime(); 00314 rpcStates[nonce] = state; 00315 return; 00316 } 00317 00318 // inform listener 00319 if ( state.listener != NULL ) 00320 state.listener->handleRpcTimeout( state.callMsg, state.dest, 00321 state.id, state.destKey ); 00322 00323 // inform overlay 00324 internalHandleRpcTimeout(state.callMsg, state.dest, 00325 state.id, state.destKey); 00326 handleRpcTimeout( state.callMsg, state.dest, state.id, state.destKey ); 00327 00328 } else { // no-> handle rpc response 00329 00330 // get parameters 00331 simtime_t rtt = simulation.simTime() - state.timeSent; 00332 BaseResponseMessage* response 00333 = dynamic_cast<BaseResponseMessage*>(msg); 00334 00335 // inform listener 00336 if ( state.listener != NULL ) 00337 state.listener->handleRpcResponse( response, state.id, rtt ); 00338 00339 // inform overlay 00340 internalHandleRpcResponse(response, state.id, rtt); 00341 handleRpcResponse(response, state.id, rtt); 00342 00343 // delete response 00344 delete response; 00345 } 00346 00347 // delete messages 00348 cancelAndDelete(state.callMsg); 00349 cancelAndDelete(state.timeoutMsg); 00350 00351 // clean up pointers 00352 state.callMsg = NULL; 00353 state.timeoutMsg = NULL; 00354 }
uint32_t BaseRpc::sendRpcMessage | ( | const TransportAddress & | dest, | |
BaseCallMessage * | msg, | |||
RpcListener * | rpcListener = NULL , |
|||
const OverlayKey & | destKey = OverlayKey::UNSPECIFIED_KEY , |
|||
int | rpcId = -1 , |
|||
simtime_t | timeout = -1 , |
|||
int | retries = 0 | |||
) | [protected] |
Sends a Remote-Procedure-Call message to the underlay.
dest | Destination node handle | |
msg | RPC Call Message | |
rpcListener | RPC Listener | |
destKey | first route the RPC to the node that is responsible for kestkey | |
rpcId | RPC id | |
timeout | RPC timeout | |
retries | How often we try to resent rpc call, if it gets lost |
00110 { 00111 if (destKey.isUnspecified()) { 00112 if (getThisCompType() == OVERLAY_COMP) { 00113 return sendUdpRpcCall(dest, msg, timeout, retries, 00114 rpcId, rpcListener); 00115 } else { 00116 return sendRouteRpcCall(getThisCompType(), dest, msg, 00117 timeout, retries, rpcId, rpcListener); 00118 } 00119 } 00120 // send message to key 00121 return sendRouteRpcCall(getThisCompType(), dest, destKey, msg, 00122 timeout, retries, rpcId, rpcListener); 00123 }
uint32_t BaseRpc::sendRpcMessage | ( | RpcAddrType | destType, | |
const TransportAddress & | dest, | |||
BaseCallMessage * | msg, | |||
RpcListener * | rpcListener = NULL , |
|||
const OverlayKey & | destKey = OverlayKey::UNSPECIFIED_KEY , |
|||
int | rpcId = -1 , |
|||
simtime_t | timeout = -1 , |
|||
int | retries = 0 | |||
) | [protected] |
Sends a Remote-Procedure-Call message to the underlay.
destType | The type of destination (RPC_TO_UDP, RPC_TO_KEY, RPC_TO_LOWERTIER, RPC_TO_UPPERTIER) | |
dest | Destination node handle | |
msg | RPC Call Message | |
rpcListener | RPC Listener | |
destKey | first route the RPC to the node that is responsible for kestkey | |
rpcId | RPC id | |
timeout | RPC timeout | |
retries | How often we try to resent rpc call, if it gets lost |
00132 { 00133 TransportType transportType = INVALID_TRANSPORT; 00134 CompType destComp = INVALID_COMP; 00135 00136 switch (destType) { 00137 case RPC_TO_OVERLAY: 00138 transportType = INTERNAL_TRANSPORT; 00139 destComp = OVERLAY_COMP; 00140 break; 00141 case RPC_TO_TIER1: 00142 transportType = INTERNAL_TRANSPORT; 00143 destComp = TIER1_COMP; 00144 break; 00145 case RPC_TO_TIER2: 00146 transportType = INTERNAL_TRANSPORT; 00147 destComp = TIER2_COMP; 00148 break; 00149 case RPC_TO_TIER3: 00150 transportType = INTERNAL_TRANSPORT; 00151 destComp = TIER3_COMP; 00152 break; 00153 case RPC_TO_KEY: 00154 transportType = ROUTE_TRANSPORT; 00155 destComp = getThisCompType(); 00156 break; 00157 case RPC_TO_UDP: 00158 if (getThisCompType() == OVERLAY_COMP) { 00159 transportType = UDP_TRANSPORT; 00160 } else { 00161 transportType = ROUTE_TRANSPORT; 00162 destComp = getThisCompType(); 00163 } 00164 break; 00165 default: 00166 opp_error("BaseRpc::sendRpcMessage(): Deprecated parameters!"); 00167 } 00168 00169 return sendRpcCall(transportType, destComp, dest, destKey, msg, 00170 timeout, retries, rpcId, rpcListener); 00171 }
uint32_t BaseRpc::sendRpcCall | ( | TransportType | transportType, | |
CompType | destComp, | |||
const TransportAddress & | dest, | |||
const OverlayKey & | destKey, | |||
BaseCallMessage * | msg, | |||
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.
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 | |
timeout | RPC timeout | |
retries | How often we try to resent rpc call, if it gets lost | |
rpcId | RPC id | |
rpcListener | RPC Listener |
00182 { 00183 // create nonce, timeout and set default parameters 00184 uint nonce; 00185 do { 00186 nonce = intuniform( 0, 2147483647); 00187 } while (rpcStates.count(nonce) > 0); 00188 00189 if (timeout == -1) { 00190 switch (transportType) { 00191 case INTERNAL_TRANSPORT: 00192 timeout = 0; 00193 break; 00194 case UDP_TRANSPORT: 00195 timeout = globalParameters->getRpcUdpTimeout(); 00196 break; 00197 case ROUTE_TRANSPORT: 00198 timeout = (destKey.isUnspecified() ? 00199 globalParameters->getRpcUdpTimeout() : 00200 globalParameters->getRpcKeyTimeout()); 00201 break; 00202 default: 00203 throw new cException("BaseRpc::sendRpcMessage(): " 00204 "Unknown RpcTransportType!"); 00205 } 00206 } 00207 00208 if (rpcListener == NULL) 00209 rpcListener = defaultRpcListener; 00210 00211 // create state 00212 RpcState state; 00213 state.id = rpcId; 00214 state.timeSent = simulation.simTime(); 00215 state.dest = dest; 00216 state.destKey = destKey; 00217 state.srcComp = getThisCompType(); 00218 state.destComp = destComp; 00219 state.listener = rpcListener; 00220 state.timeoutMsg = new RpcTimeoutMessage(); 00221 state.timeoutMsg->setNonce(nonce); 00222 state.retries = retries; 00223 state.transportType = transportType; 00224 00225 if (rpcStates.count(nonce) > 0) 00226 error("RPC nonce collision"); 00227 00228 // set message parameters 00229 msg->setNonce(nonce); 00230 msg->setSrcNode(thisNode); 00231 msg->setType(RPC); 00232 00233 // save copy of call message in RpcState 00234 state.callMsg = dynamic_cast<BaseCallMessage*>(msg->dup()); 00235 assert(!msg->encapsulatedMsg() || !msg->encapsulatedMsg()->controlInfo()); 00236 00237 // register state 00238 rpcStates[nonce] = state; 00239 00240 // schedule timeout message 00241 if (timeout!=0) 00242 scheduleAt( simulation.simTime() + timeout, state.timeoutMsg); 00243 00244 sendRpcMessageWithTransport(transportType, destComp, dest, destKey, msg); 00245 00246 return nonce; 00247 }
uint32_t BaseRpc::sendRouteRpcCall | ( | CompType | destComp, | |
const TransportAddress & | dest, | |||
const OverlayKey & | destKey, | |||
BaseCallMessage * | msg, | |||
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 | |
timeout | RPC timeout | |
retries | How often we try to resent rpc call, if it gets lost | |
rpcId | RPC id | |
rpcListener | RPC Listener |
00315 { 00316 if (dest.isUnspecified() && destKey.isUnspecified()) 00317 opp_error("BaseRpc::sendRouteRpcCall() with both key and " 00318 "transportAddress unspecified!"); 00319 return sendRpcCall(ROUTE_TRANSPORT, destComp, dest, destKey, msg, 00320 timeout, retries, rpcId, rpcListener); 00321 }
uint32_t BaseRpc::sendRouteRpcCall | ( | CompType | destComp, | |
const OverlayKey & | destKey, | |||
BaseCallMessage * | msg, | |||
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 | |
timeout | RPC timeout | |
retries | How often we try to resent rpc call, if it gets lost | |
rpcId | RPC id | |
rpcListener | RPC Listener |
00349 { 00350 return sendRpcCall(ROUTE_TRANSPORT, destComp, 00351 TransportAddress::UNSPECIFIED_NODE, 00352 destKey, msg, timeout, retries, rpcId, 00353 rpcListener); 00354 }
uint32_t BaseRpc::sendRouteRpcCall | ( | CompType | destComp, | |
const TransportAddress & | dest, | |||
BaseCallMessage * | msg, | |||
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 | |
msg | RPC Call Message | |
timeout | RPC timeout | |
retries | How often we try to resent rpc call, if it gets lost | |
rpcId | RPC id | |
rpcListener | RPC Listener |
00383 { 00384 return sendRpcCall(ROUTE_TRANSPORT, destComp, dest, 00385 OverlayKey::UNSPECIFIED_KEY, msg, timeout, 00386 retries, rpcId, rpcListener); 00387 }
uint32_t BaseRpc::sendUdpRpcCall | ( | const TransportAddress & | dest, | |
BaseCallMessage * | msg, | |||
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 | |
msg | RPC Call Message | |
timeout | RPC timeout | |
retries | How often we try to resent rpc call, if it gets lost | |
rpcId | RPC id | |
rpcListener | RPC Listener |
00412 { 00413 return sendRpcCall(UDP_TRANSPORT, INVALID_COMP, dest, 00414 OverlayKey::UNSPECIFIED_KEY, msg, 00415 timeout, retries, rpcId, rpcListener); 00416 }
uint32_t BaseRpc::sendInternalRpcCall | ( | CompType | destComp, | |
BaseCallMessage * | msg, | |||
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 | |
timeout | RPC timeout | |
retries | How often we try to resent rpc call, if it gets lost | |
rpcId | RPC id | |
rpcListener | RPC Listener |
00442 { 00443 return sendRpcCall(INTERNAL_TRANSPORT, destComp, 00444 TransportAddress::UNSPECIFIED_NODE, 00445 OverlayKey::UNSPECIFIED_KEY, msg, 00446 timeout, retries, rpcId, rpcListener); 00447 }
void BaseRpc::cancelRpcMessage | ( | uint32_t | nonce | ) | [protected] |
void BaseRpc::sendRpcResponse | ( | TransportType | transportType, | |
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 | |
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 |
00401 { 00402 if (call==NULL || response==NULL) { 00403 if ( call!=NULL ) 00404 delete call; 00405 return; 00406 } 00407 00408 OverlayCtrlInfo* overlayCtrlInfo = 00409 check_and_cast<OverlayCtrlInfo*>(call->removeControlInfo()); 00410 00411 response->setSrcNode(thisNode); 00412 response->setType(RPC); 00413 response->setNonce(call->getNonce()); 00414 sendRpcMessageWithTransport(transportType, 00415 static_cast<CompType> 00416 (overlayCtrlInfo->getSrcComp()), 00417 dest, destKey, response); 00418 delete overlayCtrlInfo; 00419 delete call; 00420 00421 }
void BaseRpc::sendRpcResponse | ( | int | destType, | |
BaseCallMessage * | call, | |||
BaseResponseMessage * | response | |||
) | [protected] |
Send Remote-Procedure response message and deletes call message.
destType | The destination type used for this RPC | |
call | The corresponding call message to the reponse | |
response | The response message |
00453 { 00454 00455 TransportType transportType = INVALID_TRANSPORT; 00456 00457 switch (destType) { 00458 case RPC_TO_OVERLAY: 00459 case RPC_TO_TIER1: 00460 case RPC_TO_TIER2: 00461 case RPC_TO_TIER3: 00462 transportType = INTERNAL_TRANSPORT; 00463 break; 00464 case RPC_TO_KEY: 00465 transportType = ROUTE_TRANSPORT; 00466 break; 00467 case RPC_TO_UDP: 00468 if (getThisCompType() == OVERLAY_COMP) { 00469 transportType = UDP_TRANSPORT; 00470 } else { 00471 transportType = ROUTE_TRANSPORT; 00472 } 00473 break; 00474 default: 00475 opp_error("BaseRpc::sendRpcResponse(): Deprecated parameters!"); 00476 } 00477 00478 sendRpcResponse(transportType, call->getSrcNode(), 00479 call->getSrcNode().key, call, response); 00480 }
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 reponse | |
response | The response message |
00426 { 00427 TransportType transportType; 00428 00429 OverlayCtrlInfo* overlayCtrlInfo = 00430 check_and_cast<OverlayCtrlInfo*>(call->controlInfo()); 00431 00432 if (overlayCtrlInfo->getTransportType() == INTERNAL_TRANSPORT) { 00433 transportType = INTERNAL_TRANSPORT; 00434 } else if (getThisCompType() == OVERLAY_COMP) { 00435 transportType = UDP_TRANSPORT; 00436 } else { 00437 transportType = ROUTE_TRANSPORT; 00438 } 00439 00440 sendRpcResponse(transportType, call->getSrcNode(), call->getSrcNode().key, 00441 call, response); 00442 }
void BaseRpc::sendInternalRpcResponse | ( | BaseCallMessage * | call, | |
BaseResponseMessage * | response | |||
) | [protected] |
Send internal RPC response message and deletes call message.
An internal RPC response message is sent to callingTier of the call message. If call or reponse is NULL no reponse will be sent. This is deprecated - use sendRpcResponse(call, response) instead.
call | The corresponding call message to the reponse | |
response | The response message |
00447 { 00448 sendRpcResponse(call, response); 00449 }
void BaseRpc::pingNode | ( | const TransportAddress & | dest, | |
simtime_t | timeout = -1 , |
|||
int | retries = 0 , |
|||
const char * | caption = NULL , |
|||
RpcListener * | rpcListener = NULL , |
|||
int | rpcId = -1 , |
|||
bool | overrideCache = false | |||
) | [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 | |
caption | special name for the ping call (instead of "PING") | |
rpcListener | RPC Listener | |
rpcId | RPC id | |
overrideCache | ignore ping cache |
00532 { 00533 if (overrideCache || pingCache->getAddressRtt(dest) == PINGSTATE_UNKNOWN) { 00534 /* if unknown or overriding, send ping call as normal */ 00535 PingCall* call = createPingCall(caption); 00536 RECORD_STATS(numPingSent++; bytesPingSent += call->byteLength()); 00537 sendUdpRpcCall(dest, call, timeout, retries, rpcId, rpcListener); 00538 pingCache->setAddressPinged(dest); 00539 } else if (pingCache->getAddressRtt(dest) != PINGSTATE_WAITING) { 00540 /* if it's time-out or a known value, reply with fake ping response */ 00541 PingResponse *pr = new PingResponse(); 00542 pr->setNonce(0); 00543 pr->setSrcNode(pingCache->getNodeHandle(dest)); 00544 handleRpcResponse(pr, rpcId, pingCache->getAddressRtt(dest)); 00545 delete pr; 00546 } 00547 }
bool BaseRpc::handleRpc | ( | BaseCallMessage * | msg | ) | [protected, virtual] |
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, and BaseOverlay.
virtual void BaseRpc::sendRpcMessageWithTransport | ( | TransportType | transportType, | |
CompType | destComp, | |||
const TransportAddress & | dest, | |||
const OverlayKey & | destKey, | |||
BaseRpcMessage * | message | |||
) | [protected, pure virtual] |
Implemented in BaseApp, and BaseOverlay.
void BaseRpc::pingRpc | ( | PingCall * | call | ) | [protected] |
00492 { 00493 PingResponse* response = ping(call); 00494 RECORD_STATS(numPingResponseSent++; bytesPingResponseSent += 00495 response->byteLength()); 00496 sendRpcResponse(call, response ); 00497 }
PingResponse * BaseRpc::ping | ( | PingCall * | call | ) | [protected] |
void BaseRpc::pingRpcResponse | ( | PingResponse * | response, | |
int | rpcId, | |||
simtime_t | rtt | |||
) | [protected] |
00510 { 00511 pingCache->insertAddressRtt(response->getSrcNode(), rtt); 00512 pingResponse(response, rpcId, rtt); 00513 }
PingCall * BaseRpc::createPingCall | ( | const char * | caption | ) | [protected] |
void BaseRpc::pingResponse | ( | PingResponse * | pingResponse, | |
int | rpcId, | |||
simtime_t | rtt | |||
) | [protected, virtual] |
void BaseRpc::pingTimeout | ( | PingResponse * | pingResponse, | |
int | rpcId | |||
) | [protected, virtual] |
NodeHandle BaseRpc::thisNode [protected] |
Virtual destructor.
bool BaseRpc::debugOutput [protected] |
Reimplemented in BaseApp, BaseOverlay, and DHTTestApp.
GlobalParameters* BaseRpc::globalParameters [protected] |
GlobalStatistics* BaseRpc::globalStatistics [protected] |
int BaseRpc::rpcsPending [private] |
RpcListener* BaseRpc::defaultRpcListener [private] |
RpcStates BaseRpc::rpcStates [private] |
double BaseRpc::rpcUdpTimeout [private] |
double BaseRpc::rpcKeyTimeout [private] |
int BaseRpc::numPingSent [protected] |
int BaseRpc::bytesPingSent [protected] |
int BaseRpc::numPingResponseSent [protected] |
int BaseRpc::bytesPingResponseSent [protected] |
PingCache* BaseRpc::pingCache [protected] |
Reimplemented in Pastry.