Chord.h

Go to the documentation of this file.
00001 //
00002 // Copyright (C) 2006 Institut fuer Telematik, Universitaet Karlsruhe (TH)
00003 //
00004 // This program is free software; you can redistribute it and/or
00005 // modify it under the terms of the GNU General Public License
00006 // as published by the Free Software Foundation; either version 2
00007 // of the License, or (at your option) any later version.
00008 //
00009 // This program is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with this program; if not, write to the Free Software
00016 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
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     // see BaseOverlay.h
00054     virtual void initializeOverlay(int stage);
00055 
00056     // see BaseOverlay.h
00057     virtual void handleTimerEvent(cMessage* msg);
00058 
00059     // see BaseOverlay.h
00060     virtual void handleUDPMessage(BaseOverlayMessage* msg);
00061 
00062     // see BaseOverlay.h
00063     virtual void recordOverlaySentStats(BaseOverlayMessage* msg);
00064 
00065     // see BaseOverlay.h
00066     virtual void finishOverlay();
00067 
00068     // see BaseOverlay.h
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     // timer messages
00100     cMessage* join_timer; 
00101     cMessage* stabilize_timer; 
00102     cMessage* fixfingers_timer; 
00103     cMessage* checkPredecessor_timer;
00104 
00105     // statistics
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     // node references
00128     NodeHandle predecessorNode; 
00129     TransportAddress bootstrapNode; 
00131     // module references
00132     ChordFingerTable* fingerTable; 
00133     ChordSuccessorList* successorList; 
00135     // chord routines
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     // see BaseOverlay.h
00185     virtual bool handleRpcCall(BaseCallMessage* msg);
00186 
00187     // see BaseOverlay.h
00188     NodeVector* findNode(const OverlayKey& key,
00189                          int numRedundantNodes,
00190                          int numSiblings,
00191                          BaseOverlayMessage* msg);
00192 
00193     // see BaseOverlay.h
00194     virtual void joinOverlay();
00195 
00196     // see BaseOverlay.h
00197     virtual void joinForeignPartition(const NodeHandle &node);
00198 
00199     // see BaseOverlay.h
00200     virtual bool isSiblingFor(const NodeHandle& node,
00201                               const OverlayKey& key,
00202                               int numSiblings, bool* err);
00203 
00204     // see BaseOverlay.h
00205     int getMaxNumSiblings();
00206 
00207     // see BaseOverlay.h
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     // see BaseOverlay.h
00239     virtual void handleRpcResponse(BaseResponseMessage* msg,
00240                                    cPolymorphic* context, int rpcId,
00241                                    simtime_t rtt);
00242 
00243     // see BaseOverlay.h
00244     virtual void handleRpcTimeout(BaseCallMessage* msg,
00245                                   const TransportAddress& dest,
00246                                   cPolymorphic* context,
00247                                   int rpcId, const OverlayKey& destKey);
00248 
00249     // see BaseRpc.h
00250     //virtual void pingResponse(PingResponse* pingResponse,
00251     //                          cPolymorphic* context, int rpcId,
00252     //                          simtime_t rtt);
00253 
00254     // see BaseRpc.h
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 }; //namespace
00276 
00277 #endif

Generated on Tue Sep 8 17:26:52 2009 for OverSim by  doxygen 1.5.8