Changeset 5756 for source/ariba/overlay/modules/chord
- Timestamp:
- Aug 7, 2009, 9:42:54 AM (15 years ago)
- Location:
- source/ariba/overlay/modules/chord
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
source/ariba/overlay/modules/chord/Chord.cpp
r5752 r5756 58 58 // create routing table 59 59 this->table = new chord_routing_table(_nodeid, 2); 60 61 // init counters 60 62 orphan_removal_counter = 0; 61 63 discovery_count = 0; … … 97 99 if (link.isUnspecified()) return 0; 98 100 return baseoverlay.sendMessage(msg, link); 101 } 102 103 const LinkID& Chord::get_next_hop( const NodeID& id ) const { 104 BOOST_FOREACH( const back_route& br, back_routes ) 105 if (br.id==id) return br.link; 106 const route_item* item = table->get_next_hop(id); 107 if (item==NULL) return LinkID::UNSPECIFIED; 108 return item->info; 99 109 } 100 110 … … 112 122 113 123 // get next hop 114 const route_item* item = table->get_next_hop(destination);115 if ( item!=NULL && !item->info.isUnspecified()) send(&cmsg, item->info);124 LinkID next_link = get_next_hop(destination); 125 if (!next_link.isUnspecified()) send(&cmsg, next_link); 116 126 } 117 127 … … 179 189 void Chord::routeMessage(const NodeID& destnode, Message* msg) { 180 190 // get next hop 181 const route_item* item = table->get_next_hop(destnode);191 LinkID next_link = get_next_hop(destnode); 182 192 183 193 // message for this node? yes-> delegate to base overlay 184 if ( item->id == nodeid ||destnode == nodeid)194 if (destnode == nodeid) 185 195 baseoverlay.incomingRouteMessage( msg, LinkID::UNSPECIFIED, nodeid ); 186 196 … … 188 198 ChordMessage cmsg(ChordMessage::route, nodeid, destnode); 189 199 cmsg.encapsulate(msg); 190 send(&cmsg, item->info);200 send(&cmsg, next_link); 191 201 } 192 202 } … … 203 213 /// @see OverlayInterface.h 204 214 const LinkID& Chord::getNextLinkId( const NodeID& id ) const { 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; 215 return get_next_hop(id); 214 216 } 215 217 … … 306 308 case M::route: { 307 309 // find next hop 308 const route_item* item = table->get_next_hop(m->getDestination()); 310 LinkID next_link = get_next_hop(m->getDestination()); 311 312 // add to back-routes 313 back_route br; 314 br.id = m->getSource(); 315 br.link = link; 316 br.lastseen = time(NULL); 317 back_routes.push_back(br); 309 318 310 319 // next hop == myself? 311 320 if (m->getDestination() == nodeid) { // yes-> route to base overlay 312 321 logging_debug("Send message to baseoverlay"); 313 baseoverlay.incomingRouteMessage( m, item->info, remote );322 baseoverlay.incomingRouteMessage( m, next_link, remote ); 314 323 } 315 324 // no-> route to next hop 316 325 else { 317 logging_debug("Route chord message to "318 << item->id.toString() << " (destination=" << m->getDestination() << ")");319 send(m, item->info);326 // logging_debug("Route chord message to " 327 // << item->id.toString() << " (destination=" << m->getDestination() << ")"); 328 send(m, next_link); 320 329 } 321 330 break; … … 376 385 else { 377 386 // find next hop 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); 387 LinkID next_link = get_next_hop(m->getDestination()); 388 // logging_debug("routing discovery message to " << 389 // linkitem->id.toString() ); 390 send(m, next_link); 383 391 } 384 392 break; … … 465 473 orphan_removal_counter++; 466 474 if (orphan_removal_counter <0 || orphan_removal_counter >= 4) { 475 back_routes.clear(); 467 476 logging_info("Running orphan removal"); 468 477 orphan_removal_counter = 0; -
source/ariba/overlay/modules/chord/Chord.h
r5743 r5756 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 82 92 // helper: sets up a link using the "base overlay" 83 93 LinkID setup( const EndpointDescriptor& endp,
Note:
See TracChangeset
for help on using the changeset viewer.