Ignore:
Timestamp:
Aug 7, 2009, 9:42:54 AM (15 years ago)
Author:
mies
Message:
 
Location:
source/ariba/overlay/modules/chord
Files:
2 edited

Legend:

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

    r5752 r5756  
    5858        // create routing table
    5959        this->table = new chord_routing_table(_nodeid, 2);
     60
     61        // init counters
    6062        orphan_removal_counter = 0;
    6163        discovery_count = 0;
     
    9799        if (link.isUnspecified()) return 0;
    98100        return baseoverlay.sendMessage(msg, link);
     101}
     102
     103const 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;
    99109}
    100110
     
    112122
    113123        // 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);
    116126}
    117127
     
    179189void Chord::routeMessage(const NodeID& destnode, Message* msg) {
    180190        // get next hop
    181         const route_item* item = table->get_next_hop(destnode);
     191        LinkID next_link = get_next_hop(destnode);
    182192
    183193        // message for this node? yes-> delegate to base overlay
    184         if (item->id == nodeid || destnode == nodeid)
     194        if (destnode == nodeid)
    185195                baseoverlay.incomingRouteMessage( msg, LinkID::UNSPECIFIED, nodeid );
    186196
     
    188198                ChordMessage cmsg(ChordMessage::route, nodeid, destnode);
    189199                cmsg.encapsulate(msg);
    190                 send(&cmsg, item->info);
     200                send(&cmsg, next_link);
    191201        }
    192202}
     
    203213/// @see OverlayInterface.h
    204214const 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);
    214216}
    215217
     
    306308        case M::route: {
    307309                // 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);
    309318
    310319                // next hop == myself?
    311320                if (m->getDestination() == nodeid) { // yes-> route to base overlay
    312321                        logging_debug("Send message to baseoverlay");
    313                         baseoverlay.incomingRouteMessage( m, item->info, remote );
     322                        baseoverlay.incomingRouteMessage( m, next_link, remote );
    314323                }
    315324                // no-> route to next hop
    316325                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);
    320329                }
    321330                break;
     
    376385                        else {
    377386                                // 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);
    383391                        }
    384392                        break;
     
    465473                orphan_removal_counter++;
    466474                if (orphan_removal_counter <0 || orphan_removal_counter >= 4) {
     475                        back_routes.clear();
    467476                        logging_info("Running orphan removal");
    468477                        orphan_removal_counter = 0;
  • source/ariba/overlay/modules/chord/Chord.h

    r5743 r5756  
    8080        int discovery_count;
    8181
     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
    8292        // helper: sets up a link using the "base overlay"
    8393        LinkID setup( const EndpointDescriptor& endp,
Note: See TracChangeset for help on using the changeset viewer.