Changeset 5316 for sample/pingpong
- Timestamp:
- Jul 24, 2009, 8:53:41 PM (15 years ago)
- Location:
- sample/pingpong
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sample/pingpong/PingPong.cpp
r5284 r5316 33 33 ariba = new AribaModule(); 34 34 35 // get the configuration object36 Configuration& config = Configuration::instance();37 38 // generate spovnet name39 35 Name spovnetName("pingpong"); 40 41 // get initiator flag 42 this->isInitiator = Configuration::instance().read<bool>("node.initiator"); 43 36 Name nodeName = Name::UNSPECIFIED; 44 37 this->name = string("<ping>"); 45 38 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() ) 57 56 58 57 // start ariba module … … 73 72 //params.setBaseOverlayType( SpoVNetProperties::ONE_HOP_OVERLAY ); // alternative: OneHop 74 73 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); 78 81 79 82 // ping pong started up... … … 122 125 // function that is implemented further down in PingPong::onLinkUp 123 126 124 // logging_info( "pinging overlay neighbors with ping id " << ++pingId ); 125 127 logging_info( "pinging overlay neighbors with ping id " << ++pingId ); 126 128 PingPongMessage pingmsg( pingId, name ); 127 129 … … 140 142 names.clear(); 141 143 } 144 142 145 vector<NodeID> nodes = node->getNeighborNodes(); 143 146 BOOST_FOREACH( NodeID nid, nodes ){ 147 logging_info( "sending ping message to " << nid.toString() ); 144 148 node->sendMessage( pingmsg, nid, PingPong::PINGPONG_SERVICEID ); 145 149 } … … 176 180 for (int i=0;i<names.size(); i++) if (names[i]==pingmsg->getName()) found=true; 177 181 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() ); 181 185 } 182 186 -
sample/pingpong/PingPong.h
r5151 r5316 68 68 vector<string> names; 69 69 70 // flag, whether this node initiates or just joins the spovnet71 bool isInitiator;72 73 70 // the ping pong service id 74 71 static ServiceID PINGPONG_SERVICEID;
Note:
See TracChangeset
for help on using the changeset viewer.