Changeset 3037 for source/ariba/overlay


Ignore:
Timestamp:
Apr 22, 2009, 9:07:53 PM (15 years ago)
Author:
Christoph Mayer
Message:

-jede Menge fixes und Umstellungen
-angefangen ariba/interface los zu werden, erste dateien sind weg

Location:
source/ariba/overlay
Files:
4 edited

Legend:

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

    r2803 r3037  
    107107
    108108        logging_info( "leaving spovnet " << spovnetId );
     109        bool ret = ( state != this->BaseOverlayStateInvalid );
    109110
    110111        logging_debug( "dropping all auto-links ..." );
    111        
     112
    112113        BOOST_FOREACH( LinkPair item, linkMapping ){
    113                 if( item.second.autolink ) 
     114                if( item.second.autolink )
    114115                        dropLink( item.first );
    115116        }
     
    135136        // inform all registered services of the event
    136137        BOOST_FOREACH( ServiceInterface* i, listenerMux.getOneList() ){
    137                 i->onOverlayDestroy( spovnetId );
     138                if( ret ) i->onLeaveSuccess( spovnetId );
     139                else      i->onLeaveFail( spovnetId );
    138140        }
    139141}
     
    159161
    160162        //
    161         // create the overlay
    162         //
    163 
    164         overlayInterface->createOverlay();
    165         BOOST_FOREACH( ServiceInterface* i, listenerMux.getOneList() ){
    166                 i->onOverlayCreate( spovnetId );
    167         }
    168 
    169         //
    170163        // bootstrap against ourselfs
    171164        //
     
    286279                                node.toString() << " for service " << service.toString() <<
    287280                                ". creating auto link ...");
    288                
     281
    289282                const LinkID link = establishLink( node, service );
    290283                LinkMapping::iterator i = linkMapping.find( link );
     
    328321        ServiceInterface* iface = listenerMux.get( sid );
    329322        listenerMux.unregisterItem( sid );
    330        
     323
    331324        return NULL; //iface;
    332325}
     
    385378                                " on link " << id.toString() );
    386379
    387                 OverlayMsg overMsg( 
    388                         OverlayMsg::OverlayMessageTypeUpdate, 
    389                         i->second.service, 
    390                         nodeId 
     380                OverlayMsg overMsg(
     381                        OverlayMsg::OverlayMessageTypeUpdate,
     382                        i->second.service,
     383                        nodeId
    391384                        );
    392385
     
    655648
    656649                overlayInterface->createOverlay();
    657 
    658                 // inform all registered services of the event
    659                 BOOST_FOREACH( ServiceInterface* i, listenerMux.getOneList() ){
    660                         i->onOverlayCreate( spovnetId );
    661                 }
    662 
    663650                overlayInterface->joinOverlay( replyMsg->getBootstrapEndpoint() );
    664651
     
    765752                        // inform all registered services of the event
    766753                        BOOST_FOREACH( ServiceInterface* i, listenerMux.getOneList() ){
    767                                 i->onOverlayDestroy( spovnetId );
     754                                i->onLeaveFail( spovnetId );
    768755                        }
    769756
     
    815802                sendMessage( message, *i, service ); // TODO: sollte auto links aufbauen fÃŒr sowas
    816803        }
     804}
     805
     806vector<NodeID> BaseOverlay::getOverlayNeighbors() const {
     807        // the known nodes _can_ also include our
     808        // node, so we remove ourselfs
     809
     810        vector<NodeID> nodes = overlayInterface->getKnownNodes();
     811        vector<NodeID>::iterator i = find( nodes.begin(), nodes.end(), this->nodeId );
     812        if( i != nodes.end() ) nodes.erase( i );
     813
     814        return nodes;
    817815}
    818816
  • source/ariba/overlay/BaseOverlay.h

    r2803 r3037  
    4444#include <algorithm>
    4545#include <ctime>
     46#include <list>
     47#include <vector>
    4648#include <boost/foreach.hpp>
    4749
     
    6668#include "ariba/overlay/messages/JoinReply.h"
    6769
     70using std::vector;
     71using std::list;
    6872using std::cout;
    6973using std::map;
    7074using std::make_pair;
    7175using std::pair;
     76using std::find;
    7277
    7378using ariba::communication::EndpointDescriptor;
     
    103108// in different namespace
    104109namespace ariba {
    105 namespace interface {
    106         class UnderlayAbstraction;
    107 }}
     110        class Node;
     111}
    108112
    109113namespace ariba {
     
    117121
    118122        use_logging_h( BaseOverlay );
    119         friend class ariba::interface::UnderlayAbstraction;
     123        friend class ariba::Node;
    120124
    121125public:
     
    166170                const ServiceID& service
    167171        );
     172
     173        /**
     174         * Get a list of overlay neighboring nodes.
     175         */
     176        vector<NodeID> getOverlayNeighbors() const;
    168177
    169178        /**
     
    324333                static const LinkItem UNSPECIFIED;
    325334
    326                 LinkItem( const LinkID& _link, const NodeID& _node, 
     335                LinkItem( const LinkID& _link, const NodeID& _node,
    327336                                const ServiceID& _service, ServiceInterface* _interface )
    328                         : link( _link ), node( _node ), service( _service ), interface( _interface ), 
     337                        : link( _link ), node( _node ), service( _service ), interface( _interface ),
    329338                                autolink( false ), lastuse( time(NULL) ) {
    330339                }
     
    350359        typedef pair<const LinkID,LinkItem> LinkPair;
    351360        LinkMapping linkMapping;
    352        
     361
    353362        // nodes with pending joines. TODO: should be cleaned every some seconds
    354363        // add timestamps to each, and check on occasion
  • source/ariba/overlay/OverlayEvents.cpp

    r3036 r3037  
    4848}
    4949
    50 void OverlayEvents::onOverlayCreate( const SpoVNetID& id ){
    51 }
    52 
    53 void OverlayEvents::onOverlayDestroy( const SpoVNetID& id ){
    54 }
    55 
    5650bool OverlayEvents::isJoinAllowed( const NodeID& nodeid, const SpoVNetID& spovnetid ){
    5751        // default: allow all nodes to join
     
    7165}
    7266
     67void OverlayEvents::onLeaveSuccess( const SpoVNetID& spovnetid ){
     68}
     69
     70void OverlayEvents::onLeaveFail( const SpoVNetID& spovnetid ){
     71}
     72
    7373void OverlayEvents::onLinkUp( const LinkID& link, const NodeID& local, const NodeID& remote ){
    7474}
  • source/ariba/overlay/OverlayEvents.h

    r3036 r3037  
    5858
    5959protected:
    60 
    61         virtual void onOverlayCreate( const SpoVNetID& id );
    62         virtual void onOverlayDestroy( const SpoVNetID& id );
    63 
    6460        /// for initiator about remote nodes
    6561        virtual bool isJoinAllowed( const NodeID& nodeid, const SpoVNetID& spovnetid );
     
    7066        virtual void onJoinSuccess( const SpoVNetID& spovnetid );
    7167        virtual void onJoinFail( const SpoVNetID& spovnetid );
     68        virtual void onLeaveSuccess( const SpoVNetID& spovnetid );
     69        virtual void onLeaveFail( const SpoVNetID& spovnetid );
    7270
    7371        virtual void onLinkUp( const LinkID& link, const NodeID& local, const NodeID& remote );
Note: See TracChangeset for help on using the changeset viewer.