Changeset 5316 for sample


Ignore:
Timestamp:
Jul 24, 2009, 8:53:41 PM (15 years ago)
Author:
Christoph Mayer
Message:

merge from bootstrap branch

Location:
sample/pingpong
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sample/pingpong/PingPong.cpp

    r5284 r5316  
    3333        ariba = new AribaModule();
    3434
    35         // get the configuration object
    36         Configuration& config = Configuration::instance();
    37 
    38         // generate spovnet name
    3935        Name spovnetName("pingpong");
    40 
    41         // get initiator flag
    42         this->isInitiator = Configuration::instance().read<bool>("node.initiator");
    43 
     36        Name nodeName = Name::UNSPECIFIED;
    4437        this->name = string("<ping>");
    4538
    46         // get node name
    47         Name nodeName = Name::UNSPECIFIED;
    48         if (config.exists("node.name")) nodeName = config.read<string> ("node.name");
    49 
    50         // configure ariba module
    51         if (config.exists("ariba.endpoints"))
    52                 ariba->setProperty("endpoints", config.read<string>("ariba.endpoints"));
    53         if (config.exists("ariba.bootstrap.hints"))
    54                 ariba->setProperty("bootstrap.hints", config.read<string>("ariba.bootstrap.hints"));
    55         if (config.exists("pingpong.name"))
    56                 name = config.read<string>("pingpong.name");
     39        // get settings from configuration object
     40        if( Configuration::haveConfig() ){
     41                Configuration& config = Configuration::instance();
     42
     43                // get node name
     44                if (config.exists("node.name"))
     45                        nodeName = config.read<string> ("node.name");
     46
     47                // configure ariba module
     48                if (config.exists("ariba.endpoints"))
     49                        ariba->setProperty("endpoints", config.read<string>("ariba.endpoints"));
     50                if (config.exists("ariba.bootstrap.hints"))
     51                        ariba->setProperty("bootstrap.hints", config.read<string>("ariba.bootstrap.hints"));
     52                if (config.exists("pingpong.name"))
     53                        name = config.read<string>("pingpong.name");
     54
     55        } // if( Configuration::haveConfig() )
    5756
    5857        // start ariba module
     
    7372        //params.setBaseOverlayType( SpoVNetProperties::ONE_HOP_OVERLAY ); // alternative: OneHop
    7473
    75         // initiate or join the spovnet
    76         if (!isInitiator) node->join(spovnetName);
    77         else node->initiate(spovnetName, params);
     74        // initiate the spovnet
     75        logging_info("initiating spovnet");
     76        node->initiate(spovnetName, params);
     77
     78        // join the spovnet
     79        logging_info("joining spovnet");
     80        node->join(spovnetName);
    7881
    7982        // ping pong started up...
     
    122125        // function that is implemented further down in PingPong::onLinkUp
    123126
    124 //      logging_info( "pinging overlay neighbors with ping id " << ++pingId );
    125 
     127        logging_info( "pinging overlay neighbors with ping id " << ++pingId );
    126128        PingPongMessage pingmsg( pingId, name );
    127129
     
    140142                names.clear();
    141143        }
     144
    142145        vector<NodeID> nodes = node->getNeighborNodes();
    143146        BOOST_FOREACH( NodeID nid, nodes ){
     147                logging_info( "sending ping message to " << nid.toString() );
    144148                node->sendMessage( pingmsg, nid, PingPong::PINGPONG_SERVICEID );
    145149        }
     
    176180        for (int i=0;i<names.size(); i++) if (names[i]==pingmsg->getName()) found=true;
    177181        if (!found) names.push_back(pingmsg->getName());
    178 //      logging_info( "received ping message on link " << lnk.toString()
    179 //                      << " from node " << remote.toString()
    180 //                      << ": " << pingmsg->info() );
     182        logging_info( "received ping message on link " << lnk.toString()
     183                        << " from node " << remote.toString()
     184                        << ": " << pingmsg->info() );
    181185}
    182186
  • sample/pingpong/PingPong.h

    r5151 r5316  
    6868        vector<string> names;
    6969
    70         // flag, whether this node initiates or just joins the spovnet
    71         bool isInitiator;
    72 
    7370        // the ping pong service id
    7471        static ServiceID PINGPONG_SERVICEID;
Note: See TracChangeset for help on using the changeset viewer.