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 bool isClosestNodeTo( const NodeID& node );
00084
00086 virtual const LinkID& getNextLinkId( const NodeID& id ) const;
00087
00089 virtual void routeMessage(const NodeID& destnode, Message* msg);
00090
00092 virtual void routeMessage(const NodeID& node, const LinkID& link, Message* msg);
00093
00095 virtual NodeList getKnownNodes(bool deep = true) const;
00096
00098 virtual void onLinkUp(const LinkID& lnk, const NodeID& remote);
00099
00101 virtual void onLinkDown(const LinkID& lnk, const NodeID& remote);
00102
00104 virtual void onMessage(const DataMessage& msg, const NodeID& remote,
00105 const LinkID& lnk = LinkID::UNSPECIFIED);
00106
00107 private:
00109 typedef map<const NodeID, const LinkID> OverlayNodeMapping;
00110 OverlayNodeMapping overlayNodes;
00111
00113 typedef enum _OneHopState {
00114 OneHopStateInvalid = 0,
00115 OneHopStateCompleted = 1,
00116 } OneHopState;
00117
00118 OneHopState state;
00119 vector<LinkID> bootstrapLinks;
00120 };
00121
00122 }}
00123
00124 #endif // _ONE_HOP_H