#include <IterativeLookup.h>

Classes | |
| class | RpcInfo |
| class | RpcInfoVector |
Public Member Functions | |
| IterativeLookup (BaseOverlay *overlay, RoutingType routingType, const IterativeLookupConfiguration &config, const cPacket *findNodeExt=NULL, bool appLookup=false) | |
| virtual | ~IterativeLookup () |
| void | lookup (const OverlayKey &key, int numSiblings=1, int hopCountMax=0, int retries=0, LookupListener *listener=NULL) |
| Lookup siblings for a key. | |
| const NodeVector & | getResult () const |
| Returns the result of the lookup. | |
| bool | isValid () const |
| Returns true, if the lookup was successful. | |
| void | abortLookup () |
| Aborts a running lookup. | |
| uint32_t | getAccumulatedHops () const |
| Returns the total number of hops for all lookup paths. | |
Protected Types | |
| typedef UNORDERED_MAP < TransportAddress, RpcInfoVector, TransportAddress::hashFcn > | RpcInfoMap |
Protected Member Functions | |
| virtual IterativePathLookup * | createPathLookup () |
| This method creates a new path lookup. | |
| virtual FindNodeCall * | createFindNodeCall (cPacket *findNodeExt=NULL) |
| Creates a find node call message. | |
| int | compare (const OverlayKey &lhs, const OverlayKey &rhs) const |
| compares two OverlayKeys and indicates which one is closer to the key to look up | |
| bool | addSibling (const NodeHandle &handle) |
| adds a node to the siblings NodeVector | |
| void | setVisited (const TransportAddress &addr, bool visitedFlag=true) |
| adds/deletes visited nodes to/from the visited TransportAddress::Set | |
| bool | getVisited (const TransportAddress &addr) |
| indicates if the specified node has been visited before | |
| void | setDead (const TransportAddress &addr) |
| add a dead node to the dead node list | |
| bool | getDead (const TransportAddress &addr) |
| check if a node seems to be dead | |
| void | handleRpcResponse (BaseResponseMessage *msg, cPolymorphic *context, int rpcId, simtime_t rtt) |
| This method is called if an RPC response has been received. | |
| void | handleRpcTimeout (BaseCallMessage *msg, const TransportAddress &dest, cPolymorphic *context, int rpcId, const OverlayKey &destKey=OverlayKey::UNSPECIFIED_KEY) |
| This method is called if an RPC timeout has been reached. | |
| void | sendRpc (const NodeHandle &handle, FindNodeCall *call, IterativePathLookup *listener, int rpcId) |
| void | start () |
| void | stop () |
| void | checkStop () |
Protected Attributes | |
| OverlayKey | key |
| key to lookup | |
| BaseOverlay * | overlay |
| ptr to overlay | |
| LookupListener * | listener |
| lookup listener | |
| std::vector < IterativePathLookup * > | paths |
| parallel paths | |
| RoutingType | routingType |
| RoutingType for this lookup. | |
| IterativeLookupConfiguration | config |
| lookup configuration | |
| cPacket * | firstCallExt |
| additional info for first findNode() | |
| uint32_t | finishedPaths |
| number of finished paths | |
| uint32_t | successfulPaths |
| number of successful paths | |
| uint32_t | accumulatedHops |
| total number of hops (for all paths) | |
| bool | finished |
| true, if lookup is finished | |
| bool | success |
| true, if lookup was successful | |
| bool | running |
| true, if lookup is running | |
| int | retries |
| number of retries, if lookup fails | |
| bool | appLookup |
| NodeVector | siblings |
| closest nodes | |
| TransportAddress::Set | visited |
| nodes already visited | |
| TransportAddress::Set | dead |
| nodes which seem to be dead | |
| int | numSiblings |
| number of siblings | |
| int | hopCountMax |
| maximum hop count | |
| RpcInfoMap | rpcs |
Friends | |
| class | IterativePathLookup |
| class | BaseOverlay |
It uses the standard metric for greedy behaviour. If another metric is needed, the distance function can be replaced by overriding the distance method.
Definition at line 80 of file IterativeLookup.h.
typedef UNORDERED_MAP<TransportAddress, RpcInfoVector, TransportAddress::hashFcn> IterativeLookup::RpcInfoMap [protected] |
Definition at line 209 of file IterativeLookup.h.
| IterativeLookup::IterativeLookup | ( | BaseOverlay * | overlay, | |
| RoutingType | routingType, | |||
| const IterativeLookupConfiguration & | config, | |||
| const cPacket * | findNodeExt = NULL, |
|||
| bool | appLookup = false | |||
| ) |
Definition at line 69 of file IterativeLookup.cc.
00073 : 00074 overlay(overlay), 00075 routingType(routingType), 00076 config(config), 00077 firstCallExt(NULL), 00078 finished(false), 00079 success(false), 00080 running(false), 00081 appLookup(appLookup) 00082 { 00083 if (findNodeExt) firstCallExt = static_cast<cPacket*>(findNodeExt->dup()); 00084 00085 if (config.secure) { 00086 throw cRuntimeError("IterativeLookup::IterativeLookup(): " 00087 "Secure IterativeLookup not implemented yet!"); 00088 } 00089 00090 if ((config.parallelPaths > 1) && (!config.merge)) { 00091 throw cRuntimeError("IterativeLookup::IterativeLookup(): " 00092 "config.merge must be enabled for " 00093 "using parallel paths!"); 00094 } 00095 00096 if ((config.useAllParallelResponses) && (!config.merge)) { 00097 throw cRuntimeError("IterativeLookup::IterativeLookup(): " 00098 "config.merge must be enabled if " 00099 "config.useAllParallelResponses is true!"); 00100 } 00101 }
| IterativeLookup::~IterativeLookup | ( | ) | [virtual] |
Definition at line 103 of file IterativeLookup.cc.
00104 { 00105 stop(); 00106 delete firstCallExt; 00107 overlay->removeLookup(this); 00108 00109 // std::cout << "time: " << simTime() << "deleting " << this << endl; 00110 }
| void IterativeLookup::abortLookup | ( | ) | [virtual] |
Aborts a running lookup.
This method aborts a running lookup without calling the listener and delete the lookup object.
Implements AbstractLookup.
Definition at line 112 of file IterativeLookup.cc.
00113 { 00114 if (listener != NULL) { 00115 delete listener; 00116 listener = NULL; 00117 } 00118 delete this; 00119 }
| bool IterativeLookup::addSibling | ( | const NodeHandle & | handle | ) | [protected] |
adds a node to the siblings NodeVector
| handle | NodeHandle of the node to add |
Definition at line 349 of file IterativeLookup.cc.
Referenced by IterativePathLookup::handleResponse(), IterativePathLookup::sendRpc(), and start().
00350 { 00351 bool result = false; 00352 00353 if (numSiblings == 0) { 00354 if (handle.getKey() == key) { 00355 siblings.clear(); 00356 siblings.push_back( handle ); 00357 result = true; 00358 } 00359 } else { 00360 if (config.parallelPaths == 1) { 00361 result = true; 00362 if (!siblings.isFull()) { 00363 siblings.push_back(handle); 00364 } 00365 } else { 00366 if (this->siblings.add(handle) >= 0) { 00367 result = true; 00368 } 00369 } 00370 } 00371 00372 return result; 00373 }
| void IterativeLookup::checkStop | ( | ) | [inline, protected] |
Definition at line 260 of file IterativeLookup.cc.
Referenced by handleRpcResponse(), handleRpcTimeout(), and start().
00261 { 00262 bool finishLookup = false; 00263 00264 // check if there are rpcs pending or lookup finished 00265 if ((successfulPaths >= 1 && numSiblings == 0) || 00266 (finishedPaths == (uint32_t)config.parallelPaths && numSiblings > 0)) { 00267 for (uint32_t i=0; i<paths.size(); i++) 00268 success |= paths[i]->success; 00269 finishLookup = true; 00270 } else if (rpcs.size() == 0) { 00271 finishLookup = true; 00272 } 00273 00274 if (finishLookup == true) { 00275 00276 if (success == false) { 00277 //cout << "failed: hops :" << accumulatedHops << endl; 00278 } 00279 00280 if (success == false && retries > 0) { 00281 // std::cout << "IterativeLookup::checkStop(): Retry..." << endl; 00282 retries--; 00283 LookupListener* oldListener = listener; 00284 listener = NULL; 00285 stop(); 00286 listener = oldListener; 00287 start(); 00288 } else { 00289 delete this; 00290 } 00291 } 00292 }
| int IterativeLookup::compare | ( | const OverlayKey & | lhs, | |
| const OverlayKey & | rhs | |||
| ) | const [protected, virtual] |
compares two OverlayKeys and indicates which one is closer to the key to look up
| lhs | the first OverlayKey | |
| rhs | the second OverlayKey |
Reimplemented from Comparator< OverlayKey >.
Definition at line 340 of file IterativeLookup.cc.
| FindNodeCall * IterativeLookup::createFindNodeCall | ( | cPacket * | findNodeExt = NULL |
) | [protected, virtual] |
Creates a find node call message.
This method can be overridden to add some additional state information to the FindNodeCall message.
| findNodeExt | Pointer to a optional cMessage, that may contain overlay specific data to be attached to FindNode RPCs and BaseRouteMessages |
Definition at line 302 of file IterativeLookup.cc.
Referenced by IterativePathLookup::sendRpc(), and start().
00303 { 00304 FindNodeCall* call = new FindNodeCall("FindNodeCall"); 00305 if (appLookup) { 00306 call->setStatType(APP_LOOKUP_STAT); 00307 } else { 00308 call->setStatType(MAINTENANCE_STAT); 00309 } 00310 00311 if (routingType == EXHAUSTIVE_ITERATIVE_ROUTING) { 00312 call->setExhaustiveIterative(true); 00313 } else { 00314 call->setExhaustiveIterative(false); 00315 } 00316 00317 call->setLookupKey(key); 00318 call->setNumRedundantNodes(config.redundantNodes); 00319 call->setNumSiblings(numSiblings); 00320 if (routingType == EXHAUSTIVE_ITERATIVE_ROUTING) { 00321 call->setExhaustiveIterative(true); 00322 } else { 00323 call->setExhaustiveIterative(false); 00324 } 00325 call->setBitLength(FINDNODECALL_L(call)); 00326 00327 // duplicate extension object 00328 if (findNodeExt) { 00329 call->addObject(static_cast<cObject*>(findNodeExt->dup())); 00330 call->addBitLength(findNodeExt->getBitLength()); 00331 } 00332 00333 return call; 00334 }
| IterativePathLookup * IterativeLookup::createPathLookup | ( | ) | [protected, virtual] |
This method creates a new path lookup.
It may be overloaded to enhance IterativePathLookup with some new information/features.
Definition at line 297 of file IterativeLookup.cc.
00298 { 00299 return new IterativePathLookup(this); 00300 }
| uint32_t IterativeLookup::getAccumulatedHops | ( | ) | const [virtual] |
Returns the total number of hops for all lookup paths.
Implements AbstractLookup.
Definition at line 631 of file IterativeLookup.cc.
00632 { 00633 return accumulatedHops; 00634 }
| bool IterativeLookup::getDead | ( | const TransportAddress & | addr | ) | [protected] |
check if a node seems to be dead
| addr | TransportAddress of the node |
Definition at line 393 of file IterativeLookup.cc.
Referenced by IterativePathLookup::handleTimeout(), and IterativePathLookup::sendRpc().
00394 { 00395 return (dead.count(addr) != 0); 00396 }
| const NodeVector & IterativeLookup::getResult | ( | ) | const [virtual] |
Returns the result of the lookup.
Implements AbstractLookup.
Definition at line 620 of file IterativeLookup.cc.
00621 { 00622 // return sibling vector 00623 return siblings; 00624 }
| bool IterativeLookup::getVisited | ( | const TransportAddress & | addr | ) | [protected] |
indicates if the specified node has been visited before
| addr | TransportAddress of the node |
Definition at line 383 of file IterativeLookup.cc.
Referenced by IterativePathLookup::sendRpc().
00384 { 00385 return (visited.count(addr) != 0); 00386 }
| void IterativeLookup::handleRpcResponse | ( | BaseResponseMessage * | msg, | |
| cPolymorphic * | context, | |||
| int | rpcId, | |||
| simtime_t | rtt | |||
| ) | [protected, virtual] |
This method is called if an RPC response has been received.
| msg | The response message. | |
| context | Pointer to an optional state object. The object has to be handled/deleted by the handleRpcResponse() code | |
| rpcId | The RPC id. | |
| rtt | The Round-Trip-Time of this RPC |
Reimplemented from RpcListener.
Definition at line 403 of file IterativeLookup.cc.
00406 { 00407 // check flags 00408 if (finished || !running) 00409 return; 00410 00411 // get source, cast messages and mark node as visited 00412 const TransportAddress& src = msg->getSrcNode(); 00413 FindNodeResponse* findNodeResponse = dynamic_cast<FindNodeResponse*>(msg); 00414 PingResponse* pingResponse = dynamic_cast<PingResponse*>(msg); 00415 FailedNodeResponse* failedNodeResponse = 00416 dynamic_cast<FailedNodeResponse*>(msg); 00417 00418 if (findNodeResponse != NULL || pingResponse != NULL) { 00419 // add authentificated sibling 00420 // addSibling( src ); 00421 } 00422 00423 // handle find node response 00424 if (findNodeResponse != NULL) { 00425 // std::cout << "time: " << simTime() << " node: " << overlay->thisNode << " this: " << this << " received rpc with nonce: " << findNodeResponse->getNonce() << " from: " << findNodeResponse->getSrcNode() << endl; 00426 00427 // check if rpc info is available, no -> exit 00428 if (rpcs.count(src) == 0) 00429 return; 00430 00431 // get info 00432 RpcInfoVector infos = rpcs[src]; 00433 rpcs.erase(src); 00434 00435 // add to siblinglist if not secure 00436 // if (!config.secure) 00437 // for (uint i=0; i<findNodeResponse->getClosestNodesArraySize(); i++) 00438 // addSibling( findNodeResponse->getClosestNodes(i) ); 00439 00440 // iterate 00441 bool rpcHandled = false; 00442 00443 for (uint32_t i=0; i<infos.size(); i++) { 00444 // get info 00445 const RpcInfo& info = infos[i]; 00446 00447 // do not handle finished paths 00448 if (info.path->finished) 00449 continue; 00450 00451 // check if path accepts the message 00452 // make an exception for responses with siblings==true 00453 if (!rpcHandled && 00454 (info.path->accepts(info.vrpcId) || 00455 ((routingType == EXHAUSTIVE_ITERATIVE_ROUTING) 00456 || findNodeResponse->getSiblings()))) { 00457 info.path->handleResponse(findNodeResponse); 00458 rpcHandled = true; 00459 } else { 00460 EV << "[IterativeLookup::handleRpcResponse()]\n" 00461 << " Path does not accept message with id " << info.vrpcId 00462 << endl; 00463 00464 info.path->handleTimeout(NULL, findNodeResponse->getSrcNode(), 00465 info.vrpcId); 00466 } 00467 00468 // count finished and successful paths 00469 if (info.path->finished) { 00470 finishedPaths++; 00471 00472 // count total number of hops 00473 accumulatedHops += info.path->hops; 00474 00475 if (info.path->success) 00476 successfulPaths++; 00477 } 00478 00479 } 00480 } 00481 00482 00483 // handle failed node response 00484 if (failedNodeResponse != NULL) { 00485 cPacket* findNodeExt = NULL; 00486 if (failedNodeResponse->hasObject("findNodeExt")) { 00487 findNodeExt = 00488 (cPacket*)failedNodeResponse->removeObject("findNodeExt"); 00489 } 00490 00491 for (std::vector<IterativePathLookup*>::iterator i = paths.begin(); 00492 i != paths.end(); i++) { 00493 00494 (*i)->handleFailedNodeResponse(failedNodeResponse->getSrcNode(), 00495 findNodeExt, 00496 failedNodeResponse->getTryAgain()); 00497 } 00498 } 00499 00500 checkStop(); 00501 }
| void IterativeLookup::handleRpcTimeout | ( | BaseCallMessage * | msg, | |
| const TransportAddress & | dest, | |||
| cPolymorphic * | context, | |||
| int | rpcId, | |||
| const OverlayKey & | destKey = OverlayKey::UNSPECIFIED_KEY | |||
| ) | [protected, virtual] |
This method is called if an RPC timeout has been reached.
| msg | The original RPC message. | |
| dest | The destination node | |
| context | Pointer to an optional state object. The object has to be handled/deleted by the handleRpcResponse() code | |
| rpcId | The RPC id. | |
| destKey | the destination OverlayKey |
Reimplemented from RpcListener.
Definition at line 504 of file IterativeLookup.cc.
00508 { 00509 // check flags 00510 if (finished || !running) 00511 return; 00512 00513 // check if rpc info is available 00514 if (rpcs.count(dest)==0) { 00515 cout << "IterativeLookup::handleRpcTimeout(): RPC Timeout, but node" 00516 << " is not in rpcs structure!" << endl; 00517 return; 00518 } 00519 00520 // mark the node as dead 00521 setDead(dest); 00522 00523 RpcInfoVector infos = rpcs[dest]; 00524 rpcs.erase(dest); 00525 00526 // iterate 00527 for (uint32_t i=0; i < infos.size(); i++) { 00528 00529 const RpcInfo& info = infos[i]; 00530 00531 // do not handle finished paths 00532 if (info.path->finished) 00533 continue; 00534 00535 // delegate timeout 00536 info.path->handleTimeout(msg, dest, info.vrpcId); 00537 00538 // count total number of hops 00539 accumulatedHops += info.path->hops; 00540 00541 // count finished and successful paths 00542 if (info.path->finished) { 00543 finishedPaths++; 00544 if (info.path->success) 00545 successfulPaths++; 00546 } 00547 } 00548 checkStop(); 00549 }
| bool IterativeLookup::isValid | ( | ) | const [virtual] |
Returns true, if the lookup was successful.
Implements AbstractLookup.
Definition at line 626 of file IterativeLookup.cc.
| void IterativeLookup::lookup | ( | const OverlayKey & | key, | |
| int | numSiblings = 1, |
|||
| int | hopCountMax = 0, |
|||
| int | retries = 0, |
|||
| LookupListener * | listener = NULL | |||
| ) | [virtual] |
Lookup siblings for a key.
| key | The key to lookup | |
| numSiblings | Number of siblings to lookup | |
| hopCountMax | Maximum hop count | |
| retries | Number of retries if lookup fails | |
| listener | Listener to inform, when the lookup is done |
Implements AbstractLookup.
Definition at line 590 of file IterativeLookup.cc.
00592 { 00593 EV << "[IterativeLookup::lookup() @ " << overlay->overlay->getThisNode().getAddress() 00594 << " (" << overlay->overlay->getThisNode().getKey().toString(16) << ")]\n" 00595 << " Lookup of key " << key 00596 << endl; 00597 00598 // check flags 00599 if (finished || running) 00600 return; 00601 00602 // set params 00603 this->key = key; 00604 this->numSiblings = numSiblings; 00605 this->hopCountMax = hopCountMax; 00606 this->listener = listener; 00607 this->retries = retries; 00608 00609 if ((routingType == EXHAUSTIVE_ITERATIVE_ROUTING) 00610 && (numSiblings > config.redundantNodes)) { 00611 throw cRuntimeError("IterativeLookup::lookup(): " 00612 "With EXHAUSTIVE_ITERATIVE_ROUTING numRedundantNodes " 00613 "must be >= numSiblings!"); 00614 } 00615 00616 // start lookup 00617 start(); 00618 }
| void IterativeLookup::sendRpc | ( | const NodeHandle & | handle, | |
| FindNodeCall * | call, | |||
| IterativePathLookup * | listener, | |||
| int | rpcId | |||
| ) | [protected] |
Definition at line 551 of file IterativeLookup.cc.
Referenced by IterativePathLookup::sendRpc().
00553 { 00554 // check flags 00555 if (finished || !running) { 00556 delete call; 00557 return; 00558 } 00559 00560 // create rpc info 00561 RpcInfo info; 00562 info.path = listener; 00563 info.vrpcId = rpcId; 00564 00565 // send new message 00566 if (rpcs.count(handle) == 0) { 00567 RpcInfoVector newVector; 00568 00569 overlay->countFindNodeCall(call); 00570 newVector.nonce = overlay->sendUdpRpcCall(handle, call, NULL, 00571 -1, 0, -1, this); 00572 00573 // std::cout << "time: " << simTime() << " node: " << overlay->thisNode << " new rpc with nonce: " << newVector.nonce << " to: " << handle << endl; 00574 rpcs[handle] = newVector; 00575 } else { 00576 EV << "[IterativeLookup::sendRpc()]\n" 00577 << " RPC already sent...not sent again" 00578 << endl; 00579 delete call; 00580 } 00581 00582 // register info 00583 rpcs[handle].push_back(info); 00584 }
| void IterativeLookup::setDead | ( | const TransportAddress & | addr | ) | [protected] |
add a dead node to the dead node list
| addr | TransportAddress of the node to add |
Definition at line 388 of file IterativeLookup.cc.
Referenced by handleRpcTimeout().
00389 { 00390 dead.insert(addr); 00391 }
| void IterativeLookup::setVisited | ( | const TransportAddress & | addr, | |
| bool | visitedFlag = true | |||
| ) | [protected] |
adds/deletes visited nodes to/from the visited TransportAddress::Set
| addr | TransportAddress of the node to add | |
| visitedFlag | if true node is added, else node is erased |
Definition at line 375 of file IterativeLookup.cc.
Referenced by IterativePathLookup::handleFailedNodeResponse(), IterativePathLookup::handleResponse(), and start().
00376 { 00377 if (visitedFlag) 00378 this->visited.insert(addr); 00379 else 00380 this->visited.erase(addr); 00381 }
| void IterativeLookup::start | ( | ) | [protected] |
Definition at line 121 of file IterativeLookup.cc.
Referenced by checkStop(), and lookup().
00122 { 00123 // std::cout << "time: " << simTime() << " start(): node: " << overlay->getThisNode() << " this: " << this << " key: " << key << endl; 00124 00125 // init params 00126 successfulPaths = 0; 00127 finishedPaths = 0; 00128 accumulatedHops = 0; 00129 00130 // init flags 00131 finished = false; 00132 success = false; 00133 running = true; 00134 00135 // init siblings vector 00136 siblings = NodeVector(numSiblings == 0 ? 1 : numSiblings, this); 00137 visited.clear(); 00138 dead.clear(); 00139 00140 // get local closest nodes 00141 FindNodeCall* call = createFindNodeCall(firstCallExt); 00142 NodeVector* nextHops = overlay->findNode(key, config.redundantNodes, 00143 (routingType == EXHAUSTIVE_ITERATIVE_ROUTING) ? -1 : numSiblings, call); 00144 00145 bool err; 00146 00147 setVisited(overlay->getThisNode()); 00148 00149 // if this node is new and no nodes are known -> stop lookup 00150 if (nextHops->size() == 0) { 00151 //std::cout << "IterativeLookup: No next hops known" << endl; 00152 finished = true; 00153 success = false; 00154 } else if ((numSiblings == 0) 00155 && overlay->isSiblingFor(overlay->getThisNode(), 00156 key, numSiblings, 00157 &err)) { 00158 if (overlay->getThisNode().getKey() == key) { 00159 addSibling(overlay->getThisNode()); 00160 success = true; 00161 } else { 00162 std::cout << "IterativeLookup: numSiblings==0 and no node with this id" 00163 << endl; 00164 success = false; 00165 } 00166 finished = true; 00167 } 00168 // finish lookup if the key is local and siblings are needed 00169 else if (numSiblings != 0 && routingType != EXHAUSTIVE_ITERATIVE_ROUTING && 00170 overlay->isSiblingFor(overlay->getThisNode(), key, 00171 numSiblings, &err) 00172 && !config.secure) { 00173 00174 for (uint32_t i=0; i<nextHops->size(); i++) { 00175 addSibling(nextHops->at(i)); 00176 } 00177 00178 success = finished = true; 00179 } 00180 00181 // if the key was local or belongs to one of our siblings we are finished 00182 if (finished) { 00183 // calls stop and finishes the lookup 00184 delete nextHops; 00185 delete call; 00186 delete this; 00187 return; 00188 } 00189 00190 // extract find node extensions 00191 cPacket* findNodeExt = NULL; 00192 if (call->hasObject("findNodeExt")) 00193 findNodeExt = (cPacket*)call->removeObject("findNodeExt"); 00194 delete call; 00195 00196 // not enough nodes for all paths? -> reduce number of parallel paths 00197 if ((uint32_t)config.parallelPaths > nextHops->size()) { 00198 config.parallelPaths = nextHops->size(); 00199 } 00200 00201 // create parallel paths and distribute nodes to paths 00202 for (int i = 0; i < config.parallelPaths; i++) { 00203 00204 // create state 00205 IterativePathLookup* pathLookup = new IterativePathLookup(this); 00206 paths.push_back(pathLookup); 00207 00208 // populate next hops 00209 for (uint32_t k=0; (k * config.parallelPaths + i) < nextHops->size(); k++) { 00210 pathLookup->add(nextHops->at(k * config.parallelPaths + i)); 00211 } 00212 00213 // send initial rpcs 00214 pathLookup->sendRpc(config.parallelRpcs, findNodeExt); 00215 } 00216 00217 00218 //std::cout << "nextHops size: " << nextHops->size() 00219 //<< " numSiblings: " << numSiblings 00220 //<< " redundantNodes: " << config.redundantNodes 00221 //<< " thisNode " << overlay->getThisNode().ip 00222 //<< " nextHop " << nextHops->at(0).ip << endl; 00223 00224 delete nextHops; 00225 delete findNodeExt; 00226 00227 checkStop(); 00228 }
| void IterativeLookup::stop | ( | ) | [protected] |
Definition at line 230 of file IterativeLookup.cc.
Referenced by checkStop(), and ~IterativeLookup().
00231 { 00232 // only stop if running 00233 if (!running) 00234 return; 00235 00236 // cancel pending rpcs 00237 for (RpcInfoMap::iterator i = rpcs.begin(); i != rpcs.end(); i++) { 00238 // std::cout << "time: " << simTime() << " node: " << overlay->thisNode << " this: " << this << " first: " << i->first << " nonce: " << i->second.nonce << endl; 00239 overlay->cancelRpcMessage(i->second.nonce); 00240 } 00241 rpcs.clear(); 00242 00243 // delete path lookups 00244 for (uint32_t i=0; i<paths.size(); i++) { 00245 delete paths[i]; 00246 } 00247 paths.clear(); 00248 00249 // reset running flag 00250 running = false; 00251 finished = true; 00252 00253 // inform listener 00254 if (listener != NULL) { 00255 listener->lookupFinished(this); 00256 listener = NULL; 00257 } 00258 }
friend class BaseOverlay [friend] |
Definition at line 85 of file IterativeLookup.h.
friend class IterativePathLookup [friend] |
uint32_t IterativeLookup::accumulatedHops [protected] |
total number of hops (for all paths)
Definition at line 122 of file IterativeLookup.h.
Referenced by getAccumulatedHops(), handleRpcResponse(), handleRpcTimeout(), and start().
bool IterativeLookup::appLookup [protected] |
IterativeLookupConfiguration IterativeLookup::config [protected] |
lookup configuration
Definition at line 118 of file IterativeLookup.h.
Referenced by IterativePathLookup::accepts(), IterativePathLookup::add(), addSibling(), checkStop(), createFindNodeCall(), IterativePathLookup::handleResponse(), IterativePathLookup::handleTimeout(), IterativePathLookup::IterativePathLookup(), lookup(), IterativePathLookup::sendNewRpcAfterTimeout(), IterativePathLookup::sendRpc(), and start().
TransportAddress::Set IterativeLookup::dead [protected] |
bool IterativeLookup::finished [protected] |
true, if lookup is finished
Definition at line 123 of file IterativeLookup.h.
Referenced by handleRpcResponse(), handleRpcTimeout(), isValid(), lookup(), sendRpc(), start(), and stop().
uint32_t IterativeLookup::finishedPaths [protected] |
number of finished paths
Definition at line 120 of file IterativeLookup.h.
Referenced by checkStop(), handleRpcResponse(), handleRpcTimeout(), and start().
cPacket* IterativeLookup::firstCallExt [protected] |
additional info for first findNode()
Definition at line 119 of file IterativeLookup.h.
Referenced by IterativeLookup(), start(), and ~IterativeLookup().
int IterativeLookup::hopCountMax [protected] |
maximum hop count
Definition at line 149 of file IterativeLookup.h.
Referenced by IterativePathLookup::sendRpc().
OverlayKey IterativeLookup::key [protected] |
key to lookup
Definition at line 113 of file IterativeLookup.h.
Referenced by addSibling(), compare(), createFindNodeCall(), IterativePathLookup::handleResponse(), and start().
LookupListener* IterativeLookup::listener [protected] |
lookup listener
Definition at line 115 of file IterativeLookup.h.
Referenced by abortLookup(), checkStop(), and stop().
int IterativeLookup::numSiblings [protected] |
number of siblings
Definition at line 148 of file IterativeLookup.h.
Referenced by addSibling(), checkStop(), createFindNodeCall(), IterativePathLookup::handleResponse(), IterativePathLookup::handleTimeout(), and start().
BaseOverlay* IterativeLookup::overlay [protected] |
ptr to overlay
Definition at line 114 of file IterativeLookup.h.
Referenced by compare(), IterativePathLookup::handleResponse(), IterativePathLookup::handleTimeout(), lookup(), sendRpc(), start(), stop(), and ~IterativeLookup().
std::vector<IterativePathLookup*> IterativeLookup::paths [protected] |
parallel paths
Definition at line 116 of file IterativeLookup.h.
Referenced by checkStop(), handleRpcResponse(), start(), and stop().
int IterativeLookup::retries [protected] |
number of retries, if lookup fails
Definition at line 126 of file IterativeLookup.h.
Referenced by checkStop().
RoutingType IterativeLookup::routingType [protected] |
RoutingType for this lookup.
Definition at line 117 of file IterativeLookup.h.
Referenced by createFindNodeCall(), IterativePathLookup::handleResponse(), handleRpcResponse(), IterativePathLookup::handleTimeout(), IterativePathLookup::IterativePathLookup(), lookup(), IterativePathLookup::sendRpc(), and start().
RpcInfoMap IterativeLookup::rpcs [protected] |
Definition at line 210 of file IterativeLookup.h.
Referenced by checkStop(), handleRpcResponse(), handleRpcTimeout(), sendRpc(), and stop().
bool IterativeLookup::running [protected] |
true, if lookup is running
Definition at line 125 of file IterativeLookup.h.
Referenced by handleRpcResponse(), handleRpcTimeout(), lookup(), sendRpc(), start(), and stop().
NodeVector IterativeLookup::siblings [protected] |
closest nodes
Definition at line 145 of file IterativeLookup.h.
Referenced by addSibling(), getResult(), and start().
bool IterativeLookup::success [protected] |
true, if lookup was successful
Definition at line 124 of file IterativeLookup.h.
Referenced by checkStop(), isValid(), and start().
uint32_t IterativeLookup::successfulPaths [protected] |
number of successful paths
Definition at line 121 of file IterativeLookup.h.
Referenced by checkStop(), handleRpcResponse(), handleRpcTimeout(), and start().
TransportAddress::Set IterativeLookup::visited [protected] |
nodes already visited
Definition at line 146 of file IterativeLookup.h.
Referenced by getVisited(), setVisited(), and start().
1.5.8