Ignore:
Timestamp:
May 26, 2009, 1:40:23 AM (15 years ago)
Author:
mies
Message:

Merged 20090512-mies-connectors changes r3472:r3689 into trunk.

File:
1 edited

Legend:

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

    r3374 r3690  
    1 // [Licence]
     1// [License]
    22// The Ariba-Underlay Copyright
    33//
     
    3535// official policies, either expressed or implied, of the Institute of
    3636// Telematics.
    37 // [Licence]
     37// [License]
    3838
    3939#ifndef BASEOVERLAY_H_
     
    6262#include "ariba/overlay/modules/OverlayFactory.h"
    6363#include "ariba/overlay/modules/OverlayStructureEvents.h"
    64 #include "ariba/overlay/messages/OverlayMsg.h"
    65 #include "ariba/overlay/messages/JoinRequest.h"
    66 #include "ariba/overlay/messages/JoinReply.h"
    67 
    68 // forward declerations
     64
     65// forward declarations
    6966namespace ariba {
    70         class NodeListener;
    71         class CommunicationListener;
    72         class SideportListener;
    73         namespace utility {
    74                 class OvlVis;
    75         }
     67class NodeListener;
     68class CommunicationListener;
     69class SideportListener;
     70namespace utility {
     71class OvlVis;
     72}
    7673}
    7774
     
    8784using ariba::CommunicationListener;
    8885
     86// communication
    8987using ariba::communication::EndpointDescriptor;
    9088using ariba::communication::BaseCommunication;
    9189using ariba::communication::CommunicationEvents;
    9290
    93 using ariba::overlay::OverlayMsg;
    94 using ariba::overlay::JoinRequest;
    95 using ariba::overlay::JoinReply;
    96 using ariba::overlay::OverlayInterface;
    97 using ariba::overlay::OverlayFactory;
    98 using ariba::overlay::OverlayStructureEvents;
    99 
     91// utilities
    10092using ariba::utility::NodeID;
    10193using ariba::utility::SpoVNetID;
     
    118110namespace overlay {
    119111
    120 class BaseOverlay :
    121         public MessageReceiver,
    122         public CommunicationEvents,
    123         public OverlayStructureEvents,
    124         protected Timer {
     112class BaseOverlay: public MessageReceiver, public CommunicationEvents,
     113        public OverlayStructureEvents, protected Timer {
     114
     115private:
     116        friend class OneHop;
     117        friend class Chord;
    125118
    126119        use_logging_h( BaseOverlay );
     120
    127121public:
     122
    128123        /**
    129124         * Constructs an empty non-functional base overlay instance
     
    139134         * Starts the Base Overlay instance
    140135         */
    141         void start( BaseCommunication& _basecomm, const NodeID& _nodeid );
     136        void start(BaseCommunication& _basecomm, const NodeID& _nodeid);
    142137
    143138        /**
     
    152147         * @param node Destination node id
    153148         * @param service Service to connect to
    154          */
    155         const LinkID establishLink( const NodeID& node, const ServiceID& service );
     149         * @param linkid Link identifier to be used with this link
     150         */
     151        const LinkID establishLink(const NodeID& node, const ServiceID& service,
     152                        const LinkID& linkid = LinkID::UNSPECIFIED);
    156153
    157154        /**
    158155         * Starts a link establishment procedure to the specified
     156         *
    159157         * endpoint and to the specified service
    160158         */
    161         const LinkID establishLink( const EndpointDescriptor& ep, const ServiceID& service );
    162 
    163         /**
    164          * TODO
    165          */
    166         void  dropLink( const LinkID& link );
    167 
    168         /**
    169          * TODO
    170          */
    171         seqnum_t sendMessage( const Message* message, const LinkID& link );
    172 
    173         /**
    174          * TODO
    175          */
    176         seqnum_t sendMessage( const Message* message, const NodeID& node, const ServiceID& service );
     159        const LinkID establishLink(const EndpointDescriptor& ep,
     160                        const ServiceID& service, const LinkID& linkid =
     161                                        LinkID::UNSPECIFIED);
     162
     163        /// drops a link
     164        void dropLink(const LinkID& link);
     165
     166        /// sends a message over an existing link
     167        seqnum_t sendMessage(const Message* message, const LinkID& link);
     168
     169        /// sends a message to a node and a specific service
     170        seqnum_t sendMessage(const Message* message, const NodeID& node,
     171                        const ServiceID& service);
    177172
    178173        /**
     
    180175         * Depending on the structure of the overlay, this can be very different.
    181176         */
    182         void broadcastMessage( Message* message, const ServiceID& service );
    183 
    184         /**
    185          * Get a list of overlay neighboring nodes.
    186          */
    187         vector<NodeID> getOverlayNeighbors() const;
     177        void broadcastMessage(Message* message, const ServiceID& service);
    188178
    189179        /**
     
    193183         * @return The end-point descriptor of the link's end-point
    194184         */
    195         const EndpointDescriptor& getEndpointDescriptor( const LinkID& link = LinkID::UNSPECIFIED ) const;
    196 
    197         /**
    198          * TODO
    199          */
    200         const EndpointDescriptor& getEndpointDescriptor( const NodeID& node ) const;
    201 
    202         /**
    203          * TODO
    204          */
     185        const EndpointDescriptor& getEndpointDescriptor(const LinkID& link =
     186                        LinkID::UNSPECIFIED) const;
     187
     188        /**
     189         * Get a list of overlay neighbors.
     190         *
     191         * @return A list of overlay neighbors.
     192         */
     193        vector<NodeID> getOverlayNeighbors() const;
     194
     195        /**
     196         * Returns a end-endpoint descriptor of a overlay neighbor.
     197         * If the node is not known -- an unspecified endpoint descriptor is
     198         * returned.
     199         *
     200         * @param node The node identifer of a overlay neighbor.
     201         * @return The end-point descriptor of the node or unspecified.
     202         */
     203        const EndpointDescriptor& getEndpointDescriptor(const NodeID& node) const;
     204
     205        // TODO: Doc
    205206        bool bind(CommunicationListener* listener, const ServiceID& sid);
    206207
    207         /**
    208          * TODO
    209          */
     208        // TODO: Doc
    210209        bool unbind(CommunicationListener* listener, const ServiceID& sid);
    211210
    212         /**
    213          * TODO
    214          */
     211        // TODO: Doc
    215212        bool bind(NodeListener* listener);
    216213
    217         /**
    218          * TODO
    219          */
     214        // TODO: Doc
    220215        bool unbind(NodeListener* listener);
    221216
    222         /**
    223          * TODO
    224          */
     217        // TODO: Doc
    225218        bool registerSidePort(SideportListener* _sideport);
    226219
    227         /**
    228          * TODO
    229          */
     220        // TODO: Doc
    230221        bool unregisterSidePort(SideportListener* _sideport);
    231222
     
    236227         * @return The NodeID of the link
    237228         */
    238         const NodeID& getNodeID( const LinkID& lid = LinkID::UNSPECIFIED ) const ;
     229        const NodeID& getNodeID(const LinkID& lid = LinkID::UNSPECIFIED) const;
    239230
    240231        /**
     
    245236         * @return a vector that contains all the link ids requested
    246237         */
    247         vector<LinkID> getLinkIDs( const NodeID& nid = NodeID::UNSPECIFIED ) const;
    248 
    249         /**
    250          * TODO
    251          */
    252         void joinSpoVNet( const SpoVNetID& id, const EndpointDescriptor& bootstrapEp );
    253 
    254         /**
    255          * TODO
    256          */
    257         void createSpoVNet(
    258                 const SpoVNetID& id,
    259                 const OverlayParameterSet& param = OverlayParameterSet::DEFAULT,
    260                 const SecurityParameterSet& sec  = SecurityParameterSet::DEFAULT,
    261                 const QoSParameterSet& qos = QoSParameterSet::DEFAULT
    262         );
    263 
    264         /**
    265          * TODO
     238        vector<LinkID> getLinkIDs(const NodeID& nid = NodeID::UNSPECIFIED) const;
     239
     240        /**
     241         * Join a existing sponaneous virtual network (spovnet).
     242         *
     243         * @param id A spovnet identifier
     244         * @param boot A bootstrap node
     245         */
     246        void joinSpoVNet(const SpoVNetID& id, const EndpointDescriptor& boot );
     247
     248        /**
     249         * Initiates a new spontaneous virtual network.
     250         * This makes this BaseOverlay to the SpoVNet-Initiator.
     251         *
     252         * @param id The spovnet identifier
     253         */
     254        void createSpoVNet(const SpoVNetID& id, const OverlayParameterSet& param =
     255                        OverlayParameterSet::DEFAULT, const SecurityParameterSet& sec =
     256                        SecurityParameterSet::DEFAULT, const QoSParameterSet& qos =
     257                        QoSParameterSet::DEFAULT);
     258
     259        /**
     260         * Let the node leave the SpoVNet.
    266261         */
    267262        void leaveSpoVNet();
     
    272267         * @see ariba::communication::CommunicationEvents.h
    273268         */
    274         virtual void onLinkUp( const LinkID& id, const NetworkLocator* local, const NetworkLocator* remote );
    275 
    276         /**
    277          * @see ariba::communication::CommunicationEvents.h
    278          */
    279         virtual void onLinkDown( const LinkID& id, const NetworkLocator* local, const NetworkLocator* remote );
    280 
    281         /**
    282          * @see ariba::communication::CommunicationEvents.h
    283          */
    284         virtual void onLinkChanged( const LinkID& id, const NetworkLocator* oldlocal, const NetworkLocator* newlocal, const NetworkLocator* oldremote, const NetworkLocator* newremote );
    285 
    286         /**
    287          * @see ariba::communication::CommunicationEvents.h
    288          */
    289         virtual void onLinkFail( const LinkID& id, const NetworkLocator* local, const NetworkLocator* remote );
    290 
    291         /**
    292          * @see ariba::communication::CommunicationEvents.h
    293          */
    294         virtual void onLinkQoSChanged( const LinkID& id, const NetworkLocator* local, const NetworkLocator* remote, const QoSParameterSet& qos );
    295 
    296         /**
    297          * @see ariba::communication::CommunicationEvents.h
    298          */
    299         virtual bool onLinkRequest( const LinkID& id, const NetworkLocator* local, const NetworkLocator* remote );
     269        virtual void onLinkUp(const LinkID& id, const NetworkLocator* local,
     270                        const NetworkLocator* remote);
     271
     272        /**
     273         * @see ariba::communication::CommunicationEvents.h
     274         */
     275        virtual void onLinkDown(const LinkID& id, const NetworkLocator* local,
     276                        const NetworkLocator* remote);
     277
     278        /**
     279         * @see ariba::communication::CommunicationEvents.h
     280         */
     281        virtual void onLinkChanged(const LinkID& id,
     282                        const NetworkLocator* oldlocal, const NetworkLocator* newlocal,
     283                        const NetworkLocator* oldremote, const NetworkLocator* newremote);
     284
     285        /**
     286         * @see ariba::communication::CommunicationEvents.h
     287         */
     288        virtual void onLinkFail(const LinkID& id, const NetworkLocator* local,
     289                        const NetworkLocator* remote);
     290
     291        /**
     292         * @see ariba::communication::CommunicationEvents.h
     293         */
     294        virtual void onLinkQoSChanged(const LinkID& id,
     295                        const NetworkLocator* local, const NetworkLocator* remote,
     296                        const QoSParameterSet& qos);
     297
     298        /**
     299         * @see ariba::communication::CommunicationEvents.h
     300         */
     301        virtual bool onLinkRequest(const LinkID& id, const NetworkLocator* local,
     302                        const NetworkLocator* remote);
    300303
    301304        //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     305
     306        /**
     307         * Processes a received message.
     308         *
     309         * Beware: nodeid is not valid in this case! (since this class implements
     310         * nodeid's in the first place *g*)
     311         */
     312        virtual bool receiveMessage(
     313                const Message* message, const LinkID& link,     const NodeID&);
     314
    302315        //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    303         //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    304 
    305         /**
    306          * TODO
    307          */
    308         virtual bool receiveMessage( const Message* message, const LinkID& link, const NodeID& ); // nodeid is not valid in this case!
    309 
    310         //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    311         //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    312         //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    313 
    314         /**
    315          * see OverlayStructureEvents.h, called from specific OverlayInterface class
    316          */
    317         virtual void incomingRouteMessage( Message* msg );
    318 
    319         /**
    320          * see OverlayStructureEvents.h, called from specific OverlayInterface class
    321          */
    322         virtual void onNodeJoin( const NodeID& node );
    323 
    324 
    325         /**
    326          * TODO, for timer events
     316
     317        /**
     318         * This method is called, when a routed message arrives from the
     319         * overlay.
     320         *
     321         * @see OverlayStructureEvents.h
     322         */
     323        virtual void incomingRouteMessage(Message* msg);
     324
     325        /**
     326         * This method is called, when a new node joined the network
     327         *
     328         * @see OverlayStructureEvents.h
     329         */
     330        virtual void onNodeJoin(const NodeID& node);
     331
     332        /**
     333         * Timer Event method
    327334         */
    328335        virtual void eventFunction();
     
    382389         */
    383390        typedef enum _BaseOverlayState {
    384                 BaseOverlayStateInvalid        = 0,
    385                 BaseOverlayStateInitiator      = 1,
    386                 BaseOverlayStateJoinInitiated  = 2,
    387                 BaseOverlayStateCompleted      = 3,
     391                BaseOverlayStateInvalid = 0,
     392                BaseOverlayStateInitiator = 1,
     393                BaseOverlayStateJoinInitiated = 2,
     394                BaseOverlayStateCompleted = 3,
    388395        } BaseOverlayState;
    389396
     
    403410        NodeID min, max;
    404411        NodeID succ, pred;
    405         void updateOvlVis( const NodeID& node );
     412        void updateOvlVis(const NodeID& node);
    406413
    407414        /**
     
    412419                static const LinkItem UNSPECIFIED;
    413420
    414                 LinkItem()
    415                         : link(LinkID::UNSPECIFIED), node(NodeID::UNSPECIFIED),
    416                                 service(ServiceID::UNSPECIFIED), interface(&CommunicationListener::DEFAULT),
    417                                 autolink(false), lastuse(0){
     421                LinkItem() :
     422                        link(LinkID::UNSPECIFIED), node(NodeID::UNSPECIFIED), service(
     423                                        ServiceID::UNSPECIFIED), interface(
     424                                        &CommunicationListener::DEFAULT), autolink(false), lastuse(
     425                                        0) {
    418426                }
    419427
    420                 LinkItem( const LinkID& _link, const NodeID& _node,
    421                                 const ServiceID& _service, CommunicationListener* _interface )
    422                         : link( _link ), node( _node ), service( _service ), interface( _interface ),
    423                                 autolink( false ), lastuse( time(NULL) ) {
     428                LinkItem(const LinkID& _link, const NodeID& _node,
     429                                const ServiceID& _service, CommunicationListener* _interface) :
     430                        link(_link), node(_node), service(_service), interface(_interface),
     431                                        autolink(false), lastuse(time(NULL)) {
    424432
    425433                        assert( _interface != NULL );
     
    434442
    435443                // information needed for auto links
    436 
    437                 void markused(){
     444                void markused() {
    438445                        lastuse = time(NULL);
    439446                }
     
    444451
    445452        typedef map<const LinkID, LinkItem> LinkMapping;
    446         typedef pair<const LinkID,LinkItem> LinkPair;
     453        typedef pair<const LinkID, LinkItem> LinkPair;
    447454        LinkMapping linkMapping;
    448455
     456        // map of a link request map a nonce to a LinkID
     457        typedef map<const uint32_t, LinkID> PendingLinkMap;
     458        PendingLinkMap pendingLinks;
    449459
    450460        /**
     
    457467};
    458468
    459 }} // namespace ariba, overlay
     469}
     470} // namespace ariba, overlay
    460471
    461472#endif /*BASEOVERLAY_H_*/
Note: See TracChangeset for help on using the changeset viewer.