Changeset 12060 for source/ariba/overlay/BaseOverlay.h
- Timestamp:
- Jun 19, 2013, 11:05:49 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
source/ariba/overlay/BaseOverlay.h
r10653 r12060 47 47 #include <vector> 48 48 #include <deque> 49 #include <stdexcept> 49 50 #include <boost/foreach.hpp> 51 52 #ifdef ECLIPSE_PARSER 53 #define foreach(a, b) for(a : b) 54 #else 55 #define foreach(a, b) BOOST_FOREACH(a, b) 56 #endif 50 57 51 58 #include "ariba/utility/messages.h" … … 64 71 #include "ariba/overlay/modules/OverlayStructureEvents.h" 65 72 #include "ariba/overlay/OverlayBootstrap.h" 73 #include "ariba/overlay/SequenceNumber.h" 66 74 67 75 // forward declarations … … 92 100 using ariba::communication::BaseCommunication; 93 101 using ariba::communication::CommunicationEvents; 102 103 // transport 104 //using ariba::transport::system_priority; 94 105 95 106 // utilities … … 103 114 using ariba::utility::Demultiplexer; 104 115 using ariba::utility::MessageReceiver; 105 using ariba::utility::MessageSender;106 116 using ariba::utility::seqnum_t; 107 117 using ariba::utility::Timer; … … 110 120 namespace overlay { 111 121 112 using namespace ariba::addressing; 122 123 124 class message_not_sent: public std::runtime_error 125 { 126 public: 127 /** Takes a character string describing the error. */ 128 explicit message_not_sent(const string& __arg) : 129 std::runtime_error(__arg) 130 { 131 } 132 133 virtual ~message_not_sent() throw() {} 134 }; 135 136 113 137 114 138 class LinkDescriptor; … … 121 145 protected Timer { 122 146 123 friend class OneHop; 147 // friend class OneHop; // DEPRECATED 124 148 friend class Chord; 125 149 friend class ariba::SideportListener; … … 128 152 129 153 public: 130 131 154 /** 132 155 * Constructs an empty non-functional base overlay instance … … 142 165 * Starts the Base Overlay instance 143 166 */ 144 void start(BaseCommunication &_basecomm, const NodeID& _nodeid);167 void start(BaseCommunication* _basecomm, const NodeID& _nodeid); 145 168 146 169 /** … … 161 184 * Starts a link establishment procedure to the specfied node 162 185 * for the service with id service 163 * 186 * 164 187 * @param node Destination node id 165 188 * @param service Service to connect to … … 179 202 void dropLink( const LinkID& link ); 180 203 204 205 206 /* +++++ Message sending +++++ */ 207 208 181 209 /// sends a message over an existing link 182 seqnum_t sendMessage(const Message* message, const LinkID& link ); 210 const SequenceNumber& sendMessage(reboost::message_t message, 211 const LinkID& link, 212 uint8_t priority ) throw(message_not_sent); 183 213 184 214 /// sends a message to a node and a specific service 185 seqnum_t sendMessage(const Message* message, const NodeID& remote, 186 const ServiceID& service = OverlayInterface::OVERLAY_SERVICE_ID); 215 const SequenceNumber& sendMessage(reboost::message_t message, 216 const NodeID& remote, 217 uint8_t priority, 218 const ServiceID& service = OverlayInterface::OVERLAY_SERVICE_ID); 219 187 220 188 221 /** … … 191 224 * @return NodeID of the (closest) destination node; 192 225 */ 193 NodeID sendMessageCloserToNodeID( const Message*message, const NodeID& address,194 const ServiceID& service = OverlayInterface::OVERLAY_SERVICE_ID);226 NodeID sendMessageCloserToNodeID(reboost::message_t message, const NodeID& address, 227 uint8_t priority, const ServiceID& service = OverlayInterface::OVERLAY_SERVICE_ID); 195 228 196 229 /** … … 198 231 * Depending on the structure of the overlay, this can be very different. 199 232 */ 200 void broadcastMessage(Message* message, const ServiceID& service); 201 233 void broadcastMessage(reboost::message_t message, const ServiceID& service, uint8_t priority); 234 235 236 /* +++++ [Message sending] +++++ */ 237 238 239 202 240 /** 203 241 * Returns the end-point descriptor of a link. … … 294 332 */ 295 333 void leaveSpoVNet(); 334 335 336 /* link status */ 337 bool isLinkDirect(const ariba::LinkID& lnk) const; 338 int getHopCount(const ariba::LinkID& lnk) const; 339 340 bool isLinkVital(const LinkDescriptor* link) const; 341 bool isLinkDirectVital(const LinkDescriptor* link) const; 296 342 297 343 protected: 298 /** 299 * @see ariba::communication::CommunicationEvents.h 300 */ 301 virtual void onLinkUp(const LinkID& id, const address_v* local, 302 const address_v* remote); 303 304 /** 305 * @see ariba::communication::CommunicationEvents.h 306 */ 307 virtual void onLinkDown(const LinkID& id, const address_v* local, 308 const address_v* remote); 309 310 /** 311 * @see ariba::communication::CommunicationEvents.h 312 */ 313 virtual void onLinkChanged(const LinkID& id, 314 const address_v* oldlocal, const address_v* newlocal, 315 const address_v* oldremote, const address_v* newremote); 316 317 /** 318 * @see ariba::communication::CommunicationEvents.h 319 */ 320 virtual void onLinkFail(const LinkID& id, const address_v* local, 321 const address_v* remote); 322 323 /** 324 * @see ariba::communication::CommunicationEvents.h 325 */ 326 virtual void onLinkQoSChanged(const LinkID& id, 327 const address_v* local, const address_v* remote, 328 const QoSParameterSet& qos); 329 330 /** 331 * @see ariba::communication::CommunicationEvents.h 332 */ 333 virtual bool onLinkRequest(const LinkID& id, const address_v* local, 334 const address_v* remote); 335 344 345 /** 346 * @see ariba::communication::CommunicationEvents.h 347 */ 348 virtual bool onLinkRequest(const LinkID& id, 349 const addressing2::EndpointPtr local, 350 const addressing2::EndpointPtr remote); 351 352 /** 353 * @see ariba::communication::CommunicationEvents.h 354 */ 355 virtual void onLinkUp(const LinkID& id, 356 const addressing2::EndpointPtr local, const addressing2::EndpointPtr remote); 357 358 /** 359 * @see ariba::communication::CommunicationEvents.h 360 */ 361 virtual void onLinkDown(const LinkID& id, 362 const addressing2::EndpointPtr local, const addressing2::EndpointPtr remote); 363 364 /** 365 * @see ariba::communication::CommunicationEvents.h 366 */ 367 virtual void onLinkChanged(const LinkID& id, 368 const addressing2::EndpointPtr oldlocal, const addressing2::EndpointPtr newlocal, 369 const addressing2::EndpointPtr oldremote, const addressing2::EndpointPtr newremote); 370 371 /** 372 * @see ariba::communication::CommunicationEvents.h 373 * 374 * NOTE: Just calls onLinkDown (at the moment..) 375 */ 376 virtual void onLinkFail(const LinkID& id, 377 const addressing2::EndpointPtr local, const addressing2::EndpointPtr remote); 378 379 /** 380 * @see ariba::communication::CommunicationEvents.h 381 */ 382 // virtual void onLinkQoSChanged(const LinkID& id, 383 // const addressing2::EndpointPtr local, const addressing2::EndpointPtr remote, 384 // const QoSParameterSet& qos); 385 386 387 388 336 389 /** 337 390 * Processes a received message from BaseCommunication … … 340 393 * the node the message came from! 341 394 */ 342 virtual bool receiveMessage( const Message* message, const LinkID& link, 343 const NodeID& ); 395 virtual bool receiveMessage( reboost::shared_buffer_t message, 396 const LinkID& link, 397 const NodeID&, 398 bool bypass_overlay ); 344 399 345 400 /** … … 359 414 std::string getLinkHTMLInfo(); 360 415 416 417 private: 418 /// NOTE: "id" is an Overlay-LinkID 419 void __onLinkEstablishmentFailed(const LinkID& id); 420 421 /// called from typeLinkClose-handler 422 void __removeDroppedLink(const LinkID& link); 423 361 424 private: 362 425 /// is the base overlay started yet … … 396 459 397 460 /// demultiplexes a incoming message with link descriptor 398 bool handleMessage( const Message*message, LinkDescriptor* ld,461 bool handleMessage( reboost::shared_buffer_t message, LinkDescriptor* ld, 399 462 const LinkID bcLink = LinkID::UNSPECIFIED ); 400 463 401 464 // handle data and signalling messages 402 bool handleData( OverlayMsg* msg, LinkDescriptor* ld ); 465 bool handleData( reboost::shared_buffer_t message, OverlayMsg* msg, LinkDescriptor* ld ); 466 bool handleLostMessage( reboost::shared_buffer_t message, OverlayMsg* msg ); 403 467 bool handleSignaling( OverlayMsg* msg, LinkDescriptor* ld ); 404 468 405 469 // handle join request / reply messages 406 bool handleJoinRequest( OverlayMsg* msg, const LinkID& bcLink );407 bool handleJoinReply( OverlayMsg* msg, const LinkID& bcLink );470 bool handleJoinRequest( reboost::shared_buffer_t message, const NodeID& source, const LinkID& bcLink ); 471 bool handleJoinReply( reboost::shared_buffer_t message, const LinkID& bcLink ); 408 472 409 473 // handle link messages 410 474 bool handleLinkRequest( OverlayMsg* msg, LinkDescriptor* ld ); 411 bool handleLinkReply( OverlayMsg* msg, LinkDescriptor* ld );475 bool handleLinkReply( OverlayMsg* msg, reboost::shared_buffer_t sub_message, LinkDescriptor* ld ); 412 476 bool handleLinkUpdate( OverlayMsg* msg, LinkDescriptor* ld ); 413 477 bool handleLinkDirect( OverlayMsg* msg, LinkDescriptor* ld ); 414 478 bool handleLinkAlive( OverlayMsg* msg, LinkDescriptor* ld ); 479 480 // ping-pong over overlaypath/routing 481 bool handlePing( OverlayMsg* overlayMsg, LinkDescriptor* ld ); 482 bool handlePong( OverlayMsg* overlayMsg, LinkDescriptor* ld ); 415 483 416 484 … … 478 546 // internal message delivery ----------------------------------------------- 479 547 548 // Convert OverlayMessage into new format and give it down to BaseCommunication 549 seqnum_t send_overlaymessage_down( OverlayMsg* message, const LinkID& bc_link, uint8_t priority ); 550 551 480 552 /// routes a message to its destination node 481 void route( OverlayMsg* message );482 553 void route( OverlayMsg* message, const NodeID& last_hop = NodeID::UNSPECIFIED ); 554 483 555 /// sends a raw message to another node, delivers it to the base overlay class 484 seqnum_t send( OverlayMsg* message, const NodeID& destination ); 556 /// may throw "message_not_sent"-exception 557 seqnum_t send( OverlayMsg* message, 558 const NodeID& destination, 559 uint8_t priority, 560 const NodeID& last_hop = NodeID::UNSPECIFIED ) 561 throw(message_not_sent); 485 562 486 563 /// send a raw message using a link descriptor, delivers it to the base overlay class 487 seqnum_t send( OverlayMsg* message, LinkDescriptor* ld, 488 bool ignore_down = false ); 564 seqnum_t send( OverlayMsg* message, 565 LinkDescriptor* ld, 566 uint8_t priority ) throw(message_not_sent); 489 567 490 568 /// send a message using a node id using overlay routing 491 569 /// sets necessary fields in the overlay message! 492 seqnum_t send_node( OverlayMsg* message, const NodeID& remote, 493 const ServiceID& service = OverlayInterface::OVERLAY_SERVICE_ID); 570 /// may throw "message_not_sent"-exception 571 seqnum_t send_node( OverlayMsg* message, const NodeID& remote, uint8_t priority, 572 const ServiceID& service = OverlayInterface::OVERLAY_SERVICE_ID) throw(message_not_sent); 494 573 495 574 /// send a message using a node id using overlay routing using a link 496 575 /// sets necessary fields in the overlay message! 497 seqnum_t send_link( OverlayMsg* message, const LinkID& link, 498 bool ignore_down = false ); 499 576 void send_link( OverlayMsg* message, 577 const LinkID& link, 578 uint8_t priority ) throw(message_not_sent); 579 580 581 /// sends a notification to a sender from whom we just dropped a message 582 void report_lost_message( const OverlayMsg* message ); 583 500 584 // misc -------------------------------------------------------------------- 501 585
Note:
See TracChangeset
for help on using the changeset viewer.