Changeset 3037 for source/ariba/Node.cpp


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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.