00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #ifndef _ONE_HOP_H
00040 #define _ONE_HOP_H
00041
00042 #include <map>
00043 #include "ariba/overlay/modules/OverlayInterface.h"
00044 #include "ariba/utility/logging/Logging.h"
00045 #include "ariba/utility/system/Timer.h"
00046
00047 using std::map;
00048 using ariba::utility::Timer;
00049
00050 namespace ariba {
00051 namespace overlay {
00052
00053 class OneHop : public OverlayInterface, protected Timer {
00054 use_logging_h( OneHop );
00055 public:
00056 OneHop(BaseOverlay& _overlay, const NodeID& _nodeid,
00057 OverlayStructureEvents* _eventsReceiver, const OverlayParameterSet& param);
00058
00059 virtual ~OneHop();
00060
00061 protected:
00062
00064 virtual void eventFunction();
00065
00067 virtual void createOverlay();
00068
00070 virtual void deleteOverlay();
00071
00073 virtual void joinOverlay(const EndpointDescriptor& boot =
00074 EndpointDescriptor::UNSPECIFIED);
00075
00077 virtual void leaveOverlay();
00078
00080 virtual const EndpointDescriptor& resolveNode(const NodeID& node);
00081
00083 virtual void routeMessage(const NodeID& destnode, Message* msg);
00084
00086 virtual NodeList getKnownNodes() const;
00087
00089 virtual void onLinkUp(const LinkID& lnk, const NodeID& remote);
00090
00092 virtual void onLinkDown(const LinkID& lnk, const NodeID& remote);
00093
00095 virtual void onMessage(const DataMessage& msg, const NodeID& remote,
00096 const LinkID& lnk = LinkID::UNSPECIFIED);
00097
00098 private:
00100 typedef map<const NodeID, const LinkID> OverlayNodeMapping;
00101 OverlayNodeMapping overlayNodes;
00102
00104 typedef enum _OneHopState {
00105 OneHopStateInvalid = 0,
00106 OneHopStateJoinInitiated = 1,
00107 OneHopStateJoinListingRequested = 2,
00108 OneHopStateCompleted = 3,
00109 } OneHopState;
00110
00111 OneHopState state;
00112 uint16_t pendingLinks;
00113 LinkID bootstrapLink;
00114 };
00115
00116 }}
00117
00118 #endif // _ONE_HOP_H