Changeset 3041 for source/ariba


Ignore:
Timestamp:
Apr 23, 2009, 9:18:12 AM (15 years ago)
Author:
Christoph Mayer
Message:

-mehrere Fixes, Tickets #25 (bind listeners earlier), #21 (better pingpong), #40 (systemqueue misbehavior)

Location:
source/ariba
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • source/ariba/AribaModule.h

    r3037 r3041  
    161161                BootstrapInfo() :
    162162                        spovnetName(), nodes() {
    163 
    164163                }
    165164
    166165                BootstrapInfo(const BootstrapInfo& copy) :
    167166                        spovnetName(copy.spovnetName), nodes(copy.nodes) {
    168 
    169167                }
    170168
  • source/ariba/Makefile.am

    r3037 r3041  
    259259
    260260nobase_libariba_la_HEADERS += \
    261   interface/UnderlayAbstraction.h \
    262   interface/AribaContext.h \
    263261  interface/ServiceInterface.h
    264262
  • source/ariba/Node.cpp

    r3037 r3041  
    129129
    130130Node::Node(AribaModule& ariba_mod, const Name& node_name) :
    131         ariba_mod(ariba_mod), name(node_name), base_overlay(NULL) {
     131        ariba_mod(ariba_mod), name(node_name) {
     132        base_overlay = new BaseOverlay();
    132133}
    133134
    134135Node::~Node() {
     136        delete base_overlay;
     137        base_overlay = NULL;
    135138}
    136139
     
    140143        nodeId = generateNodeId(name);
    141144
    142         //logging("joining spovnet on"
    143         //              << " [spovnetid=]" << spovnetId.toString()
    144         //              << " [nodeid=]" << nodeId.toString() );
    145 
    146         //logging_info("starting base communication...");
    147145        ariba_mod.base_comm->start(ariba_mod.ip_addr, ariba_mod.tcp_port);
    148 
    149         //logging_info("starting base overlay...");
    150         base_overlay = new BaseOverlay( *ariba_mod.base_comm, nodeId );
     146        base_overlay->start( *ariba_mod.base_comm, nodeId );
    151147
    152148        const communication::EndpointDescriptor* ep =
     
    165161        nodeId = generateNodeId(name);
    166162
    167         //logging("joining spovnet on"
    168         //                      << " [spovnetid=]" << spovnetId.toString()
    169         //                      << " [nodeid=]" << nodeId.toString() );
    170 
    171         //logging_info("starting base communication...");
    172163        ariba_mod.base_comm->start(ariba_mod.ip_addr, ariba_mod.tcp_port);
    173164
    174         //logging_info("starting base overlay...");
    175         base_overlay = new BaseOverlay( *ariba_mod.base_comm, nodeId );
     165        base_overlay->start( *ariba_mod.base_comm, nodeId );
    176166        base_overlay->createSpoVNet( spovnetId );
    177167
     
    184174        ariba_mod.base_comm->stop();
    185175
    186         delete base_overlay;
    187         base_overlay = NULL;
     176        base_overlay->stop();
    188177}
    189178
  • source/ariba/overlay/BaseOverlay.cpp

    r3037 r3041  
    4747use_logging_cpp(BaseOverlay);
    4848
    49 BaseOverlay::BaseOverlay( BaseCommunication& _basecomm, const NodeID& _nodeid )
    50         :       bc( _basecomm ), nodeId( _nodeid ), spovnetId( SpoVNetID::UNSPECIFIED), overlayInterface( NULL ),
    51                 initiatorLink( LinkID::UNSPECIFIED ), state( BaseOverlayStateInvalid ) {
     49BaseOverlay::BaseOverlay()
     50        : bc(NULL), overlayInterface(NULL),
     51                nodeId(NodeID::UNSPECIFIED), spovnetId(SpoVNetID::UNSPECIFIED),
     52                initiatorLink(LinkID::UNSPECIFIED), state(BaseOverlayStateInvalid){
     53}
     54
     55BaseOverlay::~BaseOverlay(){
     56}
     57
     58void BaseOverlay::start( BaseCommunication& _basecomm, const NodeID& _nodeid ){
     59
     60        bc = &_basecomm;
     61        nodeId = _nodeid;
    5262
    5363        logging_info("creating base overlay");
    5464
    55         bc.registerMessageReceiver( this );
    56         bc.registerEventListener( this );
     65        bc->registerMessageReceiver( this );
     66        bc->registerEventListener( this );
    5767
    5868        ovl.visCreate( ovlId, nodeId, string(""), string("") );
     
    7585}
    7686
    77 BaseOverlay::~BaseOverlay() {
     87void BaseOverlay::stop() {
    7888
    7989        logging_info("deleting base overlay");
    8090
    8191        Timer::stop();
    82         bc.unregisterMessageReceiver( this );
    83         bc.unregisterEventListener( this );
     92        bc->unregisterMessageReceiver( this );
     93        bc->unregisterEventListener( this );
    8494}
    8595
     
    101111        state = BaseOverlayStateJoinInitiated;
    102112
    103         initiatorLink = bc.establishLink( bootstrapEp );
     113        initiatorLink = bc->establishLink( bootstrapEp );
     114        logging_info("join process initiated for " << id.toString() << "...");
    104115}
    105116
     
    124135                // then, leave the spovnet baseoverlay
    125136                OverlayMsg overMsg( OverlayMsg::OverlayMessageTypeBye, nodeId );
    126                 bc.sendMessage( initiatorLink, &overMsg );
     137                bc->sendMessage( initiatorLink, &overMsg );
    127138
    128139                // drop the link and set to correct state
    129                 bc.dropLink( initiatorLink );
     140                bc->dropLink( initiatorLink );
    130141                initiatorLink = LinkID::UNSPECIFIED;
    131142        }
     
    175186const EndpointDescriptor& BaseOverlay::getEndpointDescriptor(const LinkID& link) const {
    176187
    177         return bc.getEndpointDescriptor( link );
     188        return bc->getEndpointDescriptor( link );
    178189}
    179190
     
    181192
    182193        if( node == nodeId || node == NodeID::UNSPECIFIED )
    183                 return bc.getEndpointDescriptor();
     194                return bc->getEndpointDescriptor();
    184195
    185196        if( overlayInterface == NULL ){
     
    216227
    217228        ServiceInterface* receiver = listenerMux.get( service );
    218         const LinkID link = bc.establishLink( ep );
     229        const LinkID link = bc->establishLink( ep );
    219230
    220231        LinkItem item (link, NodeID::UNSPECIFIED, service, receiver);
     
    237248
    238249        LinkItem item = i->second;
    239         bc.dropLink( link );
     250        bc->dropLink( link );
    240251
    241252        if( item.interface != NULL )
     
    257268
    258269        i->second.markused();
    259         return bc.sendMessage( link, &overmsg );
     270        return bc->sendMessage( link, &overmsg );
    260271}
    261272
     
    349360
    350361                state = BaseOverlayStateJoinInitiated; // state remains in JoinInitiated
    351                 bc.sendMessage( id, &overMsg );
     362                bc->sendMessage( id, &overMsg );
    352363
    353364                return;
     
    384395                        );
    385396
    386                 bc.sendMessage( id, &overMsg );
     397                bc->sendMessage( id, &overMsg );
    387398                i->second.markused();
    388399
     
    555566
    556567                retmsg.encapsulate(&replyMsg);
    557                 bc.sendMessage( link, &retmsg );
     568                bc->sendMessage( link, &retmsg );
    558569
    559570                return true;
     
    597608                if( ! replyMsg->getJoinAllowed() ){
    598609
    599                         logging_warn( "our join request has been denied" );
    600 
    601                         bc.dropLink( initiatorLink );
     610                        logging_error( "our join request has been denied" );
     611
     612                        bc->dropLink( initiatorLink );
    602613                        initiatorLink = LinkID::UNSPECIFIED;
    603614                        state = BaseOverlayStateInvalid;
     
    624635                        logging_error( "overlay structure not supported" );
    625636
    626                         bc.dropLink( initiatorLink );
     637                        bc->dropLink( initiatorLink );
    627638                        initiatorLink = LinkID::UNSPECIFIED;
    628639                        state = BaseOverlayStateInvalid;
     
    698709                if( changed ){
    699710                        OverlayMsg overMsg( OverlayMsg::OverlayMessageTypeUpdate, i->second.service, nodeId );
    700                         bc.sendMessage( link, &overMsg );
     711                        bc->sendMessage( link, &overMsg );
    701712                }
    702713
     
    744755                if( overlayMsg->getSourceNode() == spovnetInitiator ){
    745756
    746                         bc.dropLink( initiatorLink );
     757                        bc->dropLink( initiatorLink );
    747758                        initiatorLink = LinkID::UNSPECIFIED;
    748759                        state = BaseOverlayStateInvalid;
     
    800811        for( ; i != iend; i++ ){
    801812                if( *i == nodeId) continue; // don't send to ourselfs
    802                 sendMessage( message, *i, service ); // TODO: sollte auto links aufbauen fÃŒr sowas
     813                sendMessage( message, *i, service );
    803814        }
    804815}
     
    857868void BaseOverlay::incomingRouteMessage(Message* msg){
    858869        // gets handled as normal data message
    859         // TODO: passt das so?
    860870        receiveMessage( msg, LinkID::UNSPECIFIED, NodeID::UNSPECIFIED );
    861871}
  • source/ariba/overlay/BaseOverlay.h

    r3037 r3041  
    126126
    127127        /**
    128          * Constructs a Base Overlay instance
    129          */
    130         BaseOverlay( BaseCommunication& _basecomm, const NodeID& _nodeid );
    131 
    132         /**
    133          * TODO
     128         * Constructs an empty non-functional base overlay instance
     129         */
     130        BaseOverlay();
     131
     132        /**
     133         * Destructs a base overlay instance
    134134         */
    135135        virtual ~BaseOverlay();
     136
     137        /**
     138         * Starts the Base Overlay instance
     139         */
     140        void start( BaseCommunication& _basecomm, const NodeID& _nodeid );
     141
     142        /**
     143         * Stops the Base Overlay instance
     144         */
     145        void stop();
    136146
    137147        /**
     
    271281         * communicates over
    272282         */
    273         BaseCommunication& bc;
     283        BaseCommunication* bc;
    274284
    275285        /**
  • source/ariba/utility/system/StartupWrapper.cpp

    r2801 r3041  
    124124void StartupWrapper::startup(StartupInterface* service, bool block){
    125125
    126         StartupWrapper* spovnet = new StartupWrapper(service, block);
     126        StartupWrapper* startup = new StartupWrapper(service, block);
    127127
    128128#ifdef UNDERLAY_OMNET
    129129        SystemQueue::instance().scheduleEvent(
    130                 SystemEvent( spovnet, StartupWrapperEventType, NULL), 0 );
     130                SystemEvent( startup, StartupWrapperEventType, NULL), 0 );
    131131#else
    132         spovnet->handleSystemEvent(
    133                 SystemEvent( spovnet, StartupWrapperEventType, NULL));
     132        SystemQueue::instance().scheduleEvent(
     133                SystemEvent( startup, StartupWrapperEventType, NULL), 0 );
     134
     135        if( block ) getchar();
    134136#endif
    135137}
     
    149151
    150152        service->startup();
    151         waitForExit();
    152 
    153 #ifndef UNDERLAY_OMNET
    154         service->shutdown();
    155         delete event.getListener();
    156 #endif
    157153}
    158154
    159 void StartupWrapper::waitForExit(){
    160 #ifndef UNDERLAY_OMNET
    161         if( blocking ) getchar();
    162 #endif
    163 }
    164 
    165 void StartupWrapper::shutdown(){
     155void StartupWrapper::shutdown(StartupInterface* service){
    166156#ifdef UNDERLAY_OMNET
    167157        //TODO: service->shutdown();
    168158#endif
    169159
     160        service->shutdown();
    170161        SystemQueue::instance().cancel();
    171162}
  • source/ariba/utility/system/StartupWrapper.h

    r3040 r3041  
    7272        static void initConfig(string filename);
    7373        static void startup(StartupInterface* service, bool block = true);
    74         static void shutdown();
     74        static void shutdown(StartupInterface* service);
    7575
    7676#ifdef UNDERLAY_OMNET
Note: See TracChangeset for help on using the changeset viewer.