Changeset 6822


Ignore:
Timestamp:
Nov 4, 2009, 11:20:00 AM (14 years ago)
Author:
Christoph Mayer
Message:

-ovlvis verschoben und 3dvis hinzu

Location:
source/ariba
Files:
4 added
6 edited

Legend:

Unmodified
Added
Removed
  • source/ariba/Makefile.am

    r6584 r6822  
    436436
    437437libariba_la_SOURCES += \
    438   utility/visual/OvlVis.cpp
    439 
    440 nobase_libariba_la_HEADERS += \
    441   utility/visual/OvlVis.h
    442  
     438  utility/visual/OvlVis.cpp \
     439  utility/visual/ServerVis.cpp \
     440  utility/visual/DddVis.cpp
     441
     442nobase_libariba_la_HEADERS += \
     443  utility/visual/OvlVis.h \
     444  utility/visual/ServerVis.h \
     445  utility/visual/DddVis.h
  • source/ariba/Node.cpp

    r6266 r6822  
    120120
    121121NodeID Node::generateNodeId(const Name& name) const {
    122         if (name == Name::UNSPECIFIED) return Name::random().toNodeId();
     122        if (name == Name::UNSPECIFIED) return NodeID(Identifier::random());
    123123        else return name.toNodeId();
    124124}
  • source/ariba/overlay/BaseOverlay.cpp

    r6797 r6822  
    5656
    5757#include "ariba/utility/visual/OvlVis.h"
     58#include "ariba/utility/visual/DddVis.h"
     59#include "ariba/utility/visual/ServerVis.h"
    5860
    5961namespace ariba {
    6062namespace overlay {
     63
     64#define visual                          ariba::utility::DddVis::instance()
     65#define visualIdOverlay         ariba::utility::ServerVis::NETWORK_ID_BASE_OVERLAY
     66#define visualIdBase            ariba::utility::ServerVis::NETWORK_ID_BASE_COMMUNICATION
    6167
    6268class ValueEntry {
    6369public:
    6470        ValueEntry( const Data& value ) : ttl(0), last_update(time(NULL)),
    65                 last_change(time(NULL)), value(value.clone()) {
     71        last_change(time(NULL)), value(value.clone()) {
    6672        }
    6773
     
    122128                vector<Data> vect;
    123129                BOOST_FOREACH( ValueEntry& e, values )
    124                         vect.push_back( e.get_value() );
     130                vect.push_back( e.get_value() );
    125131                return vect;
    126132        }
     
    163169                                                if (verbose)
    164170                                                        std::cout << "DHT: Republished value. Refreshing value timestamp."
    165                                                         << std::endl;
     171                                                                << std::endl;
    166172                                                return;
    167173                                        }
     
    171177                                if (verbose)
    172178                                        std::cout << "DHT: Added value to "
    173                                         << " key=" << key << " with value=" << value << std::endl;
     179                                                << " key=" << key << " with value=" << value << std::endl;
    174180                                entry.values.push_back( ValueEntry( value ) );
    175181                                entry.values.back().set_ttl(ttl);
     
    181187                if (verbose)
    182188                        std::cout << "DHT: New key value pair "
    183                         << " key=" << key << " with value=" << value << std::endl;
     189                                << " key=" << key << " with value=" << value << std::endl;
    184190
    185191                // add new entry
     
    274280LinkDescriptor* BaseOverlay::getDescriptor( const LinkID& link, bool communication ) {
    275281        BOOST_FOREACH( LinkDescriptor* lp, links )
    276                 if ((communication ? lp->communicationId : lp->overlayId) == link)
    277                         return lp;
     282                                if ((communication ? lp->communicationId : lp->overlayId) == link)
     283                                        return lp;
    278284        return NULL;
    279285}
     
    281287const LinkDescriptor* BaseOverlay::getDescriptor( const LinkID& link, bool communication ) const {
    282288        BOOST_FOREACH( const LinkDescriptor* lp, links )
    283                 if ((communication ? lp->communicationId : lp->overlayId) == link)
    284                         return lp;
     289                                if ((communication ? lp->communicationId : lp->overlayId) == link)
     290                                        return lp;
    285291        return NULL;
    286292}
     
    313319        // search for a descriptor that is already up
    314320        BOOST_FOREACH( LinkDescriptor* lp, links )
    315                 if (lp->autolink && lp->remoteNode == node && lp->service == service && lp->up && lp->keepAliveMissed == 0)
    316                         return lp;
     321                                if (lp->autolink && lp->remoteNode == node && lp->service == service && lp->up && lp->keepAliveMissed == 0)
     322                                        return lp;
    317323        // if not found, search for one that is about to come up...
    318324        BOOST_FOREACH( LinkDescriptor* lp, links )
    319                 if (lp->autolink && lp->remoteNode == node && lp->service == service && lp->keepAliveMissed == 0 )
    320                         return lp;
     325        if (lp->autolink && lp->remoteNode == node && lp->service == service && lp->keepAliveMissed == 0 )
     326                return lp;
    321327        return NULL;
    322328}
     
    328334                if (!ld->up) continue;
    329335                OverlayMsg msg( OverlayMsg::typeLinkAlive,
    330                         OverlayInterface::OVERLAY_SERVICE_ID, nodeId, ld->remoteNode );
     336                                OverlayInterface::OVERLAY_SERVICE_ID, nodeId, ld->remoteNode );
    331337                if (ld->relayed) msg.setRouteRecord(true);
    332338                send_link( &msg, ld->overlayId );
     
    416422                        bool found = false;
    417423                        BOOST_FOREACH(NodeID& id, nodes)
    418                                 if (id  == ld->remoteNode) found = true;
     424                        if (id  == ld->remoteNode) found = true;
    419425                        if (found) continue;
    420426                        i++;
    421427                        nodes.push_back(ld->remoteNode);
    422428                        if ((i%1) == 1) s << "<tr style=\"background-color=#f0f0f0;\">";
    423                                 else s << "<tr>";
     429                        else s << "<tr>";
    424430                        s << "<td>" << ld->overlayId.toString().substr(0,4) << "..</td>";
    425431                        s << "<td>" << ld->remoteNode.toString().substr(0,4) << "..</td>";
     
    455461        LinkDescriptor* rhsld = getDescriptor(rhs);
    456462        if (lhsld==NULL || rhsld==NULL
    457                 || !lhsld->up || !rhsld->up
    458                 || lhsld->remoteNode != rhsld->remoteNode) return -1;
     463                        || !lhsld->up || !rhsld->up
     464                        || lhsld->remoteNode != rhsld->remoteNode) return -1;
    459465
    460466        if ((lhsld->remoteLink^lhsld->overlayId)<(rhsld->remoteLink^lhsld->overlayId)  )
     
    503509        if (destination == nodeId) {
    504510                logging_warn("Sent message to myself. Handling message.")
    505                 Message msg;
     511                                Message msg;
    506512                msg.encapsulate(message);
    507513                handleMessage( &msg, NULL );
     
    518524                        logging_warn("Could not send message. No relay hop found to "
    519525                                        << destination)
    520                         return -1;
     526                                        return -1;
    521527                }
    522528        }
     
    528534                if (next_id.isUnspecified()) {
    529535                        logging_warn("Could not send message. No next hop found to " <<
    530                                 destination );
     536                                        destination );
    531537                        return -1;
    532538                }
     
    568574        if (ldr->relayed) {
    569575                logging_debug("Resolving direct link for relayed link to "
    570                         << ldr->remoteNode);
     576                                << ldr->remoteNode);
    571577                ld = getRelayLinkTo( ldr->remoteNode );
    572578                if (ld==NULL) {
     
    592598
    593599seqnum_t BaseOverlay::send_node( OverlayMsg* message, const NodeID& remote,
    594         const ServiceID& service) {
     600                const ServiceID& service) {
    595601        message->setSourceNode(nodeId);
    596602        message->setDestinationNode(remote);
     
    627633                // relay link still used and alive?
    628634                if (ld==NULL
    629                         || !ld->isDirectVital()
    630                         || difftime(route.used, time(NULL)) > 8) {
     635                                || !ld->isDirectVital()
     636                                || difftime(route.used, time(NULL)) > 8) {
    631637                        logging_info("Forgetting relay information to node "
    632638                                        << route.node.toString() );
     
    658664        // handle relayed messages from real links only
    659665        if (ld == NULL
    660                 || ld->relayed
    661                 || message->getSourceNode()==nodeId ) return;
     666                        || ld->relayed
     667                        || message->getSourceNode()==nodeId ) return;
    662668
    663669        // update usage information
     
    691697                                // route has a shorter hop count or old link is dead? yes-> replace
    692698                                if (route.hops > message->getNumHops()
    693                                         || rld == NULL
    694                                         || !rld->isDirectVital()) {
     699                                                || rld == NULL
     700                                                || !rld->isDirectVital()) {
    695701                                        logging_info("Updating relay information to node "
    696                                                 << route.node.toString()
    697                                                 << " reducing to " << message->getNumHops() << " hops.");
     702                                                        << route.node.toString()
     703                                                        << " reducing to " << message->getNumHops() << " hops.");
    698704                                        route.hops = message->getNumHops();
    699705                                        route.link = ld->overlayId;
     
    710716                route.used = time(NULL);
    711717                logging_info("Remembering relay information to node "
    712                         << route.node.toString());
     718                                << route.node.toString());
    713719                relay_routes.push_back(route);
    714720        }
     
    739745
    740746BaseOverlay::BaseOverlay() :
    741         bc(NULL), overlayInterface(NULL), nodeId(NodeID::UNSPECIFIED),
    742         spovnetId(SpoVNetID::UNSPECIFIED), state(BaseOverlayStateInvalid),
    743         sideport(&SideportListener::DEFAULT), started(false), counter(0) {
     747                        bc(NULL), overlayInterface(NULL), nodeId(NodeID::UNSPECIFIED),
     748                        spovnetId(SpoVNetID::UNSPECIFIED), state(BaseOverlayStateInvalid),
     749                        sideport(&SideportListener::DEFAULT), started(false), counter(0) {
    744750        dht = new DHT();
    745751        localDHT = new DHT();
     
    818824                state = BaseOverlayStateCompleted;
    819825                BOOST_FOREACH( NodeListener* i, nodeListeners )
    820                         i->onJoinCompleted( spovnetId );
     826                i->onJoinCompleted( spovnetId );
    821827
    822828                //ovl.visChangeNodeIcon ( ovlId, nodeId, OvlVis::ICON_ID_CAMERA );
     
    853859        BOOST_FOREACH( LinkDescriptor* ld, links ) {
    854860                if( ld->service != OverlayInterface::OVERLAY_SERVICE_ID )
    855                 servicelinks.push_back( ld->overlayId );
     861                        servicelinks.push_back( ld->overlayId );
    856862        }
    857863
    858864        // drop all service links
    859865        BOOST_FOREACH( LinkID lnk, servicelinks )
    860                 dropLink( lnk );
     866        dropLink( lnk );
    861867
    862868        // let the node leave the spovnet overlay interface
     
    867873        // drop still open bootstrap links
    868874        BOOST_FOREACH( LinkID lnk, bootstrapLinks )
    869                 bc->dropLink( lnk );
     875        bc->dropLink( lnk );
    870876
    871877        // change to inalid state
    872878        state = BaseOverlayStateInvalid;
    873879        //ovl.visShutdown( ovlId, nodeId, string("") );
     880
     881        visual.visShutdown(visualIdOverlay, nodeId, "");
     882        visual.visShutdown(visualIdBase, nodeId, "");
    874883
    875884        // inform all registered services of the event
     
    898907
    899908                BOOST_FOREACH( NodeListener* i, nodeListeners )
    900                         i->onJoinFailed( spovnetId );
     909                i->onJoinFailed( spovnetId );
    901910
    902911                return;
    903912        }
     913
     914        visual.configure("127.0.0.1", 50005);
     915        //visual.configure("141.3.161.8", 50005);
     916        visual.visCreate(visualIdBase, nodeId, "", "");
     917        visual.visCreate(visualIdOverlay, nodeId, "", "");
    904918}
    905919
     
    907921
    908922const LinkID BaseOverlay::establishLink( const EndpointDescriptor& remoteEp,
    909         const NodeID& remoteId, const ServiceID& service ) {
     923                const NodeID& remoteId, const ServiceID& service ) {
    910924
    911925        // establish link via overlay
     
    914928        else
    915929
    916         // establish link directly if only ep is known
    917         if (remoteId.isUnspecified())
    918                 return establishDirectLink(remoteEp, service );
     930                // establish link directly if only ep is known
     931                if (remoteId.isUnspecified())
     932                        return establishDirectLink(remoteEp, service );
    919933
    920934}
     
    922936/// call base communication's establish link and add link mapping
    923937const LinkID BaseOverlay::establishDirectLink( const EndpointDescriptor& ep,
    924         const ServiceID& service ) {
     938                const ServiceID& service ) {
    925939
    926940        /// find a service listener
     
    941955        /// establish link and add mapping
    942956        logging_info("Establishing direct link " << ld->communicationId.toString()
    943                 << " using " << ep.toString());
     957                        << " using " << ep.toString());
    944958
    945959        return ld->communicationId;
     
    948962/// establishes a link between two arbitrary nodes
    949963const LinkID BaseOverlay::establishLink( const NodeID& remote,
    950         const ServiceID& service ) {
     964                const ServiceID& service ) {
    951965
    952966        // do not establish a link to myself!
     
    967981        // debug message
    968982        logging_info(
    969                 "Sending link request with"
    970                 << " link=" << ld->overlayId.toString()
    971                 << " node=" << ld->remoteNode.toString()
    972                 << " serv=" << ld->service.toString()
     983                        "Sending link request with"
     984                        << " link=" << ld->overlayId.toString()
     985                        << " node=" << ld->remoteNode.toString()
     986                        << " serv=" << ld->service.toString()
    973987        );
    974988
     
    10231037        if( ld == NULL ) {
    10241038                logging_error("Could not send message. "
    1025                         << "Link not found id=" << link.toString());
     1039                                << "Link not found id=" << link.toString());
    10261040                return -1;
    10271041        }
     
    10501064
    10511065seqnum_t BaseOverlay::sendMessage(const Message* message,
    1052         const NodeID& node, const ServiceID& service) {
     1066                const NodeID& node, const ServiceID& service) {
    10531067
    10541068        // find link for node and service
     
    10601074                // debug output
    10611075                logging_info( "No link to send message to node "
    1062                         << node.toString() << " found for service "
    1063                         << service.toString() << ". Creating auto link ..."
     1076                                << node.toString() << " found for service "
     1077                                << service.toString() << ". Creating auto link ..."
    10641078                );
    10651079
     
    11831197        // already bound? yes-> warning
    11841198        NodeListenerVector::iterator i =
    1185                 find( nodeListeners.begin(), nodeListeners.end(), listener );
     1199                        find( nodeListeners.begin(), nodeListeners.end(), listener );
    11861200        if( i != nodeListeners.end() ) {
    11871201                logging_warn("Node listener " << listener << " is already bound!" );
     
    12121226
    12131227void BaseOverlay::onLinkUp(const LinkID& id,
    1214         const address_v* local, const address_v* remote) {
     1228                const address_v* local, const address_v* remote) {
    12151229        logging_debug( "Link up with base communication link id=" << id );
    12161230
     
    12211235        if( std::find(bootstrapLinks.begin(), bootstrapLinks.end(), id) != bootstrapLinks.end() ){
    12221236                logging_info(
    1223                         "Join has been initiated by me and the link is now up. " <<
    1224                         "Sending out join request for SpoVNet " << spovnetId.toString()
     1237                                "Join has been initiated by me and the link is now up. " <<
     1238                                "Sending out join request for SpoVNet " << spovnetId.toString()
    12251239                );
    12261240
    12271241                // send join request message
    12281242                OverlayMsg overlayMsg( OverlayMsg::typeJoinRequest,
    1229                         OverlayInterface::OVERLAY_SERVICE_ID, nodeId );
     1243                                OverlayInterface::OVERLAY_SERVICE_ID, nodeId );
    12301244                JoinRequest joinRequest( spovnetId, nodeId );
    12311245                overlayMsg.encapsulate( &joinRequest );
     
    12491263                // -> wait for update message!
    12501264
    1251         // link mapping found? -> send update message with node-id and service id
     1265                // link mapping found? -> send update message with node-id and service id
    12521266        } else {
    12531267                logging_info( "onLinkUp descriptor (initiated locally):" << ld );
     
    12711285                        // note: necessary to validate the link on the remote side!
    12721286                        logging_info( "Sending out update" <<
    1273                                 " for service " << ld->service.toString() <<
    1274                                 " with local node id " << nodeId.toString() <<
    1275                                 " on link " << ld->overlayId.toString() );
     1287                                        " for service " << ld->service.toString() <<
     1288                                        " with local node id " << nodeId.toString() <<
     1289                                        " on link " << ld->overlayId.toString() );
    12761290
    12771291                        // compile and send update message
     
    12851299
    12861300void BaseOverlay::onLinkDown(const LinkID& id,
    1287         const address_v* local, const address_v* remote) {
     1301                const address_v* local, const address_v* remote) {
    12881302
    12891303        // erase bootstrap links
     
    13181332
    13191333void BaseOverlay::onLinkChanged(const LinkID& id,
    1320         const address_v* oldlocal, const address_v* newlocal,
    1321         const address_v* oldremote, const address_v* newremote) {
     1334                const address_v* oldlocal, const address_v* newlocal,
     1335                const address_v* oldremote, const address_v* newremote) {
    13221336
    13231337        // get descriptor for link
     
    13351349
    13361350void BaseOverlay::onLinkFail(const LinkID& id,
    1337         const address_v* local, const address_v* remote) {
     1351                const address_v* local, const address_v* remote) {
    13381352        logging_debug( "Link fail with base communication link id=" << id );
    13391353
     
    13531367
    13541368void BaseOverlay::onLinkQoSChanged(const LinkID& id, const address_v* local,
    1355         const address_v* remote, const QoSParameterSet& qos) {
     1369                const address_v* remote, const QoSParameterSet& qos) {
    13561370        logging_debug( "Link quality changed with base communication link id=" << id );
    13571371
     
    13631377
    13641378bool BaseOverlay::onLinkRequest( const LinkID& id, const address_v* local,
    1365         const address_v* remote ) {
     1379                const address_v* remote ) {
    13661380        logging_debug("Accepting link request from " << remote->to_string() );
    13671381        return true;
     
    13891403        if( joinReq->getSpoVNetID() != spovnetId ) {
    13901404                logging_error(
    1391                         "Received join request for spovnet we don't handle " <<
    1392                         joinReq->getSpoVNetID().toString() );
     1405                                "Received join request for spovnet we don't handle " <<
     1406                                joinReq->getSpoVNetID().toString() );
    13931407                return false;
    13941408        }
     
    14051419        assert( overlayInterface != NULL );
    14061420        logging_debug( "Using bootstrap end-point "
    1407                 << getEndpointDescriptor().toString() )
     1421                        << getEndpointDescriptor().toString() )
    14081422        OverlayParameterSet parameters = overlayInterface->getParameters();
    14091423        OverlayMsg retmsg( OverlayMsg::typeJoinReply,
    1410                 OverlayInterface::OVERLAY_SERVICE_ID, nodeId );
     1424                        OverlayInterface::OVERLAY_SERVICE_ID, nodeId );
    14111425        JoinReply replyMsg( spovnetId, parameters,
    14121426                        allow, getEndpointDescriptor() );
     
    14481462                // inform all registered services of the event
    14491463                BOOST_FOREACH( NodeListener* i, nodeListeners )
    1450                         i->onJoinFailed( spovnetId );
     1464                i->onJoinFailed( spovnetId );
    14511465
    14521466                delete replyMsg;
     
    14591473
    14601474        logging_debug( "Using bootstrap end-point "
    1461                 << replyMsg->getBootstrapEndpoint().toString() );
     1475                        << replyMsg->getBootstrapEndpoint().toString() );
    14621476
    14631477        // create overlay structure from spovnet parameter set
     
    14681482
    14691483                overlayInterface = OverlayFactory::create(
    1470                         *this, replyMsg->getParam(), nodeId, this );
     1484                                *this, replyMsg->getParam(), nodeId, this );
    14711485
    14721486                // overlay structure supported? no-> fail!
     
    15031517                // inform all registered services of the event
    15041518                BOOST_FOREACH( NodeListener* i, nodeListeners )
    1505                         i->onJoinCompleted( spovnetId );
     1519                i->onJoinCompleted( spovnetId );
    15061520
    15071521                delete replyMsg;
     
    15261540        const ServiceID& service = overlayMsg->getService();
    15271541        logging_debug( "Received data for service " << service.toString()
    1528                 << " on link " << overlayMsg->getDestinationLink().toString() );
     1542                        << " on link " << overlayMsg->getDestinationLink().toString() );
    15291543
    15301544        // delegate data message
    15311545        getListener(service)->onMessage(
    1532                 overlayMsg,
    1533                 overlayMsg->getSourceNode(),
    1534                 overlayMsg->getDestinationLink()
     1546                        overlayMsg,
     1547                        overlayMsg->getSourceNode(),
     1548                        overlayMsg->getDestinationLink()
    15351549        );
    15361550
     
    15501564        // update our link mapping information for this link
    15511565        bool changed =
    1552                 ( ld->remoteNode != overlayMsg->getSourceNode() )
    1553                 || ( ld->service != overlayMsg->getService() );
     1566                        ( ld->remoteNode != overlayMsg->getSourceNode() )
     1567                        || ( ld->service != overlayMsg->getService() );
    15541568
    15551569        // set parameters
     
    15911605
    15921606                logging_debug("Link id=" << ld->overlayId.toString() <<
    1593                         " has been denied by service " << ld->service.toString() << ", dropping link");
     1607                                " has been denied by service " << ld->service.toString() << ", dropping link");
    15941608
    15951609                // prevent onLinkDown calls to the service
     
    16681682        if (ldn == NULL) {
    16691683                logging_error( "No link request pending for "
    1670                         << overlayMsg->getDestinationLink().toString() );
     1684                                << overlayMsg->getDestinationLink().toString() );
    16711685                return false;
    16721686        }
     
    16811695        // debug message
    16821696        logging_debug( "Link request reply received. Establishing link"
    1683                 << " for service " << overlayMsg->getService().toString()
    1684                 << " with local id=" << overlayMsg->getDestinationLink()
    1685                 << " and remote link id=" << overlayMsg->getSourceLink()
    1686                 << " to " << overlayMsg->getSourceEndpoint().toString()
     1697                        << " for service " << overlayMsg->getService().toString()
     1698                        << " with local id=" << overlayMsg->getDestinationLink()
     1699                        << " and remote link id=" << overlayMsg->getSourceLink()
     1700                        << " to " << overlayMsg->getSourceEndpoint().toString()
    16871701        );
    16881702
     
    17021716        if( ldn->messageQueue.size() > 0 ) {
    17031717                logging_info( "Sending out queued messages on link " <<
    1704                         ldn->overlayId.toString() );
     1718                                ldn->overlayId.toString() );
    17051719                BOOST_FOREACH( Message* msg, ldn->messageQueue ) {
    17061720                        sendMessage( msg, ldn->overlayId );
     
    17151729        // try to replace relay link with direct link
    17161730        ldn->communicationId =
    1717                 bc->establishLink( overlayMsg->getSourceEndpoint() );
     1731                        bc->establishLink( overlayMsg->getSourceEndpoint() );
    17181732
    17191733        return true;
     
    17251739        if ( rld != NULL ) {
    17261740                logging_debug("Keep-Alive for " <<
    1727                         overlayMsg->getDestinationLink() );
     1741                                overlayMsg->getDestinationLink() );
    17281742                if (overlayMsg->isRouteRecord())
    17291743                        rld->routeRecord = overlayMsg->getRouteRecord();
     
    17651779/// handles an incoming message
    17661780bool BaseOverlay::handleMessage( const Message* message, LinkDescriptor* ld,
    1767         const LinkID bcLink ) {
     1781                const LinkID bcLink ) {
    17681782        logging_debug( "Handling message: " << message->toString());
    17691783
    17701784        // decapsulate overlay message
    17711785        OverlayMsg* overlayMsg =
    1772                 const_cast<Message*>(message)->decapsulate<OverlayMsg>();
     1786                        const_cast<Message*>(message)->decapsulate<OverlayMsg>();
    17731787        if( overlayMsg == NULL ) return false;
    17741788
     
    17881802        // handle signaling messages (do not route!)
    17891803        if (overlayMsg->getType()>=OverlayMsg::typeSignalingStart &&
    1790                 overlayMsg->getType()<=OverlayMsg::typeSignalingEnd ) {
     1804                        overlayMsg->getType()<=OverlayMsg::typeSignalingEnd ) {
    17911805                overlayInterface->onMessage(overlayMsg, NodeID::UNSPECIFIED, LinkID::UNSPECIFIED);
    17921806                delete overlayMsg;
     
    17961810        // message for reached destination? no-> route message
    17971811        if (!overlayMsg->getDestinationNode().isUnspecified() &&
    1798                  overlayMsg->getDestinationNode() != nodeId ) {
     1812                        overlayMsg->getDestinationNode() != nodeId ) {
    17991813                logging_debug("Routing message "
    1800                         << " from " << overlayMsg->getSourceNode()
    1801                         << " to " << overlayMsg->getDestinationNode()
     1814                                << " from " << overlayMsg->getSourceNode()
     1815                                << " to " << overlayMsg->getDestinationNode()
    18021816                );
    18031817                route( overlayMsg );
     
    18181832        switch ( overlayMsg->getType() ) {
    18191833
    1820                 // data transport messages
    1821                 case OverlayMsg::typeData:
    1822                         ret = handleData(overlayMsg, ld);                       break;
     1834        // data transport messages
     1835        case OverlayMsg::typeData:
     1836                ret = handleData(overlayMsg, ld);                       break;
    18231837
    18241838                // overlay setup messages
    1825                 case OverlayMsg::typeJoinRequest:
    1826                         ret = handleJoinRequest(overlayMsg, bcLink );   break;
    1827                 case OverlayMsg::typeJoinReply:
    1828                         ret = handleJoinReply(overlayMsg, bcLink );     break;
     1839        case OverlayMsg::typeJoinRequest:
     1840                ret = handleJoinRequest(overlayMsg, bcLink );   break;
     1841        case OverlayMsg::typeJoinReply:
     1842                ret = handleJoinReply(overlayMsg, bcLink );     break;
    18291843
    18301844                // link specific messages
    1831                 case OverlayMsg::typeLinkRequest:
    1832                         ret = handleLinkRequest(overlayMsg, ld );       break;
    1833                 case OverlayMsg::typeLinkReply:
    1834                         ret = handleLinkReply(overlayMsg, ld );         break;
    1835                 case OverlayMsg::typeLinkUpdate:
    1836                         ret = handleLinkUpdate(overlayMsg, ld );        break;
    1837                 case OverlayMsg::typeLinkAlive:
    1838                         ret = handleLinkAlive(overlayMsg, ld );         break;
    1839                 case OverlayMsg::typeLinkDirect:
    1840                         ret = handleLinkDirect(overlayMsg, ld );        break;
     1845        case OverlayMsg::typeLinkRequest:
     1846                ret = handleLinkRequest(overlayMsg, ld );       break;
     1847        case OverlayMsg::typeLinkReply:
     1848                ret = handleLinkReply(overlayMsg, ld );         break;
     1849        case OverlayMsg::typeLinkUpdate:
     1850                ret = handleLinkUpdate(overlayMsg, ld );        break;
     1851        case OverlayMsg::typeLinkAlive:
     1852                ret = handleLinkAlive(overlayMsg, ld );         break;
     1853        case OverlayMsg::typeLinkDirect:
     1854                ret = handleLinkDirect(overlayMsg, ld );        break;
    18411855
    18421856                // handle unknown message type
    1843                 default: {
    1844                         logging_error( "received message in invalid state! don't know " <<
     1857        default: {
     1858                logging_error( "received message in invalid state! don't know " <<
    18451859                                "what to do with this message of type " << overlayMsg->getType() );
    1846                         ret = false;
    1847                         break;
    1848                 }
     1860                ret = false;
     1861                break;
     1862        }
    18491863        }
    18501864
     
    19101924        stabilizeLinks();
    19111925        stabilizeDHT();
    1912 }
    1913 
     1926        updateVisual();
     1927}
     1928
     1929void BaseOverlay::updateVisual(){
     1930
     1931        //
     1932        // update base overlay structure
     1933        //
     1934
     1935        static NodeID pre = NodeID::UNSPECIFIED;
     1936        static NodeID suc = NodeID::UNSPECIFIED;
     1937
     1938        vector<NodeID> nodes = this->getOverlayNeighbors(false);
     1939
     1940        if(nodes.size() == 0){
     1941
     1942                if(pre != NodeID::UNSPECIFIED){
     1943                        visual.visDisconnect(visualIdOverlay, this->nodeId, pre, "");
     1944                        pre = NodeID::UNSPECIFIED;
     1945                }
     1946                if(suc != NodeID::UNSPECIFIED){
     1947                        visual.visDisconnect(visualIdOverlay, this->nodeId, suc, "");
     1948                        suc = NodeID::UNSPECIFIED;
     1949                }
     1950
     1951        } // if(nodes.size() == 0)
     1952
     1953        if(nodes.size() == 1){
     1954                // only one node, make this pre and succ
     1955                // and then go into the node.size()==2 case
     1956                //nodes.push_back(nodes.at(0));
     1957
     1958                if(pre != nodes.at(0)){
     1959                        pre = nodes.at(0);
     1960                        if(pre != NodeID::UNSPECIFIED)
     1961                                visual.visConnect(visualIdOverlay, this->nodeId, pre, "");
     1962                }
     1963        }
     1964
     1965        if(nodes.size() == 2){
     1966
     1967                // old finger
     1968                if(nodes.at(0) != pre){
     1969                        if(pre != NodeID::UNSPECIFIED)
     1970                                visual.visDisconnect(visualIdOverlay, this->nodeId, pre, "");
     1971                        pre = NodeID::UNSPECIFIED;
     1972                }
     1973                if(nodes.at(1) != suc){
     1974                        if(suc != NodeID::UNSPECIFIED)
     1975                                visual.visDisconnect(visualIdOverlay, this->nodeId, suc, "");
     1976                        suc = NodeID::UNSPECIFIED;
     1977                }
     1978
     1979                // connect with fingers
     1980                if(pre == NodeID::UNSPECIFIED){
     1981                        pre = nodes.at(0);
     1982                        if(pre != NodeID::UNSPECIFIED)
     1983                                visual.visConnect(visualIdOverlay, this->nodeId, pre, "");
     1984                }
     1985                if(suc == NodeID::UNSPECIFIED){
     1986                        suc = nodes.at(1);
     1987                        if(suc != NodeID::UNSPECIFIED)
     1988                                visual.visConnect(visualIdOverlay, this->nodeId, suc, "");
     1989                }
     1990
     1991        } //if(nodes.size() == 2)
     1992
     1993//      {
     1994//              logging_error("================================");
     1995//              logging_error("my nodeid " << nodeId.get(MAX_KEYLENGTH-16, 16));
     1996//              logging_error("================================");
     1997//              if(nodes.size()>= 1){
     1998//                      logging_error("real pre " << nodes.at(0).toString());
     1999//                      logging_error("real pre " << nodes.at(0).get(MAX_KEYLENGTH-16, 16));
     2000//              }
     2001//              if(nodes.size()>= 2){
     2002//                      logging_error("real suc " << nodes.at(1).toString());
     2003//                      logging_error("real suc " << nodes.at(1).get(MAX_KEYLENGTH-16, 16));
     2004//              }
     2005//              logging_error("================================");
     2006//              if(pre == NodeID::UNSPECIFIED){
     2007//                      logging_error("pre: unspecified");
     2008//              }else{
     2009//                      unsigned int prei = pre.get(MAX_KEYLENGTH-16, 16);
     2010//                      logging_error("pre: " << prei);
     2011//              }
     2012//              if(suc == NodeID::UNSPECIFIED){
     2013//                      logging_error("suc: unspecified");
     2014//              }else{
     2015//                      unsigned int suci = suc.get(MAX_KEYLENGTH-16, 16);
     2016//                      logging_error("suc: " << suci);
     2017//              }
     2018//              logging_error("================================");
     2019//      }
     2020
     2021        //
     2022        // update base communication links
     2023        //
     2024
     2025        static set<NodeID> linkset;
     2026        set<NodeID> remotenodes;
     2027        BOOST_FOREACH( LinkDescriptor* ld, links ) {
     2028                if (!ld->isVital() || ld->service != OverlayInterface::OVERLAY_SERVICE_ID)
     2029                        continue;
     2030
     2031                if (ld->routeRecord.size()>1 && ld->relayed) {
     2032                        for (size_t i=1; i<ld->routeRecord.size(); i++)
     2033                                remotenodes.insert( ld->routeRecord[ld->routeRecord.size()-i-1] );
     2034                } else {
     2035                        remotenodes.insert(ld->remoteNode);
     2036                }
     2037        }
     2038
     2039        // which links are old and need deletion?
     2040        BOOST_FOREACH(NodeID n, linkset){
     2041                if(remotenodes.find(n) == remotenodes.end()){
     2042                        visual.visDisconnect(visualIdBase, this->nodeId, n, "");
     2043                        linkset.erase(n);
     2044                }
     2045        }
     2046
     2047        // which links are new and need creation?
     2048        BOOST_FOREACH(NodeID n, remotenodes){
     2049                if(linkset.find(n) == linkset.end()){
     2050                        visual.visConnect(visualIdBase, this->nodeId, n, "");
     2051                        linkset.insert(n);
     2052                }
     2053        }
     2054
     2055}
    19142056
    19152057// ----------------------------------------------------------------------------
     
    19542096        if (!overlayInterface->isClosestNodeTo(msg->getDestinationNode())) {
    19552097                logging_debug("Routing DHT message to closest node "
    1956                         << " from " << msg->getSourceNode()
    1957                         << " to " << msg->getDestinationNode()
     2098                                << " from " << msg->getSourceNode()
     2099                                << " to " << msg->getDestinationNode()
    19582100                );
    19592101                route( msg );
     
    19662108        case OverlayMsg::typeDHTPut: {
    19672109                BOOST_FOREACH( Data value, dhtMsg->getValues() )
    1968                         dht->put(dhtMsg->getKey(), value, dhtMsg->getTTL() );
     2110                                        dht->put(dhtMsg->getKey(), value, dhtMsg->getTTL() );
    19692111                break;
    19702112        }
     
    19872129                if (dhtMsg->hasValues()) {
    19882130                        BOOST_FOREACH( Data value, dhtMsg->getValues() )
    1989                                         dht->remove(dhtMsg->getKey(), value );
     2131                                                        dht->remove(dhtMsg->getKey(), value );
    19902132                } else
    19912133                        dht->remove( dhtMsg->getKey() );
  • source/ariba/overlay/BaseOverlay.h

    r6786 r6822  
    7070  class CommunicationListener;
    7171  class SideportListener;
    72   namespace utility {
    73     class OvlVis;
    74   }
    7572}
    7673
     
    110107using ariba::utility::seqnum_t;
    111108using ariba::utility::Timer;
    112 using ariba::utility::OvlVis;
    113 
    114 //#define ovl OvlVis::instance()
    115 //#define ovlId OvlVis::NETWORK_ID_BASE_OVERLAY
    116109
    117110namespace ariba {
     
    519512        typedef vector<NodeID> JoiningNodes;
    520513        JoiningNodes joiningNodes;
     514
     515        void updateVisual();
    521516};
    522517
  • source/ariba/utility/visual/OvlVis.cpp

    r6584 r6822  
    4242namespace utility {
    4343
    44 //*****************************************************
    45 //*****************************************************
    46 //*****************************************************
    47 
    4844use_logging_cpp(OvlVis);
    4945
    50 OvlVis::OvlVis() : socket(io_service), socketOpened(false) {
    51 
    52         if( ! Configuration::haveConfig() ) return;
    53         if( ! Configuration::instance().exists("DEMO_OvlVisIP") )   return;
    54         if( ! Configuration::instance().exists("DEMO_OvlVisPort") ) return;
    55 
    56         string serverIP = Configuration::instance().read<string>("DEMO_OvlVisIP");
    57         string serverPort = Configuration::instance().read<string>("DEMO_OvlVisPort");
    58         if( serverIP.length() == 0 || serverPort.length() == 0) return;
    59 
    60         logging_debug( "connecting to ovlvis " + serverIP + " on " + serverPort );
    61 
    62         tcp::resolver resolver(io_service);
    63         tcp::resolver::query query(
    64                 serverIP,
    65                 serverPort,
    66                 tcp::resolver::query::passive |
    67                 tcp::resolver::query::address_configured |
    68                 tcp::resolver::query::numeric_service);
    69 
    70         tcp::resolver::iterator endpoint_iterator = resolver.resolve(query);
    71         tcp::resolver::iterator end;
    72 
    73         boost::system::error_code error = boost::asio::error::host_not_found;
    74         while (error && endpoint_iterator != end){
    75                 socket.close();
    76                 socket.connect(*endpoint_iterator++, error);
    77         }
    78 
    79         if (error){
    80                 logging_warn( "OvlVis could not connect to GUI" );
    81         } else {
    82                 socketOpened = true;
    83         }
     46OvlVis::OvlVis() {
    8447}
    8548
    8649OvlVis::~OvlVis(){
    87 
    88         socket.close();
    89 
    9050}
    9151
     
    11575//      }
    11676
    117 }
    118 
    119 void OvlVis::sendSocket(const string msg){
    120         if( socket.is_open() && socketOpened )
    121                 socket.send( boost::asio::buffer(msg) );
    12277}
    12378
     
    665620}
    666621
    667 //*****************************************************
    668 //*****************************************************
    669 //*****************************************************
    670 
    671622}} // namespace ariba, common
  • source/ariba/utility/visual/OvlVis.h

    r6584 r6822  
    4545#include <map>
    4646#include <boost/utility.hpp>
    47 #include <boost/asio.hpp>
    48 #include "ariba/utility/types/NodeID.h"
    49 #include "ariba/utility/logging/Logging.h"
    5047#include "ariba/utility/system/Timer.h"
    5148#include "ariba/utility/misc/Helper.h"
    5249#include "ariba/utility/misc/KeyMapping.hpp"
    53 #include "ariba/utility/configuration/Configuration.h"
     50#include "ariba/utility/visual/ServerVis.h"
    5451
    5552using std::string;
     
    5956using std::cout;
    6057using std::ostringstream;
    61 using boost::asio::ip::tcp;
    62 using ariba::utility::NodeID;
    63 using ariba::utility::Configuration;
    6458using ariba::utility::KeyMapping;
    6559using ariba::utility::Timer;
     
    6862namespace utility {
    6963
    70 class OvlVis : private boost::noncopyable {
     64class OvlVis : public ServerVis, private boost::noncopyable {
    7165        use_logging_h(OvlVis);
    7266public:
    7367        static OvlVis& instance() { static OvlVis the_inst; return the_inst; }
    7468
    75         typedef enum _NETWORK_ID {
    76                 NETWORK_ID_BASE_COMMUNICATION   = 1,
    77                                 NETWORK_ID_BASE_OVERLAY = 2,
    78                                 NETWORK_ID_EONSON               = 3,
    79                                 NETWORK_ID_MCPO                 = 4,
    80                                 NETWORK_ID_CLIO                 = 5,
    81                                 NETWORK_ID_VIDEOSTREAM  = 6,
    82                                 NETWORK_ID_GAME                 = 7,
    83                                 NETWORK_ID_SECURITY     = 8,
    84         } NETWORK_ID;
    85 
    8669        //****************************************************************
    8770        // Node creation, node connections, status, node deletion, ...
     
    162145                        unsigned char b
    163146        );
    164 
    165         typedef enum _NODE_COLORS {
    166                 NODE_COLORS_GREY,
    167                 NODE_COLORS_GREEN,
    168                 NODE_COLORS_RED,
    169         } NODE_COLORS;
    170147
    171148        /**
     
    385362protected:
    386363        OvlVis();
    387         ~OvlVis();
     364        virtual ~OvlVis();
    388365
    389366private:
    390367        void sendMessage( const string msg, NETWORK_ID nid );
    391         void sendSocket( const string msg );
    392 
    393         /**
    394          * boost asio stuff for connecting to ovlvis
    395          */
    396         boost::asio::io_service io_service;
    397         tcp::socket socket;
    398         volatile bool socketOpened;
    399368
    400369        typedef pair<NodeID, NodeID> NodePair;
Note: See TracChangeset for help on using the changeset viewer.