Changeset 5151 for source/ariba/overlay/BaseOverlay.h
- Timestamp:
- Jul 21, 2009, 1:54:55 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
source/ariba/overlay/BaseOverlay.h
r4836 r5151 86 86 // ariba interface 87 87 using ariba::NodeListener; 88 using ariba::SideportListener; 88 89 using ariba::CommunicationListener; 89 90 … … 117 118 namespace overlay { 118 119 119 class BaseOverlay: public MessageReceiver, public CommunicationEvents, 120 public OverlayStructureEvents, protected Timer { 121 122 private: 120 class LinkDescriptor; 121 122 class BaseOverlay: public MessageReceiver, 123 public CommunicationEvents, 124 public OverlayStructureEvents, 125 protected Timer { 126 123 127 friend class OneHop; 124 128 friend class Chord; 129 friend class ariba::SideportListener; 125 130 126 131 use_logging_h( BaseOverlay ); … … 157 162 */ 158 163 const LinkID establishLink(const NodeID& node, const ServiceID& service, 159 164 const LinkID& linkid = LinkID::UNSPECIFIED); 160 165 161 166 /** 162 167 * Starts a link establishment procedure to the specified 163 * 168 * endpoint and to the specified service. Concurrently it tries to 169 * establish a relay link over the overlay using the nodeid 170 */ 171 const LinkID establishLink(const EndpointDescriptor& ep, const NodeID& nodeid, 172 const ServiceID& service, const LinkID& linkid = LinkID::UNSPECIFIED); 173 174 /** 175 * Starts a link establishment procedure to the specified 164 176 * endpoint and to the specified service 165 177 */ 166 178 const LinkID establishLink(const EndpointDescriptor& ep, 167 const ServiceID& service, const LinkID& linkid = 168 LinkID::UNSPECIFIED); 179 const ServiceID& service, const LinkID& linkid = LinkID::UNSPECIFIED); 169 180 170 181 /// drops a link … … 176 187 /// sends a message to a node and a specific service 177 188 seqnum_t sendMessage(const Message* message, const NodeID& node, 178 189 const ServiceID& service); 179 190 180 191 /** … … 251 262 * @param boot A bootstrap node 252 263 */ 253 void joinSpoVNet(const SpoVNetID& id, const EndpointDescriptor& boot 264 void joinSpoVNet(const SpoVNetID& id, const EndpointDescriptor& boot); 254 265 255 266 /** … … 275 286 */ 276 287 virtual void onLinkUp(const LinkID& id, const NetworkLocator* local, 277 288 const NetworkLocator* remote); 278 289 279 290 /** … … 281 292 */ 282 293 virtual void onLinkDown(const LinkID& id, const NetworkLocator* local, 283 294 const NetworkLocator* remote); 284 295 285 296 /** … … 287 298 */ 288 299 virtual void onLinkChanged(const LinkID& id, 289 290 300 const NetworkLocator* oldlocal, const NetworkLocator* newlocal, 301 const NetworkLocator* oldremote, const NetworkLocator* newremote); 291 302 292 303 /** … … 294 305 */ 295 306 virtual void onLinkFail(const LinkID& id, const NetworkLocator* local, 296 307 const NetworkLocator* remote); 297 308 298 309 /** … … 300 311 */ 301 312 virtual void onLinkQoSChanged(const LinkID& id, 302 303 313 const NetworkLocator* local, const NetworkLocator* remote, 314 const QoSParameterSet& qos); 304 315 305 316 /** … … 307 318 */ 308 319 virtual bool onLinkRequest(const LinkID& id, const NetworkLocator* local, 309 const NetworkLocator* remote); 320 const NetworkLocator* remote); 321 322 /** 323 * Processes a received message from BaseCommunication 324 * 325 * In case of a message routed by the overlay the source identifies 326 * the node the message came from! 327 */ 328 virtual bool receiveMessage(const Message* message, const LinkID& link, 329 const NodeID& source = NodeID::UNSPECIFIED); 310 330 311 331 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 312 332 313 /** 314 * Processes a received message. 315 * 316 * Beware: nodeid is not valid in this case! (since this class implements 317 * nodeid's in the first place *g*) 318 */ 319 virtual bool receiveMessage( 320 const Message* message, const LinkID& link, const NodeID&); 333 /// handles an incoming message with link descriptor 334 bool handleMessage(const Message* message, 335 const LinkID& boLink, const LinkID& bcLink, const NodeID& remoteNode ); 321 336 322 337 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 323 324 338 /** 325 339 * This method is called, when a routed message arrives from the … … 328 342 * @see OverlayStructureEvents.h 329 343 */ 330 virtual void incomingRouteMessage(Message* msg); 344 virtual void incomingRouteMessage(Message* msg, 345 const LinkID& link = LinkID::UNSPECIFIED, 346 const NodeID& source = NodeID::UNSPECIFIED); 331 347 332 348 /** … … 343 359 344 360 private: 345 /** 346 * The BaseCommunication the BaseOverlay 347 * communicates over 348 */ 349 BaseCommunication* bc; 350 351 /** 352 * The nodeid of this BaseOverlay instance. 353 */ 354 NodeID nodeId; 355 356 /** 357 * The SpoVNetID that we are joined to 358 * or that we have created. 359 */ 360 SpoVNetID spovnetId; 361 362 /** 363 * TODO 364 */ 365 Demultiplexer<CommunicationListener*, ServiceID> communicationListeners; 366 367 /** 368 * TODO 369 */ 370 typedef vector<NodeListener*> NodeListenerVector; 371 372 /** 373 * TODO 374 */ 375 NodeListenerVector nodeListeners; 376 377 /** 378 * TODO 379 */ 380 SideportListener* sideport; 381 382 /** 383 * The abstract overlay interface that implements 384 * the overlay specific functionality. 385 */ 386 OverlayInterface* overlayInterface; 387 388 /** 389 * The special link to the Initiator of the SpoVNet 390 * or LinkID::UNDEFINED if we are the Initiator 391 */ 392 LinkID initiatorLink; 393 394 /** 395 * The state of the BaseOverlay 396 */ 361 362 /// The state of the BaseOverlay 397 363 typedef enum _BaseOverlayState { 398 364 BaseOverlayStateInvalid = 0, … … 402 368 } BaseOverlayState; 403 369 404 /** 405 * TODO 406 */ 407 BaseOverlayState state; 408 409 /** 410 * The initiator node 411 */ 412 NodeID spovnetInitiator; 413 414 /** 415 * OvlVis 416 */ 417 NodeID min, max; 418 NodeID succ, pred; 419 void updateOvlVis(const NodeID& node); 420 421 /** 422 * Link management 423 */ 424 class LinkItem { 425 public: 426 static const LinkItem UNSPECIFIED; 427 428 LinkItem() : 429 link(LinkID::UNSPECIFIED), 430 node(NodeID::UNSPECIFIED), 431 service(ServiceID::UNSPECIFIED), 432 interface(&CommunicationListener::DEFAULT), 433 autolink(false), 434 lastuse(0), 435 linkup(false){ 436 } 437 438 LinkItem(const LinkID& _link, const NodeID& _node, 439 const ServiceID& _service, CommunicationListener* _interface) : 440 link(_link), 441 node(_node), 442 service(_service), 443 interface(_interface), 444 autolink(false), 445 lastuse(time(NULL)), 446 linkup(false){ 447 448 assert( _interface != NULL ); 449 } 450 451 LinkItem(const LinkItem& rh) : 452 link(rh.link), 453 node(rh.node), 454 service(rh.service), 455 interface(rh.interface), 456 autolink(rh.autolink), 457 lastuse(rh.lastuse), 458 linkup(rh.linkup){ 459 460 BOOST_FOREACH( Message* msg, rh.waitingmsg ){ 461 waitingmsg.push_back( msg ); 462 } 463 } 464 465 void deleteWaiting(){ 466 BOOST_FOREACH( Message* msg, waitingmsg ){ 467 delete msg; 468 } 469 waitingmsg.clear(); 470 } 471 472 // general information about the link 473 const LinkID link; 474 NodeID node; 475 ServiceID service; 476 CommunicationListener* interface; 477 bool linkup; 478 479 // information needed for auto links 480 void markused() { 481 lastuse = time(NULL); 482 } 483 484 bool autolink; 485 time_t lastuse; 486 deque<Message*> waitingmsg; 487 }; 488 489 typedef map<const LinkID, LinkItem> LinkMapping; 490 typedef pair<const LinkID, LinkItem> LinkPair; 491 LinkMapping linkMapping; 370 BaseOverlayState state; ///< Current Base-Overlay state 371 BaseCommunication* bc; ///< reference to the base communication 372 NodeID nodeId; ///< the node id of this node 373 SpoVNetID spovnetId; ///< the spovnet id of the currently joined overlay 374 LinkID initiatorLink; ///< the link id of the link to the initiator node 375 NodeID spovnetInitiator;///< The initiator node 376 377 /// the service id communication listeners 378 Demultiplexer<CommunicationListener*, ServiceID> communicationListeners; 379 380 /// the node listeners 381 typedef vector<NodeListener*> NodeListenerVector; 382 NodeListenerVector nodeListeners; 383 384 /// the sideport listener 385 SideportListener* sideport; 386 387 /// the used overlay structure 388 OverlayInterface* overlayInterface; 389 390 /// The link mapping of the node 391 vector<LinkDescriptor*> links; 392 void eraseDescriptor(const LinkID& link, bool communication = false); 393 394 /// returns a link descriptor for the given id 395 LinkDescriptor* getDescriptor(const LinkID& link, 396 bool communication = false); 397 398 /// returns a link descriptor for the given id 399 const LinkDescriptor* getDescriptor(const LinkID& link, 400 bool communication = false) const; 401 402 /// returns a auto-link descriptor for the given node and service id 403 LinkDescriptor* getAutoDescriptor(const NodeID& node, const ServiceID& service); 404 405 /// adds a new link descriptor or uses an existing one 406 LinkDescriptor* addDescriptor(const LinkID& link = LinkID::UNSPECIFIED); 407 408 /// returns a direct link relay descriptor to the given relay node 409 LinkDescriptor* getRelayDescriptor( const NodeID& relayNode ); 410 411 /// find a proper relay node that is directly connected to this node 412 const NodeID findRelayNode( const NodeID& id ); 413 414 /// forwards a message over relays/overlay/directly using link descriptor 415 seqnum_t sendMessage( Message* message, const LinkDescriptor* ld ); 416 417 /// creates a link descriptor, applys relay semantics if possible 418 LinkDescriptor* createLinkDescriptor( 419 const NodeID& remoteNode, const ServiceID& service, const LinkID& link_id ); 492 420 493 421 // map of a link request map a nonce to a LinkID … … 495 423 PendingLinkMap pendingLinks; 496 424 425 void showLinkState(); 426 497 427 /** 498 428 * nodes with pending joines. TODO: should be cleaned every … … 502 432 JoiningNodes joiningNodes; 503 433 434 int counter; 435 504 436 /** 505 437 * Bootstrapper for our spovnet
Note:
See TracChangeset
for help on using the changeset viewer.