Ignore:
Timestamp:
Jul 24, 2009, 8:53:41 PM (15 years ago)
Author:
Christoph Mayer
Message:

merge from bootstrap branch

Location:
source/ariba/overlay/modules/onehop
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • source/ariba/overlay/modules/onehop/OneHop.cpp

    r5151 r5316  
    5252                OverlayStructureEvents* _eventsReceiver, const OverlayParameterSet& param)
    5353        :       OverlayInterface( _baseoverlay, _nodeid, _eventsReceiver, param ),
    54                 state           ( OneHopStateInvalid ),
    55                 bootstrapLink   ( LinkID::UNSPECIFIED ),
    56                 pendingLinks    ( 0 ) {
     54                state( OneHopStateInvalid ) {
    5755
    5856        //
     
    8886        logging_debug( "routing message to node " << destnode.toString() );
    8987
     88        // msg for ourselfs
     89        if(destnode == nodeid)
     90                baseoverlay.incomingRouteMessage( msg, LinkID::UNSPECIFIED, nodeid );
     91
     92        // msg for other node
    9093        OverlayNodeMapping::const_iterator i = overlayNodes.find( destnode );
    9194        if (i == overlayNodes.end()) {
     
    116119        // the create and join process is completed now.
    117120        logging_info( "creating onehop overlay structure" );
    118         state = OneHopStateCompleted;
    119121}
    120122
     
    123125        logging_info( "deleting onehop overlay structure" );
    124126        state = OneHopStateInvalid;
    125         pendingLinks = 0;
    126 }
    127 
    128 OverlayInterface::NodeList OneHop::getKnownNodes() const {
     127}
     128
     129OverlayInterface::NodeList OneHop::getKnownNodes(bool deep) const {
    129130
    130131        OverlayInterface::NodeList retlist;
     
    142143
    143144        logging_info( "joining onehop overlay structure through end-point " <<
    144                         (bootstrapEp == EndpointDescriptor::UNSPECIFIED ?
    145                                         "local" : bootstrapEp.toString()) );
    146 
    147         state = OneHopStateJoinInitiated;
    148         pendingLinks = 0;
    149 
    150         if( bootstrapEp == EndpointDescriptor::UNSPECIFIED ){
     145                        (bootstrapEp.isUnspecified() ? "local" : bootstrapEp.toString()) );
     146
     147        if( bootstrapEp.isUnspecified() ){
    151148
    152149                // we are the initiator and we are to bootstrap against
     
    156153                state = OneHopStateCompleted;
    157154        } else {
    158                 bootstrapLink = baseoverlay.establishLink( bootstrapEp,
    159                                         OverlayInterface::OVERLAY_SERVICE_ID );
     155                bootstrapLinks.push_back(
     156                                baseoverlay.establishLink( bootstrapEp,
     157                                        OverlayInterface::OVERLAY_SERVICE_ID )
     158                                        );
    160159        }
    161160}
     
    187186                }
    188187        }
    189 
    190         pendingLinks = 0;
    191188}
    192189
     
    210207                }
    211208        }
     209
     210        vector<LinkID>::iterator it = std::find( bootstrapLinks.begin(), bootstrapLinks.end(), lnk );
     211        if( it != bootstrapLinks.end() ) bootstrapLinks.erase( it );
    212212}
    213213
    214214void OneHop::onLinkUp(const LinkID& lnk, const NodeID& remote){
    215 
    216         //
    217         // as soon as a link goes up, we always request the node listing.
    218         // and try to get connections to as much nodes as possible in a greedy way.
    219         //
    220 
    221         if( lnk != bootstrapLink ){
    222                 if( pendingLinks > 0 )  pendingLinks--;
    223                 if( pendingLinks == 0 ) state = OneHopStateCompleted;
    224         }
    225215
    226216        logging_debug( "link is up, sending out node listing request" );
     
    230220        onemsg.encapsulate( &requestmsg );
    231221
    232         state = OneHopStateJoinListingRequested;
    233222        baseoverlay.sendMessage( &onemsg, lnk );
    234223}
     
    309298                const NodeListingReply::NodeEndpointList& endpoints = reply->getList();
    310299                logging_debug( "received " << endpoints.size() << " nodes in listing" );
    311                 pendingLinks = 0;
    312300
    313301                NodeListingReply::NodeEndpointList::const_iterator i = endpoints.begin();
     
    330318
    331319                        overlayNodes.insert( make_pair(node, link) );
    332                         pendingLinks++;
    333320
    334321                } // for( ; i != iend; i++ )
     
    356343        if( onemsg->isType( OneHopMessage::OneHopMessageTypeRoute) ){
    357344                logging_debug( "Route message arrived at destination node -> delegate to BaseOverlay" );
    358                 baseoverlay.incomingRouteMessage( onemsg );
     345                baseoverlay.incomingRouteMessage( onemsg, lnk, remote);
    359346        } // OneHopMessageTypeRoute
    360347
  • source/ariba/overlay/modules/onehop/OneHop.h

    r5151 r5316  
    9090
    9191        /// @see OverlayInterface.h
    92         virtual NodeList getKnownNodes() const;
     92        virtual NodeList getKnownNodes(bool deep = true) const;
    9393
    9494        /// @see CommunicationListener.h or @see OverlayInterface.h
     
    110110        typedef enum _OneHopState {
    111111                OneHopStateInvalid = 0,
    112                 OneHopStateJoinInitiated = 1,
    113                 OneHopStateJoinListingRequested = 2,
    114                 OneHopStateCompleted = 3,
     112                OneHopStateCompleted = 1,
    115113        } OneHopState;
    116114
    117115        OneHopState state;
    118         uint16_t pendingLinks;
    119         LinkID bootstrapLink;
     116        vector<LinkID> bootstrapLinks;
    120117};
    121118
Note: See TracChangeset for help on using the changeset viewer.