Changeset 5151 for source/ariba/overlay/modules/chord
- Timestamp:
- Jul 21, 2009, 1:54:55 PM (15 years ago)
- Location:
- source/ariba/overlay/modules/chord
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
source/ariba/overlay/modules/chord/Chord.cpp
r3718 r5151 71 71 72 72 /// helper: sets up a link using the base overlay 73 LinkID Chord::setup(const EndpointDescriptor& endp ) {73 LinkID Chord::setup(const EndpointDescriptor& endp, const NodeID& node) { 74 74 75 75 logging_debug("request to setup link to " << endp.toString() ); 76 77 for (size_t i=0; i<pending.size(); i++) 78 if (pending[i]==node) return LinkID::UNSPECIFIED; 79 pending.push_back(node); 80 76 81 // establish link via base overlay 77 return baseoverlay.establishLink(endp, OverlayInterface::OVERLAY_SERVICE_ID);82 return baseoverlay.establishLink(endp, node, OverlayInterface::OVERLAY_SERVICE_ID); 78 83 } 79 84 … … 86 91 /// sends a discovery message 87 92 void Chord::send_discovery_to(const NodeID& destination, int ttl) { 88 logging_debug("Initiating discovery of " << destination.toString() );93 // logging_debug("Initiating discovery of " << destination.toString() ); 89 94 Message msg; 90 95 ChordMessage cmsg(ChordMessage::discovery, nodeid, destination); … … 111 116 112 117 // initiator? no->setup first link 113 if (!(boot == EndpointDescriptor::UNSPECIFIED)) bootstrapLink = setup(boot); 118 if (!(boot == EndpointDescriptor::UNSPECIFIED)) 119 bootstrapLink = setup(boot); 114 120 115 121 // timer for stabilization management … … 138 144 139 145 // message for this node? yes-> delegate to base overlay 140 if (item->id == nodeid) baseoverlay.incomingRouteMessage(msg); 146 if (item->id == nodeid || destnode == nodeid) 147 baseoverlay.incomingRouteMessage( msg, LinkID::UNSPECIFIED, nodeid ); 148 141 149 else { // no-> send to next hop 142 150 ChordMessage cmsg(ChordMessage::route, nodeid, destnode); … … 144 152 send(&cmsg, item->info); 145 153 } 154 } 155 156 /// @see OverlayInterface.h 157 void Chord::routeMessage(const NodeID& node, const LinkID& link, Message* msg) { 158 logging_debug("Redirect over Chord to node id=" << node.toString() 159 << " link id=" << link.toString() ); 160 ChordMessage cmsg(ChordMessage::route, nodeid, node); 161 cmsg.encapsulate(msg); 162 send(&cmsg, link); 163 } 164 165 /// @see OverlayInterface.h 166 const LinkID& Chord::getNextLinkId( const NodeID& id ) const { 167 // get next hop 168 const route_item* item = table->get_next_hop(id); 169 170 // returns a unspecified id when this is itself 171 if (item == NULL || item->id == nodeid) 172 return LinkID::UNSPECIFIED; 173 174 /// return routing info 175 return item->info; 146 176 } 147 177 … … 160 190 logging_debug("link_up: link=" << lnk.toString() << " remote=" << 161 191 remote.toString() ); 192 for (vector<NodeID>::iterator i=pending.begin(); i!=pending.end(); i++) 193 if (*i == remote) { 194 pending.erase(i); 195 break; 196 } 162 197 route_item* item = table->insert(remote); 163 198 … … 207 242 break; 208 243 209 244 // route message with payload 210 245 case M::route: { 211 246 // find next hop … … 214 249 // next hop == myself? 215 250 if (m->getDestination() == nodeid) { // yes-> route to base overlay 216 logging_debug(" send message to baseoverlay");217 baseoverlay.incomingRouteMessage( m);251 logging_debug("Send message to baseoverlay"); 252 baseoverlay.incomingRouteMessage( m, item->info, remote ); 218 253 } 219 254 // no-> route to next hop 220 255 else { 221 logging_debug("route chord message to " << item->id.toString() ); 256 logging_debug("Route chord message to " 257 << item->id.toString() << " (destination=" << m->getDestination() << ")"); 222 258 send(m, item->info); 223 259 } … … 236 272 237 273 // check if source node can be added to routing table and setup link 238 if (m->getSource() != nodeid && table->is_insertable(m->getSource())) setup(239 *dmsg->getSourceEndpoint());274 if (m->getSource() != nodeid && table->is_insertable(m->getSource())) 275 setup(*dmsg->getSourceEndpoint(), m->getSource() ); 240 276 241 277 // delegate discovery message … … 302 338 } 303 339 if (item == NULL) break; 304 logging_debug("routing discovery message to succ/pred "340 logging_debug("routing discovery message to succ/pred " 305 341 << item->id.toString() ); 306 342 ChordMessage cmsg(*m); … … 327 363 328 364 void Chord::eventFunction() { 329 if (!LinkID::UNSPECIFIED.isUnspecified())330 logging_error("LinkID::UNSPECIFIED not unspecified!!!!");331 365 stabilize_counter++; 332 366 if (stabilize_counter == 3) { 367 pending.clear(); 333 368 size_t numNeighbors = 0; 334 369 for (size_t i = 0; i < table->size(); i++) { … … 368 403 } 369 404 370 } 371 } // namespace ariba, overlay 405 }} // namespace ariba, overlay -
source/ariba/overlay/modules/chord/Chord.h
r3718 r5151 77 77 int stabilize_finger; 78 78 LinkID bootstrapLink; 79 vector<NodeID> pending; 79 80 80 81 // helper: sets up a link using the "base overlay" 81 LinkID setup( const EndpointDescriptor& endp );82 LinkID setup( const EndpointDescriptor& endp, const NodeID& node = NodeID::UNSPECIFIED ); 82 83 83 84 // helper: sends a message using the "base overlay" … … 91 92 OverlayStructureEvents* _eventsReceiver, const OverlayParameterSet& param); 92 93 virtual ~Chord(); 94 95 /// @see OverlayInterface.h 96 virtual const LinkID& getNextLinkId( const NodeID& id ) const; 93 97 94 98 /// @see OverlayInterface.h … … 113 117 114 118 /// @see OverlayInterface.h 119 virtual void routeMessage(const NodeID& node, const LinkID& link, Message* msg); 120 121 /// @see OverlayInterface.h 115 122 virtual NodeList getKnownNodes() const; 116 123
Note:
See TracChangeset
for help on using the changeset viewer.