Changeset 2483 for source/ariba/overlay
- Timestamp:
- Feb 24, 2009, 10:06:43 PM (16 years ago)
- Location:
- source/ariba/overlay
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
source/ariba/overlay/BaseOverlay.cpp
r2473 r2483 69 69 // ovl.visChangeNodeIcon(ovlId, nodeId, OvlVis::ICON_ID_CHARACTER_W); 70 70 // } 71 72 // timer for auto link management 73 Timer::setInterval( 5000 ); 74 Timer::start(); 71 75 } 72 76 … … 75 79 logging_info("deleting base overlay"); 76 80 81 Timer::stop(); 77 82 bc.unregisterMessageReceiver( this ); 78 83 bc.unregisterEventListener( this ); … … 147 152 // 148 153 // create the overlay 149 // and bootstrap against ourselfs150 154 // 151 155 152 156 overlayInterface->createOverlay(); 157 BOOST_FOREACH( ServiceInterface* i, listenerMux.getOneList() ){ 158 i->onOverlayCreate( spovnetId ); 159 } 160 161 // 162 // bootstrap against ourselfs 163 // 164 153 165 overlayInterface->joinOverlay(); 166 BOOST_FOREACH( ServiceInterface* i, listenerMux.getOneList() ){ 167 i->onJoinSuccess( spovnetId ); 168 } 154 169 155 170 ovl.visChangeNodeIcon ( ovlId, nodeId, OvlVis::ICON_ID_CAMERA ); 156 171 ovl.visChangeNodeColor( ovlId, nodeId, OvlVis::NODE_COLORS_GREEN); 157 158 // inform all registered services of the event159 BOOST_FOREACH( ServiceInterface* i, listenerMux.getOneList() ){160 i->onOverlayCreate( spovnetId );161 }162 172 } 163 173 … … 245 255 overmsg.encapsulate( const_cast<Message*>(message) ); 246 256 257 i->second.markused(); 247 258 return bc.sendMessage( link, &overmsg ); 248 259 } … … 263 274 264 275 if( link == LinkID::UNSPECIFIED ){ 265 logging_error( "no link could be found to send message to node " << 266 node.toString() << " for service " << service.toString() ); 267 return -1; 268 } 269 276 277 logging_info( "no link could be found to send message to node " << 278 node.toString() << " for service " << service.toString() << 279 ". creating auto link ..."); 280 281 const LinkID link = establishLink( node, service ); 282 LinkMapping::iterator i = linkMapping.find( link ); 283 284 if( i == linkMapping.end() ){ 285 logging_error( "failed to establish auto link to node " << node.toString() << 286 " for service " << service.toString() ); 287 return -1; 288 } 289 290 i->second.autolink = true; 291 292 } // if( link != LinkID::UNSPECIFIED ) 293 294 i->second.markused(); 270 295 return sendMessage( message, link ); 271 296 } … … 352 377 " on link " << id.toString() ); 353 378 354 OverlayMsg overMsg( OverlayMsg::OverlayMessageTypeUpdate, i->second.service, nodeId ); 379 OverlayMsg overMsg( 380 OverlayMsg::OverlayMessageTypeUpdate, 381 i->second.service, 382 nodeId 383 ); 384 355 385 bc.sendMessage( id, &overMsg ); 386 i->second.markused(); 356 387 357 388 } // if( i == linkMapping.end() ) … … 397 428 if( i->second.interface != NULL ) 398 429 i->second.interface->onLinkChanged( id, nodeId, i->second.node ); 430 431 i->second.markused(); 399 432 } 400 433 … … 412 445 if( i->second.interface != NULL ) 413 446 i->second.interface->onLinkFail( id, nodeId, i->second.node ); 447 448 i->second.markused(); 414 449 } 415 450 … … 427 462 if( i->second.interface != NULL ) 428 463 i->second.interface->onLinkQoSChanged( id, nodeId, i->second.node, qos ); 464 465 i->second.markused(); 429 466 } 430 467 … … 434 471 OverlayMsg* overlayMsg = ((Message*)message)->decapsulate<OverlayMsg>(); 435 472 if( overlayMsg == NULL ) return false; 473 474 // mark the link as in action 475 LinkMapping::iterator item = linkMapping.find( link ); 476 if( item != linkMapping.end() ) item->second.markused(); 436 477 437 478 // … … 683 724 i->second.interface = iface; 684 725 iface->onLinkUp( link, nodeId, sourcenode ); 726 i->second.markused(); 685 727 686 728 return true ; … … 828 870 } 829 871 872 void BaseOverlay::eventFunction(){ 873 874 list<LinkID> oldlinks; 875 time_t now = time(NULL); 876 877 // first gather all the links from linkMapping that need droppin 878 // don't directly drop, as the dropLink function affects the 879 // linkMapping structure that we are traversing here. 880 // drop links after a timeout of 30s 881 882 // the macro gets confused if type is passed directly 883 // because of the comma in the pair definition 884 typedef pair<LinkID,LinkItem> pairitem; 885 886 BOOST_FOREACH( pairitem item, linkMapping ){ 887 if( item.second.autolink && difftime(now, item.second.lastuse) > 30) 888 oldlinks.push_back( item.first ); 889 } 890 891 BOOST_FOREACH( const LinkID lnk, oldlinks ){ 892 dropLink( lnk ); 893 } 894 } 895 830 896 }} // namespace ariba, overlay -
source/ariba/overlay/BaseOverlay.h
r2473 r2483 43 43 #include <iostream> 44 44 #include <algorithm> 45 #include <ctime> 45 46 #include <boost/foreach.hpp> 46 47 … … 50 51 #include "ariba/utility/misc/Demultiplexer.hpp" 51 52 #include "ariba/utility/logging/Logging.h" 53 #include "ariba/utility/system/Timer.h" 52 54 53 55 #include "ariba/communication/EndpointDescriptor.h" … … 67 69 using std::map; 68 70 using std::make_pair; 71 using std::pair; 69 72 70 73 using ariba::communication::EndpointDescriptor; … … 92 95 using ariba::utility::MessageSender; 93 96 using ariba::utility::seqnum_t; 97 using ariba::utility::Timer; 94 98 95 99 #define ovl OvlVis::instance() … … 109 113 public MessageReceiver, 110 114 public CommunicationEvents, 111 public OverlayStructureEvents { 115 public OverlayStructureEvents, 116 protected Timer { 112 117 113 118 use_logging_h( BaseOverlay ); … … 248 253 virtual void onNodeJoin( const NodeID& node ); 249 254 255 // for timer events 256 virtual void eventFunction(); 257 250 258 private: 251 259 … … 316 324 static const LinkItem UNSPECIFIED; 317 325 318 LinkItem( const LinkID& _link, const NodeID& _node, 326 LinkItem( const LinkID& _link, const NodeID& _node, 319 327 const ServiceID& _service, ServiceInterface* _interface ) 320 : link( _link ), node( _node ), service( _service ), interface( _interface ){ 328 : link( _link ), node( _node ), service( _service ), interface( _interface ), 329 autolink( false ), lastuse( time(NULL) ) { 321 330 } 331 332 // general information about the link 322 333 323 334 const LinkID link; … … 325 336 ServiceID service; 326 337 ServiceInterface* interface; 338 339 // information needed for auto links 340 341 void markused(){ 342 lastuse = time(NULL); 343 } 344 345 bool autolink; 346 time_t lastuse; 327 347 }; 328 348
Note:
See TracChangeset
for help on using the changeset viewer.