Changeset 5870 for source/ariba/overlay/LinkDescriptor.h
- Timestamp:
- Aug 11, 2009, 4:11:02 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
source/ariba/overlay/LinkDescriptor.h
r5284 r5870 39 39 // default values 40 40 this->up = false; 41 this->dropWhenRelaysLeft = false;42 41 this->fromRemote = false; 43 42 this->remoteNode = NodeID::UNSPECIFIED; 44 this->overlayId = LinkID:: UNSPECIFIED;43 this->overlayId = LinkID::create(); 45 44 this->communicationUp = false; 46 45 this->communicationId = LinkID::UNSPECIFIED; 47 46 this->keepAliveTime = time(NULL); 48 47 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; 51 51 this->service = ServiceID::UNSPECIFIED; 52 52 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; 57 55 this->autolink = false; 58 56 this->lastuse = time(NULL); … … 64 62 } 65 63 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 67 68 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 71 73 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 -------------------------------------------------- 78 75 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() { 82 78 keepAliveMissed = 0; 83 79 keepAliveTime = time(NULL); 84 80 } 85 81 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; 87 86 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); 94 94 } 95 95 96 // owner -------------------------------------------------------------- 96 // owner ------------------------------------------------------------------- 97 97 ServiceID service; ///< service using this link 98 98 CommunicationListener* listener; ///< the listener using this node 99 99 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 -------------------------------------------------------------- 107 101 bool autolink; ///< flag, whether this link is a auto-link 108 102 time_t lastuse; ///< time, when the link was last used 109 103 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); 114 106 } 115 116 /// drops waiting messsages 107 /// drops waiting auto-link messages 117 108 void flushQueue() { 118 BOOST_FOREACH( Message* msg, messageQueue ) 119 delete msg; 109 BOOST_FOREACH( Message* msg, messageQueue ) delete msg; 120 110 messageQueue.clear(); 121 111 } 122 112 113 // string representation --------------------------------------------------- 123 114 std::string to_string() const { 124 115 std::ostringstream s; 125 116 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) << " "; 128 119 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 << ") "; 138 136 } 139 s << "auto=" << autolink;140 137 return s.str(); 141 138 }
Note:
See TracChangeset
for help on using the changeset viewer.