Ignore:
Timestamp:
Aug 11, 2009, 4:11:02 PM (15 years ago)
Author:
Christoph Mayer
Message:

merge noch nicht fertig

File:
1 edited

Legend:

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

    r5743 r5870  
    121121
    122122class LinkDescriptor;
     123class OverlayMsg;
    123124
    124125class BaseOverlay: public MessageReceiver,
     
    161162
    162163        /// Tries to establish a direct or overlay link
    163         const LinkID establishLink(const EndpointDescriptor& ep,
    164                 const NodeID& node, const ServiceID& service,
    165                 const NodeID& remoteRelay = NodeID::UNSPECIFIED,
    166                 const LinkID& linkid = LinkID::UNSPECIFIED);
     164        const LinkID establishLink(     const EndpointDescriptor& ep,
     165                const NodeID& node, const ServiceID& service );
    167166
    168167        /**
     
    174173         * @param linkid Link identifier to be used with this link
    175174         */
    176         const LinkID establishLink(const NodeID& node, const ServiceID& service,
    177                 const NodeID& remoteRelay = NodeID::UNSPECIFIED,
    178                 const LinkID& linkid = LinkID::UNSPECIFIED);
     175        const LinkID establishLink(     const NodeID& remote,
     176                const ServiceID& service = OverlayInterface::OVERLAY_SERVICE_ID );
    179177
    180178        /**
     
    182180         * endpoint and to the specified service
    183181         */
    184         const LinkID establishDirectLink(const EndpointDescriptor& ep,
    185                 const ServiceID& service, const LinkID& linkid = LinkID::UNSPECIFIED);
     182        const LinkID establishDirectLink( const EndpointDescriptor& endpoint,
     183                const ServiceID& service = OverlayInterface::OVERLAY_SERVICE_ID );
    186184
    187185        /// drops a link
    188         void dropLink(const LinkID& link);
     186        void dropLink( const LinkID& link );
    189187
    190188        /// sends a message over an existing link
    191         seqnum_t sendMessage(const Message* message, const LinkID& link);
     189        seqnum_t sendMessage(const Message* message, const LinkID& link );
    192190
    193191        /// sends a message to a node and a specific service
    194         seqnum_t sendMessage(const Message* message, const NodeID& node,
    195                 const ServiceID& service);
     192        seqnum_t sendMessage(const Message* message, const NodeID& remote,
     193                const ServiceID& service = OverlayInterface::OVERLAY_SERVICE_ID);
    196194
    197195        /**
     
    207205         * @return The end-point descriptor of the link's end-point
    208206         */
    209         const EndpointDescriptor& getEndpointDescriptor(const LinkID& link =
    210                         LinkID::UNSPECIFIED) const;
     207        const EndpointDescriptor& getEndpointDescriptor(
     208                const LinkID& link = LinkID::UNSPECIFIED) const;
    211209
    212210        /**
     
    332330         * the node the message came from!
    333331         */
    334         virtual bool receiveMessage(const Message* message, const LinkID& link,
    335                 const NodeID& source = NodeID::UNSPECIFIED);
     332        virtual bool receiveMessage( const Message* message, const LinkID& link,
     333                const NodeID& );
     334
     335        /**
     336         * This method is called, when a new node joined the network
     337         *
     338         * @see OverlayStructureEvents.h
     339         */
     340        virtual void onNodeJoin(const NodeID& node);
     341
     342        /**
     343         * Timer Event method
     344         */
     345        virtual void eventFunction();
    336346
    337347        //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    338348
    339         /// handles an incoming message with link descriptor
    340         bool handleMessage(const Message* message,
    341                 const LinkID& boLink, const LinkID& bcLink, const NodeID& remoteNode );
    342 
    343         //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    344         /**
    345          * This method is called, when a routed message arrives from the
    346          * overlay.
    347          *
    348          * @see OverlayStructureEvents.h
    349          */
    350         virtual void incomingRouteMessage(Message* msg,
    351                 const LinkID& link = LinkID::UNSPECIFIED,
    352                 const NodeID& source = NodeID::UNSPECIFIED);
    353 
    354         /**
    355          * This method is called, when a new node joined the network
    356          *
    357          * @see OverlayStructureEvents.h
    358          */
    359         virtual void onNodeJoin(const NodeID& node);
    360 
    361         /**
    362          * Timer Event method
    363          */
    364         virtual void eventFunction();
    365349
    366350private:
     351        /// is the base overlay started yet
     352        bool started;
    367353
    368354        /// The state of the BaseOverlay
     
    372358        } BaseOverlayState;
    373359
    374         BaseOverlayState state;          ///< Current Base-Overlay state
    375         BaseCommunication* bc;           ///< reference to the base communication
    376         NodeID nodeId;                   ///< the node id of this node
    377         SpoVNetID spovnetId;             ///< the spovnet id of the currently joined overlay
    378         vector<LinkID> bootstrapLinks;   ///< the link id of the link to the initiator node
    379         NodeID spovnetInitiator;         ///< The initiator node
     360        BaseOverlayState state;         ///< Current Base-Overlay state
     361        BaseCommunication* bc;          ///< reference to the base communication
     362        NodeID nodeId;                  ///< the node id of this node
     363        SpoVNetID spovnetId;            ///< the spovnet id of the currently joined overlay
     364        vector<LinkID> bootstrapLinks;  ///< the link id of the link to the initiator node
     365        NodeID spovnetInitiator;        ///< The initiator node
    380366
    381367        /// the service id communication listeners
    382368        Demultiplexer<CommunicationListener*, ServiceID> communicationListeners;
     369        CommunicationListener* getListener( const ServiceID& id );
    383370
    384371        /// the node listeners
     
    392379        OverlayInterface* overlayInterface;
    393380
     381        /// Bootstrapper for our spovnet
     382        OverlayBootstrap overlayBootstrap;
     383
     384        // message handlers --------------------------------------------------------
     385
     386        /// demultiplexes a incoming message with link descriptor
     387        bool handleMessage( const Message* message, LinkDescriptor* ld,
     388                const LinkID bcLink = LinkID::UNSPECIFIED );
     389
     390        // handle data and signalling messages
     391        bool handleData( OverlayMsg* msg, LinkDescriptor* ld );
     392        bool handleSignaling( OverlayMsg* msg, LinkDescriptor* ld );
     393
     394        // handle join request / reply messages
     395        bool handleJoinRequest( OverlayMsg* msg, const LinkID& bcLink );
     396        bool handleJoinReply( OverlayMsg* msg, const LinkID& bcLink );
     397
     398        // handle link messages
     399        bool handleLinkRequest( OverlayMsg* msg, LinkDescriptor* ld );
     400        bool handleLinkReply( OverlayMsg* msg, LinkDescriptor* ld );
     401        bool handleLinkUpdate( OverlayMsg* msg, LinkDescriptor* ld );
     402        bool handleLinkDirect( OverlayMsg* msg, LinkDescriptor* ld );
     403        bool handleLinkAlive( OverlayMsg* msg, LinkDescriptor* ld );
     404
     405        // link state handling -----------------------------------------------------
     406
     407        /// link state information counter
     408        int counter;
     409
    394410        /// The link mapping of the node
    395411        vector<LinkDescriptor*> links;
     412
     413        /// erases a link descriptor
    396414        void eraseDescriptor(const LinkID& link, bool communication = false);
    397415
     
    410428        LinkDescriptor* addDescriptor(const LinkID& link = LinkID::UNSPECIFIED);
    411429
    412         /// returns a direct link relay descriptor to the given relay node
    413         LinkDescriptor* getRelayDescriptor( const NodeID& remoteNode );
    414 
    415         /// returns the local relay node to a given remote node
    416         NodeID getRelayNode( const NodeID& remoteNode );
    417 
    418         /// returns the direct link the message to a neighbor is send to
    419         LinkDescriptor* getSendDescriptor( const NodeID& nodeid, bool follow = true );
    420 
    421         /// routes a message over the overlay or directly sends it when a link is open
    422         seqnum_t sendOverlay( Message* message, const NodeID& nodeid,
    423                 const NodeID& remoteRelay = NodeID::UNSPECIFIED );
    424 
    425         /// forwards a message over relays/overlay/directly using link descriptor
    426         seqnum_t sendMessage( Message* message, const LinkDescriptor* ld );
    427 
    428         /// creates a link descriptor, applys relay semantics if possible
    429         LinkDescriptor* createLinkDescriptor(
    430                 const NodeID remoteNode, const ServiceID service, const LinkID link_id );
    431 
    432         // map of a link request map a nonce to a LinkID
    433         typedef map<const uint32_t, LinkID> PendingLinkMap;
    434         PendingLinkMap pendingLinks;
    435 
    436         void showLinkState();
     430        /// stabilizes link information
     431        void stabilizeLinks();
     432
     433        /// print the currently known links
     434        void showLinks();
     435
     436        // relay route management --------------------------------------------------
     437
     438        /// relay route definitions
     439        class relay_route {
     440        public:
     441                NodeID  node;
     442                LinkID  link;
     443                uint8_t hops;
     444                time_t  used;
     445        };
     446        vector<relay_route> relay_routes;
     447
     448        /// stabilize relay information
     449        void stabilizeRelays();
     450
     451        /// refreshes relay information
     452        void refreshRelayInformation( const OverlayMsg* message, LinkDescriptor* ld );
     453
     454        /// returns a known relay link
     455        LinkDescriptor* getRelayLinkTo( const NodeID& remote );
     456
     457        /// removes relay link information
     458        void removeRelayLink( const LinkID& link );
     459
     460        /// removes relay node information
     461        void removeRelayNode( const NodeID& link );
     462
     463        // internal message delivery -----------------------------------------------
     464
     465        /// routes a message to its destination node
     466        void route( OverlayMsg* message, LinkDescriptor* incomingLink );
     467
     468        /// sends a raw message to another node, delivers it to the base overlay class
     469        seqnum_t send( OverlayMsg* message, const NodeID& destination );
     470
     471        /// send a raw message using a link descriptor, delivers it to the base overlay class
     472        seqnum_t send( OverlayMsg* message, LinkDescriptor* ld,
     473                bool ignore_down = false );
     474
     475        /// send a message using a node id using overlay routing
     476        /// sets necessary fields in the overlay message!
     477        seqnum_t send_node( OverlayMsg* message, const NodeID& remote,
     478                const ServiceID& service = OverlayInterface::OVERLAY_SERVICE_ID);
     479
     480        /// send a message using a node id using overlay routing using a link
     481        /// sets necessary fields in the overlay message!
     482        seqnum_t send_link( OverlayMsg* message, const LinkID& link,
     483                bool ignore_down = false );
     484
     485        // misc --------------------------------------------------------------------
    437486
    438487        /**
     
    442491        typedef vector<NodeID> JoiningNodes;
    443492        JoiningNodes joiningNodes;
    444 
    445         int counter;
    446 
    447         /**
    448          * Bootstrapper for our spovnet
    449          */
    450         OverlayBootstrap overlayBootstrap;
    451 
    452         /// is the base overlay started yet
    453         bool started;
    454493};
    455494
Note: See TracChangeset for help on using the changeset viewer.