Changeset 5151 for source/ariba/overlay/modules
- Timestamp:
- Jul 21, 2009, 1:54:55 PM (15 years ago)
- Location:
- source/ariba/overlay/modules
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
source/ariba/overlay/modules/OverlayInterface.h
r3718 r5151 128 128 129 129 /** 130 * Routes a message to a given node by using an existing link. 131 * 132 * TODO: This is a hack. This method allows the BaseOverlay class to 133 * use overlay signaling links to transfer data for relaying 134 * 135 * @param node The destination node. 136 * @param link An established link 137 * @param msg The message to be sent. 138 */ 139 virtual void routeMessage(const NodeID& node, const LinkID& link, Message* msg) = 0; 140 141 /** 130 142 * Returns the nodes known to this overlay. 131 143 * … … 139 151 virtual NodeList getKnownNodes() const = 0; 140 152 153 /** 154 * Returns the link id of the next hop a route message would take. 155 * 156 * @param id The destination node id 157 * @return The link id of the next hop 158 */ 159 virtual const LinkID& getNextLinkId( const NodeID& id ) const = 0; 160 141 161 //--- functions from CommunicationListener that we _can_ use as overlay --- 142 162 143 163 /// @see CommunicationListener 144 164 virtual void onLinkUp(const LinkID& lnk, const NodeID& remote); 165 145 166 /// @see CommunicationListener 146 167 virtual void onLinkDown(const LinkID& lnk, const NodeID& remote); 168 147 169 /// @see CommunicationListener 148 170 virtual void onLinkChanged(const LinkID& lnk, const NodeID& remote); 171 149 172 /// @see CommunicationListener 150 173 virtual void onLinkFail(const LinkID& lnk, const NodeID& remote); 174 151 175 /// @see CommunicationListener 152 176 virtual void onLinkQoSChanged(const LinkID& lnk, const NodeID& remote, 153 177 const LinkProperties& prop); 178 154 179 /// @see CommunicationListener 155 180 virtual bool onLinkRequest(const NodeID& remote, const DataMessage& msg); 181 156 182 /// @see CommunicationListener 157 183 virtual void onMessage(const DataMessage& msg, const NodeID& remote, … … 162 188 163 189 protected: 164 165 190 /// Reference to an active base overlay 166 191 BaseOverlay& baseoverlay; -
source/ariba/overlay/modules/OverlayStructureEvents.cpp
r3690 r5151 47 47 } 48 48 49 void OverlayStructureEvents::incomingRouteMessage(Message* msg ){49 void OverlayStructureEvents::incomingRouteMessage(Message* msg, const LinkID& link, const NodeID& source ){ 50 50 } 51 51 -
source/ariba/overlay/modules/OverlayStructureEvents.h
r3690 r5151 61 61 62 62 protected: 63 virtual void incomingRouteMessage( Message* msg );63 virtual void incomingRouteMessage( Message* msg, const LinkID& link = LinkID::UNSPECIFIED, const NodeID& source = NodeID::UNSPECIFIED ); 64 64 virtual void onNodeJoin( const NodeID& node ); 65 65 }; -
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 -
source/ariba/overlay/modules/onehop/OneHop.cpp
r3718 r5151 99 99 } 100 100 101 void OneHop::routeMessage(const NodeID& node, const LinkID& link, Message* msg) { 102 OneHopMessage onehopRoute( OneHopMessage::OneHopMessageTypeRoute ); 103 onehopRoute.encapsulate(msg); 104 baseoverlay.sendMessage( &onehopRoute, link ); 105 } 106 107 /// @see OverlayInterface.h 108 const LinkID& OneHop::getNextLinkId( const NodeID& id ) const { 109 OverlayNodeMapping::const_iterator i = overlayNodes.find( id ); 110 if (i == overlayNodes.end()) return LinkID::UNSPECIFIED; 111 return i->second; 112 } 113 101 114 void OneHop::createOverlay() { 102 115 // don't need to bootstrap against ourselfs. -
source/ariba/overlay/modules/onehop/OneHop.h
r3718 r5151 81 81 82 82 /// @see OverlayInterface.h 83 virtual const LinkID& getNextLinkId( const NodeID& id ) const; 84 85 /// @see OverlayInterface.h 83 86 virtual void routeMessage(const NodeID& destnode, Message* msg); 87 88 /// @see OverlayInterface.h 89 virtual void routeMessage(const NodeID& node, const LinkID& link, Message* msg); 84 90 85 91 /// @see OverlayInterface.h
Note:
See TracChangeset
for help on using the changeset viewer.