Ignore:
Timestamp:
Jul 21, 2009, 1:54:55 PM (15 years ago)
Author:
Christoph Mayer
Message:

begin merge back from relay branch

File:
1 edited

Legend:

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

    r4836 r5151  
    8686// ariba interface
    8787using ariba::NodeListener;
     88using ariba::SideportListener;
    8889using ariba::CommunicationListener;
    8990
     
    117118namespace overlay {
    118119
    119 class BaseOverlay: public MessageReceiver, public CommunicationEvents,
    120         public OverlayStructureEvents, protected Timer {
    121 
    122 private:
     120class LinkDescriptor;
     121
     122class BaseOverlay: public MessageReceiver,
     123                public CommunicationEvents,
     124                public OverlayStructureEvents,
     125                protected Timer {
     126
    123127        friend class OneHop;
    124128        friend class Chord;
     129        friend class ariba::SideportListener;
    125130
    126131        use_logging_h( BaseOverlay );
     
    157162         */
    158163        const LinkID establishLink(const NodeID& node, const ServiceID& service,
    159                         const LinkID& linkid = LinkID::UNSPECIFIED);
     164                const LinkID& linkid = LinkID::UNSPECIFIED);
    160165
    161166        /**
    162167         * 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
    164176         * endpoint and to the specified service
    165177         */
    166178        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);
    169180
    170181        /// drops a link
     
    176187        /// sends a message to a node and a specific service
    177188        seqnum_t sendMessage(const Message* message, const NodeID& node,
    178                         const ServiceID& service);
     189                const ServiceID& service);
    179190
    180191        /**
     
    251262         * @param boot A bootstrap node
    252263         */
    253         void joinSpoVNet(const SpoVNetID& id, const EndpointDescriptor& boot );
     264        void joinSpoVNet(const SpoVNetID& id, const EndpointDescriptor& boot);
    254265
    255266        /**
     
    275286         */
    276287        virtual void onLinkUp(const LinkID& id, const NetworkLocator* local,
    277                         const NetworkLocator* remote);
     288                const NetworkLocator* remote);
    278289
    279290        /**
     
    281292         */
    282293        virtual void onLinkDown(const LinkID& id, const NetworkLocator* local,
    283                         const NetworkLocator* remote);
     294                const NetworkLocator* remote);
    284295
    285296        /**
     
    287298         */
    288299        virtual void onLinkChanged(const LinkID& id,
    289                         const NetworkLocator* oldlocal, const NetworkLocator* newlocal,
    290                         const NetworkLocator* oldremote, const NetworkLocator* newremote);
     300                const NetworkLocator* oldlocal, const NetworkLocator* newlocal,
     301                const NetworkLocator* oldremote, const NetworkLocator* newremote);
    291302
    292303        /**
     
    294305         */
    295306        virtual void onLinkFail(const LinkID& id, const NetworkLocator* local,
    296                         const NetworkLocator* remote);
     307                const NetworkLocator* remote);
    297308
    298309        /**
     
    300311         */
    301312        virtual void onLinkQoSChanged(const LinkID& id,
    302                         const NetworkLocator* local, const NetworkLocator* remote,
    303                         const QoSParameterSet& qos);
     313                const NetworkLocator* local, const NetworkLocator* remote,
     314                const QoSParameterSet& qos);
    304315
    305316        /**
     
    307318         */
    308319        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);
    310330
    311331        //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    312332
    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 );
    321336
    322337        //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    323 
    324338        /**
    325339         * This method is called, when a routed message arrives from the
     
    328342         * @see OverlayStructureEvents.h
    329343         */
    330         virtual void incomingRouteMessage(Message* msg);
     344        virtual void incomingRouteMessage(Message* msg,
     345                const LinkID& link = LinkID::UNSPECIFIED,
     346                const NodeID& source = NodeID::UNSPECIFIED);
    331347
    332348        /**
     
    343359
    344360private:
    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
    397363        typedef enum _BaseOverlayState {
    398364                BaseOverlayStateInvalid = 0,
     
    402368        } BaseOverlayState;
    403369
    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 );
    492420
    493421        // map of a link request map a nonce to a LinkID
     
    495423        PendingLinkMap pendingLinks;
    496424
     425        void showLinkState();
     426
    497427        /**
    498428         * nodes with pending joines. TODO: should be cleaned every
     
    502432        JoiningNodes joiningNodes;
    503433
     434        int counter;
     435
    504436        /**
    505437         * Bootstrapper for our spovnet
Note: See TracChangeset for help on using the changeset viewer.