Changeset 3037


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

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

Files:
4 deleted
23 edited

Legend:

Unmodified
Added
Removed
  • sample/pingpong/PingPong.cpp

    r2483 r3037  
    1212use_logging_cpp( PingPong );
    1313
    14 // the service id of the ping pong service
     14// the service that the pingpong wants to use
    1515ServiceID PingPong::PINGPONG_ID = ServiceID( 111 );
    1616
     
    4040
    4141        // get initiator flag
    42         this->isInitiator = Configuration::instance().read<bool> ("node.initiator");
     42        this->isInitiator = Configuration::instance().read<bool>("node.initiator");
    4343
    4444        // get node name
    4545        Name nodeName = Name::UNSPECIFIED;
    46         if (config.exists("node.name")) nodeName
    47                         = config.read<string> ("node.name");
     46        if (config.exists("node.name")) nodeName = config.read<string> ("node.name");
    4847
    4948        // configure ariba module
    5049        if (config.exists("ariba.ip.addr")) ariba->setProperty("ip.addr",
    51                         config.read<string> ("ariba.ip.addr"));
     50                        config.read<string>("ariba.ip.addr"));
    5251        if (config.exists("ariba.tcp.port")) ariba->setProperty("tcp.port",
    53                         config.read<string> ("ariba.tcp.port"));
     52                        config.read<string>("ariba.tcp.port"));
    5453        if (config.exists("ariba.udp.port")) ariba->setProperty("udp.port",
    55                         config.read<string> ("ariba.udp.port"));
     54                        config.read<string>("ariba.udp.port"));
    5655        if (config.exists("ariba.bootstrap.hints")) ariba->setProperty("bootstrap.hints",
    57                         config.read<string> ("ariba.bootstrap.hints"));
     56                        config.read<string>("ariba.bootstrap.hints"));
    5857
    5958        // start ariba module
     
    7170
    7271        // bind communication and node listener
    73         node->bind( this );
    74         node->bind( this, PingPong::PINGPONG_ID);
    75        
     72        node->bind( this );                       /*NodeListener*/
     73        node->bind( this, PingPong::PINGPONG_ID); /*CommunicationListener*/
     74
    7675        // start the ping timer. if we are not
    7776        // the initiator this will happen in onJoinCompleted
     
    7978
    8079        // ping pong started up...
    81         logging_info( "pingpong started up ");
     80        logging_info( "pingpong starting up with"
     81                        << " [spovnetid " << node->getSpoVNetId().toString() << "]"
     82                        << " and [nodeid " << node->getNodeId().toString() << "]" );
    8283}
    8384
     
    9192
    9293        // unbind communication and node listener
    93         node->unbind( this );
    94         node->unbind( this, PingPong::PINGPONG_ID );
     94        node->unbind( this );                        /*NodeListener*/
     95        node->unbind( this, PingPong::PINGPONG_ID ); /*CommunicationListener*/
    9596
    9697        // leave spovnet
     
    110111// node listener interface
    111112void PingPong::onJoinCompleted( const SpoVNetID& vid ) {
    112         logging_info( "pingpong node join completed, spovnetid=" << vid.toString() );
     113        logging_error( "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX pingpong node join completed, spovnetid=" << vid.toString() );
    113114
    114115        // start the timer to ping every second
     
    117118
    118119void PingPong::onJoinFailed( const SpoVNetID& vid ) {
    119         logging_error(" pingpong node join failed, spovnetid=" << vid.toString() );
     120        logging_error("pingpong node join failed, spovnetid=" << vid.toString() );
     121}
     122
     123void PingPong::onLeaveCompleted( const SpoVNetID& vid ){
     124        logging_info("pingpong node leave completed, spovnetid=" << vid.toString() );
     125}
     126
     127void PingPong::onLeaveFailed( const SpoVNetID& vid ){
     128        logging_error("pingpong node leave failed, spovnetid=" << vid.toString() );
     129}
     130
     131// timer event
     132void PingPong::eventFunction() {
     133
     134        // we ping all nodes that are known in the overlay structure
     135        // this can be all nodes (OneHop) overlay or just some neighbors
     136        // in case of a Chord or Kademlia structure
     137
     138        logging_info( "pinging overlay neighbors with ping id " << ++pingId );
     139
     140        PingPongMessage pingmsg( pingId );
     141
     142        //-----------------------------------------------------------------------
     143        // Option 1: get all neighboring nodes and send the message to each
     144        //-----------------------------------------------------------------------
     145        vector<NodeID> nodes = node->getNeighborNodes();
     146        BOOST_FOREACH( NodeID nid, nodes ){
     147                node->sendMessage( pingmsg, nid, PingPong::PINGPONG_ID );
     148        }
     149
     150        //-----------------------------------------------------------------------
     151        // Option 2: send a "broadcast message" that actually does the same thing
     152        //           internally, gets all neighboring nodes and sends the message
     153        //-----------------------------------------------------------------------
     154        // node->sendBroadcastMessage( pingmsg, PingPong::PINGPONG_ID );
    120155}
    121156
     
    127162void PingPong::onMessage(const DataMessage& msg, const NodeID& remote, const LinkID& lnk) {
    128163
    129         PingPongMessage* pingmsg = msg.getMessage()->decapsulate<PingPongMessage> ();
     164        PingPongMessage* pingmsg = msg.getMessage()->convert<PingPongMessage> ();
    130165
    131166        logging_info( "received ping message on link " << lnk.toString()
     
    134169}
    135170
    136 // timer event
    137 void PingPong::eventFunction() {
    138        
    139         // we ping all nodes that are known in the overlay structure
    140         // this can be all nodes (OneHop) overlay or just some neighbors
    141         // in case of a Chord or Kademlia structure
    142        
    143         logging_info( "pinging overlay neighbors with ping id " << ++pingId );
    144 
    145         PingPongMessage pingmsg( pingId );
    146         node->sendBroadcastMessage( pingmsg, PingPong::PINGPONG_ID );
     171void PingPong::onLinkUp(const LinkID& lnk, const NodeID& remote){
     172        logging_info( "received link-up event for link " << lnk.toString()
     173                        << " and node " << remote.toString() );
     174}
     175
     176void PingPong::onLinkDown(const LinkID& lnk, const NodeID& remote){
     177        logging_info( "received link-down event for link " << lnk.toString()
     178                        << " and node " << remote.toString() );
     179}
     180
     181void PingPong::onLinkChanged(const LinkID& lnk, const NodeID& remote){
     182        logging_info( "received link-changed event for link " << lnk.toString()
     183                        << " and node " << remote.toString() );
     184}
     185
     186void PingPong::onLinkFail(const LinkID& lnk, const NodeID& remote){
     187        logging_info( "received link-failed event for link " << lnk.toString()
     188                        << " and node " << remote.toString() );
     189}
     190
     191void PingPong::onLinkQoSChanged(const LinkID& lnk, const NodeID& remote, const LinkProperties& prop){
     192        logging_info( "received link-qos-changed event for link " << lnk.toString()
     193                                << " and node " << remote.toString()
     194                                << " with link properties " << prop.toString() );
     195}
     196
     197void PingPong::onMessageSent(seqnum_t seq_num, bool failed, const DataMessage& msg ){
     198        logging_info( "received message sent event for seqnum " << seq_num
     199                        << " with result " << failed );
    147200}
    148201
  • sample/pingpong/PingPong.h

    r2483 r3037  
    3737        virtual bool onLinkRequest(const NodeID& remote, const DataMessage& msg);
    3838        virtual void onMessage(const DataMessage& msg, const NodeID& remote, const LinkID& lnk= LinkID::UNSPECIFIED);
     39        virtual void onLinkUp(const LinkID& lnk, const NodeID& remote);
     40        virtual void onLinkDown(const LinkID& lnk, const NodeID& remote);
     41        virtual void onLinkChanged(const LinkID& lnk, const NodeID& remote);
     42        virtual void onLinkFail(const LinkID& lnk, const NodeID& remote);
     43        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);
    3945
    4046        // node listener interface
    4147        virtual void onJoinCompleted( const SpoVNetID& vid );
    4248        virtual void onJoinFailed( const SpoVNetID& vid );
     49        virtual void onLeaveCompleted( const SpoVNetID& vid );
     50        virtual void onLeaveFailed( const SpoVNetID& vid );
    4351
    4452        // startup wrapper interface
     
    5462        Node* node;
    5563
    56         // flag, wheter this node initiates or just joins the spovnet
     64        // flag, whether this node initiates or just joins the spovnet
    5765        bool isInitiator;
    5866
  • source/ariba/AribaModule.cpp

    r2467 r3037  
    4646#include "ariba/utility/misc/Helper.h"
    4747#include "ariba/utility/misc/StringFormat.h"
    48 
    49 // hack includes
    50 #include "ariba/interface/UnderlayAbstraction.h"
     48#include "ariba/communication/BaseCommunication.h"
    5149#include "ariba/communication/EndpointDescriptor.h"
    5250#include "ariba/communication/modules/network/NetworkLocator.h"
    5351
    5452using namespace ariba::utility::Helper;
    55 using ariba::interface::UnderlayAbstraction;
     53using ariba::communication::BaseCommunication;
    5654using ariba::communication::EndpointDescriptor;
    5755
     
    6159
    6260        // init with default values
    63         this->underlay_abs = NULL;
     61        this->base_comm = NULL;
    6462        this->ip_addr = NULL;
    6563        this->tcp_port = 41402;
     
    132130        }
    133131
    134         //std::cout << "added bootstrap info: " << getBootstrapHints() << std::endl;
     132        //logging_debug( "added bootstrap info: " << getBootstrapHints() );
    135133}
    136134
     
    154152
    155153        // init variables
    156         underlay_abs = NULL;
     154        base_comm = NULL;
    157155}
    158156
     
    161159
    162160        // preconditions
    163         assert(underlay_abs == NULL);
     161        assert(base_comm == NULL);
    164162        assert(!started);
    165163
    166164        // create the base communication component
    167165        started = true;
    168         underlay_abs = new interface::UnderlayAbstraction();
     166        base_comm = new BaseCommunication();
    169167}
    170168
     
    173171
    174172        // preconditions
    175         assert(underlay_abs != NULL);
     173        assert(base_comm != NULL);
    176174        assert(started);
    177175
    178176        // delete base communication component
    179177        started = false;
    180         delete underlay_abs;
     178        delete base_comm;
    181179}
    182180
  • source/ariba/AribaModule.h

    r2454 r3037  
    6464class NetworkLocator;
    6565}
    66 namespace interface {
    67 class UnderlayAbstraction;
     66namespace communication {
     67class BaseCommunication;
    6868}
    6969
     
    185185                        const Name& spovnet) const;
    186186
    187         // TODO: merge with old interface
    188         interface::UnderlayAbstraction* underlay_abs;
     187        communication::BaseCommunication* base_comm;
    189188
    190189        // TODO: use "abstract" representations here!
  • source/ariba/LinkProperties.cpp

    r2409 r3037  
    5252}
    5353
     54string LinkProperties::toString() const {
     55        std::ostringstream buf;
     56        buf << "[reliable=" << (reliable ? "yes" : "no") << "]";
     57        return buf.str();
     58}
     59
    5460} // namespace ariba
  • source/ariba/LinkProperties.h

    r2436 r3037  
    4040#define LINKPROPERTIES_H_
    4141
     42#include <string>
     43#include <iostream>
     44#include <sstream>
     45
     46using std::string;
     47
    4248namespace ariba {
    4349// forward declaration
     
    5258        ~LinkProperties();
    5359
     60        string toString() const;
    5461        static const LinkProperties DEFAULT;
    5562
  • source/ariba/Makefile.am

    r2467 r3037  
    256256
    257257libariba_la_SOURCES += \
    258   interface/UnderlayAbstraction.cpp \
    259   interface/AribaContext.cpp \
    260258  interface/ServiceInterface.cpp
    261259
  • source/ariba/Node.cpp

    r2482 r3037  
    4141#include "ariba/overlay/BaseOverlay.h"
    4242#include "ariba/utility/types/OverlayParameterSet.h"
    43 #include "ariba/interface/AribaContext.h"
    4443#include "ariba/interface/ServiceInterface.h"
    45 #include "ariba/interface/UnderlayAbstraction.h"
    4644#include "ariba/communication/EndpointDescriptor.h"
    4745
    4846using ariba::communication::EndpointDescriptor;
    49 using ariba::interface::UnderlayAbstraction;
    5047
    5148namespace ariba {
     
    6461                nodeListener(NULL), commListener(listener) {
    6562        }
    66        
     63
    6764        ~ServiceInterfaceWrapper() {
    6865        }
    6966
    7067protected:
    71         void onOverlayCreate(const SpoVNetID& id) {
    72 
    73         }
    74 
    75         void onOverlayDestroy(const SpoVNetID& id) {
    76 
    77         }
    7868
    7969        bool isJoinAllowed(const NodeID& nodeid, const SpoVNetID& spovnetid) {
     
    9585        void onJoinFail(const SpoVNetID& spovnetid) {
    9686                if (nodeListener != NULL) nodeListener->onJoinFailed(spovnetid);
     87        }
     88
     89        void onLeaveSuccess( const SpoVNetID& spovnetid ){
     90                if (nodeListener != NULL) nodeListener->onLeaveCompleted(spovnetid);
     91        }
     92
     93        void onLeaveFail( const SpoVNetID& spovnetid ){
     94                if (nodeListener != NULL) nodeListener->onLeaveFailed(spovnetid);
    9795        }
    9896
     
    131129
    132130Node::Node(AribaModule& ariba_mod, const Name& node_name) :
    133         ariba_mod(ariba_mod), name(node_name), context(NULL) {
     131        ariba_mod(ariba_mod), name(node_name), base_overlay(NULL) {
    134132}
    135133
     
    137135}
    138136
     137//TODO: Implement error handling: no bootstrap node available
    139138void Node::join(const Name& vnetname) {
    140139        spovnetId = vnetname.toSpoVNetId();
    141140        nodeId = generateNodeId(name);
    142         this->context = ariba_mod.underlay_abs->joinSpoVNet(spovnetId,
    143                                 *ariba_mod.getBootstrapNode(vnetname), nodeId,
    144                                 ariba_mod.ip_addr, ariba_mod.tcp_port);
    145 }
    146 
    147 //TODO: Implement error handling: no bootstrap node available
     141
     142        //logging("joining spovnet on"
     143        //              << " [spovnetid=]" << spovnetId.toString()
     144        //              << " [nodeid=]" << nodeId.toString() );
     145
     146        //logging_info("starting base communication...");
     147        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 );
     151
     152        const communication::EndpointDescriptor* ep =
     153                        ariba_mod.getBootstrapNode(vnetname);
     154        if( ep == NULL ) return;
     155
     156        base_overlay->joinSpoVNet( spovnetId, *ep);
     157}
     158
    148159void Node::initiate(const Name& vnetname, const SpoVNetProperties& parm) {
    149160        utility::OverlayParameterSet ovrpset =
    150                         (utility::OverlayParameterSet::_OverlayStructure) 
     161                        (utility::OverlayParameterSet::_OverlayStructure)
    151162                        parm.getBaseOverlayType();
    152163
     
    154165        nodeId = generateNodeId(name);
    155166
    156         this->context = ariba_mod.underlay_abs->createSpoVNet(
    157                                 spovnetId, nodeId, ariba_mod.ip_addr,
    158                                 ariba_mod.tcp_port);
     167        //logging("joining spovnet on"
     168        //                      << " [spovnetid=]" << spovnetId.toString()
     169        //                      << " [nodeid=]" << nodeId.toString() );
     170
     171        //logging_info("starting base communication...");
     172        ariba_mod.base_comm->start(ariba_mod.ip_addr, ariba_mod.tcp_port);
     173
     174        //logging_info("starting base overlay...");
     175        base_overlay = new BaseOverlay( *ariba_mod.base_comm, nodeId );
     176        base_overlay->createSpoVNet( spovnetId );
    159177
    160178        ariba_mod.addBootstrapNode(vnetname,
    161                 new EndpointDescriptor(this->context->
    162                 getBaseCommunication().getEndpointDescriptor()));
     179                new EndpointDescriptor(ariba_mod.base_comm->getEndpointDescriptor()));
    163180}
    164181
    165182void Node::leave() {
    166         ariba_mod.underlay_abs->leaveSpoVNet( context );
    167         context = NULL;
     183        base_overlay->leaveSpoVNet();
     184        ariba_mod.base_comm->stop();
     185
     186        delete base_overlay;
     187        base_overlay = NULL;
    168188}
    169189
     
    177197
    178198const NodeID& Node::getNodeId(const LinkID& lid) const {
    179         return nodeId;
     199        if( lid == LinkID::UNSPECIFIED ) return nodeId;
     200        else return base_overlay->getNodeID( lid );
    180201}
    181202
     
    185206}
    186207
     208vector<NodeID> Node::getNeighborNodes() const {
     209        return base_overlay->getOverlayNeighbors();
     210}
     211
    187212LinkID Node::establishLink(const NodeID& nid, const ServiceID& sid,
    188213                const LinkProperties& req, const DataMessage& msg) {
    189         return context->getOverlay().establishLink(nid, sid);
     214        return base_overlay->establishLink(nid, sid);
    190215}
    191216
    192217void Node::dropLink(const LinkID& lnk) {
    193         context->getOverlay().dropLink(lnk);
     218        base_overlay->dropLink(lnk);
    194219}
    195220
    196221seqnum_t Node::sendMessage(const DataMessage& msg, const NodeID& nid,
    197222                const ServiceID& sid, const LinkProperties& req) {
    198         return context->getOverlay().sendMessage((Message*) msg, nid, sid);
     223        return base_overlay->sendMessage((Message*) msg, nid, sid);
    199224}
    200225
    201226seqnum_t Node::sendMessage(const DataMessage& msg, const LinkID& lnk) {
    202         return context->getOverlay().sendMessage((Message*) msg, lnk);
     227        return base_overlay->sendMessage((Message*) msg, lnk);
    203228}
    204229
    205230void Node::sendBroadcastMessage(const DataMessage& msg, const ServiceID& sid) {
    206         return context->getOverlay().broadcastMessage((Message*)msg, sid);
     231        return base_overlay->broadcastMessage((Message*)msg, sid);
    207232}
    208233
    209234void Node::bind(NodeListener* listener) {
    210         context->getOverlay().bind(new ServiceInterfaceWrapper(listener),
     235        base_overlay->bind(new ServiceInterfaceWrapper(listener),
    211236                        Node::anonymousService);
    212237}
    213238
    214239void Node::unbind(NodeListener* listener) {
    215         delete context->getOverlay().unbind(Node::anonymousService);
     240        delete base_overlay->unbind(Node::anonymousService);
    216241}
    217242
    218243void Node::bind(CommunicationListener* listener, const ServiceID& sid) {
    219         context->getOverlay().bind(new ServiceInterfaceWrapper(listener), sid);
     244        base_overlay->bind(new ServiceInterfaceWrapper(listener), sid);
    220245}
    221246
    222247void Node::unbind(CommunicationListener* listener, const ServiceID& sid) {
    223         delete context->getOverlay().unbind(sid);
     248        delete base_overlay->unbind(sid);
    224249}
    225250
  • source/ariba/Node.h

    r2473 r3037  
    4545}
    4646
     47#include <vector>
    4748#include "Module.h"
    4849#include "Identifiers.h"
     
    5455#include "DataMessage.h"
    5556
     57using std::vector;
     58
    5659namespace ariba {
    5760
    5861// forward declaration
    5962namespace interface {
    60 class AribaContext;
    6163class ServiceInterface;
     64}
     65
     66namespace overlay {
     67class BaseOverlay;
    6268}
    6369
     
    6672 *
    6773 * @author Sebastian Mies <mies@tm.uka.de>
     74 * @author Christoph Mayer <mayer@tm.uka.de>
    6875 */
    6976class Node: public Module {
     
    181188         */
    182189        const Name getNodeName(const LinkID& lid = LinkID::UNSPECIFIED) const;
     190
     191        /**
     192         * Get a list of neighboring nodes in the overlay structure.
     193         * The number and identities of nodes depends highly on the
     194         * used overlay structure.
     195         *
     196         * @return a list of NodeIDs that are neighbors in the overlay structure
     197         * @see sendBroadcastMessage
     198         */
     199        vector<NodeID> getNeighborNodes() const;
    183200
    184201        //--- communication ---
     
    241258         * @param msg The message to be send
    242259         * @param sid The id of the service that should receive the message
     260         * @see getNeighborNodes
    243261         */
    244262        void sendBroadcastMessage(const DataMessage& msg, const ServiceID& sid);
     
    317335
    318336        // member variables
    319         Name name;              //< node name
    320         AribaModule& ariba_mod; //< ariba module
    321         SpoVNetID spovnetId;    //< current spovnet id
    322         NodeID nodeId;          //< current node id
     337        Name name;                             //< node name
     338        AribaModule& ariba_mod;                //< ariba module
     339        SpoVNetID spovnetId;                   //< current spovnet id
     340        NodeID nodeId;                             //< current node id
     341        overlay::BaseOverlay* base_overlay;    //< the base overlay
    323342
    324343        // delegates
    325         interface::AribaContext* context;
    326344        static ServiceID anonymousService;
    327345};
  • source/ariba/NodeListener.cpp

    r2409 r3037  
    4242namespace ariba {
    4343
    44 // dummy
    4544NodeListener::NodeListener() {
    4645}
    4746
    48 // dummy
    4947NodeListener::~NodeListener() {
    5048}
    5149
    52 // dummy
    5350void NodeListener::onJoinCompleted(const SpoVNetID& vid ) {
    5451}
    5552
    56 // dummy
    5753void NodeListener::onJoinFailed(const SpoVNetID& vid ) {
    5854}
    5955
    60 // dummy
    6156void NodeListener::onLeaveCompleted(const SpoVNetID& vid ) {
    6257}
    6358
    64 // dummy
    6559void NodeListener::onLeaveFailed(const SpoVNetID& vid ) {
    6660}
  • source/ariba/communication/BaseCommunication.cpp

    r2802 r3037  
    5555const BaseCommunication::LinkDescriptor BaseCommunication::LinkDescriptor::UNSPECIFIED;
    5656
    57 BaseCommunication::BaseCommunication(const NetworkLocator* _locallocator, const uint16_t _listenport)
    58         : messageReceiver( NULL ), currentSeqnum( 0 ), listenport( _listenport ) {
     57BaseCommunication::BaseCommunication()
     58        : messageReceiver(NULL), network(NULL), transport(NULL){
     59}
     60
     61BaseCommunication::~BaseCommunication(){
     62}
     63
     64void BaseCommunication::start(const NetworkLocator* _locallocator, const uint16_t _listenport){
     65
     66        currentSeqnum = 0;
     67        listenport = _listenport;
    5968
    6069        logging_info( "starting up base communication and creating transports ..." );
     
    139148}
    140149
    141 BaseCommunication::~BaseCommunication() {
     150void BaseCommunication::stop() {
    142151
    143152        logging_info( "stopping base communication and transport ..." );
     
    210219        // warn if this link has some queued messages attached
    211220        if( descriptor.waitingmsg.size() > 0 ){
    212                 logging_warn( "dropping link " << link.toString() << 
     221                logging_warn( "dropping link " << link.toString() <<
    213222                        " that has " << descriptor.waitingmsg.size() << " waiting messages" );
    214223        }
     
    368377                const NetworkLocator* remoteLocator = dynamic_cast<const NetworkLocator*>(message->getSourceAddress());
    369378
    370                 logging_debug( "localLocator=" << localLocator->toString() 
     379                logging_debug( "localLocator=" << localLocator->toString()
    371380                                << " remoteLocator=" << remoteLocator->toString());
    372381
     
    419428                // the link is now open
    420429                //
    421                
     430
    422431                BOOST_FOREACH( CommunicationEvents* i, eventListener ){
    423432                        i->onLinkUp( localLink, localLocator, remoteLocator );
     
    444453
    445454                linkDesc.remoteLink = spovmsg->getLocalLink();
    446                 linkDesc.linkup = true; 
    447        
     455                linkDesc.linkup = true;
     456
    448457                logging_debug( "the link is now up with local link id " << spovmsg->getRemoteLink().toString() );
    449458
     
    452461                }
    453462
    454                 if( linkDesc.waitingmsg.size() > 0 ){ 
     463                if( linkDesc.waitingmsg.size() > 0 ){
    455464                        logging_info( "sending out queued messages on link " << linkDesc.localLink.toString() );
    456465
     
    564573        for( ; i != iend; i++){
    565574                if( (*i).localLink != localLink) continue;
    566                
     575
    567576                BOOST_FOREACH( Message* msg, i->waitingmsg ){
    568577                        delete msg;
  • source/ariba/communication/BaseCommunication.h

    r2483 r3037  
    122122 */
    123123class BaseCommunication : public MessageReceiver, NetworkChangeInterface {
    124 
    125124        use_logging_h(BaseCommunication);
    126 
    127125public:
    128         /**
    129          * Constructs a Base Communication instance.
    130          * Listens default on port number 41402
    131          */
    132         BaseCommunication(const NetworkLocator* _locallocator, const uint16_t _listenport);
    133 
    134         /**
    135          * Destructs a Base Communication instance
     126
     127        /**
     128         * Default ctor that just creates an empty
     129         * non functional base communication
     130         */
     131        BaseCommunication();
     132
     133        /**
     134         * Default dtor that does nothing
    136135         */
    137136        virtual ~BaseCommunication();
     137
     138        /**
     139         * Startup the base communication, start modules etc.
     140         */
     141        void start(const NetworkLocator* _locallocator, const uint16_t _listenport);
     142
     143        /**
     144         * stop the base communication, stop modules etc.
     145         */
     146        void stop();
    138147
    139148        /**
  • source/ariba/communication/EndpointDescriptor.cpp

    r2457 r3037  
    5757
    5858EndpointDescriptor::EndpointDescriptor(const Locator* _locator){
     59        if( _locator == NULL ) return;
     60
    5961        locator = new IPv4Locator(*dynamic_cast<IPv4Locator*>((Locator*)_locator));
    6062        isUnspec = false;
  • source/ariba/communication/EndpointDescriptor.h

    r3036 r3037  
    5151using ariba::communication::IPv4Locator;
    5252
    53 // needed for friend decleration
    54 // in different namespace
    55 namespace ariba {
    56 namespace interface {
    57         class UnderlayAbstraction;
    58 }}
    59 
    6053namespace ariba {
    6154namespace communication {
     
    6760
    6861        friend class BaseCommunication;
    69         friend class ariba::interface::UnderlayAbstraction;
    7062
    7163public:
  • source/ariba/interface/ServiceInterface.cpp

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

    r2473 r3037  
    7474
    7575protected:
    76         virtual void onOverlayCreate( const SpoVNetID& id );
    77         virtual void onOverlayDestroy( const SpoVNetID& id );
    78 
    7976        virtual bool isJoinAllowed( const NodeID& nodeid, const SpoVNetID& spovnetid );
    8077        virtual void onNodeJoin( const NodeID& nodeid, const SpoVNetID& spovnetid );
     
    8380        virtual void onJoinSuccess( const SpoVNetID& spovnetid );
    8481        virtual void onJoinFail( const SpoVNetID& spovnetid );
     82        virtual void onLeaveSuccess( const SpoVNetID& spovnetid );
     83        virtual void onLeaveFail( const SpoVNetID& spovnetid );
    8584
    8685        virtual void onLinkUp( const LinkID& link, const NodeID& local, const NodeID& remote );
  • 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 );
  • source/ariba/utility/messages/Message.h

    r3036 r3037  
    235235                }
    236236                return NULL;
     237        }
     238       
     239        /**
     240         * The same as decapsulate, but this function
     241         * is used in the samples to make the semantics easier
     242         * to understand. The semantics is shown to be: you get
     243         * a message and convert it to your type. Not as: you
     244         * get a message and have to extract your message from it.
     245         */ 
     246        template<class T>
     247        inline T* convert() {
     248                return decapsulate<T>();       
    237249        }
    238250
  • source/ariba/utility/misc/Helper.cpp

    r3036 r3037  
    4949        _ultoa_s (val, buf, 16, 10);
    5050#else
    51         sprintf (buf, "%u", val);
     51        sprintf (buf, "%lu", val);
    5252#endif
    5353
     
    6262        _ltoa_s (val, buf, 16, 10);
    6363#else
    64         sprintf (buf, "%i", val);
     64        sprintf (buf, "%li", val);
    6565#endif
    6666
     
    7575        _ultoa_s (val, buf, 16, 16);
    7676#else
    77         sprintf (buf, "%x", val);
     77        sprintf (buf, "%lx", val);
    7878#endif
    7979
     
    9393        _ltoa_s (val, buf, 16, 16);
    9494#else
    95         sprintf (buf, "%x", val);
     95        sprintf (buf, "%lx", val);
    9696#endif
    9797
  • source/ariba/utility/system/StartupInterface.h

    r3036 r3037  
    4545
    4646namespace ariba {
    47 namespace interface {
    48         class UnderlayAbstraction;
    49 }}
    50 
    51 using ariba::interface::UnderlayAbstraction;
    52 
    53 namespace ariba {
    5447namespace utility {
    5548
Note: See TracChangeset for help on using the changeset viewer.