An Overlay-based
Virtual Network Substrate
SpoVNet

Ignore:
Timestamp:
Jun 19, 2013, 11:05:49 AM (9 years ago)
Author:
hock@…
Message:

Reintegrate branch: 20130111-hock-message_classes

improvements:

  • new message classes (reboost, zero-copy)
  • "fast path" for direct links (skip overlay layer)
  • link-properties accessible from the application
  • SystemQueue? can call boost::bind functions
  • protlib compatibility removed (32bit overhead saved in every message)
  • addressing2
  • AddressDiscovery? discoveres only addresses on which we're actually listening
  • ariba serialization usage reduced (sill used in OverlayMsg?)
  • Node::connect, easier and cleaner interface to start-up ariba from the application
  • ariba configs via JSON, XML, etc (boost::property_tree)
  • keep-alive overhead greatly reduced
  • (relayed) overlay links can actually be closed now
  • lost messages are detected in most cases
  • notification to the application when link is transformed into direct-link
  • overlay routing: send message to second best hop if it would be dropped otherwise
  • SequenceNumbers? (only mechanisms, so for: upward compatibility)
  • various small fixes


regressions:

  • bluetooth is not yet working again
  • bootstrap modules deactivated
  • liblog4xx is not working (use cout-logging)

This patch brings great performance and stability improvements at cost of backward compatibility.
Also bluetooth and the bootstrap modules have not been ported to the new interfaces, yet.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • source/ariba/overlay/BaseOverlay.h

    r10653 r12060  
    4747#include <vector>
    4848#include <deque>
     49#include <stdexcept>
    4950#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
    5057
    5158#include "ariba/utility/messages.h"
     
    6471#include "ariba/overlay/modules/OverlayStructureEvents.h"
    6572#include "ariba/overlay/OverlayBootstrap.h"
     73#include "ariba/overlay/SequenceNumber.h"
    6674
    6775// forward declarations
     
    92100using ariba::communication::BaseCommunication;
    93101using ariba::communication::CommunicationEvents;
     102
     103// transport
     104//using ariba::transport::system_priority;
    94105
    95106// utilities
     
    103114using ariba::utility::Demultiplexer;
    104115using ariba::utility::MessageReceiver;
    105 using ariba::utility::MessageSender;
    106116using ariba::utility::seqnum_t;
    107117using ariba::utility::Timer;
     
    110120namespace overlay {
    111121
    112 using namespace ariba::addressing;
     122
     123
     124class message_not_sent: public std::runtime_error
     125{
     126public:
     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
    113137
    114138class LinkDescriptor;
     
    121145                protected Timer {
    122146
    123         friend class OneHop;
     147//      friend class OneHop;  // DEPRECATED
    124148        friend class Chord;
    125149        friend class ariba::SideportListener;
     
    128152
    129153public:
    130 
    131154        /**
    132155         * Constructs an empty non-functional base overlay instance
     
    142165         * Starts the Base Overlay instance
    143166         */
    144         void start(BaseCommunication& _basecomm, const NodeID& _nodeid);
     167        void start(BaseCommunication* _basecomm, const NodeID& _nodeid);
    145168
    146169        /**
     
    161184         * Starts a link establishment procedure to the specfied node
    162185         * for the service with id service
    163          *
     186         * 
    164187         * @param node Destination node id
    165188         * @param service Service to connect to
     
    179202        void dropLink( const LinkID& link );
    180203
     204       
     205       
     206        /* +++++ Message sending +++++ */
     207       
     208       
    181209        /// 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);
    183213
    184214        /// 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
    187220
    188221    /**
     
    191224     *  @return NodeID of the (closest) destination node;
    192225     */
    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);
    195228       
    196229        /**
     
    198231         * Depending on the structure of the overlay, this can be very different.
    199232         */
    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       
    202240        /**
    203241         * Returns the end-point descriptor of a link.
     
    294332         */
    295333        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;
    296342
    297343protected:
    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       
    336389        /**
    337390         * Processes a received message from BaseCommunication
     
    340393         * the node the message came from!
    341394         */
    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 );
    344399
    345400        /**
     
    359414        std::string getLinkHTMLInfo();
    360415
     416
     417private:
     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       
    361424private:
    362425        /// is the base overlay started yet
     
    396459
    397460        /// 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,
    399462                const LinkID bcLink = LinkID::UNSPECIFIED );
    400463
    401464        // 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 );
    403467        bool handleSignaling( OverlayMsg* msg, LinkDescriptor* ld );
    404468
    405469        // 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 );
    408472
    409473        // handle link messages
    410474        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 );
    412476        bool handleLinkUpdate( OverlayMsg* msg, LinkDescriptor* ld );
    413477        bool handleLinkDirect( OverlayMsg* msg, LinkDescriptor* ld );
    414478        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 );
    415483
    416484
     
    478546        // internal message delivery -----------------------------------------------
    479547
     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   
    480552        /// 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       
    483555        /// 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);
    485562
    486563        /// 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);
    489567
    490568        /// send a message using a node id using overlay routing
    491569        /// 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);
    494573
    495574        /// send a message using a node id using overlay routing using a link
    496575        /// 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       
    500584        // misc --------------------------------------------------------------------
    501585
Note: See TracChangeset for help on using the changeset viewer.