#include <Pastry.h>

Definition at line 54 of file Pastry.h.
Public Member Functions | |
| virtual | ~Pastry () |
| virtual void | initializeOverlay (int stage) |
| Initializes derived-class-attributes. | |
| virtual void | handleTimerEvent (cMessage *msg) |
| Processes "timer" self-messages. | |
| virtual void | handleUDPMessage (BaseOverlayMessage *msg) |
| Processes messages from underlay. | |
| void | handleStateMessage (PastryStateMessage *msg) |
| processes state messages, merging with own state tables | |
Protected Member Functions | |
| virtual void | changeState (int toState) |
| changes node state | |
Private Member Functions | |
| void | doSecondStage (void) |
| do the second stage of initialization as described in the paper | |
| bool | handleFailedNode (const TransportAddress &failed) |
| notifies leafset and routingtable of a failed node and sends out a repair request if possible | |
| void | checkProxCache (void) |
| checks whether proxCache is complete, takes appropriate actions depending on the protocol state | |
| void | processState (void) |
| bool | mergeState (void) |
| void | endProcessingState (void) |
| void | doJoinUpdate (void) |
| send updated state to all nodes when entering ready state | |
| virtual void | joinOverlay () |
| Join the overlay with a given nodeID in thisNode.key. | |
Private Attributes | |
| double | secondStageWaitAmount |
| double | ringCheckInterval |
| double | discoveryTimeoutAmount |
| bool | partialJoinPath |
| int | depth |
| bool | useSecondStage |
| bool | sendStateAtLeafsetRepair |
| bool | pingBeforeSecondStage |
| bool | overrideOldPastry |
| bool | overrideNewPastry |
| cMessage * | secondStageWait |
| cMessage * | ringCheck |
| cMessage * | discoveryTimeout |
| Pastry::~Pastry | ( | ) | [virtual] |
Definition at line 41 of file Pastry.cc.
00042 { 00043 // destroy self timer messages 00044 cancelAndDelete(readyWait); 00045 cancelAndDelete(joinUpdateWait); 00046 cancelAndDelete(secondStageWait); 00047 cancelAndDelete(ringCheck); 00048 if (useDiscovery) cancelAndDelete(discoveryTimeout); 00049 if (repairTaskTimeoutAmount > 0) cancelAndDelete(repairTaskTimeout); 00050 }
| void Pastry::initializeOverlay | ( | int | stage | ) | [virtual] |
Initializes derived-class-attributes.
Initializes derived-class-attributes, called by BaseOverlay::initialize(). By default this method is called once. If more stages are needed one can overload numInitStages() and add more stages.
| stage | the init stage |
Reimplemented from BaseOverlay.
Definition at line 52 of file Pastry.cc.
00053 { 00054 if ( stage != MIN_STAGE_OVERLAY ) 00055 return; 00056 00057 // Pastry provides KBR services 00058 kbr = true; 00059 00060 baseInit(); 00061 00062 useDiscovery = par("useDiscovery"); 00063 pingBeforeSecondStage = par("pingBeforeSecondStage"); 00064 secondStageWaitAmount = par("secondStageWait"); 00065 discoveryTimeoutAmount = par("discoveryTimeoutAmount"); 00066 repairTaskTimeoutAmount = par("repairTaskTimeoutAmount"); 00067 sendStateAtLeafsetRepair = par("sendStateAtLeafsetRepair"); 00068 ringCheckInterval = par("ringCheckInterval"); 00069 partialJoinPath = par("partialJoinPath"); 00070 readyWaitAmount = par("readyWait"); 00071 00072 overrideOldPastry = par("overrideOldPastry"); 00073 overrideNewPastry = par("overrideNewPastry"); 00074 00075 if (overrideOldPastry) { 00076 //useSecondStage = true; 00077 //secondStageWaitAmount = ???; 00078 useDiscovery = false; 00079 sendStateAtLeafsetRepair = true; 00080 repairTaskTimeoutAmount = 0; 00081 } 00082 00083 if (overrideNewPastry) { 00084 //useSecondStage = false; 00085 secondStageWaitAmount = 0; 00086 useDiscovery = true; 00087 discoveryTimeoutAmount = 0.4; 00088 repairTaskTimeoutAmount = 60; 00089 sendStateAtLeafsetRepair = false; 00090 } 00091 00092 joinTimeout = new cMessage("joinTimeout"); 00093 readyWait = new cMessage("readyWait"); 00094 secondStageWait = new cMessage("secondStageWait"); 00095 joinUpdateWait = new cMessage("joinUpdateWait"); 00096 ringCheck = new cMessage("ringCheck"); 00097 00098 if (useDiscovery) discoveryTimeout = new cMessage("discoveryTimeout"); 00099 if (repairTaskTimeoutAmount > 0) repairTaskTimeout = 00100 new cMessage("repairTaskTimeout"); 00101 00102 sendPullFlag = false; 00103 00104 }
| void Pastry::handleTimerEvent | ( | cMessage * | msg | ) | [virtual] |
Processes "timer" self-messages.
| msg | A self-message |
Reimplemented from BaseOverlay.
Definition at line 201 of file Pastry.cc.
00202 { 00203 00204 if (msg->isName("joinTimeout")) { 00205 EV << "[Pastry::handleTimerEvent() @ " << thisNode.ip 00206 << " (" << thisNode.key.toString(16) << ")]\n" 00207 << " timeout expired, restarting..." 00208 << endl; 00209 //std::cout << simTime() << " " << thisNode.ip << " " << stReceived.size() <<" Pastry: join timeout expired, restarting..." << std::endl; 00210 joinOverlay(); 00211 } else if (msg->isName("readyWait")) { 00212 if (partialJoinPath) { 00213 RECORD_STATS(joinPartial++); 00214 sort(stReceived.begin(), stReceived.end(), stateMsgIsSmaller); 00215 00216 // start pinging the nodes found in the first state message: 00217 stReceivedPos = stReceived.begin(); 00218 stateCache = *stReceivedPos; 00219 EV << "[Pastry::handleTimerEvent() @ " << thisNode.ip 00220 << " (" << thisNode.key.toString(16) << ")]\n" 00221 << " joining despite some missing STATE messages." 00222 << endl; 00223 processState(); 00224 /*if (pingBeforeSecondStage || 00225 stateCache.msg->getPastryStateMsgType() == PASTRY_STATE_STD) { 00226 pingNodes(); 00227 } else { 00228 mergeState(); //JOINING / stateCache 00229 endProcessingState(); 00230 //TODO -> READY 00231 }*/ 00232 } else { 00233 EV << "[Pastry::handleTimerEvent() @ " << thisNode.ip 00234 << " (" << thisNode.key.toString(16) << ")]\n" 00235 << " timeout waiting for missing state messages in JOIN state, restarting..." 00236 << endl; 00237 //std::cout << thisNode.ip << "Pastry: timeout waiting for missing state messages in JOIN " 00238 // "state, restarting..." << std::endl; 00239 joinOverlay(); 00240 } 00241 } else if (msg->isName("joinUpdateWait")) { 00242 EV << "[Pastry::handleTimerEvent() @ " << thisNode.ip 00243 << " (" << thisNode.key.toString(16) << ")]\n" 00244 << " sending state updates to all nodes." 00245 << endl; 00246 doJoinUpdate(); 00247 } else if (msg->isName("secondStageWait")) { 00248 EV << "[Pastry::handleTimerEvent() @ " << thisNode.ip 00249 << " (" << thisNode.key.toString(16) << ")]\n" 00250 << " sending STATE requests to all nodes in second stage of initialization." 00251 << endl; 00252 doSecondStage(); 00253 } else if (msg->isName("ringCheck")) { 00254 if (state == READY) { 00255 // ping direct neighbors on the ring: 00256 const NodeHandle& pred = leafSet->getPredecessor(); 00257 const NodeHandle& succ = leafSet->getSuccessor(); 00258 if (! pred.isUnspecified()) { 00259 pingNode(pred, timeoutPing, pingRetries, 00260 NULL, "PING ring check"); 00261 } 00262 if (! succ.isUnspecified()) { 00263 pingNode(succ, timeoutPing, pingRetries, 00264 NULL, "PING ring check"); 00265 } 00266 } 00267 scheduleAt(simTime() + ringCheckInterval, ringCheck); 00268 } else if (msg->isName("sendStateWait")) { 00269 PastrySendState* sendStateMsg = check_and_cast<PastrySendState*>(msg); 00270 00271 std::vector<PastrySendState*>::iterator pos = 00272 std::find(sendStateWait.begin(), sendStateWait.end(), 00273 sendStateMsg); 00274 if (pos != sendStateWait.end()) sendStateWait.erase(pos); 00275 00276 sendStateTables(sendStateMsg->getDest()); 00277 delete sendStateMsg; 00278 } else if (msg->isName("discoveryTimeout")) { 00279 if ((depth == 0) && (nearNodeImproved)) { 00280 depth++; //repeat last step if closer node was found 00281 } 00282 if ((depth == 0) || (pingedNodes < 1)) { 00283 changeState(JOINING_2); 00284 } else { 00285 PastryRoutingRowRequestMessage* msg = new PastryRoutingRowRequestMessage("ROWREQ"); 00286 msg->setPastryMsgType(PASTRY_MSG_ROWREQ); 00287 msg->setStatType(MAINTENANCE_STAT); 00288 msg->setSendStateTo(thisNode); 00289 msg->setRow(depth); 00290 msg->setBitLength(PASTRYRTREQ_L(msg)); 00291 RECORD_STATS(routingTableReqSent++; routingTableReqBytesSent += msg->getByteLength()); 00292 sendMessageToUDP(nearNode, msg); 00293 } 00294 } else if (msg->isName("repairTaskTimeout")) { 00295 EV << "[Pastry::handleTimerEvent() @ " << thisNode.ip 00296 << " (" << thisNode.key.toString(16) << ")]\n" 00297 << " starting routing table maintenance" 00298 << endl; 00299 doRoutingTableMaintenance(); 00300 scheduleAt(simTime() + repairTaskTimeoutAmount, repairTaskTimeout); 00301 } 00302 }
| void Pastry::handleUDPMessage | ( | BaseOverlayMessage * | msg | ) | [virtual] |
Processes messages from underlay.
| msg | Message from UDP |
Reimplemented from BaseOverlay.
Definition at line 304 of file Pastry.cc.
00305 { 00306 PastryMessage* pastryMsg = check_and_cast<PastryMessage*>(msg); 00307 uint32_t type = pastryMsg->getPastryMsgType(); 00308 00309 if (debugOutput) { 00310 EV << "[Pastry::handleUDPMessage() @ " << thisNode.ip 00311 << " (" << thisNode.key.toString(16) << ")]\n" 00312 << " incoming message of type "; 00313 switch(type) { 00314 case PASTRY_MSG_STD: 00315 EV << "PASTRY_MSG_STD"; 00316 break; 00317 case PASTRY_MSG_JOIN: 00318 EV << "PASTRY_MSG_JOIN"; 00319 break; 00320 case PASTRY_MSG_STATE: 00321 EV << "PASTRY_MSG_STATE"; 00322 break; 00323 case PASTRY_MSG_LEAFSET: 00324 EV << "PASTRY_MSG_LEAFSET"; 00325 break; 00326 case PASTRY_MSG_ROWREQ: 00327 EV << "PASTRY_MSG_ROWREQ"; 00328 break; 00329 case PASTRY_MSG_RROW: 00330 EV << "PASTRY_MSG_RROW"; 00331 break; 00332 case PASTRY_MSG_REQ: 00333 EV << "PASTRY_MSG_REQ"; 00334 break; 00335 default: 00336 EV << "UNKNOWN (" << type <<")"; 00337 break; 00338 } 00339 EV << endl; 00340 } 00341 00342 switch (type) { 00343 case PASTRY_MSG_STD: 00344 opp_error("Pastry received PastryMessage of unknown type!"); 00345 break; 00346 00347 case PASTRY_MSG_JOIN: { 00348 PastryJoinMessage* jmsg = 00349 check_and_cast<PastryJoinMessage*>(pastryMsg); 00350 RECORD_STATS(joinReceived++; joinBytesReceived += 00351 jmsg->getByteLength()); 00352 if (state != READY) { 00353 if (jmsg->getSendStateTo() == thisNode) { 00354 EV << "[Pastry::handleUDPMessage() @ " << thisNode.ip 00355 << " (" << thisNode.key.toString(16) << ")]\n" 00356 << " PastryJoinMessage received by originator!" 00357 << endl; 00358 } else { 00359 EV << "[Pastry::handleUDPMessage() @ " << thisNode.ip 00360 << " (" << thisNode.key.toString(16) << ")]\n" 00361 << " received join message before reaching " 00362 << "READY state, dropping message!" 00363 << endl; 00364 } 00365 } 00366 else if (jmsg->getSendStateTo() == thisNode) { 00367 EV << "[Pastry::handleUDPMessage() @ " << thisNode.ip 00368 << " (" << thisNode.key.toString(16) << ")]\n" 00369 << " PastryJoinMessage gets dropped because it is " 00370 << "outdated and has been received by originator!" 00371 << endl; 00372 } else { 00373 OverlayCtrlInfo* overlayCtrlInfo 00374 = check_and_cast<OverlayCtrlInfo*>(jmsg->getControlInfo()); 00375 00376 uint32_t joinHopCount = overlayCtrlInfo->getHopCount(); 00377 if ((joinHopCount > 1) && 00378 ((defaultRoutingType == ITERATIVE_ROUTING) || 00379 (defaultRoutingType == EXHAUSTIVE_ITERATIVE_ROUTING))) 00380 joinHopCount--; 00381 00382 // remove node from state if it is rejoining 00383 handleFailedNode(jmsg->getSendStateTo()); 00384 00385 sendStateTables(jmsg->getSendStateTo(), 00386 PASTRY_STATE_JOIN, joinHopCount, true); 00387 } 00388 00389 delete jmsg; 00390 } 00391 break; 00392 00393 case PASTRY_MSG_LEAFSET: { 00394 PastryLeafsetMessage* lmsg = 00395 check_and_cast<PastryLeafsetMessage*>(pastryMsg); 00396 RECORD_STATS(leafsetReceived++; leafsetBytesReceived += 00397 lmsg->getByteLength()); 00398 00399 if (state == DISCOVERY) { 00400 uint32_t lsSize = lmsg->getLeafSetArraySize(); 00401 const NodeHandle* node; 00402 pingedNodes = 0; 00403 00404 for (uint32_t i = 0; i < lsSize; i++) { 00405 node = &(lmsg->getLeafSet(i)); 00406 // unspecified nodes not considered 00407 if ( !(node->isUnspecified()) ) { 00408 pingNode(*node, discoveryTimeoutAmount, 0, 00409 NULL, "PING received leafs for nearest node", 00410 NULL, -1, UDP_TRANSPORT, false);//??? 00411 pingedNodes++; 00412 } 00413 } 00414 00415 EV << "[Pastry::handleUDPMessage() @ " << thisNode.ip 00416 << " (" << thisNode.key.toString(16) << ")]\n" 00417 << " received leafset, waiting for pings" 00418 << endl; 00419 if (discoveryTimeout->isScheduled()) cancelEvent(discoveryTimeout); 00420 scheduleAt(simTime() + discoveryTimeoutAmount, discoveryTimeout); 00421 delete lmsg; 00422 } 00423 00424 else if (state == READY) { 00425 handleLeafsetMessage(lmsg, false); 00426 00427 } else { 00428 delete lmsg; 00429 } 00430 } 00431 break; 00432 00433 case PASTRY_MSG_ROWREQ: { 00434 PastryRoutingRowRequestMessage* rtrmsg = 00435 check_and_cast<PastryRoutingRowRequestMessage*>(pastryMsg); 00436 RECORD_STATS(routingTableReqReceived++; routingTableReqBytesReceived += 00437 rtrmsg->getByteLength()); 00438 if (state == READY) 00439 if (rtrmsg->getRow() == -1) 00440 sendRoutingRow(rtrmsg->getSendStateTo(), routingTable->getLastRow()); 00441 else if (rtrmsg->getRow() > routingTable->getLastRow()) 00442 EV << "[Pastry::handleUDPMessage() @ " << thisNode.ip 00443 << " (" << thisNode.key.toString(16) << ")]\n" 00444 << " received request for nonexistent routing" 00445 << "table row, dropping message!" 00446 << endl; 00447 else sendRoutingRow(rtrmsg->getSendStateTo(), rtrmsg->getRow()); 00448 else 00449 EV << "[Pastry::handleUDPMessage() @ " << thisNode.ip 00450 << " (" << thisNode.key.toString(16) << ")]\n" 00451 << " received routing table request before reaching " 00452 << "READY state, dropping message!" 00453 << endl; 00454 delete rtrmsg; 00455 } 00456 break; 00457 00458 case PASTRY_MSG_RROW: { 00459 PastryRoutingRowMessage* rtmsg = 00460 check_and_cast<PastryRoutingRowMessage*>(pastryMsg); 00461 RECORD_STATS(routingTableReceived++; routingTableBytesReceived += 00462 rtmsg->getByteLength()); 00463 00464 if (state == DISCOVERY) { 00465 uint32_t nodesPerRow = rtmsg->getRoutingTableArraySize(); 00466 const NodeHandle* node; 00467 if (depth == -1) { 00468 depth = rtmsg->getRow(); 00469 } 00470 pingedNodes = 0; 00471 nearNodeImproved = false; 00472 00473 if (depth > 0) { 00474 for (uint32_t i = 0; i < nodesPerRow; i++) { 00475 node = &(rtmsg->getRoutingTable(i)); 00476 // unspecified nodes not considered 00477 if ( !(node->isUnspecified()) ) { 00478 // we look for best connection here, so Timeout is short and there are no retries 00479 pingNode(*node, discoveryTimeoutAmount, 0, NULL, 00480 "PING received routing table for nearest node", 00481 NULL, -1, UDP_TRANSPORT, false); 00482 pingedNodes++; 00483 } 00484 } 00485 depth--; 00486 } 00487 EV << "[Pastry::handleUDPMessage() @ " << thisNode.ip 00488 << " (" << thisNode.key.toString(16) << ")]\n" 00489 << " received routing table, waiting for pings" 00490 << endl; 00491 if (discoveryTimeout->isScheduled()) { 00492 cancelEvent(discoveryTimeout); 00493 } 00494 scheduleAt(simTime() + discoveryTimeoutAmount, discoveryTimeout); 00495 } 00496 00497 else if (state == READY) { 00498 00499 uint32_t nodesPerRow = rtmsg->getRoutingTableArraySize(); 00500 PastryStateMessage* stateMsg; 00501 00502 stateMsg = new PastryStateMessage("STATE"); 00503 stateMsg->setTimestamp(rtmsg->getTimestamp()); 00504 stateMsg->setPastryMsgType(PASTRY_MSG_STATE); 00505 stateMsg->setStatType(MAINTENANCE_STAT); 00506 stateMsg->setSender(rtmsg->getSender()); 00507 stateMsg->setLeafSetArraySize(0); 00508 stateMsg->setNeighborhoodSetArraySize(0); 00509 stateMsg->setRoutingTableArraySize(nodesPerRow); 00510 00511 for (uint32_t i = 0; i < nodesPerRow; i++) { 00512 stateMsg->setRoutingTable(i, rtmsg->getRoutingTable(i)); 00513 } 00514 00515 handleStateMessage(stateMsg); 00516 } 00517 00518 delete rtmsg; 00519 } 00520 break; 00521 00522 case PASTRY_MSG_REQ: { 00523 PastryRequestMessage* lrmsg = 00524 check_and_cast<PastryRequestMessage*>(pastryMsg); 00525 handleRequestMessage(lrmsg); 00526 } 00527 break; 00528 00529 case PASTRY_MSG_STATE: { 00530 PastryStateMessage* stateMsg = 00531 check_and_cast<PastryStateMessage*>(msg); 00532 RECORD_STATS(stateReceived++; stateBytesReceived += 00533 stateMsg->getByteLength()); 00534 handleStateMessage(stateMsg); 00535 } 00536 break; 00537 } 00538 }
| void Pastry::handleStateMessage | ( | PastryStateMessage * | msg | ) | [virtual] |
processes state messages, merging with own state tables
| msg | the pastry state message |
Implements BasePastry.
Definition at line 951 of file Pastry.cc.
Referenced by handleUDPMessage().
00952 { 00953 if (debugOutput) { 00954 EV << "[Pastry::handleStateMessage() @ " << thisNode.ip 00955 << " (" << thisNode.key.toString(16) << ")]\n" 00956 << " new STATE message to process " 00957 << static_cast<void*>(msg) << " in state " << 00958 ((state == READY)?"READY":((state == JOINING_2)?"JOIN":"INIT")) 00959 << endl; 00960 if (state == JOINING_2) { 00961 EV << "[Pastry::handleStateMessage() @ " << thisNode.ip 00962 << " (" << thisNode.key.toString(16) << ")]\n" 00963 << " *** own joinHopCount: " << joinHopCount << endl 00964 << " *** already received: " << stReceived.size() << endl 00965 << " *** last-hop flag: " << msg->getLastHop() << endl 00966 << " *** msg joinHopCount: " 00967 << msg->getJoinHopCount() << endl; 00968 } 00969 } 00970 if (state == INIT || state == DISCOVERY) { 00971 EV << "[Pastry::handleStateMessage() @ " << thisNode.ip 00972 << " (" << thisNode.key.toString(16) << ")]\n" 00973 << " can't handle state messages until at least reaching JOIN state." 00974 << endl; 00975 delete msg; 00976 return; 00977 } 00978 00979 PastryStateMsgHandle handle(msg); 00980 00981 // in JOIN state, store all received state Messages, need them later: 00982 if (state == JOINING_2) { 00983 //std::cout << simTime() << " " << thisNode.ip << " " 00984 // << msg->getJoinHopCount() 00985 // << (msg->getLastHop() ? " *" : "") << std::endl; 00986 00987 if (msg->getPastryStateMsgType() != PASTRY_STATE_JOIN) { 00988 delete msg; 00989 return; 00990 } 00991 00992 if (joinHopCount && stReceived.size() == joinHopCount) { 00993 EV << "[Pastry::handleStateMessage() @ " << thisNode.ip 00994 << " (" << thisNode.key.toString(16) << ")]\n" 00995 << " Warning: dropping state message received after " 00996 << "all needed state messages were collected in JOIN state." 00997 << endl; 00998 delete msg; 00999 return; 01000 } 01001 01002 stReceived.push_back(handle); 01003 if (pingBeforeSecondStage) prePing(msg); 01004 01005 if (msg->getLastHop()) { 01006 if (joinTimeout->isScheduled()) { 01007 //std::cout << simTime() << " " << thisNode.ip 01008 //<< " cancelEvent(joinTimeout), received:" 01009 //<< stReceived.size() << ", hopcount:" << joinHopCount << std::endl; 01010 cancelEvent(joinTimeout); 01011 } 01012 if (msg->getSender().key == thisNode.key) { 01013 EV << "[Pastry::handleStateMessage() @ " << thisNode.ip 01014 << " (" << thisNode.key.toString(16) << ")]\n" 01015 << " Error: OverlayKey already in use, restarting!" 01016 << endl; 01017 //std::cout << "Pastry: Error: OverlayKey already in use, restarting!" 01018 // << std::endl; 01019 joinOverlay(); 01020 return; 01021 } 01022 01023 if (joinHopCount) { 01024 EV << "[Pastry::handleStateMessage() @ " << thisNode.ip 01025 << " (" << thisNode.key.toString(16) << ")]\n" 01026 << " Error: received a second `last' state message! Restarting ..." 01027 << endl; 01028 //std::cout << thisNode.ip << "Pastry: Error: received a second `last' state message! " 01029 // "Restarting ..." << std::endl; 01030 joinOverlay(); 01031 return; 01032 } 01033 01034 joinHopCount = msg->getJoinHopCount(); 01035 //std::cout << stReceived.size() << " " << joinHopCount << std::endl; 01036 if (stReceived.size() < joinHopCount) { 01037 // some states still missing: 01038 cancelEvent(readyWait); 01039 scheduleAt(simTime() + readyWaitAmount, readyWait); 01040 //std::cout << simTime() << " " << thisNode.ip << " readyWait scheduled!" << std::endl; 01041 } 01042 } 01043 01044 if (joinHopCount) { 01045 if (stReceived.size() > joinHopCount) { 01046 EV << "[Pastry::handleStateMessage() @ " << thisNode.ip 01047 << " (" << thisNode.key.toString(16) << ")]\n" 01048 << " Error: too many state messages received in JOIN state! (" 01049 << stReceived.size() << " > " << joinHopCount << ") Restarting ..." 01050 << endl; 01051 //std::cout << " failed!" << std::endl; 01052 joinOverlay(); 01053 return; 01054 } 01055 if (stReceived.size() == joinHopCount) { 01056 // all state messages are here, sort by hopcount: 01057 sort(stReceived.begin(), stReceived.end(), 01058 stateMsgIsSmaller); 01059 01060 // start pinging the nodes found in the first state message: 01061 stReceivedPos = stReceived.begin(); 01062 stateCache = *stReceivedPos; 01063 EV << "[Pastry::handleStateMessage() @ " << thisNode.ip 01064 << " (" << thisNode.key.toString(16) << ")]\n" 01065 << " have all STATE messages, now pinging nodes." 01066 << endl; 01067 if (pingBeforeSecondStage) pingNodes(); 01068 else { 01069 mergeState(); // JOINING / stateCache 01070 //endProcessingState(); no way 01071 //stateCache.msg = NULL; //test 01072 changeState(READY); 01073 EV << "[Pastry::handleStateMessage() @ " << thisNode.ip 01074 << " (" << thisNode.key.toString(16) << ")]\n" 01075 << " changeState(READY) called" 01076 << endl; 01077 } 01078 01079 // cancel timeout: 01080 if (readyWait->isScheduled()) cancelEvent(readyWait); 01081 } else { 01082 //TODO occasionally, here we got a wrong hop count in 01083 // iterative mode due to more than one it. lookup during join 01084 // procedure 01085 EV << "[Pastry::handleStateMessage() @ " << thisNode.ip 01086 << " (" << thisNode.key.toString(16) << ")]\n" 01087 << " Still need some STATE messages." 01088 << endl; 01089 } 01090 01091 } 01092 return; 01093 } 01094 01095 if (debugOutput) { 01096 EV << "[Pastry::handleStateMessage() @ " << thisNode.ip 01097 << " (" << thisNode.key.toString(16) << ")]\n" 01098 << " handling STATE message" 01099 << endl; 01100 EV << " type: " << ((msg->getPastryStateMsgType() 01101 == PASTRY_STATE_UPDATE) ? "update" 01102 :"standard") 01103 << endl; 01104 if (msg->getPastryStateMsgType() == PASTRY_STATE_UPDATE) { 01105 EV << " msg timestamp: " << 01106 msg->getTimestamp() << endl; 01107 EV << " last state change: " << 01108 lastStateChange << endl; 01109 } 01110 } 01111 01112 if (((msg->getPastryStateMsgType() == PASTRY_STATE_UPDATE)) 01113 && (msg->getTimestamp() <= lastStateChange)) { 01114 // if we received an update based on our outdated state, 01115 // mark handle for retrying later: 01116 EV << "[Pastry::handleStateMessage() @ " << thisNode.ip 01117 << " (" << thisNode.key.toString(16) << ")]\n" 01118 << " outdated state from " << msg->getSender() 01119 << endl; 01120 handle.outdatedUpdate = true; 01121 } 01122 01123 // determine aliveTable to prevent leafSet from merging nodes that are 01124 // known to be dead: 01125 determineAliveTable(msg); 01126 01127 if (msg->getPastryStateMsgType() == PASTRY_STATE_REPAIR) { 01128 // try to repair leafset based on repair message right now 01129 const TransportAddress& askLs = leafSet->repair(msg, &aliveTable); 01130 if (! askLs.isUnspecified()) { 01131 sendRequest(askLs, PASTRY_REQ_REPAIR); 01132 } 01133 01134 // while not really known, it's safe to assume that a repair 01135 // message changed our state: 01136 lastStateChange = simTime(); 01137 newLeafs(); 01138 } else if (leafSet->mergeState(msg, &aliveTable)) { 01139 // merged state into leafset right now 01140 lastStateChange = simTime(); 01141 newLeafs(); 01142 updateTooltip(); 01143 } 01144 // in READY state, only ping nodes to get proximity metric: 01145 if (!stateCache.msg) { 01146 // no state message is processed right now, start immediately: 01147 stateCache = handle; 01148 processState(); 01149 } else { 01150 if (pingBeforeSecondStage || 01151 msg->getPastryStateMsgType() == PASTRY_STATE_STD) { 01152 // enqueue message for later processing: 01153 stateCacheQueue.push(handle); 01154 prePing(msg); 01155 } else { 01156 bool temp = true; 01157 if (!neighborhoodSet->mergeState(msg, NULL)) { 01158 temp = false; 01159 } 01160 if (!leafSet->mergeState(msg, NULL)) { 01161 temp = false; 01162 } else { 01163 newLeafs(); 01164 } 01165 if (!routingTable->mergeState(msg, NULL)) { 01166 temp = false; 01167 } 01168 if (temp) lastStateChange = simTime(); 01169 delete msg; 01170 } 01171 } 01172 }
| void Pastry::changeState | ( | int | toState | ) | [protected, virtual] |
changes node state
| toState | state to change to |
Reimplemented from BasePastry.
Definition at line 121 of file Pastry.cc.
Referenced by checkProxCache(), handleStateMessage(), handleTimerEvent(), and joinOverlay().
00122 { 00123 if (ringCheck->isScheduled()) cancelEvent(ringCheck); 00124 if (readyWait->isScheduled()) cancelEvent(readyWait); 00125 baseChangeState(toState); 00126 00127 switch (toState) { 00128 case INIT: 00129 cancelAllRpcs(); 00130 purgeVectors(); 00131 break; 00132 00133 case DISCOVERY: 00134 state = DISCOVERY; 00135 //nearNode = bootstrapNode; 00136 nearNodeRtt = MAXTIME; 00137 pingNode(bootstrapNode, discoveryTimeoutAmount, 0, 00138 NULL, "PING bootstrapNode in discovery mode", 00139 NULL, -1, UDP_TRANSPORT, false); 00140 sendRequest(bootstrapNode, PASTRY_REQ_LEAFSET); 00141 depth = -1; 00142 00143 break; 00144 00145 case JOINING_2: 00146 00147 joinHopCount = 0; 00148 00149 { 00150 PastryJoinMessage* msg = new PastryJoinMessage("JOIN-Request"); 00151 //TODO add timestamp to join msg 00152 msg->setPastryMsgType(PASTRY_MSG_JOIN); 00153 msg->setStatType(MAINTENANCE_STAT); 00154 //msg->setJoinHopCount(1); 00155 msg->setSendStateTo(thisNode); 00156 msg->setBitLength(PASTRYJOIN_L(msg)); 00157 RECORD_STATS(joinSent++; joinBytesSent += msg->getByteLength()); 00158 std::vector<TransportAddress> sourceRoute; 00159 sourceRoute.push_back(nearNode); 00160 sendToKey(thisNode.key, msg, 0/*1*/, sourceRoute); 00161 00162 } 00163 00164 00165 break; 00166 00167 case READY: 00168 if (ringCheckInterval > 0) { 00169 scheduleAt(simTime()+ringCheckInterval, ringCheck); 00170 } 00171 00172 // determine list of all known nodes as notifyList 00173 notifyList.clear(); 00174 leafSet->dumpToVector(notifyList); 00175 routingTable->dumpToVector(notifyList); 00176 sort(notifyList.begin(), notifyList.end()); 00177 notifyList.erase(unique(notifyList.begin(), notifyList.end()), 00178 notifyList.end()); 00179 00180 // schedule update 00181 cancelEvent(joinUpdateWait); 00182 scheduleAt(simTime() + sendStateWaitAmount, joinUpdateWait); 00183 00184 // schedule second stage 00185 if (secondStageWaitAmount > 0) { 00186 cancelEvent(secondStageWait); 00187 scheduleAt(simTime() + secondStageWaitAmount, secondStageWait); 00188 } 00189 00190 // schedule routing table maintenance task 00191 if (repairTaskTimeoutAmount > 0) { 00192 cancelEvent(repairTaskTimeout); 00193 scheduleAt(simTime() + repairTaskTimeoutAmount, repairTaskTimeout); 00194 //leaf2ask = NULL; 00195 } 00196 00197 break; 00198 } 00199 }
| void Pastry::doSecondStage | ( | void | ) | [private] |
do the second stage of initialization as described in the paper
Definition at line 573 of file Pastry.cc.
Referenced by handleTimerEvent().
00574 { 00575 getParentModule()->getParentModule()->bubble("entering SECOND STAGE"); 00576 00577 // probe nodes in local state 00578 if (leafSet->isValid()) { 00579 PastryStateMessage* stateMsg = new PastryStateMessage("STATE"); 00580 stateMsg->setPastryMsgType(PASTRY_MSG_STATE); 00581 stateMsg->setStatType(MAINTENANCE_STAT); 00582 stateMsg->setPastryStateMsgType(PASTRY_STATE_STD); 00583 stateMsg->setSender(thisNode); 00584 routingTable->dumpToStateMessage(stateMsg); 00585 leafSet->dumpToStateMessage(stateMsg); 00586 neighborhoodSet->dumpToStateMessage(stateMsg); 00587 //stateMsg->setBitLength(PASTRYSTATE_L(stateMsg)); 00588 PastryStateMsgHandle handle(stateMsg); 00589 00590 if (!stateCache.msg) { 00591 stateCache = handle; 00592 processState(); 00593 } else { 00594 stateCacheQueue.push(handle); 00595 prePing(stateMsg); 00596 } 00597 } 00598 00599 // "second stage" for locality: 00600 notifyList.clear(); 00601 routingTable->dumpToVector(notifyList); 00602 neighborhoodSet->dumpToVector(notifyList); 00603 sort(notifyList.begin(), notifyList.end()); 00604 notifyList.erase(unique(notifyList.begin(), notifyList.end()), 00605 notifyList.end()); 00606 for (std::vector<TransportAddress>::iterator it = notifyList.begin(); 00607 it != notifyList.end(); it++) { 00608 if (*it == thisNode) continue; 00609 EV << "[Pastry::doSecondStage() @ " << thisNode.ip 00610 << " (" << thisNode.key.toString(16) << ")]\n" 00611 << " second stage: requesting state from " << *it 00612 << endl; 00613 sendRequest(*it, PASTRY_REQ_STATE); 00614 } 00615 notifyList.clear(); 00616 }
| bool Pastry::handleFailedNode | ( | const TransportAddress & | failed | ) | [private, virtual] |
notifies leafset and routingtable of a failed node and sends out a repair request if possible
| failed | the failed node |
Reimplemented from BaseOverlay.
Definition at line 618 of file Pastry.cc.
Referenced by handleUDPMessage().
00619 { 00620 if (state != READY) { 00621 return false; 00622 } 00623 bool wasValid = leafSet->isValid(); 00624 00625 //std::cout << thisNode.ip << " is handling failed node: " << failed.ip << std::endl; 00626 if (failed.isUnspecified()) 00627 opp_error("Pastry::handleFailedNode(): failed is unspecified!"); 00628 00629 const TransportAddress& lsAsk = leafSet->failedNode(failed); 00630 const TransportAddress& rtAsk = routingTable->failedNode(failed); 00631 neighborhoodSet->failedNode(failed); 00632 00633 if (! lsAsk.isUnspecified()) { 00634 newLeafs(); 00635 if (sendStateAtLeafsetRepair) sendRequest(lsAsk, PASTRY_REQ_REPAIR); 00636 else sendRequest(lsAsk, PASTRY_REQ_LEAFSET); 00637 } 00638 if (! rtAsk.isUnspecified() && 00639 (lsAsk.isUnspecified() || 00640 lsAsk != rtAsk)) sendRequest(rtAsk, PASTRY_REQ_REPAIR); 00641 00642 if (wasValid && lsAsk.isUnspecified() && (! leafSet->isValid())) { 00643 EV << "[Pastry::handleFailedNode() @ " << thisNode.ip 00644 << " (" << thisNode.key.toString(16) << ")]\n" 00645 << " lost connection to the network, trying to re-join." 00646 << endl; 00647 //std::cout << thisNode.ip << " Pastry: lost connection to the network, trying to re-join." 00648 // << std::endl; 00649 joinOverlay(); 00650 return false; 00651 } 00652 00653 return true; 00654 }
| void Pastry::checkProxCache | ( | void | ) | [private, virtual] |
checks whether proxCache is complete, takes appropriate actions depending on the protocol state
Implements BasePastry.
Definition at line 656 of file Pastry.cc.
00657 { 00658 EV << "[Pastry::checkProxCache() @ " << thisNode.ip 00659 << " (" << thisNode.key.toString(16) << ")]" 00660 << endl; 00661 00662 // no cached STATE message? 00663 if (!(stateCache.msg && stateCache.prox)) return; 00664 00665 // no entries in stateCache.prox? 00666 if (stateCache.prox->pr_rt.empty() && 00667 stateCache.prox->pr_ls.empty() && 00668 stateCache.prox->pr_ns.empty()) 00669 throw new cRuntimeError("ERROR in Pastry: stateCache.prox empty!"); 00670 00671 /* 00672 //debug 00673 for (uint i = 0; i < stateCache.prox->pr_rt.size(); ++i) { 00674 if (stateCache.prox->pr_rt[i] == -3) 00675 EV << stateCache.msg->getRoutingTable(i).ip << " "; 00676 } 00677 for (uint i = 0; i < stateCache.prox->pr_ls.size(); ++i) { 00678 if (stateCache.prox->pr_ls[i] == -3) 00679 EV << stateCache.msg->getLeafSet(i).ip << " "; 00680 } 00681 for (uint i = 0; i < stateCache.prox->pr_ns.size(); ++i) { 00682 if (stateCache.prox->pr_ns[i] == -3) 00683 EV << stateCache.msg->getNeighborhoodSet(i).ip << " "; 00684 } 00685 EV << endl; 00686 */ 00687 00688 // some entries not yet determined? 00689 if ((find(stateCache.prox->pr_rt.begin(), stateCache.prox->pr_rt.end(), 00690 PASTRY_PROX_PENDING) != stateCache.prox->pr_rt.end()) || 00691 (find(stateCache.prox->pr_ls.begin(), stateCache.prox->pr_ls.end(), 00692 PASTRY_PROX_PENDING) != stateCache.prox->pr_ls.end()) || 00693 (find(stateCache.prox->pr_ns.begin(), stateCache.prox->pr_ns.end(), 00694 PASTRY_PROX_PENDING) != stateCache.prox->pr_ns.end())) { 00695 return; 00696 } 00697 00698 EV << "[Pastry::checkProxCache() @ " << thisNode.ip 00699 << " (" << thisNode.key.toString(16) << ")]\n" 00700 << " all proximities for current STATE message from " 00701 << stateCache.msg->getSender().ip 00702 << " collected!" 00703 << endl; 00704 /* 00705 //debug 00706 if (stateCache.prox != NULL) { 00707 std::vector<PastryStateMsgHandle>::iterator it; 00708 for (it = stReceived.begin(); it != stReceived.end(); ++it) { 00709 if (it->prox == NULL) { 00710 EV << ". " << endl; 00711 continue; 00712 } 00713 for (uint i = 0; i < it->prox->pr_rt.size(); ++i) { 00714 EV << it->prox->pr_rt[i] << " "; 00715 } 00716 for (uint i = 0; i < it->prox->pr_ls.size(); ++i) { 00717 EV << it->prox->pr_ls[i] << " "; 00718 } 00719 for (uint i = 0; i < it->prox->pr_ns.size(); ++i) { 00720 EV << it->prox->pr_ns[i] << " "; 00721 } 00722 EV << endl; 00723 } 00724 EV << endl; 00725 } else EV << "NULL" << endl; 00726 */ 00727 00728 simtime_t now = simTime(); 00729 00730 if (state == JOINING_2) { 00731 // save pointer to proximity vectors: 00732 stReceivedPos->prox = stateCache.prox; 00733 00734 // collected proximities for all STATE messages? 00735 if (++stReceivedPos == stReceived.end()) { 00736 EV << "[Pastry::checkProxCache() @ " << thisNode.ip 00737 << " (" << thisNode.key.toString(16) << ")]\n" 00738 << " proximities for all STATE messages collected!" 00739 << endl; 00740 stateCache.msg = NULL; 00741 stateCache.prox = NULL; 00742 if (debugOutput) { 00743 EV << "[Pastry::checkProxCache() @ " << thisNode.ip 00744 << " (" << thisNode.key.toString(16) << ")]\n" 00745 << " [JOIN] starting to build own state from " 00746 << stReceived.size() << " received state messages..." 00747 << endl; 00748 } 00749 if (mergeState()) { 00750 //if (readyWait->isScheduled()) cancelEvent(readyWait); //test 00751 //stateCache.msg = NULL; //test 00752 changeState(READY); 00753 EV << "[Pastry::checkProxCache() @ " << thisNode.ip 00754 << " (" << thisNode.key.toString(16) << ")]\n" 00755 << " changeState(READY) called" 00756 << endl; 00757 } else { 00758 EV << "[Pastry::checkProxCache() @ " << thisNode.ip 00759 << " (" << thisNode.key.toString(16) << ")]\n" 00760 << " Error initializing while joining! Restarting ..." 00761 << endl; 00762 joinOverlay(); 00763 } 00764 00765 } else { 00766 EV << "[Pastry::checkProxCache() @ " << thisNode.ip 00767 << " (" << thisNode.key.toString(16) << ")]\n" 00768 << " NOT all proximities for all STATE messages collected!" 00769 << endl; 00770 for (uint32_t i = 0; i < stReceived.size(); ++i) { 00771 if (stReceived[i].msg == stReceivedPos->msg) EV << " *"; 00772 EV << stReceived[i].msg; 00773 } 00774 EV << endl; 00775 00776 // process next state message in vector: 00777 if (stReceivedPos->msg == NULL) 00778 throw cRuntimeError("stReceivedPos->msg = NULL"); 00779 stateCache = *stReceivedPos; 00780 if (stateCache.msg == NULL) 00781 throw cRuntimeError("msg = NULL"); 00782 processState(); 00783 /*if (pingBeforeSecondStage) { // no second stage states are processed here 00784 pingNodes(); 00785 } else { 00786 mergeState(); // JOINING / stateCache 00787 endProcessingState(); 00788 }*/ 00789 } 00790 } else { 00791 // state == READY 00792 if (stateCache.msg->getPastryStateMsgType() == PASTRY_STATE_REPAIR) { 00793 // try to repair routingtable based on repair message: 00794 const TransportAddress& askRt = 00795 routingTable->repair(stateCache.msg, stateCache.prox); 00796 if (! askRt.isUnspecified()) { 00797 sendRequest(askRt, PASTRY_REQ_REPAIR); 00798 } 00799 00800 // while not really known, it's safe to assume that a repair 00801 // message changed our state: 00802 lastStateChange = now; 00803 } else { 00804 if (stateCache.outdatedUpdate) { 00805 // send another STATE message on outdated state update: 00806 sendStateDelayed(stateCache.msg->getSender()); 00807 00808 } else {//hack 00809 00810 // merge info in own state tables 00811 // except leafset (was already handled in handleStateMessage) 00812 if (neighborhoodSet->mergeState(stateCache.msg, stateCache.prox)) 00813 lastStateChange = now; 00814 EV << "[Pastry::checkProxCache() @ " << thisNode.ip 00815 << " (" << thisNode.key.toString(16) << ")]\n" 00816 << " Merging nodes into routing table" 00817 << endl; 00818 if (routingTable->mergeState(stateCache.msg, stateCache.prox)) { 00819 lastStateChange = now; 00820 EV << "[Pastry::checkProxCache() @ " << thisNode.ip 00821 << " (" << thisNode.key.toString(16) << ")]\n" 00822 << " Merged nodes into routing table" 00823 << endl; 00824 } 00825 } 00826 } 00827 updateTooltip(); 00828 00829 endProcessingState(); 00830 } 00831 }
| void Pastry::processState | ( | void | ) | [private] |
Definition at line 1174 of file Pastry.cc.
Referenced by checkProxCache(), doSecondStage(), endProcessingState(), handleStateMessage(), and handleTimerEvent().
01175 { 01176 if (pingBeforeSecondStage || 01177 stateCache.msg->getPastryStateMsgType() == PASTRY_STATE_STD) { 01178 pingNodes(); 01179 } else { 01180 mergeState(); 01181 endProcessingState(); 01182 } 01183 }
| bool Pastry::mergeState | ( | void | ) | [private] |
Definition at line 865 of file Pastry.cc.
Referenced by checkProxCache(), handleStateMessage(), and processState().
00866 { 00867 bool ret = true; 00868 00869 if (state == JOINING_2) { 00870 // building initial state 00871 if (debugOutput) { 00872 EV << "[Pastry::mergeState() @ " << thisNode.ip 00873 << " (" << thisNode.key.toString(16) << ")]\n" 00874 << " [JOIN] starting to build own state from " 00875 << stReceived.size() << " received state messages..." 00876 << endl; 00877 EV << "[Pastry::checkProxCache() @ " << thisNode.ip 00878 << " (" << thisNode.key.toString(16) << ")]\n" 00879 << " [JOIN] initializing NeighborhoodSet from " 00880 << stReceived.front().msg->getJoinHopCount() << ". hop" 00881 << endl; 00882 } 00883 if (!neighborhoodSet->mergeState(stReceived.front().msg, 00884 stReceived.front().prox )) { 00885 EV << "[Pastry::checkProxCache() @ " << thisNode.ip 00886 << " (" << thisNode.key.toString(16) << ")]\n" 00887 << " Error initializing own neighborhoodSet while joining! Restarting ..." 00888 << endl; 00889 //std::cout << "Pastry: Error initializing own neighborhoodSet while " 00890 // "joining! Restarting ..." << std::endl; 00891 ret = false; 00892 } 00893 if (debugOutput) { 00894 EV << "[Pastry::checkProxCache() @ " << thisNode.ip 00895 << " (" << thisNode.key.toString(16) << ")]\n" 00896 << " [JOIN] initializing LeafSet from " 00897 << stReceived.back().msg->getJoinHopCount() << ". hop" 00898 << endl; 00899 } 00900 00901 if (!leafSet->mergeState(stReceived.back().msg, 00902 stReceived.back().prox )) { 00903 EV << "[Pastry::checkProxCache() @ " << thisNode.ip 00904 << " (" << thisNode.key.toString(16) << ")]\n" 00905 << " Error initializing own leafSet while joining! Restarting ..." 00906 << endl; 00907 //std::cout << "Pastry: Error initializing own leafSet while " 00908 // "joining! Restarting ..." << std::endl; 00909 ret = false; 00910 } else { 00911 newLeafs(); 00912 } 00913 if (debugOutput) { 00914 EV << "[Pastry::checkProxCache() @ " << thisNode.ip 00915 << " (" << thisNode.key.toString(16) << ")]\n" 00916 << " [JOIN] initializing RoutingTable from all hops" 00917 << endl; 00918 } 00919 00920 if (!routingTable->initStateFromHandleVector(stReceived)) { 00921 EV << "[Pastry::checkProxCache() @ " << thisNode.ip 00922 << " (" << thisNode.key.toString(16) << ")]\n" 00923 << " Error initializing own routingTable while joining! Restarting ..." 00924 << endl; 00925 //std::cout << "Pastry: Error initializing own routingTable " 00926 // "while joining! Restarting ..." << std::endl; 00927 00928 ret = false; 00929 } 00930 stateCache.msg = NULL; 00931 stateCache.prox = NULL; 00932 } else if (state == READY) { 00933 // merging singe state (stateCache.msg) 00934 if (!neighborhoodSet->mergeState(stateCache.msg, NULL)) { 00935 ret = false; 00936 } 00937 if (!leafSet->mergeState(stateCache.msg, NULL)) { 00938 ret = false; 00939 } else { 00940 newLeafs(); 00941 } 00942 if (!routingTable->mergeState(stateCache.msg, NULL)) { 00943 ret = false; 00944 } 00945 } 00946 00947 if (ret) lastStateChange = simTime(); 00948 return ret; 00949 }
| void Pastry::endProcessingState | ( | void | ) | [private] |
Definition at line 833 of file Pastry.cc.
Referenced by checkProxCache(), and processState().
00834 { 00835 // if state message was not an update, send one back: 00836 if (stateCache.msg && 00837 stateCache.msg->getPastryStateMsgType() != PASTRY_STATE_UPDATE && 00838 (alwaysSendUpdate || lastStateChange == simTime()) && 00839 thisNode != stateCache.msg->getSender()) {//hack 00840 simtime_t timestamp = stateCache.msg->getTimestamp(); 00841 sendStateTables(stateCache.msg->getSender(), PASTRY_STATE_UPDATE, 00842 ×tamp); 00843 } 00844 00845 delete stateCache.msg; 00846 stateCache.msg = NULL; 00847 delete stateCache.prox; 00848 stateCache.prox = NULL; 00849 00850 // process next queued message: 00851 if (! stateCacheQueue.empty()) { 00852 stateCache = stateCacheQueue.front(); 00853 stateCacheQueue.pop(); 00854 processState(); 00855 /*if (pingBeforeSecondStage || 00856 stateCache.msg->getPastryStateMsgType() == PASTRY_STATE_STD) { 00857 pingNodes(); 00858 } else { 00859 mergeState(); //unknown / stateCache 00860 endProcessingState(); 00861 }*/ 00862 } 00863 }
| void Pastry::doJoinUpdate | ( | void | ) | [private] |
send updated state to all nodes when entering ready state
Definition at line 540 of file Pastry.cc.
Referenced by handleTimerEvent().
00541 { 00542 // send "update" state message to all nodes who sent us their state 00543 // during INIT, remove these from notifyList so they don't get our 00544 // state twice 00545 std::vector<TransportAddress>::iterator nListPos; 00546 if (!stReceived.empty()) { 00547 for (std::vector<PastryStateMsgHandle>::iterator it = 00548 stReceived.begin(); it != stReceived.end(); ++it) { 00549 simtime_t timestamp = it->msg->getTimestamp(); 00550 sendStateTables(it->msg->getSender(), PASTRY_STATE_UPDATE, 00551 ×tamp); 00552 nListPos = find(notifyList.begin(), notifyList.end(), 00553 it->msg->getSender()); 00554 if (nListPos != notifyList.end()) { 00555 notifyList.erase(nListPos); 00556 } 00557 delete it->msg; 00558 delete it->prox; 00559 } 00560 stReceived.clear(); 00561 } 00562 00563 // send a normal STATE message to all remaining known nodes 00564 for (std::vector<TransportAddress>::iterator it = 00565 notifyList.begin(); it != notifyList.end(); it++) { 00566 if (*it != thisNode) sendStateTables(*it, PASTRY_STATE_JOINUPDATE); 00567 } 00568 notifyList.clear(); 00569 00570 updateTooltip(); 00571 }
| void Pastry::joinOverlay | ( | ) | [private, virtual] |
Join the overlay with a given nodeID in thisNode.key.
Join the overlay with a given nodeID in thisNode.key. This method may be called by an application to join the overlay with a specific nodeID. It is also called if the node's IP address changes.
Reimplemented from BaseOverlay.
Definition at line 106 of file Pastry.cc.
Referenced by checkProxCache(), handleFailedNode(), handleStateMessage(), and handleTimerEvent().
00107 { 00108 changeState(INIT); 00109 00110 if (bootstrapNode.isUnspecified()) { 00111 // no existing pastry network -> first node of a new one 00112 changeState(READY); 00113 } else { 00114 // join existing pastry network 00115 nearNode = bootstrapNode; 00116 if (useDiscovery) changeState(DISCOVERY); 00117 else changeState(JOINING_2); 00118 } 00119 }
double Pastry::secondStageWaitAmount [private] |
double Pastry::ringCheckInterval [private] |
Definition at line 82 of file Pastry.h.
Referenced by changeState(), handleTimerEvent(), and initializeOverlay().
double Pastry::discoveryTimeoutAmount [private] |
Definition at line 83 of file Pastry.h.
Referenced by changeState(), handleUDPMessage(), and initializeOverlay().
bool Pastry::partialJoinPath [private] |
int Pastry::depth [private] |
Definition at line 86 of file Pastry.h.
Referenced by changeState(), handleTimerEvent(), and handleUDPMessage().
bool Pastry::useSecondStage [private] |
bool Pastry::sendStateAtLeafsetRepair [private] |
bool Pastry::pingBeforeSecondStage [private] |
Definition at line 90 of file Pastry.h.
Referenced by handleStateMessage(), initializeOverlay(), and processState().
bool Pastry::overrideOldPastry [private] |
bool Pastry::overrideNewPastry [private] |
cMessage* Pastry::secondStageWait [private] |
Definition at line 95 of file Pastry.h.
Referenced by changeState(), initializeOverlay(), and ~Pastry().
cMessage* Pastry::ringCheck [private] |
Definition at line 96 of file Pastry.h.
Referenced by changeState(), handleTimerEvent(), initializeOverlay(), and ~Pastry().
cMessage* Pastry::discoveryTimeout [private] |
Definition at line 97 of file Pastry.h.
Referenced by handleUDPMessage(), initializeOverlay(), and ~Pastry().
1.5.5