Chord.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00024 #ifndef __CHORD_H_
00025 #define __CHORD_H_
00026
00027 #include <BaseOverlay.h>
00028 #include <NeighborCache.h>
00029
00030 #include "ChordMessage_m.h"
00031
00032 namespace oversim {
00033
00034 class ChordSuccessorList;
00035 class ChordFingerTable;
00036
00047 class Chord : public BaseOverlay, public ProxListener
00048 {
00049 public:
00050 Chord();
00051 virtual ~Chord();
00052
00053
00054 virtual void initializeOverlay(int stage);
00055
00056
00057 virtual void handleTimerEvent(cMessage* msg);
00058
00059
00060 virtual void handleUDPMessage(BaseOverlayMessage* msg);
00061
00062
00063 virtual void recordOverlaySentStats(BaseOverlayMessage* msg);
00064
00065
00066 virtual void finishOverlay();
00067
00068
00069 OverlayKey distance(const OverlayKey& x, const OverlayKey& y) const;
00070
00074 virtual void updateTooltip();
00075
00076 void proxCallback(const TransportAddress &node, int rpcId,
00077 cPolymorphic *contextPointer, Prox prox);
00078
00079 protected:
00080 int joinRetry;
00081 int stabilizeRetry;
00082 double joinDelay;
00083 double stabilizeDelay;
00084 double fixfingersDelay;
00085 double checkPredecessorDelay;
00086 int successorListSize;
00087 bool aggressiveJoinMode;
00088 bool extendedFingerTable;
00089 unsigned int numFingerCandidates;
00090 bool proximityRouting;
00091 bool memorizeFailedSuccessor;
00092 bool newChordFingerTable;
00093 bool mergeOptimizationL1;
00094 bool mergeOptimizationL2;
00095 bool mergeOptimizationL3;
00096 bool mergeOptimizationL4;
00097
00098
00099
00100 cMessage* join_timer;
00101 cMessage* stabilize_timer;
00102 cMessage* fixfingers_timer;
00103 cMessage* checkPredecessor_timer;
00104
00105
00106 int joinCount;
00107 int stabilizeCount;
00108 int fixfingersCount;
00109 int notifyCount;
00110 int newsuccessorhintCount;
00111 int joinBytesSent;
00112 int stabilizeBytesSent;
00113 int notifyBytesSent;
00114 int fixfingersBytesSent;
00115 int newsuccessorhintBytesSent;
00117 int keyLength;
00118 int missingPredecessorStabRequests;
00125 virtual void changeState(int toState);
00126
00127
00128 NodeHandle predecessorNode;
00129 TransportAddress bootstrapNode;
00131
00132 ChordFingerTable* fingerTable;
00133 ChordSuccessorList* successorList;
00135
00136
00142 virtual void handleJoinTimerExpired(cMessage* msg);
00143
00149 virtual void handleStabilizeTimerExpired(cMessage* msg);
00150
00156 virtual void handleFixFingersTimerExpired(cMessage* msg);
00157
00163 virtual void handleNewSuccessorHint(ChordMessage* chordMsg);
00164
00171 virtual NodeVector* closestPreceedingNode(const OverlayKey& key);
00172
00173
00177 virtual void findFriendModules();
00178
00182 virtual void initializeFriendModules();
00183
00184
00185 virtual bool handleRpcCall(BaseCallMessage* msg);
00186
00187
00188 NodeVector* findNode(const OverlayKey& key,
00189 int numRedundantNodes,
00190 int numSiblings,
00191 BaseOverlayMessage* msg);
00192
00193
00194 virtual void joinOverlay();
00195
00196
00197 virtual void joinForeignPartition(const NodeHandle &node);
00198
00199
00200 virtual bool isSiblingFor(const NodeHandle& node,
00201 const OverlayKey& key,
00202 int numSiblings, bool* err);
00203
00204
00205 int getMaxNumSiblings();
00206
00207
00208 int getMaxNumRedundantNodes();
00209
00215 void rpcFixfingers(FixfingersCall* call);
00216
00222 virtual void rpcJoin(JoinCall* call);
00223
00229 virtual void rpcNotify(NotifyCall* call);
00230
00236 void rpcStabilize(StabilizeCall* call);
00237
00238
00239 virtual void handleRpcResponse(BaseResponseMessage* msg,
00240 cPolymorphic* context, int rpcId,
00241 simtime_t rtt);
00242
00243
00244 virtual void handleRpcTimeout(BaseCallMessage* msg,
00245 const TransportAddress& dest,
00246 cPolymorphic* context,
00247 int rpcId, const OverlayKey& destKey);
00248
00249
00250
00251
00252
00253
00254
00255 virtual void pingTimeout(PingCall* pingCall,
00256 const TransportAddress& dest,
00257 cPolymorphic* context,
00258 int rpcId);
00259
00260 virtual void handleRpcJoinResponse(JoinResponse* joinResponse);
00261 virtual void handleRpcNotifyResponse(NotifyResponse* notifyResponse);
00262 virtual void handleRpcStabilizeResponse(StabilizeResponse* stabilizeResponse);
00263 virtual void handleRpcFixfingersResponse(FixfingersResponse* fixfingersResponse,
00264 double rtt = -1);
00265
00266 virtual bool handleFailedNode(const TransportAddress& failed);
00267
00268 friend class ChordSuccessorList;
00269 friend class ChordFingerTable;
00270
00271 private:
00272 TransportAddress failedSuccessor;
00273 };
00274
00275 };
00276
00277 #endif