Ignore:
Timestamp:
Aug 10, 2009, 5:55:19 PM (15 years ago)
Author:
huebsch
Message:

revert des kompletten overlay ordners auf revision 5752

File:
1 edited

Legend:

Unmodified
Added
Removed
  • source/ariba/overlay/modules/chord/Chord.cpp

    r5780 r5803  
    5858        // create routing table
    5959        this->table = new chord_routing_table(_nodeid, 2);
    60 
    61         // init counters
    6260        orphan_removal_counter = 0;
    6361        discovery_count = 0;
     
    9290
    9391        // 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 );
    9693}
    9794
     
    10097        if (link.isUnspecified()) return 0;
    10198        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;
    11099}
    111100
     
    123112
    124113        // 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);
    127116}
    128117
     
    190179void Chord::routeMessage(const NodeID& destnode, Message* msg) {
    191180        // get next hop
    192         LinkID next_link = get_next_hop(destnode);
     181        const route_item* item = table->get_next_hop(destnode);
    193182
    194183        // message for this node? yes-> delegate to base overlay
    195         if (destnode == nodeid)
     184        if (item->id == nodeid || destnode == nodeid)
    196185                baseoverlay.incomingRouteMessage( msg, LinkID::UNSPECIFIED, nodeid );
    197186
     
    199188                ChordMessage cmsg(ChordMessage::route, nodeid, destnode);
    200189                cmsg.encapsulate(msg);
    201                 send(&cmsg, next_link);
     190                send(&cmsg, item->info);
    202191        }
    203192}
     
    214203/// @see OverlayInterface.h
    215204const 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;
    217214}
    218215
     
    223220                // all nodes that I know, fingers, succ/pred
    224221                for (size_t i = 0; i < table->size(); i++){
    225                         if (/*(*table)[i]->ref_count != 0
    226                                         &&*/ !(*table)[i]->info.isUnspecified())
     222                        if ((*table)[i]->ref_count != 0
     223                                        && !(*table)[i]->info.isUnspecified())
    227224                                nodelist.push_back((*table)[i]->id);
    228225                }
     
    309306        case M::route: {
    310307                // 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());
    330309
    331310                // next hop == myself?
    332311                if (m->getDestination() == nodeid) { // yes-> route to base overlay
    333312                        logging_debug("Send message to baseoverlay");
    334                         baseoverlay.incomingRouteMessage( m, next_link, remote );
     313                        baseoverlay.incomingRouteMessage( m, item->info, remote );
    335314                }
    336315                // no-> route to next hop
    337316                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);
    341320                }
    342321                break;
     
    378357                                        logging_debug("Discovery split: routing discovery message to successor "
    379358                                                        << succ_item->id.toString() );
    380                                         cmsg_s.setDestination(succ_item->id);
    381359                                        send(&cmsg_s, succ_item->info);
    382360                                }
     
    392370                                        logging_debug("Discovery split: routing discovery message to predecessor "
    393371                                                        << pred_item->id.toString() );
    394                                         cmsg_p.setDestination(pred_item->id);
    395372                                        send(&cmsg_p, pred_item->info);
    396373                                }
     
    399376                        else {
    400377                                // 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);
    405383                        }
    406384                        break;
     
    453431void Chord::eventFunction() {
    454432        stabilize_counter++;
    455         if (stabilize_counter < 0 || stabilize_counter >= 2) {
     433        if (stabilize_counter < 0 || stabilize_counter == 4) {
    456434
    457435                // reset counter
     
    487465                orphan_removal_counter++;
    488466                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 */
    497467                        logging_info("Running orphan removal");
    498468                        orphan_removal_counter = 0;
Note: See TracChangeset for help on using the changeset viewer.