- Timestamp:
- Aug 10, 2009, 5:55:19 PM (15 years ago)
- Location:
- source/ariba/overlay
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
source/ariba/overlay/BaseOverlay.cpp
r5779 r5803 118 118 // get descriptor of first hop 119 119 rld = getDescriptor(rlid); 120 if (rld!=NULL) { 121 // is first hop a relay path use local relay 122 if ( rld->relay ) relayNode = rld->localRelay; 123 124 // no-> a proper relay node has been found 125 else relayNode = rld->remoteNode; 126 } 120 121 // is first hop a relay path use local relay 122 if ( rld->relay ) relayNode = rld->localRelay; 123 124 // no-> a proper relay node has been found 125 else relayNode = rld->remoteNode; 127 126 } 128 127 … … 148 147 lp->service == OverlayInterface::OVERLAY_SERVICE_ID && 149 148 lp->relay == false && 150 lp->up) { 151 152 // std::cout << "using relay node: " << lp->remoteNode.toString() << std::endl; 149 lp->up) 153 150 return lp; 154 }155 151 156 152 return NULL; … … 1156 1152 // delegate data message 1157 1153 listener->onMessage( overlayMsg, 1158 overlayMsg->getSourceNode(), ld ==NULL ? LinkID::UNSPECIFIED : ld->overlayId );1154 overlayMsg->getSourceNode(), ld->overlayId ); 1159 1155 1160 1156 ret = true; … … 1395 1391 RelayMessage* relayMsg = overlayMsg->decapsulate<RelayMessage>(); 1396 1392 1397 // mark incoming link as relay1398 if (ld!=NULL) ld->markAsRelay();1399 1400 // am I the destination of this message? yes->1401 if (relayMsg->getDestNode() == nodeId ) {1402 // deliver relay message locally!1403 logging_debug("Relay message reached destination. Handling the message.");1404 handleMessage( relayMsg, relayMsg->getDestLink(), LinkID::UNSPECIFIED, remoteNode );1405 ret = true;1406 break;1407 }1408 1409 1393 // is relay message informative? 1410 1394 switch (relayMsg->getType()) { … … 1416 1400 << " destination " << relayMsg->getDestNode() ); 1417 1401 1402 // mark incoming link as relay 1403 if (ld!=NULL) ld->markAsRelay(); 1404 1405 // am I the destination of this message? yes-> 1406 if (relayMsg->getDestNode() == nodeId ) { 1407 // deliver relay message locally! 1408 logging_debug("Relay message reached destination. Handling the message."); 1409 handleMessage( relayMsg, relayMsg->getDestLink(), LinkID::UNSPECIFIED, remoteNode ); 1410 ret = true; 1411 break; 1412 } 1413 1418 1414 // create route message 1419 1415 OverlayMsg _overMsg( *overlayMsg ); 1420 relayMsg->setType( RelayMessage::typeRoute ); 1421 _overMsg.encapsulate( relayMsg ); 1416 RelayMessage _relayMsg( *relayMsg ); 1417 _relayMsg.setType( RelayMessage::typeRoute ); 1418 _overMsg.encapsulate( &_relayMsg ); 1422 1419 1423 1420 // forward message … … 1439 1436 << " destination " << relayMsg->getDestNode() ); 1440 1437 1438 // mark incoming link as relay 1439 if (ld!=NULL) ld->markAsRelay(); 1440 1441 // am I the destination of this message? yes-> 1442 if (relayMsg->getDestNode() == nodeId ) { 1443 // deliver relay message locally! 1444 logging_debug("Relay message reached destination. Handling the message."); 1445 handleMessage( relayMsg, relayMsg->getDestLink(), LinkID::UNSPECIFIED, remoteNode ); 1446 ret = true; 1447 break; 1448 } 1449 1441 1450 // am I the relay for this message? yes-> 1442 1451 if (relayMsg->getRelayNode() == nodeId ) { 1443 1452 logging_debug("I'm the relay for this message. Sending to destination."); 1444 1453 OverlayMsg _overMsg( *overlayMsg ); 1445 _overMsg.encapsulate(relayMsg); 1454 RelayMessage _relayMsg( *relayMsg ); 1455 _overMsg.encapsulate(&_relayMsg); 1446 1456 1447 1457 /// this must be handled by using relay link! … … 1607 1617 1608 1618 // missed more than four keep-alive messages (10 sec)? -> drop link 1609 if (ld->keepAliveMissed > 8) {1619 if (ld->keepAliveMissed > 4) { 1610 1620 logging_info( "Link connection request is stale, closing: " << ld ); 1611 1621 oldlinks.push_back( ld ); -
source/ariba/overlay/messages/RelayMessage.h
r5758 r5803 37 37 /// contructs a unspecified relay message 38 38 RelayMessage() : 39 type(typeInvalid), relayNode(NodeID::UNSPECIFIED), destNode(NodeID::UNSPECIFIED), destLink(LinkID::UNSPECIFIED) { 40 } 41 42 RelayMessage( const RelayMessage& rhs ) : 43 type(rhs.type), relayNode(rhs.relayNode), destNode(rhs.destNode), destLink(rhs.destLink) { 44 39 type(typeInvalid), relayNode(NodeID::UNSPECIFIED), destNode(NodeID::UNSPECIFIED) { 45 40 } 46 41 -
source/ariba/overlay/modules/chord/Chord.cpp
r5780 r5803 58 58 // create routing table 59 59 this->table = new chord_routing_table(_nodeid, 2); 60 61 // init counters62 60 orphan_removal_counter = 0; 63 61 discovery_count = 0; … … 92 90 93 91 // establish link via base overlay 94 return baseoverlay.establishLink(endp, node, OverlayInterface::OVERLAY_SERVICE_ID, 95 remoteRelay ); 92 return baseoverlay.establishLink(endp, node, OverlayInterface::OVERLAY_SERVICE_ID, remoteRelay ); 96 93 } 97 94 … … 100 97 if (link.isUnspecified()) return 0; 101 98 return baseoverlay.sendMessage(msg, link); 102 }103 104 const LinkID& Chord::get_next_hop( const NodeID& id ) const {105 BOOST_FOREACH( const back_route& br, back_routes )106 if (br.id==id) return br.link;107 const route_item* item = table->get_next_hop(id);108 if (item==NULL) return LinkID::UNSPECIFIED;109 return item->info;110 99 } 111 100 … … 123 112 124 113 // get next hop 125 LinkID next_link =get_next_hop(destination);126 if ( !next_link.isUnspecified()) send(&cmsg, next_link);114 const route_item* item = table->get_next_hop(destination); 115 if (item!=NULL && !item->info.isUnspecified()) send(&cmsg, item->info); 127 116 } 128 117 … … 190 179 void Chord::routeMessage(const NodeID& destnode, Message* msg) { 191 180 // get next hop 192 LinkID next_link =get_next_hop(destnode);181 const route_item* item = table->get_next_hop(destnode); 193 182 194 183 // message for this node? yes-> delegate to base overlay 195 if ( destnode == nodeid)184 if (item->id == nodeid || destnode == nodeid) 196 185 baseoverlay.incomingRouteMessage( msg, LinkID::UNSPECIFIED, nodeid ); 197 186 … … 199 188 ChordMessage cmsg(ChordMessage::route, nodeid, destnode); 200 189 cmsg.encapsulate(msg); 201 send(&cmsg, next_link);190 send(&cmsg, item->info); 202 191 } 203 192 } … … 214 203 /// @see OverlayInterface.h 215 204 const LinkID& Chord::getNextLinkId( const NodeID& id ) const { 216 return get_next_hop(id); 205 // get next hop 206 const route_item* item = table->get_next_hop(id); 207 208 // returns a unspecified id when this is itself 209 if (item == NULL || item->id == nodeid) 210 return LinkID::UNSPECIFIED; 211 212 /// return routing info 213 return item->info; 217 214 } 218 215 … … 223 220 // all nodes that I know, fingers, succ/pred 224 221 for (size_t i = 0; i < table->size(); i++){ 225 if ( /*(*table)[i]->ref_count != 0226 && */!(*table)[i]->info.isUnspecified())222 if ((*table)[i]->ref_count != 0 223 && !(*table)[i]->info.isUnspecified()) 227 224 nodelist.push_back((*table)[i]->id); 228 225 } … … 309 306 case M::route: { 310 307 // find next hop 311 LinkID next_link = get_next_hop(m->getDestination()); 312 313 // add to back-routes 314 bool found = false; 315 BOOST_FOREACH( back_route br, back_routes) { 316 if (br.id == m->getSource()) { 317 br.link = link; 318 br.lastseen = time(NULL); 319 found = true; 320 break; 321 } 322 } 323 if (!found) { 324 back_route br; 325 br.id = m->getSource(); 326 br.link = link; 327 br.lastseen = time(NULL); 328 back_routes.push_back(br); 329 } 308 const route_item* item = table->get_next_hop(m->getDestination()); 330 309 331 310 // next hop == myself? 332 311 if (m->getDestination() == nodeid) { // yes-> route to base overlay 333 312 logging_debug("Send message to baseoverlay"); 334 baseoverlay.incomingRouteMessage( m, next_link, remote );313 baseoverlay.incomingRouteMessage( m, item->info, remote ); 335 314 } 336 315 // no-> route to next hop 337 316 else { 338 //logging_debug("Route chord message to "339 //<< item->id.toString() << " (destination=" << m->getDestination() << ")");340 send(m, next_link);317 logging_debug("Route chord message to " 318 << item->id.toString() << " (destination=" << m->getDestination() << ")"); 319 send(m, item->info); 341 320 } 342 321 break; … … 378 357 logging_debug("Discovery split: routing discovery message to successor " 379 358 << succ_item->id.toString() ); 380 cmsg_s.setDestination(succ_item->id);381 359 send(&cmsg_s, succ_item->info); 382 360 } … … 392 370 logging_debug("Discovery split: routing discovery message to predecessor " 393 371 << pred_item->id.toString() ); 394 cmsg_p.setDestination(pred_item->id);395 372 send(&cmsg_p, pred_item->info); 396 373 } … … 399 376 else { 400 377 // find next hop 401 LinkID next_link = get_next_hop(m->getDestination()); 402 // logging_debug("routing discovery message to " << 403 // linkitem->id.toString() ); 404 send(m, next_link); 378 const route_item* item = table->get_next_hop(m->getDestination()); 379 if (item == NULL || item->id == nodeid) break; 380 logging_debug("routing discovery message to " << 381 item->id.toString() ); 382 send(m, item->info); 405 383 } 406 384 break; … … 453 431 void Chord::eventFunction() { 454 432 stabilize_counter++; 455 if (stabilize_counter < 0 || stabilize_counter >= 2) {433 if (stabilize_counter < 0 || stabilize_counter == 4) { 456 434 457 435 // reset counter … … 487 465 orphan_removal_counter++; 488 466 if (orphan_removal_counter <0 || orphan_removal_counter >= 4) { 489 back_routes.clear();490 /* for (vector<back_route>::iterator i = back_routes.begin();491 i!=back_routes.end(); i++) {492 back_route& br = *i;493 if (difftime(br.lastseen,time(NULL))>5) i =494 back_routes.erase(i)-1;495 }496 */497 467 logging_info("Running orphan removal"); 498 468 orphan_removal_counter = 0; -
source/ariba/overlay/modules/chord/Chord.h
r5756 r5803 80 80 int discovery_count; 81 81 82 class back_route {83 public:84 NodeID id;85 LinkID link;86 time_t lastseen;87 };88 vector<back_route> back_routes;89 90 const LinkID& get_next_hop( const NodeID& id ) const;91 92 82 // helper: sets up a link using the "base overlay" 93 83 LinkID setup( const EndpointDescriptor& endp, -
source/ariba/overlay/modules/chord/messages/ChordMessage.h
r5776 r5803 88 88 } 89 89 90 void setSource(const NodeID& source ) {91 this->source = source;92 }93 94 90 const NodeID& getSource() const { 95 91 return source; 96 }97 98 void setDestination(const NodeID& destination ) {99 this->destination = destination;100 92 } 101 93
Note:
See TracChangeset
for help on using the changeset viewer.