Changeset 3699 for source/ariba/overlay/modules/chord
- Timestamp:
- May 26, 2009, 1:27:41 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
source/ariba/overlay/modules/chord/Chord.cpp
r3696 r3699 49 49 50 50 typedef chord_routing_table::item route_item; 51 use_logging_cpp( Chord ) 52 ;51 52 use_logging_cpp( Chord ); 53 53 54 54 Chord::Chord(BaseOverlay& _baseoverlay, const NodeID& _nodeid, … … 95 95 cmsg.encapsulate(&dmsg); 96 96 msg.encapsulate(&cmsg); 97 logging_debug("" << (int)cmsg.getType());98 97 this->onMessage(&msg, NodeID::UNSPECIFIED, LinkID::UNSPECIFIED); 99 98 } … … 150 149 OverlayInterface::NodeList nodelist; 151 150 for (size_t i = 0; i < table->size(); i++) 152 if ((*table)[i]->ref_count != 0) nodelist.push_back((*table)[i]->id); 151 if ((*table)[i]->ref_count != 0 152 && !(*table)[i]->info.isUnspecified()) 153 nodelist.push_back((*table)[i]->id); 153 154 return nodelist; 154 155 } … … 161 162 route_item* item = table->insert(remote); 162 163 164 165 // item added to routing table? 166 if (item != NULL) { // yes-> add to routing table 167 logging_info("new routing neighbor: " << remote.toString() 168 << " with link " << lnk.toString()); 169 item->info = lnk; 170 } else { // no-> add orphan entry to routing table 171 logging_info("new orphan: " << remote.toString() 172 << " with link " << lnk.toString()); 173 table->insert_orphan(remote)->info = lnk; 174 } 175 163 176 if (!bootstrapLink.isUnspecified() && lnk == bootstrapLink) { 164 177 send_discovery_to(nodeid); 165 178 bootstrapLink = LinkID::UNSPECIFIED; 166 }167 168 // item added to routing table?169 if (item != NULL) { // yes-> add to routing table170 logging_debug("new routing neighbor: " << remote.toString() );171 item->info = lnk;172 } else { // no-> add orphan entry to routing table173 logging_debug("new orphan: " << remote.toString() );174 table->insert_orphan(remote)->info = lnk;175 179 } 176 180 } … … 312 316 // leave 313 317 case M::leave: { 314 baseoverlay.dropLink(link); 318 if (link!=LinkID::UNSPECIFIED) { 319 route_item* item = table->get(remote); 320 if (item!=NULL) item->info = LinkID::UNSPECIFIED; 321 table->remove(remote); 322 baseoverlay.dropLink(link); 323 } 315 324 break; 316 325 } … … 319 328 320 329 void Chord::eventFunction() { 330 if (!LinkID::UNSPECIFIED.isUnspecified()) 331 logging_error("LinkID::UNSPECIFIED not unspecified!!!!"); 321 332 stabilize_counter++; 322 333 if (stabilize_counter == 3) { 334 size_t numNeighbors = 0; 335 for (size_t i = 0; i < table->size(); i++) { 336 route_item* it = (*table)[i]; 337 if (it->ref_count != 0 && !it->info.isUnspecified()) numNeighbors++; 338 } 339 logging_info("Running stabilization: #links=" 340 << table->size() << " #neighbors=" << numNeighbors ); 323 341 stabilize_counter = 0; 324 342 stabilize_finger = ((stabilize_finger+1) % table->get_finger_table_size() ); 325 logging_debug("sending discovery message to my neighbors"); 326 send_discovery_to(nodeid); 327 send_discovery_to( 328 table->get_finger_table(stabilize_finger).get_compare().get_center() 329 ); 343 logging_debug("Sending discovery message to my neighbors and fingers"); 344 NodeID disc1 = nodeid; 345 NodeID disc2 = 346 table->get_finger_table(stabilize_finger).get_compare().get_center(); 347 send_discovery_to(disc1); 348 if (disc1 != disc2) send_discovery_to(disc2); 330 349 orphan_removal_counter++; 331 350 if (orphan_removal_counter == 2) { 351 logging_info("Running orphan removal"); 332 352 orphan_removal_counter = 0; 333 353 for (size_t i = 0; i < table->size(); i++) { 334 354 route_item* it = (*table)[i]; 335 355 if (it->ref_count == 0 && !it->info.isUnspecified()) { 356 logging_info("Dropping orphaned link " << it->info.toString() << " to " << it->id.toString()); 336 357 baseoverlay.dropLink(it->info); 337 logging_debug("dropping orphaned link " << it->info.toString() << " to " << it->id.toString());358 it->info = LinkID::UNSPECIFIED; 338 359 } 339 360 } … … 341 362 } 342 363 logging_debug("--- chord routing information ----------------------------------"); 343 logging_debug("predecessor: " << (table->get_predesessor()==NULL? "<none>" : table->get_predesessor()->toString()) ); 364 logging_debug("predecessor: " << (table->get_predesessor()==NULL? "<none>" : 365 table->get_predesessor()->toString()) ); 344 366 logging_debug("node_id : " << nodeid.toString() ); 345 logging_debug("successor : " << (table->get_successor()==NULL? "<none>" : table->get_successor()->toString())); 367 logging_debug("successor : " << (table->get_successor()==NULL? "<none>" : 368 table->get_successor()->toString())); 346 369 logging_debug("----------------------------------------------------------------"); 347 370 }
Note:
See TracChangeset
for help on using the changeset viewer.