Changeset 3055 for source/ariba/overlay
- Timestamp:
- Apr 23, 2009, 5:55:59 PM (16 years ago)
- Location:
- source/ariba/overlay
- Files:
-
- 2 deleted
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
source/ariba/overlay/BaseOverlay.cpp
r3041 r3055 40 40 41 41 #include "ariba/utility/misc/OvlVis.h" 42 using ariba::utility::OvlVis; 42 #include "ariba/NodeListener.h" 43 #include "ariba/CommunicationListener.h" 43 44 44 45 namespace ariba { … … 146 147 147 148 // inform all registered services of the event 148 BOOST_FOREACH( ServiceInterface* i, listenerMux.getOneList()){149 BOOST_FOREACH( NodeListener* i, nodeListeners ){ 149 150 if( ret ) i->onLeaveSuccess( spovnetId ); 150 151 else i->onLeaveFail( spovnetId ); … … 176 177 177 178 overlayInterface->joinOverlay(); 178 BOOST_FOREACH( ServiceInterface* i, listenerMux.getOneList()){179 BOOST_FOREACH( NodeListener* i, nodeListeners ){ 179 180 i->onJoinSuccess( spovnetId ); 180 181 } … … 221 222 const LinkID BaseOverlay::establishLink(const EndpointDescriptor& ep, const ServiceID& service){ 222 223 223 if( ! listenerMux.contains( service ) ){224 if( !communicationListeners.contains( service ) ){ 224 225 logging_error( "no registered listener on serviceid " << service.toString() ); 225 226 return LinkID::UNSPECIFIED; 226 227 } 227 228 228 ServiceInterface* receiver = listenerMux.get( service );229 CommunicationListener* receiver = communicationListeners.get( service ); 229 230 const LinkID link = bc->establishLink( ep ); 230 231 … … 308 309 } 309 310 310 bool BaseOverlay::bind(ServiceInterface* service, const ServiceID& sid) { 311 312 logging_debug( "binding service " << service << " on serviceid " << sid.toString() ); 313 314 if( listenerMux.contains( sid ) ){ 315 logging_error( "some service already registered for service id " << sid.toString() ); 311 void BaseOverlay::bind(CommunicationListener* listener, const ServiceID& sid){ 312 logging_debug( "binding communication listener " << listener 313 << " on serviceid " << sid.toString() ); 314 315 if( communicationListeners.contains( sid ) ){ 316 logging_error( "some listener already registered for service id " 317 << sid.toString() ); 316 318 return false; 317 319 } 318 320 319 listenerMux.registerItem( service, sid );321 communicationListeners.registerItem( listener, sid ); 320 322 return true; 321 323 } 322 324 323 ServiceInterface* BaseOverlay::unbind(const ServiceID& sid){ 324 325 logging_debug( "unbinding service from serviceid " << sid.toString() ); 326 327 if( !listenerMux.contains( sid ) ){ 328 logging_warn( "cannot unbind service. no service registered on service id " << sid.toString() ); 329 return NULL; 330 } 331 332 ServiceInterface* iface = listenerMux.get( sid ); 333 listenerMux.unregisterItem( sid ); 334 335 return NULL; //iface; 325 void BaseOverlay::unbind(CommunicationListener* listener, const ServiceID& sid){ 326 logging_debug( "unbinding listener " << listener 327 << " from serviceid " << sid.toString() ); 328 329 if( !communicationListeners.contains( sid ) ){ 330 logging_warn( "cannot unbind listener. no listener registered on service id " << sid.toString() ); 331 return; 332 } 333 334 if( communicationListeners.get(sid) != listener ){ 335 logging_warn( "listener bound to service id " << sid.toString() 336 << " is different than listener trying to unbind" ); 337 return; 338 } 339 340 communicationListeners.unregisterItem( sid ); 341 } 342 343 void BaseOverlay::bind(NodeListener* listener){ 344 logging_debug( "binding node listener " << listener ); 345 346 NodeListenerVector::iterator i = nodeListeners.find( listener ); 347 if( i != nodeListeners.end() ){ 348 logging_warn( "node listener " << listener << " is already bound, cannot bind" ); 349 return; 350 } 351 352 nodeListeners.push_back( listener ); 353 } 354 355 void BaseOverlay::unbind(NodeListener* listener){ 356 logging_debug( "unbinding node listener " << listener ); 357 358 NodeListenerVector::iterator i = nodeListeners.find( listener ); 359 if( i == nodeListeners.end() ){ 360 logging_warn( "node listener " << listener << " is not bound, cannot unbind" ); 361 return; 362 } 363 364 nodeListeners.erase( i ); 336 365 } 337 366 … … 501 530 502 531 const ServiceID& service = overlayMsg->getService(); 503 ServiceInterface* serviceListener = listenerMux.get( service );532 CommunicationListener* serviceListener = communicationListeners.get( service ); 504 533 505 534 logging_debug( "received data for service " << service.toString() ); … … 544 573 bool allow = true; 545 574 546 BOOST_FOREACH( ServiceInterface* i, listenerMux.getOneList()){575 BOOST_FOREACH( NodeListener* i, nodeListeners ){ 547 576 allow &= i->isJoinAllowed( overlayMsg->getSourceNode(), spovnetId ); 548 577 } … … 615 644 616 645 // inform all registered services of the event 617 BOOST_FOREACH( ServiceInterface* i, listenerMux.getOneList() ){646 BOOST_FOREACH( NodeListener* i, nodeListeners{ 618 647 i->onJoinFail( spovnetId ); 619 648 } … … 640 669 641 670 // inform all registered services of the event 642 BOOST_FOREACH( ServiceInterface* i, listenerMux.getOneList()){671 BOOST_FOREACH( NodeListener* i, nodeListeners ){ 643 672 i->onJoinFail( spovnetId ); 644 673 } … … 662 691 663 692 // inform all registered services of the event 664 BOOST_FOREACH( ServiceInterface* i, listenerMux.getOneList()){693 BOOST_FOREACH( NodeListener* i, nodeListeners ){ 665 694 i->onJoinSuccess( spovnetId ); 666 695 } … … 717 746 // 718 747 719 if( ! listenerMux.contains( service ) ){748 if( !communicationListeners.contains( service ) ){ 720 749 logging_warn( "linkup event for service that has not been registered" ); 721 750 return false; 722 751 } 723 752 724 ServiceInterface* iface = listenerMux.get( service );753 CommunicationListener* iface = communicationListeners.get( service ); 725 754 if( iface == NULL ){ 726 755 logging_warn( "linkup event for service that has been registered with a NULL interface" ); … … 762 791 763 792 // inform all registered services of the event 764 BOOST_FOREACH( ServiceInterface* i, listenerMux.getOneList()){793 BOOST_FOREACH( NodeListener* i, nodeListeners ){ 765 794 i->onLeaveFail( spovnetId ); 766 795 } … … 774 803 775 804 // inform all registered services of the event 776 BOOST_FOREACH( ServiceInterface* i, listenerMux.getOneList()){805 BOOST_FOREACH( NodeListener* i, nodeListeners ){ 777 806 i->onNodeLeave( overlayMsg->getSourceNode(), spovnetId ); 778 807 } … … 879 908 << node.toString() ); 880 909 881 BOOST_FOREACH( ServiceInterface* i, listenerMux.getOneList()){910 BOOST_FOREACH( NodeListener* i, nodeListeners ){ 882 911 i->onNodeJoin( node, spovnetId ); 883 912 } -
source/ariba/overlay/BaseOverlay.h
r3041 r3055 59 59 #include "ariba/communication/CommunicationEvents.h" 60 60 61 #include "ariba/interface/ServiceInterface.h"62 63 61 #include "ariba/overlay/modules/OverlayInterface.h" 64 62 #include "ariba/overlay/modules/OverlayFactory.h" … … 67 65 #include "ariba/overlay/messages/JoinRequest.h" 68 66 #include "ariba/overlay/messages/JoinReply.h" 67 68 // forward declerations 69 namespace ariba { 70 class NodeListener; 71 class CommunicationListener; 72 73 namespace utility { 74 class OvlVis; 75 } 76 } 69 77 70 78 using std::vector; … … 76 84 using std::find; 77 85 86 using ariba::NodeListener; 87 using ariba::CommunicationListener; 88 78 89 using ariba::communication::EndpointDescriptor; 79 90 using ariba::communication::BaseCommunication; 80 91 using ariba::communication::CommunicationEvents; 81 82 using ariba::interface::ServiceInterface;83 92 84 93 using ariba::overlay::OverlayMsg; … … 101 110 using ariba::utility::seqnum_t; 102 111 using ariba::utility::Timer; 112 using ariba::utility::OvlVis; 103 113 104 114 #define ovl OvlVis::instance() 105 115 #define ovlId OvlVis::NETWORK_ID_BASE_OVERLAY 106 107 // needed for friend decleration108 // in different namespace109 namespace ariba {110 class Node;111 }112 116 113 117 namespace ariba { … … 121 125 122 126 use_logging_h( BaseOverlay ); 123 friend class ariba::Node;124 125 127 public: 126 127 128 /** 128 129 * Constructs an empty non-functional base overlay instance … … 147 148 /** 148 149 * Starts a link establishment procedure to the specfied node 150 * for the service with id service 149 151 * 150 * @param node The node id 152 * @param node Destination node id 153 * @param service Service to connect to 151 154 */ 152 155 const LinkID establishLink( const NodeID& node, const ServiceID& service ); 153 156 154 157 /** 155 * TODO 158 * Starts a link establishment procedure to the specified 159 * endpoint and to the specified service 156 160 */ 157 161 const LinkID establishLink( const EndpointDescriptor& ep, const ServiceID& service ); … … 176 180 * Depending on the structure of the overlay, this can be very different. 177 181 */ 178 void broadcastMessage( 179 Message* message, 180 const ServiceID& service 181 ); 182 void broadcastMessage( Message* message, const ServiceID& service ); 182 183 183 184 /** … … 200 201 201 202 /** 202 * Registers a receiver. 203 * 204 * @param receiver An implementation of the receiver interface 205 */ 206 bool bind( ServiceInterface* service, const ServiceID& sid ); 207 208 /** 209 * Unregister a receiver. 210 * 211 * @param sid The service id to unregister 212 */ 213 ServiceInterface* unbind( const ServiceID& sid ); 203 * TODO 204 */ 205 void bind(CommunicationListener* listener, const ServiceID& sid); 206 207 /** 208 * TODO 209 */ 210 void unbind(CommunicationListener* listener, const ServiceID& sid); 211 212 /** 213 * TODO 214 */ 215 void bind(NodeListener* listener); 216 217 /** 218 * TODO 219 */ 220 void unbind(NodeListener* listener); 214 221 215 222 /** … … 221 228 const NodeID& getNodeID( const LinkID& lid = LinkID::UNSPECIFIED ) const ; 222 229 223 protected: 224 225 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 226 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 227 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 228 229 void joinSpoVNet( 230 const SpoVNetID& id, 231 const EndpointDescriptor& bootstrapEp 232 ); 233 230 /** 231 * TODO 232 */ 233 void joinSpoVNet( const SpoVNetID& id, const EndpointDescriptor& bootstrapEp ); 234 235 /** 236 * TODO 237 */ 234 238 void createSpoVNet( 235 239 const SpoVNetID& id, … … 239 243 ); 240 244 241 void leaveSpoVNet( 242 ); 243 244 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 245 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 246 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 247 245 /** 246 * TODO 247 */ 248 void leaveSpoVNet(); 249 250 protected: 251 252 /** 253 * TODO 254 */ 248 255 virtual void onLinkUp( const LinkID& id, const NetworkLocator* local, const NetworkLocator* remote ); 249 256 257 /** 258 * TODO 259 */ 250 260 virtual void onLinkDown( const LinkID& id, const NetworkLocator* local, const NetworkLocator* remote ); 251 261 252 262 virtual void onLinkChanged( const LinkID& id, const NetworkLocator* oldlocal, const NetworkLocator* newlocal, const NetworkLocator* oldremote, const NetworkLocator* newremote ); 253 263 264 /** 265 * TODO 266 */ 254 267 virtual void onLinkFail( const LinkID& id, const NetworkLocator* local, const NetworkLocator* remote ); 255 268 269 /** 270 * TODO 271 */ 256 272 virtual void onLinkQoSChanged( const LinkID& id, const NetworkLocator* local, const NetworkLocator* remote, const QoSParameterSet& qos ); 257 273 … … 260 276 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 261 277 278 /** 279 * TODO 280 */ 262 281 virtual bool receiveMessage( const Message* message, const LinkID& link, const NodeID& ); // nodeid is not valid in this case! 263 282 … … 270 289 */ 271 290 virtual void incomingRouteMessage( Message* msg ); 291 292 /** 293 * see OverlayStructureEvents.h, called from specific OverlayInterface class 294 */ 272 295 virtual void onNodeJoin( const NodeID& node ); 273 296 274 // for timer events 297 298 /** 299 * TODO, for timer events 300 */ 275 301 virtual void eventFunction(); 276 302 277 303 private: 278 279 304 /** 280 305 * The BaseCommunication the BaseOverlay … … 295 320 296 321 /** 297 * A demultiplexer that maps listeners to service ids 298 * to deliver upcoming messages to the correct service. 299 */ 300 Demultiplexer<ServiceInterface*, ServiceID> listenerMux; 322 * TODO 323 */ 324 Demultiplexer<CommunicationListener*, ServiceID> communicationListeners; 325 326 /** 327 * TODO 328 */ 329 typedef vector<NodeListener*> NodeListenerVector; 330 331 /** 332 * TODO 333 */ 334 NodeListenerVector nodeListeners; 301 335 302 336 /** … … 322 356 } BaseOverlayState; 323 357 358 /** 359 * TODO 360 */ 324 361 BaseOverlayState state; 325 362 … … 344 381 345 382 LinkItem( const LinkID& _link, const NodeID& _node, 346 const ServiceID& _service, ServiceInterface* _interface )383 const ServiceID& _service, CommunicationListener* _interface ) 347 384 : link( _link ), node( _node ), service( _service ), interface( _interface ), 348 385 autolink( false ), lastuse( time(NULL) ) { … … 354 391 NodeID node; 355 392 ServiceID service; 356 ServiceInterface* interface;393 CommunicationListener* interface; 357 394 358 395 // information needed for auto links … … 370 407 LinkMapping linkMapping; 371 408 372 // nodes with pending joines. TODO: should be cleaned every some seconds 373 // add timestamps to each, and check on occasion 409 410 /** 411 * nodes with pending joines. TODO: should be cleaned every 412 * some seconds, add timestamps to each, and check on occasion 413 */ 374 414 typedef vector<NodeID> JoiningNodes; 375 415 JoiningNodes joiningNodes; -
source/ariba/overlay/modules/OverlayInterface.h
r3054 r3055 40 40 #define __OVERLAY_INTERFACE_H 41 41 42 #include "ariba/CommunicationListener.h" 42 43 #include "ariba/communication/EndpointDescriptor.h" 43 #include "ariba/interface/ServiceInterface.h"44 44 #include "ariba/overlay/modules/OverlayStructureEvents.h" 45 45 #include "ariba/utility/types/NodeID.h" 46 46 #include "ariba/utility/types/ServiceID.h" 47 47 48 using ariba::CommunicationListener; 48 49 using ariba::communication::EndpointDescriptor; 49 using ariba::interface::ServiceInterface;50 50 using ariba::overlay::OverlayStructureEvents; 51 51 using ariba::utility::NodeID; … … 57 57 class BaseOverlay; 58 58 59 class OverlayInterface : public ServiceInterface{59 class OverlayInterface : public CommunicationListener { 60 60 public: 61 61 OverlayInterface( -
source/ariba/overlay/modules/onehop/OneHop.h
r3054 r3055 85 85 86 86 // 87 // see ServiceInterface.h and OverlayInterface.h87 // see CommunicationListener.h and OverlayInterface.h 88 88 // 89 89
Note:
See TracChangeset
for help on using the changeset viewer.