Changeset 5316 for source/ariba/overlay
- Timestamp:
- Jul 24, 2009, 8:53:41 PM (15 years ago)
- Location:
- source/ariba/overlay
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
source/ariba/overlay/BaseOverlay.cpp
r5284 r5316 245 245 BaseOverlay::BaseOverlay() : 246 246 bc(NULL), overlayInterface(NULL), nodeId(NodeID::UNSPECIFIED), 247 spovnetId(SpoVNetID::UNSPECIFIED), initiatorLink(LinkID::UNSPECIFIED),248 s tate(BaseOverlayStateInvalid), sideport(&SideportListener::DEFAULT) {247 spovnetId(SpoVNetID::UNSPECIFIED), state(BaseOverlayStateInvalid), 248 sideport(&SideportListener::DEFAULT), started(false) { 249 249 } 250 250 … … 268 268 Timer::setInterval( 500 ); 269 269 Timer::start(); 270 271 started = true; 272 state = BaseOverlayStateInvalid; 270 273 } 271 274 … … 285 288 bc->unregisterMessageReceiver( this ); 286 289 bc->unregisterEventListener( this ); 290 291 started = false; 292 state = BaseOverlayStateInvalid; 293 } 294 295 bool BaseOverlay::isStarted(){ 296 return started; 287 297 } 288 298 … … 292 302 const EndpointDescriptor& bootstrapEp) { 293 303 294 ovl.visShowNodeBubble ( ovlId, nodeId, "joining..." ); 304 if(id != spovnetId){ 305 logging_error("attempt to join against invalid spovnet, call initiate first"); 306 return; 307 } 308 309 310 //ovl.visShowNodeBubble ( ovlId, nodeId, "joining..." ); 295 311 logging_info( "Starting to join spovnet " << id.toString() << 296 312 " with nodeid " << nodeId.toString()); 297 313 298 // contact the spovnet initiator and request to join. if the join is granted we will 299 // receive further information on the structure of the overlay that is used in the spovnet 300 // but first, we have to establish a link to the initiator... 301 spovnetId = id; 302 state = BaseOverlayStateJoinInitiated; 303 304 initiatorLink = bc->establishLink( bootstrapEp ); 305 logging_info("join process initiated for " << id.toString() << "..."); 314 if(bootstrapEp == EndpointDescriptor::UNSPECIFIED && state == BaseOverlayStateInvalid){ 315 316 // bootstrap against ourselfs 317 logging_debug("joining spovnet locally"); 318 319 overlayInterface->joinOverlay(); 320 state = BaseOverlayStateCompleted; 321 BOOST_FOREACH( NodeListener* i, nodeListeners ) 322 i->onJoinCompleted( spovnetId ); 323 324 //ovl.visChangeNodeIcon ( ovlId, nodeId, OvlVis::ICON_ID_CAMERA ); 325 //ovl.visChangeNodeColor( ovlId, nodeId, OvlVis::NODE_COLORS_GREEN ); 326 327 logging_debug("starting overlay bootstrap module"); 328 overlayBootstrap.start(this, spovnetId, nodeId); 329 overlayBootstrap.publish(bc->getEndpointDescriptor()); 330 331 } else { 332 333 // bootstrap against another node 334 logging_debug("joining spovnet remotely against " << bootstrapEp.toString()); 335 336 const LinkID& lnk = bc->establishLink( bootstrapEp ); 337 bootstrapLinks.push_back(lnk); 338 logging_info("join process initiated for " << id.toString() << "..."); 339 } 306 340 } 307 341 … … 310 344 logging_info( "Leaving spovnet " << spovnetId ); 311 345 bool ret = ( state != this->BaseOverlayStateInvalid ); 346 347 logging_debug("stopping overlay bootstrap module"); 348 overlayBootstrap.stop(); 349 overlayBootstrap.revoke(); 312 350 313 351 logging_debug( "Dropping all auto-links" ); … … 329 367 overlayInterface->leaveOverlay(); 330 368 331 // leave spovnet 332 if( state != BaseOverlayStateInitiator ) { 333 // then, leave the spovnet baseoverlay 334 OverlayMsg overMsg( OverlayMsg::typeBye, nodeId ); 335 bc->sendMessage( initiatorLink, &overMsg ); 336 337 // drop the link and set to correct state 338 bc->dropLink( initiatorLink ); 339 initiatorLink = LinkID::UNSPECIFIED; 340 } 369 // drop still open bootstrap links 370 BOOST_FOREACH( LinkID lnk, bootstrapLinks ) 371 bc->dropLink( lnk ); 341 372 342 373 // change to inalid state 343 374 state = BaseOverlayStateInvalid; 344 ovl.visShutdown( ovlId, nodeId, string("") );375 //ovl.visShutdown( ovlId, nodeId, string("") ); 345 376 346 377 // inform all registered services of the event … … 362 393 363 394 spovnetId = id; 364 state = BaseOverlayStateInitiator;365 395 366 396 overlayInterface = OverlayFactory::create( *this, param, nodeId, this ); … … 368 398 logging_fatal( "overlay structure not supported" ); 369 399 state = BaseOverlayStateInvalid; 400 401 BOOST_FOREACH( NodeListener* i, nodeListeners ) 402 i->onJoinFailed( spovnetId ); 403 370 404 return; 371 405 } 372 373 // bootstrap against ourselfs374 overlayInterface->joinOverlay();375 BOOST_FOREACH( NodeListener* i, nodeListeners )376 i->onJoinCompleted( spovnetId );377 378 ovl.visChangeNodeIcon ( ovlId, nodeId, OvlVis::ICON_ID_CAMERA );379 ovl.visChangeNodeColor( ovlId, nodeId, OvlVis::NODE_COLORS_GREEN );380 406 } 381 407 … … 695 721 LinkDescriptor* ld = getDescriptor(id, true); 696 722 697 // handle initiator link698 if( state == BaseOverlayStateJoinInitiated && id == initiatorLink){723 // handle bootstrap link we initiated 724 if( std::find(bootstrapLinks.begin(), bootstrapLinks.end(), id) != bootstrapLinks.end() ){ 699 725 logging_info( 700 726 "Join has been initiated by me and the link is now up. " << … … 759 785 const address_v* local, const address_v* remote) { 760 786 787 // erase bootstrap links 788 vector<LinkID>::iterator it = std::find( bootstrapLinks.begin(), bootstrapLinks.end(), id ); 789 if( it != bootstrapLinks.end() ) bootstrapLinks.erase( it ); 790 761 791 // get descriptor for link 762 792 LinkDescriptor* ld = getDescriptor(id, true); … … 800 830 const address_v* local, const address_v* remote) { 801 831 logging_debug( "Link fail with base communication link id=" << id ); 832 833 // erase bootstrap links 834 vector<LinkID>::iterator it = std::find( bootstrapLinks.begin(), bootstrapLinks.end(), id ); 835 if( it != bootstrapLinks.end() ) bootstrapLinks.erase( it ); 802 836 803 837 // get descriptor for link … … 927 961 logging_debug("received join reply message"); 928 962 JoinReply* replyMsg = overlayMsg->decapsulate<JoinReply>(); 929 assert(state == BaseOverlayStateJoinInitiated);930 963 931 964 // correct spovnet? … … 942 975 943 976 // drop initiator link 944 bc->dropLink( initiatorLink ); 945 initiatorLink = LinkID::UNSPECIFIED; 946 state = BaseOverlayStateInvalid; 977 978 if(bcLink != LinkID::UNSPECIFIED){ 979 bc->dropLink( bcLink ); 980 981 vector<LinkID>::iterator it = std::find( 982 bootstrapLinks.begin(), bootstrapLinks.end(), bcLink); 983 if( it != bootstrapLinks.end() ) 984 bootstrapLinks.erase(it); 985 } 947 986 948 987 // inform all registered services of the event 949 988 BOOST_FOREACH( NodeListener* i, nodeListeners ) 950 989 i->onJoinFailed( spovnetId ); 990 951 991 return true; 952 992 } … … 956 996 spovnetId.toString() ); 957 997 998 logging_debug( "Using bootstrap end-point " 999 << replyMsg->getBootstrapEndpoint().toString() ); 1000 1001 // 958 1002 // create overlay structure from spovnet parameter set 959 overlayInterface = OverlayFactory::create( 960 *this, replyMsg->getParam(), nodeId, this ); 961 962 // overlay structure supported? no-> fail! 963 if( overlayInterface == NULL ) { 964 logging_error( "overlay structure not supported" ); 965 966 bc->dropLink( initiatorLink ); 967 initiatorLink = LinkID::UNSPECIFIED; 968 state = BaseOverlayStateInvalid; 1003 // if we have not boostrapped yet against some other node 1004 // 1005 1006 if( overlayInterface == NULL ){ 1007 1008 logging_debug("first-time bootstrapping"); 1009 1010 overlayInterface = OverlayFactory::create( 1011 *this, replyMsg->getParam(), nodeId, this ); 1012 1013 // overlay structure supported? no-> fail! 1014 if( overlayInterface == NULL ) { 1015 logging_error( "overlay structure not supported" ); 1016 1017 if(bcLink != LinkID::UNSPECIFIED){ 1018 bc->dropLink( bcLink ); 1019 1020 vector<LinkID>::iterator it = std::find( 1021 bootstrapLinks.begin(), bootstrapLinks.end(), bcLink); 1022 if( it != bootstrapLinks.end() ) 1023 bootstrapLinks.erase(it); 1024 } 1025 1026 // inform all registered services of the event 1027 BOOST_FOREACH( NodeListener* i, nodeListeners ) 1028 i->onJoinFailed( spovnetId ); 1029 1030 return true; 1031 } 1032 1033 // everything ok-> join the overlay! 1034 state = BaseOverlayStateCompleted; 1035 overlayInterface->createOverlay(); 1036 1037 overlayInterface->joinOverlay( replyMsg->getBootstrapEndpoint() ); 1038 1039 // update ovlvis 1040 //ovl.visChangeNodeColor( ovlId, nodeId, OvlVis::NODE_COLORS_GREEN); 969 1041 970 1042 // inform all registered services of the event 971 1043 BOOST_FOREACH( NodeListener* i, nodeListeners ) 972 i->onJoinFailed( spovnetId ); 973 974 return true; 975 } 976 977 // everything ok-> join the overlay! 978 state = BaseOverlayStateCompleted; 979 overlayInterface->createOverlay(); 980 logging_debug( "Using bootstrap end-point " 981 << replyMsg->getBootstrapEndpoint().toString() ); 982 overlayInterface->joinOverlay( replyMsg->getBootstrapEndpoint() ); 983 984 // update ovlvis 985 ovl.visChangeNodeColor( ovlId, nodeId, OvlVis::NODE_COLORS_GREEN); 986 987 // inform all registered services of the event 988 BOOST_FOREACH( NodeListener* i, nodeListeners ) 989 i->onJoinCompleted( spovnetId ); 1044 i->onJoinCompleted( spovnetId ); 1045 1046 } else { 1047 1048 // this is not the first bootstrap, just join the additional node 1049 logging_debug("not first-time bootstrapping"); 1050 overlayInterface->joinOverlay( replyMsg->getBootstrapEndpoint() ); 1051 1052 } // if( overlayInterface == NULL ) 990 1053 991 1054 return true; … … 1103 1166 1104 1167 // --------------------------------------------------------------------- 1105 // handle bye messages1106 // ---------------------------------------------------------------------1107 case OverlayMsg::typeBye: {1108 logging_debug( "received bye message from " <<1109 overlayMsg->getSourceNode().toString() );1110 1111 /* if we are the initiator and receive a bye from a node1112 * the node just left. if we are a node and receive a bye1113 * from the initiator, we have to close, too.1114 */1115 if( overlayMsg->getSourceNode() == spovnetInitiator ) {1116 1117 bc->dropLink( initiatorLink );1118 initiatorLink = LinkID::UNSPECIFIED;1119 state = BaseOverlayStateInvalid;1120 1121 logging_fatal( "initiator ended spovnet" );1122 1123 // inform all registered services of the event1124 BOOST_FOREACH( NodeListener* i, nodeListeners )1125 i->onLeaveFailed( spovnetId );1126 1127 } else {1128 // a node that said goodbye and we are the initiator don't have to1129 // do much here, as the node also will go out of the overlay1130 // structure1131 logging_info( "node left " << overlayMsg->getSourceNode() );1132 }1133 1134 return true;1135 1136 }1137 1138 // ---------------------------------------------------------------------1139 1168 // handle link request forwarded through the overlay 1140 1169 // --------------------------------------------------------------------- 1141 1170 case OverlayMsg::typeLinkRequest: { 1171 1172 logging_debug( "received link request on link" ); 1142 1173 1143 1174 // decapsulate message … … 1261 1292 case OverlayMsg::typeRelay: { 1262 1293 1294 logging_debug( "received relay request on link" ); 1295 1263 1296 // decapsulate message 1264 1297 RelayMessage* relayMsg = overlayMsg->decapsulate<RelayMessage>(); … … 1347 1380 // --------------------------------------------------------------------- 1348 1381 case OverlayMsg::typeKeepAlive: { 1382 1383 logging_debug( "received keep-alive on link" ); 1384 1349 1385 if ( ld != NULL ) { 1350 1386 //logging_force("Keep-Alive for "<< ld->overlayId); … … 1358 1394 // --------------------------------------------------------------------- 1359 1395 case OverlayMsg::typeDirectLink: { 1396 1397 logging_debug( "received direct link replacement request" ); 1398 1360 1399 LinkDescriptor* rld = getDescriptor( overlayMsg->getRelayLink() ); 1361 1400 logging_force( "Received direct link convert notification for " << rld ); … … 1380 1419 1381 1420 } /* switch */ 1421 1382 1422 return false; 1383 1423 } … … 1398 1438 } 1399 1439 1400 vector<NodeID> BaseOverlay::getOverlayNeighbors( ) const {1440 vector<NodeID> BaseOverlay::getOverlayNeighbors(bool deep) const { 1401 1441 // the known nodes _can_ also include our node, so we remove ourself 1402 vector<NodeID> nodes = overlayInterface->getKnownNodes( );1442 vector<NodeID> nodes = overlayInterface->getKnownNodes(deep); 1403 1443 vector<NodeID>::iterator i = find( nodes.begin(), nodes.end(), this->nodeId ); 1404 1444 if( i != nodes.end() ) nodes.erase( i ); … … 1499 1539 // drop links 1500 1540 BOOST_FOREACH( const LinkDescriptor* ld, oldlinks ) { 1501 if (!ld->communicationId.isUnspecified() && ld->communicationId == initiatorLink) { 1541 1542 vector<LinkID>::iterator it = std::find( 1543 bootstrapLinks.begin(), bootstrapLinks.end(), ld->communicationId); 1544 1545 if (!ld->communicationId.isUnspecified() && it != bootstrapLinks.end() ){ 1502 1546 logging_force( "Not dropping initiator link: " << ld ); 1503 1547 continue; -
source/ariba/overlay/BaseOverlay.h
r5284 r5316 112 112 using ariba::utility::OvlVis; 113 113 114 #define ovl OvlVis::instance()115 #define ovlId OvlVis::NETWORK_ID_BASE_OVERLAY114 //#define ovl OvlVis::instance() 115 //#define ovlId OvlVis::NETWORK_ID_BASE_OVERLAY 116 116 117 117 namespace ariba { … … 156 156 157 157 /** 158 * Is the BaseOverlay instance started up yet 159 */ 160 bool isStarted(); 161 162 /** 158 163 * Starts a link establishment procedure to the specfied node 159 164 * for the service with id service … … 211 216 * @return A list of overlay neighbors. 212 217 */ 213 vector<NodeID> getOverlayNeighbors( ) const;218 vector<NodeID> getOverlayNeighbors(bool deep = true) const; 214 219 215 220 /** … … 264 269 * @param boot A bootstrap node 265 270 */ 266 void joinSpoVNet(const SpoVNetID& id, const EndpointDescriptor& boot );271 void joinSpoVNet(const SpoVNetID& id, const EndpointDescriptor& boot = EndpointDescriptor::UNSPECIFIED); 267 272 268 273 /** … … 365 370 typedef enum _BaseOverlayState { 366 371 BaseOverlayStateInvalid = 0, 367 BaseOverlayStateInitiator = 1, 368 BaseOverlayStateJoinInitiated = 2, 369 BaseOverlayStateCompleted = 3, 372 BaseOverlayStateCompleted = 1, 370 373 } BaseOverlayState; 371 374 372 BaseOverlayState state; ///< Current Base-Overlay state373 BaseCommunication* bc; ///< reference to the base communication374 NodeID nodeId; ///< the node id of this node375 SpoVNetID spovnetId; ///< the spovnet id of the currently joined overlay376 LinkID initiatorLink; ///< the link id of the link to the initiator node377 NodeID spovnetInitiator; ///< The initiator node375 BaseOverlayState state; ///< Current Base-Overlay state 376 BaseCommunication* bc; ///< reference to the base communication 377 NodeID nodeId; ///< the node id of this node 378 SpoVNetID spovnetId; ///< the spovnet id of the currently joined overlay 379 vector<LinkID> bootstrapLinks; ///< the link id of the link to the initiator node 380 NodeID spovnetInitiator; ///< The initiator node 378 381 379 382 /// the service id communication listeners … … 440 443 */ 441 444 OverlayBootstrap overlayBootstrap; 445 446 /// is the base overlay started yet 447 bool started; 442 448 }; 443 449 -
source/ariba/overlay/OverlayBootstrap.cpp
r5002 r5316 61 61 nodeid = _nodeid; 62 62 63 logging_info("starting overlay bootstrap"); 64 63 65 manager.registerCallback( this ); 64 //manager.registerModule( BootstrapManager::BootstrapTypePeriodicBroadcast ); 66 manager.registerModule( BootstrapManager::BootstrapTypePeriodicBroadcast ); 67 //manager.registerModule( BootstrapManager::BootstrapTypeBluetoothSdp ); 65 68 } 66 69 … … 70 73 nodeid = NodeID::UNSPECIFIED; 71 74 75 logging_info("stopping overlay bootstrap"); 76 72 77 manager.unregisterCallback( this ); 73 //manager.unregisterModule( BootstrapManager::BootstrapTypePeriodicBroadcast ); 78 manager.unregisterModule( BootstrapManager::BootstrapTypePeriodicBroadcast ); 79 //manager.unregisterModule( BootstrapManager::BootstrapTypeBluetoothSdp ); 74 80 } 75 81 … … 83 89 // tell the base overlay to join using this endpoint 84 90 assert( overlay != NULL ); 85 // TODO:overlay->joinSpoVNet( spovnetid, data->endpoint );91 overlay->joinSpoVNet( spovnetid, data->endpoint ); 86 92 87 93 delete data; -
source/ariba/overlay/messages/OverlayMsg.h
r5151 r5316 70 70 typeJoinReply = 3, ///< join reply 71 71 typeUpdate = 4, ///< update message for link association 72 typeBye = 5, ///< leave (no encapsulated messages) 73 typeLinkRequest = 6, ///< link request (sent over the overlay) 74 typeRelay = 7, ///< relay message 75 typeKeepAlive = 8, ///< a keep-alive message 76 typeDirectLink = 9, 72 typeLinkRequest = 5, ///< link request (sent over the overlay) 73 typeRelay = 6, ///< relay message 74 typeKeepAlive = 7, ///< a keep-alive message 75 typeDirectLink = 8, 77 76 ///< a direct connection has been established 78 77 }; -
source/ariba/overlay/modules/OverlayInterface.h
r5151 r5316 149 149 * @return The list of all known nodes 150 150 */ 151 virtual NodeList getKnownNodes( ) const = 0;151 virtual NodeList getKnownNodes(bool deep = true) const = 0; 152 152 153 153 /** -
source/ariba/overlay/modules/chord/Chord.cpp
r5151 r5316 61 61 stabilize_counter = 0; 62 62 stabilize_finger = 0; 63 bootstrapLink = LinkID::UNSPECIFIED;64 63 } 65 64 … … 112 111 void Chord::joinOverlay(const EndpointDescriptor& boot) { 113 112 logging_info( "joining Chord overlay structure through end-point " << 114 (boot == EndpointDescriptor::UNSPECIFIED ? 115 "local" : boot.toString()) ); 113 (boot.isUnspecified() ? "local" : boot.toString()) ); 116 114 117 115 // initiator? no->setup first link 118 if (! (boot == EndpointDescriptor::UNSPECIFIED))119 bootstrapLink = setup(boot);116 if (!boot.isUnspecified()) 117 bootstrapLinks.push_back( setup(boot) ); 120 118 121 119 // timer for stabilization management … … 176 174 } 177 175 178 OverlayInterface::NodeList Chord::getKnownNodes( ) const {176 OverlayInterface::NodeList Chord::getKnownNodes(bool deep) const { 179 177 OverlayInterface::NodeList nodelist; 180 for (size_t i = 0; i < table->size(); i++) 181 if ((*table)[i]->ref_count != 0 182 && !(*table)[i]->info.isUnspecified()) 183 nodelist.push_back((*table)[i]->id); 178 179 if( deep ){ 180 // all nodes that I know, fingers, succ/pred 181 for (size_t i = 0; i < table->size(); i++){ 182 if ((*table)[i]->ref_count != 0 183 && !(*table)[i]->info.isUnspecified()) 184 nodelist.push_back((*table)[i]->id); 185 } 186 } else { 187 // only succ and pred 188 if( table->get_predesessor() != NULL ) 189 nodelist.push_back( *(table->get_predesessor()) ); 190 191 if( table->get_successor() != NULL ) 192 nodelist.push_back( *(table->get_successor()) ); 193 } 194 184 195 return nodelist; 185 196 } … … 208 219 } 209 220 210 if (!bootstrapLink.isUnspecified() && lnk == bootstrapLink) { 221 vector<LinkID>::iterator it = std::find(bootstrapLinks.begin(), bootstrapLinks.end(), lnk); 222 if( it != bootstrapLinks.end() ) { 211 223 send_discovery_to(nodeid); 212 bootstrapLink = LinkID::UNSPECIFIED;224 bootstrapLinks.erase( it ); 213 225 } 214 226 } -
source/ariba/overlay/modules/chord/Chord.h
r5151 r5316 76 76 int stabilize_counter; 77 77 int stabilize_finger; 78 LinkID bootstrapLink;78 vector<LinkID> bootstrapLinks; 79 79 vector<NodeID> pending; 80 80 … … 120 120 121 121 /// @see OverlayInterface.h 122 virtual NodeList getKnownNodes( ) const;122 virtual NodeList getKnownNodes(bool deep = true) const; 123 123 124 124 /// @see CommunicationListener.h or @see OverlayInterface.h -
source/ariba/overlay/modules/onehop/OneHop.cpp
r5151 r5316 52 52 OverlayStructureEvents* _eventsReceiver, const OverlayParameterSet& param) 53 53 : OverlayInterface( _baseoverlay, _nodeid, _eventsReceiver, param ), 54 state ( OneHopStateInvalid ), 55 bootstrapLink ( LinkID::UNSPECIFIED ), 56 pendingLinks ( 0 ) { 54 state( OneHopStateInvalid ) { 57 55 58 56 // … … 88 86 logging_debug( "routing message to node " << destnode.toString() ); 89 87 88 // msg for ourselfs 89 if(destnode == nodeid) 90 baseoverlay.incomingRouteMessage( msg, LinkID::UNSPECIFIED, nodeid ); 91 92 // msg for other node 90 93 OverlayNodeMapping::const_iterator i = overlayNodes.find( destnode ); 91 94 if (i == overlayNodes.end()) { … … 116 119 // the create and join process is completed now. 117 120 logging_info( "creating onehop overlay structure" ); 118 state = OneHopStateCompleted;119 121 } 120 122 … … 123 125 logging_info( "deleting onehop overlay structure" ); 124 126 state = OneHopStateInvalid; 125 pendingLinks = 0; 126 } 127 128 OverlayInterface::NodeList OneHop::getKnownNodes() const { 127 } 128 129 OverlayInterface::NodeList OneHop::getKnownNodes(bool deep) const { 129 130 130 131 OverlayInterface::NodeList retlist; … … 142 143 143 144 logging_info( "joining onehop overlay structure through end-point " << 144 (bootstrapEp == EndpointDescriptor::UNSPECIFIED ? 145 "local" : bootstrapEp.toString()) ); 146 147 state = OneHopStateJoinInitiated; 148 pendingLinks = 0; 149 150 if( bootstrapEp == EndpointDescriptor::UNSPECIFIED ){ 145 (bootstrapEp.isUnspecified() ? "local" : bootstrapEp.toString()) ); 146 147 if( bootstrapEp.isUnspecified() ){ 151 148 152 149 // we are the initiator and we are to bootstrap against … … 156 153 state = OneHopStateCompleted; 157 154 } else { 158 bootstrapLink = baseoverlay.establishLink( bootstrapEp, 159 OverlayInterface::OVERLAY_SERVICE_ID ); 155 bootstrapLinks.push_back( 156 baseoverlay.establishLink( bootstrapEp, 157 OverlayInterface::OVERLAY_SERVICE_ID ) 158 ); 160 159 } 161 160 } … … 187 186 } 188 187 } 189 190 pendingLinks = 0;191 188 } 192 189 … … 210 207 } 211 208 } 209 210 vector<LinkID>::iterator it = std::find( bootstrapLinks.begin(), bootstrapLinks.end(), lnk ); 211 if( it != bootstrapLinks.end() ) bootstrapLinks.erase( it ); 212 212 } 213 213 214 214 void OneHop::onLinkUp(const LinkID& lnk, const NodeID& remote){ 215 216 //217 // as soon as a link goes up, we always request the node listing.218 // and try to get connections to as much nodes as possible in a greedy way.219 //220 221 if( lnk != bootstrapLink ){222 if( pendingLinks > 0 ) pendingLinks--;223 if( pendingLinks == 0 ) state = OneHopStateCompleted;224 }225 215 226 216 logging_debug( "link is up, sending out node listing request" ); … … 230 220 onemsg.encapsulate( &requestmsg ); 231 221 232 state = OneHopStateJoinListingRequested;233 222 baseoverlay.sendMessage( &onemsg, lnk ); 234 223 } … … 309 298 const NodeListingReply::NodeEndpointList& endpoints = reply->getList(); 310 299 logging_debug( "received " << endpoints.size() << " nodes in listing" ); 311 pendingLinks = 0;312 300 313 301 NodeListingReply::NodeEndpointList::const_iterator i = endpoints.begin(); … … 330 318 331 319 overlayNodes.insert( make_pair(node, link) ); 332 pendingLinks++;333 320 334 321 } // for( ; i != iend; i++ ) … … 356 343 if( onemsg->isType( OneHopMessage::OneHopMessageTypeRoute) ){ 357 344 logging_debug( "Route message arrived at destination node -> delegate to BaseOverlay" ); 358 baseoverlay.incomingRouteMessage( onemsg 345 baseoverlay.incomingRouteMessage( onemsg, lnk, remote); 359 346 } // OneHopMessageTypeRoute 360 347 -
source/ariba/overlay/modules/onehop/OneHop.h
r5151 r5316 90 90 91 91 /// @see OverlayInterface.h 92 virtual NodeList getKnownNodes( ) const;92 virtual NodeList getKnownNodes(bool deep = true) const; 93 93 94 94 /// @see CommunicationListener.h or @see OverlayInterface.h … … 110 110 typedef enum _OneHopState { 111 111 OneHopStateInvalid = 0, 112 OneHopStateJoinInitiated = 1, 113 OneHopStateJoinListingRequested = 2, 114 OneHopStateCompleted = 3, 112 OneHopStateCompleted = 1, 115 113 } OneHopState; 116 114 117 115 OneHopState state; 118 uint16_t pendingLinks; 119 LinkID bootstrapLink; 116 vector<LinkID> bootstrapLinks; 120 117 }; 121 118
Note:
See TracChangeset
for help on using the changeset viewer.