Changeset 3056


Ignore:
Timestamp:
Apr 23, 2009, 6:58:34 PM (15 years ago)
Author:
Christoph Mayer
Message:

-fixed all compile errors, but now the overlay functionality is messed up somewhere

Files:
8 edited

Legend:

Unmodified
Added
Removed
  • sample/pingpong/PingPong.cpp

    r3055 r3056  
    1313
    1414// the service that the pingpong wants to use
    15 ServiceID PingPong::PINGPONG_ID = ServiceID( 111 );
     15ServiceID PingPong::PINGPONG_SERVICEID = ServiceID( 111 );
    1616
    1717// construction
     
    6363
    6464        // bind communication and node listener
    65         node->bind( this );                       /*NodeListener*/
    66         node->bind( this, PingPong::PINGPONG_ID); /*CommunicationListener*/
     65        node->bind( this );                              /*NodeListener*/
     66        node->bind( this, PingPong::PINGPONG_SERVICEID); /*CommunicationListener*/
    6767
    6868        // start node module
     
    8888
    8989        // unbind communication and node listener
    90         node->unbind( this );                        /*NodeListener*/
    91         node->unbind( this, PingPong::PINGPONG_ID ); /*CommunicationListener*/
     90        node->unbind( this );                               /*NodeListener*/
     91        node->unbind( this, PingPong::PINGPONG_SERVICEID ); /*CommunicationListener*/
    9292
    9393        // leave spovnet
     
    121121        vector<NodeID> nodes = node->getNeighborNodes();
    122122        BOOST_FOREACH( NodeID nid, nodes ){
    123                 node->sendMessage( pingmsg, nid, PingPong::PINGPONG_ID );
     123                node->sendMessage( pingmsg, nid, PingPong::PINGPONG_SERVICEID );
    124124        }
    125125
     
    128128        //           internally, gets all neighboring nodes and sends the message
    129129        //-----------------------------------------------------------------------
    130         // node->sendBroadcastMessage( pingmsg, PingPong::PINGPONG_ID );
     130        // node->sendBroadcastMessage( pingmsg, PingPong::PINGPONG_SERVICEID );
    131131}
    132132
    133 // node listener interface
    134133void PingPong::onJoinCompleted( const SpoVNetID& vid ) {
    135134        logging_info( "pingpong node join completed, spovnetid=" << vid.toString() );
     
    153152// communication listener
    154153bool PingPong::onLinkRequest(const NodeID& remote, const DataMessage& msg) {
    155         return false;
     154        logging_debug( "node " << remote.toString() << " wants to build up a link with us ... allowing" );
     155        return true;
    156156}
    157157
     
    191191}
    192192
    193 void PingPong::onMessageSent(seqnum_t seq_num, bool failed, const DataMessage& msg ){
    194         logging_info( "received message sent event for seqnum " << seq_num
    195                         << " with result " << failed );
    196 }
    197 
    198193}}} // namespace ariba, application, pingpong
  • sample/pingpong/PingPong.h

    r3037 r3056  
    4242        virtual void onLinkFail(const LinkID& lnk, const NodeID& remote);
    4343        virtual void onLinkQoSChanged(const LinkID& lnk, const NodeID& remote, const LinkProperties& prop);
    44         virtual void onMessageSent(seqnum_t seq_num, bool failed, const DataMessage& msg = DataMessage::UNSPECIFIED);
    4544
    4645        // node listener interface
     
    6059        // the ariba module and a node
    6160        AribaModule* ariba;
    62         Node* node;
     61        Node*        node;
    6362
    6463        // flag, whether this node initiates or just joins the spovnet
     
    6665
    6766        // the ping pong service id
    68         static ServiceID PINGPONG_ID;
     67        static ServiceID PINGPONG_SERVICEID;
    6968
    7069        // the current ping id
  • source/ariba/CommunicationListener.cpp

    r3055 r3056  
    6565bool CommunicationListener::onLinkRequest(const NodeID& remote,
    6666                const DataMessage& msg) {
    67         return false;
     67        return true;
    6868}
    6969
     
    7272}
    7373
     74// --- extended message functionality ---
    7475// void CommunicationListener::onMessageSent(seqnum_t seq_num, bool failed,
    7576//              const DataMessage& msg) {
  • source/ariba/CommunicationListener.h

    r3055 r3056  
    4040#define COMMUNICATIONLISTENER_H_
    4141
    42 namespace ariba {
    43 // forward declaration
    44 class CommunicationListener;
    45 }
    46 
    4742#include "Message.h"
    4843#include "Identifiers.h"
     
    5247namespace ariba {
    5348
     49// forward decl
     50namespace overlay {
     51        class BaseOverlay;
     52}
     53
    5454/**
    5555 * Listener for communication events on links.
    5656 */
    5757class CommunicationListener {
    58         friend class Node;
     58        friend class ariba::overlay::BaseOverlay;
    5959protected:
    6060        CommunicationListener();
  • source/ariba/NodeListener.h

    r3055 r3056  
    4040#define NODELISTENER_H_
    4141
    42 // forward declaration
    43 namespace ariba {
    44 class NodeListener;
    45 class Node;
    46 }
    47 
    4842#include "Identifiers.h"
    4943
    5044namespace ariba {
     45
     46// forward decl
     47namespace overlay {
     48        class BaseOverlay;
     49}
    5150
    5251/**
     
    5756 */
    5857class NodeListener {
    59         friend class Node;
     58        friend class ariba::overlay::BaseOverlay;
    6059public:
    6160        NodeListener();
    6261        virtual ~NodeListener();
     62
    6363protected:
    6464        /**
  • source/ariba/overlay/BaseOverlay.cpp

    r3055 r3056  
    148148        // inform all registered services of the event
    149149        BOOST_FOREACH( NodeListener* i, nodeListeners ){
    150                 if( ret ) i->onLeaveSuccess( spovnetId );
    151                 else      i->onLeaveFail( spovnetId );
     150                if( ret ) i->onLeaveCompleted( spovnetId );
     151                else      i->onLeaveFailed( spovnetId );
    152152        }
    153153}
     
    178178        overlayInterface->joinOverlay();
    179179        BOOST_FOREACH( NodeListener* i, nodeListeners ){
    180                 i->onJoinSuccess( spovnetId );
     180                i->onJoinCompleted( spovnetId );
    181181        }
    182182
     
    252252
    253253        if( item.interface != NULL )
    254                 item.interface->onLinkDown( spovnetId, nodeId, item.node );
     254                item.interface->onLinkDown( link, item.node );
    255255}
    256256
     
    310310
    311311void BaseOverlay::bind(CommunicationListener* listener, const ServiceID& sid){
    312         logging_debug( "binding communication listener " << listener 
     312        logging_debug( "binding communication listener " << listener
    313313                << " on serviceid " << sid.toString() );
    314314
    315315        if( communicationListeners.contains( sid ) ){
    316                 logging_error( "some listener already registered for service id " 
     316                logging_error( "some listener already registered for service id "
    317317                        << sid.toString() );
    318                 return false;
     318                return;
    319319        }
    320320
    321321        communicationListeners.registerItem( listener, sid );
    322         return true;
    323322}
    324323
    325324void BaseOverlay::unbind(CommunicationListener* listener, const ServiceID& sid){
    326         logging_debug( "unbinding listener " << listener 
     325        logging_debug( "unbinding listener " << listener
    327326                << " from serviceid " << sid.toString() );
    328327
     
    333332
    334333        if( communicationListeners.get(sid) != listener ){
    335                 logging_warn( "listener bound to service id " << sid.toString() 
     334                logging_warn( "listener bound to service id " << sid.toString()
    336335                        << " is different than listener trying to unbind" );
    337336                return;
     
    344343        logging_debug( "binding node listener " << listener );
    345344
    346         NodeListenerVector::iterator i = nodeListeners.find( listener );
     345        NodeListenerVector::iterator i = find( nodeListeners.begin(), nodeListeners.end(), listener );
    347346        if( i != nodeListeners.end() ){
    348347                logging_warn( "node listener " << listener << " is already bound, cannot bind" );
    349348                return;
    350349        }
    351        
     350
    352351        nodeListeners.push_back( listener );
    353352}
     
    356355        logging_debug( "unbinding node listener " << listener );
    357356
    358         NodeListenerVector::iterator i = nodeListeners.find( listener );
     357        NodeListenerVector::iterator i = find( nodeListeners.begin(), nodeListeners.end(), listener );
    359358        if( i == nodeListeners.end() ){
    360359                logging_warn( "node listener " << listener << " is not bound, cannot unbind" );
    361360                return;
    362361        }
    363        
     362
    364363        nodeListeners.erase( i );
    365364}
     
    451450
    452451        if( i->second.interface != NULL )
    453                 i->second.interface->onLinkDown( id, nodeId, i->second.node );
     452                i->second.interface->onLinkDown( id, i->second.node );
    454453
    455454        linkMapping.erase( i );
     
    468467
    469468        if( i->second.interface != NULL )
    470                 i->second.interface->onLinkChanged( id, nodeId, i->second.node );
     469                i->second.interface->onLinkChanged( id, i->second.node );
    471470
    472471        i->second.markused();
     
    485484
    486485        if( i->second.interface != NULL )
    487                 i->second.interface->onLinkFail( id, nodeId, i->second.node );
     486                i->second.interface->onLinkFail( id, i->second.node );
    488487
    489488        i->second.markused();
     
    501500        if( i == linkMapping.end() ) return;
    502501
     502        // TODO: convert QoSParameterSet to the LinkProperties properties
    503503        if( i->second.interface != NULL )
    504                 i->second.interface->onLinkQoSChanged( id, nodeId, i->second.node, qos );
     504                i->second.interface->onLinkQoSChanged( id, i->second.node, LinkProperties::DEFAULT );
    505505
    506506        i->second.markused();
     
    535535
    536536                if( serviceListener != NULL )
    537                         serviceListener->receiveMessage( overlayMsg, link, overlayMsg->getSourceNode() );
     537                        serviceListener->onMessage( overlayMsg, overlayMsg->getSourceNode(), link );
    538538
    539539                return true;
     
    571571                //
    572572
     573                // TODO: here you can implement mechanisms to deny joining of a node
    573574                bool allow = true;
    574 
    575                 BOOST_FOREACH( NodeListener* i, nodeListeners ){
    576                         allow &= i->isJoinAllowed( overlayMsg->getSourceNode(), spovnetId );
    577                 }
    578575
    579576                logging_info( "sending back join reply for spovnet " <<
     
    644641
    645642                        // inform all registered services of the event
    646                         BOOST_FOREACH( NodeListener* i, nodeListeners{
    647                                 i->onJoinFail( spovnetId );
     643                        BOOST_FOREACH( NodeListener* i, nodeListeners ){
     644                                i->onJoinFailed( spovnetId );
    648645                        }
    649646
     
    670667                        // inform all registered services of the event
    671668                        BOOST_FOREACH( NodeListener* i, nodeListeners ){
    672                                 i->onJoinFail( spovnetId );
     669                                i->onJoinFailed( spovnetId );
    673670                        }
    674671
     
    692689                // inform all registered services of the event
    693690                BOOST_FOREACH( NodeListener* i, nodeListeners ){
    694                         i->onJoinSuccess( spovnetId );
     691                        i->onJoinCompleted( spovnetId );
    695692                }
    696693
     
    758755
    759756                i->second.interface = iface;
    760                 iface->onLinkUp( link, nodeId, sourcenode );
     757                iface->onLinkUp( link, sourcenode );
    761758                i->second.markused();
    762759
     
    792789                        // inform all registered services of the event
    793790                        BOOST_FOREACH( NodeListener* i, nodeListeners ){
    794                                 i->onLeaveFail( spovnetId );
     791                                i->onLeaveFailed( spovnetId );
    795792                        }
    796793
     
    802799                        logging_info( "node left " << overlayMsg->getSourceNode() );
    803800
    804                         // inform all registered services of the event
    805                         BOOST_FOREACH( NodeListener* i, nodeListeners ){
    806                                 i->onNodeLeave( overlayMsg->getSourceNode(), spovnetId );
    807                         }
    808801                }
    809802
     
    908901                                << node.toString() );
    909902
    910         BOOST_FOREACH( NodeListener* i, nodeListeners ){
    911                 i->onNodeJoin( node, spovnetId );
    912         }
    913 
    914903        joiningNodes.erase( i );
    915904}
  • source/ariba/overlay/BaseOverlay.h

    r3055 r3056  
    7070        class NodeListener;
    7171        class CommunicationListener;
    72 
    7372        namespace utility {
    7473                class OvlVis;
     
    204203         */
    205204        void bind(CommunicationListener* listener, const ServiceID& sid);
    206        
     205
    207206        /**
    208207         * TODO
    209208         */
    210209        void unbind(CommunicationListener* listener, const ServiceID& sid);
    211        
     210
    212211        /**
    213212         * TODO
    214213         */
    215214        void bind(NodeListener* listener);
    216        
     215
    217216        /**
    218217         * TODO
     
    289288         */
    290289        virtual void incomingRouteMessage( Message* msg );
    291        
     290
    292291        /**
    293292         * see OverlayStructureEvents.h, called from specific OverlayInterface class
     
    295294        virtual void onNodeJoin( const NodeID& node );
    296295
    297        
     296
    298297        /**
    299298         * TODO, for timer events
     
    407406        LinkMapping linkMapping;
    408407
    409        
    410         /**
    411          * nodes with pending joines. TODO: should be cleaned every 
     408
     409        /**
     410         * nodes with pending joines. TODO: should be cleaned every
    412411         * some seconds, add timestamps to each, and check on occasion
    413412         */
  • source/ariba/overlay/modules/OverlayInterface.cpp

    r2473 r3056  
    5757
    5858OverlayInterface::~OverlayInterface(){
    59         baseoverlay.unbind( OVERLAY_SERVICE_ID );
     59        baseoverlay.unbind( this, OVERLAY_SERVICE_ID );
    6060}
    6161
Note: See TracChangeset for help on using the changeset viewer.