Changeset 3690 for source/ariba/overlay/BaseOverlay.h
- Timestamp:
- May 26, 2009, 1:40:23 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
source/ariba/overlay/BaseOverlay.h
r3374 r3690 1 // [Licen ce]1 // [License] 2 2 // The Ariba-Underlay Copyright 3 3 // … … 35 35 // official policies, either expressed or implied, of the Institute of 36 36 // Telematics. 37 // [Licen ce]37 // [License] 38 38 39 39 #ifndef BASEOVERLAY_H_ … … 62 62 #include "ariba/overlay/modules/OverlayFactory.h" 63 63 #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 69 66 namespace ariba { 70 71 72 73 74 75 67 class NodeListener; 68 class CommunicationListener; 69 class SideportListener; 70 namespace utility { 71 class OvlVis; 72 } 76 73 } 77 74 … … 87 84 using ariba::CommunicationListener; 88 85 86 // communication 89 87 using ariba::communication::EndpointDescriptor; 90 88 using ariba::communication::BaseCommunication; 91 89 using ariba::communication::CommunicationEvents; 92 90 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 100 92 using ariba::utility::NodeID; 101 93 using ariba::utility::SpoVNetID; … … 118 110 namespace overlay { 119 111 120 class BaseOverlay : 121 public MessageReceiver, 122 public CommunicationEvents, 123 public OverlayStructureEvents, 124 protected Timer { 112 class BaseOverlay: public MessageReceiver, public CommunicationEvents, 113 public OverlayStructureEvents, protected Timer { 114 115 private: 116 friend class OneHop; 117 friend class Chord; 125 118 126 119 use_logging_h( BaseOverlay ); 120 127 121 public: 122 128 123 /** 129 124 * Constructs an empty non-functional base overlay instance … … 139 134 * Starts the Base Overlay instance 140 135 */ 141 void start( BaseCommunication& _basecomm, const NodeID& _nodeid);136 void start(BaseCommunication& _basecomm, const NodeID& _nodeid); 142 137 143 138 /** … … 152 147 * @param node Destination node id 153 148 * @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); 156 153 157 154 /** 158 155 * Starts a link establishment procedure to the specified 156 * 159 157 * endpoint and to the specified service 160 158 */ 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); 177 172 178 173 /** … … 180 175 * Depending on the structure of the overlay, this can be very different. 181 176 */ 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); 188 178 189 179 /** … … 193 183 * @return The end-point descriptor of the link's end-point 194 184 */ 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 205 206 bool bind(CommunicationListener* listener, const ServiceID& sid); 206 207 207 /** 208 * TODO 209 */ 208 // TODO: Doc 210 209 bool unbind(CommunicationListener* listener, const ServiceID& sid); 211 210 212 /** 213 * TODO 214 */ 211 // TODO: Doc 215 212 bool bind(NodeListener* listener); 216 213 217 /** 218 * TODO 219 */ 214 // TODO: Doc 220 215 bool unbind(NodeListener* listener); 221 216 222 /** 223 * TODO 224 */ 217 // TODO: Doc 225 218 bool registerSidePort(SideportListener* _sideport); 226 219 227 /** 228 * TODO 229 */ 220 // TODO: Doc 230 221 bool unregisterSidePort(SideportListener* _sideport); 231 222 … … 236 227 * @return The NodeID of the link 237 228 */ 238 const NodeID& getNodeID( const LinkID& lid = LinkID::UNSPECIFIED ) const;229 const NodeID& getNodeID(const LinkID& lid = LinkID::UNSPECIFIED) const; 239 230 240 231 /** … … 245 236 * @return a vector that contains all the link ids requested 246 237 */ 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. 266 261 */ 267 262 void leaveSpoVNet(); … … 272 267 * @see ariba::communication::CommunicationEvents.h 273 268 */ 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); 300 303 301 304 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 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 302 315 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 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 327 334 */ 328 335 virtual void eventFunction(); … … 382 389 */ 383 390 typedef enum _BaseOverlayState { 384 BaseOverlayStateInvalid 385 BaseOverlayStateInitiator 386 BaseOverlayStateJoinInitiated 387 BaseOverlayStateCompleted 391 BaseOverlayStateInvalid = 0, 392 BaseOverlayStateInitiator = 1, 393 BaseOverlayStateJoinInitiated = 2, 394 BaseOverlayStateCompleted = 3, 388 395 } BaseOverlayState; 389 396 … … 403 410 NodeID min, max; 404 411 NodeID succ, pred; 405 void updateOvlVis( const NodeID& node);412 void updateOvlVis(const NodeID& node); 406 413 407 414 /** … … 412 419 static const LinkItem UNSPECIFIED; 413 420 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) { 418 426 } 419 427 420 LinkItem( 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)) { 424 432 425 433 assert( _interface != NULL ); … … 434 442 435 443 // information needed for auto links 436 437 void markused(){ 444 void markused() { 438 445 lastuse = time(NULL); 439 446 } … … 444 451 445 452 typedef map<const LinkID, LinkItem> LinkMapping; 446 typedef pair<const LinkID, LinkItem> LinkPair;453 typedef pair<const LinkID, LinkItem> LinkPair; 447 454 LinkMapping linkMapping; 448 455 456 // map of a link request map a nonce to a LinkID 457 typedef map<const uint32_t, LinkID> PendingLinkMap; 458 PendingLinkMap pendingLinks; 449 459 450 460 /** … … 457 467 }; 458 468 459 }} // namespace ariba, overlay 469 } 470 } // namespace ariba, overlay 460 471 461 472 #endif /*BASEOVERLAY_H_*/
Note:
See TracChangeset
for help on using the changeset viewer.