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 CHORD_H_
00040 #define CHORD_H_
00041
00042 #include "ariba/utility/system/Timer.h"
00043 #include "ariba/utility/logging/Logging.h"
00044 #include "ariba/communication/EndpointDescriptor.h"
00045 #include "../OverlayInterface.h"
00046 #include <vector>
00047
00048 class chord_routing_table;
00049
00050 namespace ariba {
00051 namespace overlay {
00052
00053 class OverlayMsg;
00054
00055 using ariba::communication::EndpointDescriptor;
00056 using ariba::utility::Timer;
00057
00058 using namespace std;
00059
00073 class Chord : public OverlayInterface, protected Timer {
00074 use_logging_h( Chord );
00075 private:
00076 chord_routing_table* table;
00077 int orphan_removal_counter;
00078 int stabilize_counter;
00079 int stabilize_finger;
00080 vector<LinkID> bootstrapLinks;
00081 vector<NodeID> pending;
00082 vector<NodeID> discovery;
00083 int discovery_count;
00084
00085
00086 LinkID setup( const EndpointDescriptor& endp,
00087 const NodeID& node = NodeID::UNSPECIFIED );
00088
00089
00090 seqnum_t send( OverlayMsg* msg, const LinkID& link );
00091
00092
00093 void send_discovery_to( const NodeID& destination, int ttl = 3 );
00094
00095 void discover_neighbors( const LinkID& lnk );
00096
00097 void showLinks();
00098
00099 public:
00100 Chord(BaseOverlay& _baseoverlay, const NodeID& _nodeid,
00101 OverlayStructureEvents* _eventsReceiver, const OverlayParameterSet& param);
00102 virtual ~Chord();
00103
00105 virtual const LinkID& getNextLinkId( const NodeID& id ) const;
00106
00108 virtual void createOverlay();
00109
00111 virtual void deleteOverlay();
00112
00114 virtual void joinOverlay(
00115 const EndpointDescriptor& boot = EndpointDescriptor::UNSPECIFIED()
00116 );
00117
00119 virtual void leaveOverlay();
00120
00122 virtual const EndpointDescriptor& resolveNode( const NodeID& node );
00123
00125 virtual NodeList getKnownNodes(bool deep = true) const;
00126
00128 virtual void onLinkUp(const LinkID& lnk, const NodeID& remote);
00129
00131 virtual void onLinkDown(const LinkID& lnk, const NodeID& remote);
00132
00134 virtual void onMessage(const DataMessage& msg, const NodeID& remote,
00135 const LinkID& lnk = LinkID::UNSPECIFIED);
00136
00138 virtual void eventFunction();
00139
00140 };
00141
00142 }}
00143
00144 #endif