Ignore:
Timestamp:
Jul 21, 2009, 1:54:55 PM (15 years ago)
Author:
Christoph Mayer
Message:

begin merge back from relay branch

File:
1 edited

Legend:

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

    r3718 r5151  
    7171
    7272/// helper: sets up a link using the base overlay
    73 LinkID Chord::setup(const EndpointDescriptor& endp) {
     73LinkID Chord::setup(const EndpointDescriptor& endp, const NodeID& node) {
    7474
    7575        logging_debug("request to setup link to " << endp.toString() );
     76
     77        for (size_t i=0; i<pending.size(); i++)
     78                if (pending[i]==node) return LinkID::UNSPECIFIED;
     79        pending.push_back(node);
     80
    7681        // establish link via base overlay
    77         return baseoverlay.establishLink(endp, OverlayInterface::OVERLAY_SERVICE_ID);
     82        return baseoverlay.establishLink(endp, node, OverlayInterface::OVERLAY_SERVICE_ID);
    7883}
    7984
     
    8691/// sends a discovery message
    8792void Chord::send_discovery_to(const NodeID& destination, int ttl) {
    88         logging_debug("Initiating discovery of " << destination.toString() );
     93//      logging_debug("Initiating discovery of " << destination.toString() );
    8994        Message msg;
    9095        ChordMessage cmsg(ChordMessage::discovery, nodeid, destination);
     
    111116
    112117        // initiator? no->setup first link
    113         if (!(boot == EndpointDescriptor::UNSPECIFIED)) bootstrapLink = setup(boot);
     118        if (!(boot == EndpointDescriptor::UNSPECIFIED))
     119                bootstrapLink = setup(boot);
    114120
    115121        // timer for stabilization management
     
    138144
    139145        // message for this node? yes-> delegate to base overlay
    140         if (item->id == nodeid) baseoverlay.incomingRouteMessage(msg);
     146        if (item->id == nodeid || destnode == nodeid)
     147                baseoverlay.incomingRouteMessage( msg, LinkID::UNSPECIFIED, nodeid );
     148
    141149        else { // no-> send to next hop
    142150                ChordMessage cmsg(ChordMessage::route, nodeid, destnode);
     
    144152                send(&cmsg, item->info);
    145153        }
     154}
     155
     156/// @see OverlayInterface.h
     157void Chord::routeMessage(const NodeID& node, const LinkID& link, Message* msg) {
     158        logging_debug("Redirect over Chord to node id=" << node.toString()
     159                        << " link id=" << link.toString() );
     160        ChordMessage cmsg(ChordMessage::route, nodeid, node);
     161        cmsg.encapsulate(msg);
     162        send(&cmsg, link);
     163}
     164
     165/// @see OverlayInterface.h
     166const LinkID& Chord::getNextLinkId( const NodeID& id ) const {
     167        // get next hop
     168        const route_item* item = table->get_next_hop(id);
     169
     170        // returns a unspecified id when this is itself
     171        if (item == NULL || item->id == nodeid)
     172                return LinkID::UNSPECIFIED;
     173
     174        /// return routing info
     175        return item->info;
    146176}
    147177
     
    160190        logging_debug("link_up: link=" << lnk.toString() << " remote=" <<
    161191                        remote.toString() );
     192        for (vector<NodeID>::iterator i=pending.begin(); i!=pending.end(); i++)
     193                if (*i == remote) {
     194                        pending.erase(i);
     195                        break;
     196                }
    162197        route_item* item = table->insert(remote);
    163198
     
    207242                break;
    208243
    209                 // route message with payload
     244        // route message with payload
    210245        case M::route: {
    211246                // find next hop
     
    214249                // next hop == myself?
    215250                if (m->getDestination() == nodeid) { // yes-> route to base overlay
    216                         logging_debug("send message to baseoverlay");
    217                         baseoverlay.incomingRouteMessage(m);
     251                        logging_debug("Send message to baseoverlay");
     252                        baseoverlay.incomingRouteMessage( m, item->info, remote );
    218253                }
    219254                // no-> route to next hop
    220255                else {
    221                         logging_debug("route chord message to " << item->id.toString() );
     256                        logging_debug("Route chord message to "
     257                                << item->id.toString() << " (destination=" << m->getDestination() << ")");
    222258                        send(m, item->info);
    223259                }
     
    236272
    237273                // check if source node can be added to routing table and setup link
    238                 if (m->getSource() != nodeid && table->is_insertable(m->getSource())) setup(
    239                                 *dmsg->getSourceEndpoint());
     274                if (m->getSource() != nodeid && table->is_insertable(m->getSource()))
     275                        setup(*dmsg->getSourceEndpoint(), m->getSource() );
    240276
    241277                // delegate discovery message
     
    302338                        }
    303339                        if (item == NULL) break;
    304                         logging_debug("routing discovery message to succ/pred "
     340                                logging_debug("routing discovery message to succ/pred "
    305341                                        << item->id.toString() );
    306342                        ChordMessage cmsg(*m);
     
    327363
    328364void Chord::eventFunction() {
    329         if (!LinkID::UNSPECIFIED.isUnspecified())
    330                 logging_error("LinkID::UNSPECIFIED not unspecified!!!!");
    331365        stabilize_counter++;
    332366        if (stabilize_counter == 3) {
     367                pending.clear();
    333368                size_t numNeighbors = 0;
    334369                for (size_t i = 0; i < table->size(); i++) {
     
    368403}
    369404
    370 }
    371 } // namespace ariba, overlay
     405}} // namespace ariba, overlay
Note: See TracChangeset for help on using the changeset viewer.