Changeset 3067 for source/ariba/overlay


Ignore:
Timestamp:
Apr 24, 2009, 10:04:11 AM (16 years ago)
Author:
Christoph Mayer
Message:

-fixed #30 (stress test pingpong, has some errors), #24 (autolinks for easy message sending)

Location:
source/ariba/overlay
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • source/ariba/overlay/BaseOverlay.cpp

    r3056 r3067  
    123123        logging_debug( "dropping all auto-links ..." );
    124124
     125        // now we start leaving the spovnet: fist delete all links
     126        // that we still have in the baseoverlay initiated by
     127        // some services, the leave the actual overlay structure,
     128        // then leave the spovnet
     129
     130        // --> drop all service links
     131
     132        vector<LinkID> servicelinks;
    125133        BOOST_FOREACH( LinkPair item, linkMapping ){
    126                 if( item.second.autolink )
    127                         dropLink( item.first );
    128         }
     134                if( item.second.service != OverlayInterface::OVERLAY_SERVICE_ID )
     135                        servicelinks.push_back( item.first );
     136        }
     137        BOOST_FOREACH( LinkID lnk, servicelinks ){
     138                // the dropLink function will remove
     139                // the item from the linkMapping
     140                dropLink( lnk );
     141        }
     142
     143        // --> leave overlay structure
    129144
    130145        logging_debug( "leaving overlay" );
    131146        // first, leave the overlay interface
    132147        overlayInterface->leaveOverlay();
     148
     149        // --> leave spovnet
    133150
    134151        if( state != BaseOverlayStateInitiator ){
     
    185202}
    186203
    187 const EndpointDescriptor& BaseOverlay::getEndpointDescriptor(const LinkID& link) const {
    188 
    189         return bc->getEndpointDescriptor( link );
    190 }
    191 
    192 const EndpointDescriptor& BaseOverlay::getEndpointDescriptor(const NodeID& node) const {
    193 
    194         if( node == nodeId || node == NodeID::UNSPECIFIED )
    195                 return bc->getEndpointDescriptor();
    196 
    197         if( overlayInterface == NULL ){
    198                 logging_error( "overlay interface not set, cannot resolve endpoint" );
    199                 return EndpointDescriptor::UNSPECIFIED;
    200         }
    201 
    202         // TODO: if this is not a onehop overlay the operation will go asynchronously
    203         return overlayInterface->resolveNode( node );
    204 }
    205 
    206204const LinkID BaseOverlay::establishLink(const NodeID& node, const ServiceID& service){
    207205
     
    227225        }
    228226
     227        const LinkID link = bc->establishLink( ep );
     228
    229229        CommunicationListener* receiver = communicationListeners.get( service );
    230         const LinkID link = bc->establishLink( ep );
    231 
    232230        LinkItem item (link, NodeID::UNSPECIFIED, service, receiver);
    233231        linkMapping.insert( make_pair(link, item) );
     
    292290                                ". creating auto link ...");
    293291
    294                 const LinkID link = establishLink( node, service );
     292                link = establishLink( node, service );
    295293                LinkMapping::iterator i = linkMapping.find( link );
    296294
    297                 if( i == linkMapping.end() ){
     295                if( i == linkMapping.end() || link == LinkID::UNSPECIFIED ){
    298296                        logging_error( "failed to establish auto link to node " << node.toString() <<
    299297                                        " for service " << service.toString() );
     
    303301                i->second.autolink = true;
    304302
     303                logging_debug( "establishing autolink in progress to node "
     304                                << node.toString() << " with new link-id " << link.toString() );
     305
    305306        } // if( link != LinkID::UNSPECIFIED )
    306307
     308        assert( link != LinkID::UNSPECIFIED );
     309
     310        // mark the link as used, as we
     311        // now send a message through it
    307312        i->second.markused();
     313
     314        // send the message through the new link. the link may not be functional,
     315        // but for us there is a link-id so we can send messages through it. if
     316        // the link is not yet up and the message needs to be cached, this is the
     317        // task of the BaseCommunication, it will cache and send it later.
    308318        return sendMessage( message, link );
    309319}
    310320
    311 void BaseOverlay::bind(CommunicationListener* listener, const ServiceID& sid){
     321const EndpointDescriptor& BaseOverlay::getEndpointDescriptor(const LinkID& link) const {
     322
     323        return bc->getEndpointDescriptor( link );
     324}
     325
     326const EndpointDescriptor& BaseOverlay::getEndpointDescriptor(const NodeID& node) const {
     327
     328        if( node == nodeId || node == NodeID::UNSPECIFIED )
     329                return bc->getEndpointDescriptor();
     330
     331        if( overlayInterface == NULL ){
     332                logging_error( "overlay interface not set, cannot resolve endpoint" );
     333                return EndpointDescriptor::UNSPECIFIED;
     334        }
     335
     336        // TODO: if this is not a onehop overlay the operation will go asynchronously
     337        return overlayInterface->resolveNode( node );
     338}
     339
     340bool BaseOverlay::bind(CommunicationListener* listener, const ServiceID& sid){
    312341        logging_debug( "binding communication listener " << listener
    313342                << " on serviceid " << sid.toString() );
     
    316345                logging_error( "some listener already registered for service id "
    317346                        << sid.toString() );
    318                 return;
     347                return false;
    319348        }
    320349
    321350        communicationListeners.registerItem( listener, sid );
    322 }
    323 
    324 void BaseOverlay::unbind(CommunicationListener* listener, const ServiceID& sid){
     351        return true;
     352}
     353
     354bool BaseOverlay::unbind(CommunicationListener* listener, const ServiceID& sid){
    325355        logging_debug( "unbinding listener " << listener
    326356                << " from serviceid " << sid.toString() );
     
    328358        if( !communicationListeners.contains( sid ) ){
    329359                logging_warn( "cannot unbind listener. no listener registered on service id " << sid.toString() );
    330                 return;
     360                return false;
    331361        }
    332362
     
    334364                logging_warn( "listener bound to service id " << sid.toString()
    335365                        << " is different than listener trying to unbind" );
    336                 return;
     366                return false;
    337367        }
    338368
    339369        communicationListeners.unregisterItem( sid );
    340 }
    341 
    342 void BaseOverlay::bind(NodeListener* listener){
     370        return true;
     371}
     372
     373bool BaseOverlay::bind(NodeListener* listener){
    343374        logging_debug( "binding node listener " << listener );
    344375
     
    346377        if( i != nodeListeners.end() ){
    347378                logging_warn( "node listener " << listener << " is already bound, cannot bind" );
    348                 return;
     379                return false;
    349380        }
    350381
    351382        nodeListeners.push_back( listener );
    352 }
    353 
    354 void BaseOverlay::unbind(NodeListener* listener){
     383        return true;
     384}
     385
     386bool BaseOverlay::unbind(NodeListener* listener){
    355387        logging_debug( "unbinding node listener " << listener );
    356388
     
    358390        if( i == nodeListeners.end() ){
    359391                logging_warn( "node listener " << listener << " is not bound, cannot unbind" );
    360                 return;
     392                return false;
    361393        }
    362394
    363395        nodeListeners.erase( i );
     396        return true;
    364397}
    365398
     
    445478        if( i == linkMapping.end() ) {
    446479                // this can also be one of the baseoverlay links that
    447                 // no mapping is stored for. therefore we issue no warning
     480                // no mapping is stored for. therefore we issue no warning.
     481                // it can also be a link that has been dropped and the
     482                // mapping is already deleted in the dropLink function.
     483                // also, the service notification is issued then in dropLink
    448484                return;
    449485        }
  • source/ariba/overlay/BaseOverlay.h

    r3056 r3067  
    202202         * TODO
    203203         */
    204         void bind(CommunicationListener* listener, const ServiceID& sid);
    205 
    206         /**
    207          * TODO
    208          */
    209         void unbind(CommunicationListener* listener, const ServiceID& sid);
    210 
    211         /**
    212          * TODO
    213          */
    214         void bind(NodeListener* listener);
    215 
    216         /**
    217          * TODO
    218          */
    219         void unbind(NodeListener* listener);
     204        bool bind(CommunicationListener* listener, const ServiceID& sid);
     205
     206        /**
     207         * TODO
     208         */
     209        bool unbind(CommunicationListener* listener, const ServiceID& sid);
     210
     211        /**
     212         * TODO
     213         */
     214        bool bind(NodeListener* listener);
     215
     216        /**
     217         * TODO
     218         */
     219        bool unbind(NodeListener* listener);
    220220
    221221        /**
  • source/ariba/overlay/modules/OverlayInterface.h

    r3057 r3067  
    5858
    5959class OverlayInterface : public CommunicationListener {
     60        friend class BaseOverlay;
    6061public:
    6162        OverlayInterface(
  • source/ariba/overlay/modules/onehop/OneHop.cpp

    r3057 r3067  
    146146        logging_info( "leaving onehop overlay structure" );
    147147
     148        // set the state to invalid, this will prevent from
     149        // handling onLinkDown events, as we are traversing the
     150        // overlayNodes map and the onLinkDown function is called
     151        // from the BaseOverlay and OneHop::onLinkDown will also
     152        // try to access the overlayNodes structure.
     153        state = OneHopStateInvalid;
     154
    148155        //
    149156        // close all links, this will indicate the other nodes that we left
     
    158165        }
    159166
    160         state = OneHopStateInvalid;
    161167        pendingLinks = 0;
    162168}
     
    164170
    165171void OneHop::onLinkDown(const LinkID& lnk, const NodeID& remote){
     172
     173        // don't handle when we are in state-invalid,
     174        // see comment in OneHop::leaveOverlay
     175        if( state == OneHopStateInvalid ) return;
    166176
    167177        //
Note: See TracChangeset for help on using the changeset viewer.