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/LinkDescriptor.h

    r5284 r5870  
    3939                // default values
    4040                this->up = false;
    41                 this->dropWhenRelaysLeft = false;
    4241                this->fromRemote = false;
    4342                this->remoteNode = NodeID::UNSPECIFIED;
    44                 this->overlayId  = LinkID::UNSPECIFIED;
     43                this->overlayId  = LinkID::create();
    4544                this->communicationUp = false;
    4645                this->communicationId = LinkID::UNSPECIFIED;
    4746                this->keepAliveTime = time(NULL);
    4847                this->keepAliveMissed = 0;
    49                 this->usedAsRelay     = false;
    50                 this->timeUsedAsRelay = time(NULL);
     48                this->relaying     = false;
     49                this->timeRelaying = time(NULL);
     50                this->dropAfterRelaying = false;
    5151                this->service  = ServiceID::UNSPECIFIED;
    5252                this->listener = &CommunicationListener::DEFAULT;
    53                 this->relay = false;
    54                 this->localRelay   = NodeID::UNSPECIFIED;
    55                 this->remoteRelay  = NodeID::UNSPECIFIED;
    56                 this->remoteLinkId = LinkID::UNSPECIFIED;
     53                this->relayed = false;
     54                this->remoteLink = LinkID::UNSPECIFIED;
    5755                this->autolink = false;
    5856                this->lastuse = time(NULL);
     
    6462        }
    6563
    66         // general information about the link ---------------------------------
     64        // general information about the link --------------------------------------
     65        bool up;           ///< flag whether this link is up and running
     66        bool fromRemote;   ///< flag, whether this link was requested from remote
     67        NodeID remoteNode; ///< remote end-point node
    6768
    68         bool up; ///< flag wheter this link is up and running
    69         bool dropWhenRelaysLeft;
    70         bool fromRemote; ///<flag, wheter this link was requested from remote
     69        // link identifiers --------------------------------------------------------
     70        LinkID overlayId;       ///< the base overlay link id
     71        LinkID communicationId; ///< the communication id
     72        bool   communicationUp;   ///< flag, whether the communication is up
    7173
    72         NodeID remoteNode; ///< remote endpoint node
    73 
    74         LinkID overlayId; ///< the base overlay link id
    75         LinkID communicationId; ///< the communication id
    76         bool communicationUp; ///< flag, wheter the communication is up
    77 
     74        // link alive information --------------------------------------------------
    7875        time_t keepAliveTime; ///< the last time a keep-alive message was received
    79         int keepAliveMissed; ///< the number of missed keep-alive messages
    80 
    81         void markAlive() {
     76        int keepAliveMissed;  ///< the number of missed keep-alive messages
     77        void setAlive() {
    8278                keepAliveMissed = 0;
    8379                keepAliveTime = time(NULL);
    8480        }
    8581
    86         // relay state --------------------------------------------------------
     82        // relay information -------------------------------------------------------
     83        bool   relayed;    ///< flag whether this link is a relayed link
     84        LinkID remoteLink; ///< the remote link id
     85        vector<NodeID> routeRecord;
    8786
    88         bool   usedAsRelay; ///< flag, wheter this link has been used as relay
    89         time_t timeUsedAsRelay; ///< last time the link has been used as relay
    90 
    91         void markAsRelay() {
    92                 usedAsRelay = true;
    93                 timeUsedAsRelay = time(NULL);
     87        // relay state -------------------------------------------------------------
     88        bool   relaying;     ///< flag, wheter this link has been used as relay
     89        bool   dropAfterRelaying;
     90        time_t timeRelaying; ///< last time the link has been used as relay
     91        void setRelaying() {
     92                relaying = true;
     93                timeRelaying = time(NULL);
    9494        }
    9595
    96         // owner --------------------------------------------------------------
     96        // owner -------------------------------------------------------------------
    9797        ServiceID service; ///< service using this link
    9898        CommunicationListener* listener; ///< the listener using this node
    9999
    100         // relay information --------------------------------------------------
    101         bool relay;          ///< flag whether this link is a relay link
    102         NodeID localRelay;   ///< the local relay node
    103         NodeID remoteRelay;  ///< the remote relay node
    104         LinkID remoteLinkId; ///< the remote link id
    105 
    106         // auto links ---------------------------------------------------------
     100        // auto links --------------------------------------------------------------
    107101        bool autolink;  ///< flag, whether this link is a auto-link
    108102        time_t lastuse; ///< time, when the link was last used
    109103        deque<Message*> messageQueue; ///< waiting messages to be delivered
    110 
    111         /// updates the timestamp
    112         void markAsUsed() {
    113                 lastuse = time(NULL);
     104        void setAutoUsed() {
     105                if (autolink) lastuse = time(NULL);
    114106        }
    115 
    116         /// drops waiting messsages
     107        /// drops waiting auto-link messages
    117108        void flushQueue() {
    118                 BOOST_FOREACH( Message* msg, messageQueue )
    119                         delete msg;
     109                BOOST_FOREACH( Message* msg, messageQueue )     delete msg;
    120110                messageQueue.clear();
    121111        }
    122112
     113        // string representation ---------------------------------------------------
    123114        std::string to_string() const {
    124115                std::ostringstream s;
    125116                s << "up=" << up << " ";
    126                 s << "fromRem=" << fromRemote << " ";
    127                 s << "remNode=" << remoteNode.toString().substr(0,6) << " ";
     117                s << "init=" << !fromRemote << " ";
     118                s << "id=" << overlayId.toString().substr(0,4) << " ";
    128119                s << "serv=" << service.toString() << " ";
    129                 s << "overId=" << overlayId.toString().substr(0,6) << " ";
    130                 s << "commUp=" << communicationUp << " ";
    131                 s << "commId=" << communicationId.toString().substr(0,6) << " ";
    132                 s << "usedAsRel=" << usedAsRelay << " ";
    133                 s << "KeepAliveMiss=" << keepAliveMissed << " ";
    134                 if ( !localRelay.isUnspecified() ) {
    135                         s << "locRel=" << localRelay.toString().substr(0,6) << " ";
    136                         s << "remRel=" << remoteRelay.toString().substr(0,6) << " ";
    137                         s << "remLink=" << remoteLinkId.toString().substr(0,6) << " ";
     120                s << "node=" << remoteNode.toString().substr(0,4) << " ";
     121                s << "relaying=" << relaying << " ";
     122                s << "miss=" << keepAliveMissed << " ";
     123                s << "auto=" << autolink << " ";
     124                if ( relayed ) {
     125                        s << "| Relayed: ";
     126                        s << "remote link=" << remoteLink.toString().substr(0,4) << " ";
     127                        if (routeRecord.size()>0) {
     128                                cout << "route record=";
     129                                for (size_t i=0; i<routeRecord.size(); i++)
     130                                        cout << routeRecord[i].toString().substr(0,4) << " ";
     131                        }
     132                } else {
     133                        s << "| Direct: ";
     134                        s << "using id=" << communicationId.toString().substr(0,4) << " ";
     135                        s << "(up=" << communicationUp << ") ";
    138136                }
    139                 s << "auto=" << autolink;
    140137                return s.str();
    141138        }
Note: See TracChangeset for help on using the changeset viewer.