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 using ariba::communication::EndpointDescriptor;
00054 using ariba::utility::Timer;
00055
00056 using namespace std;
00057
00071 class Chord : public OverlayInterface, protected Timer {
00072 use_logging_h( Chord );
00073 private:
00074 chord_routing_table* table;
00075 int orphan_removal_counter;
00076 int stabilize_counter;
00077 int stabilize_finger;
00078 LinkID bootstrapLink;
00079
00080
00081 LinkID setup( const EndpointDescriptor& endp );
00082
00083
00084 seqnum_t send( Message* msg, const LinkID& link );
00085
00086
00087 void send_discovery_to( const NodeID& destination, int ttl = 4 );
00088
00089 public:
00090 Chord(BaseOverlay& _baseoverlay, const NodeID& _nodeid,
00091 OverlayStructureEvents* _eventsReceiver, const OverlayParameterSet& param);
00092 virtual ~Chord();
00093
00095 virtual void createOverlay();
00096
00098 virtual void deleteOverlay();
00099
00101 virtual void joinOverlay(
00102 const EndpointDescriptor& boot = EndpointDescriptor::UNSPECIFIED
00103 );
00104
00106 virtual void leaveOverlay();
00107
00109 virtual const EndpointDescriptor& resolveNode( const NodeID& node );
00110
00112 virtual void routeMessage( const NodeID& destnode, Message* msg );
00113
00115 virtual NodeList getKnownNodes() const;
00116
00118 virtual void onLinkUp(const LinkID& lnk, const NodeID& remote);
00119
00121 virtual void onLinkDown(const LinkID& lnk, const NodeID& remote);
00122
00124 virtual void onMessage(const DataMessage& msg, const NodeID& remote,
00125 const LinkID& lnk = LinkID::UNSPECIFIED);
00126
00128 virtual void eventFunction();
00129 };
00130
00131 }}
00132
00133 #endif