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,
00070                         const OverlayKey& y,
00071                         bool useAlternative = false) const;
00072 
00076     virtual void updateTooltip();
00077 
00078     void proxCallback(const TransportAddress &node, int rpcId,
00079                       cPolymorphic *contextPointer, Prox prox);
00080 
00081 protected:
00082     int joinRetry; 
00083     int stabilizeRetry; 
00084     double joinDelay; 
00085     double stabilizeDelay; 
00086     double fixfingersDelay; 
00087     double checkPredecessorDelay;
00088     int successorListSize; 
00089     bool aggressiveJoinMode; 
00090     bool extendedFingerTable;
00091     unsigned int numFingerCandidates;
00092     bool proximityRouting;
00093     bool memorizeFailedSuccessor;
00094     bool newChordFingerTable;
00095     bool mergeOptimizationL1;
00096     bool mergeOptimizationL2;
00097     bool mergeOptimizationL3;
00098     bool mergeOptimizationL4;
00099 
00100 
00101     // timer messages
00102     cMessage* join_timer; 
00103     cMessage* stabilize_timer; 
00104     cMessage* fixfingers_timer; 
00105     cMessage* checkPredecessor_timer;
00106 
00107     // statistics
00108     int joinCount; 
00109     int stabilizeCount; 
00110     int fixfingersCount; 
00111     int notifyCount; 
00112     int newsuccessorhintCount; 
00113     int joinBytesSent; 
00114     int stabilizeBytesSent; 
00115     int notifyBytesSent; 
00116     int fixfingersBytesSent; 
00117     int newsuccessorhintBytesSent; 
00119     int keyLength; 
00120     int missingPredecessorStabRequests; 
00127     virtual void changeState(int toState);
00128 
00129     // node references
00130     NodeHandle predecessorNode; 
00131     TransportAddress bootstrapNode; 
00133     // module references
00134     ChordFingerTable* fingerTable; 
00135     ChordSuccessorList* successorList; 
00137     // chord routines
00138 
00144     virtual void handleJoinTimerExpired(cMessage* msg);
00145 
00151     virtual void handleStabilizeTimerExpired(cMessage* msg);
00152 
00158     virtual void handleFixFingersTimerExpired(cMessage* msg);
00159 
00165     virtual void handleNewSuccessorHint(ChordMessage* chordMsg);
00166 
00173     virtual NodeVector* closestPreceedingNode(const OverlayKey& key);
00174 
00175 
00179     virtual void findFriendModules();
00180 
00184     virtual void initializeFriendModules();
00185 
00186     // see BaseOverlay.h
00187     virtual bool handleRpcCall(BaseCallMessage* msg);
00188 
00189     // see BaseOverlay.h
00190     NodeVector* findNode(const OverlayKey& key,
00191                          int numRedundantNodes,
00192                          int numSiblings,
00193                          BaseOverlayMessage* msg);
00194 
00195     // see BaseOverlay.h
00196     virtual void joinOverlay();
00197 
00198     // see BaseOverlay.h
00199     virtual void joinForeignPartition(const NodeHandle &node);
00200 
00201     // see BaseOverlay.h
00202     virtual bool isSiblingFor(const NodeHandle& node,
00203                               const OverlayKey& key,
00204                               int numSiblings, bool* err);
00205 
00206     // see BaseOverlay.h
00207     int getMaxNumSiblings();
00208 
00209     // see BaseOverlay.h
00210     int getMaxNumRedundantNodes();
00211 
00217     void rpcFixfingers(FixfingersCall* call);
00218 
00224     virtual void rpcJoin(JoinCall* call);
00225 
00231     virtual void rpcNotify(NotifyCall* call);
00232 
00238     void rpcStabilize(StabilizeCall* call);
00239 
00240     // see BaseOverlay.h
00241     virtual void handleRpcResponse(BaseResponseMessage* msg,
00242                                    cPolymorphic* context, int rpcId,
00243                                    simtime_t rtt);
00244 
00245     // see BaseOverlay.h
00246     virtual void handleRpcTimeout(BaseCallMessage* msg,
00247                                   const TransportAddress& dest,
00248                                   cPolymorphic* context,
00249                                   int rpcId, const OverlayKey& destKey);
00250 
00251     // see BaseRpc.h
00252     virtual void pingResponse(PingResponse* pingResponse,
00253                               cPolymorphic* context, int rpcId,
00254                               simtime_t rtt);
00255 
00256     // see BaseRpc.h
00257     virtual void pingTimeout(PingCall* pingCall,
00258                              const TransportAddress& dest,
00259                              cPolymorphic* context,
00260                              int rpcId);
00261 
00262     virtual void handleRpcJoinResponse(JoinResponse* joinResponse);
00263     virtual void handleRpcNotifyResponse(NotifyResponse* notifyResponse);
00264     virtual void handleRpcStabilizeResponse(StabilizeResponse* stabilizeResponse);
00265     virtual void handleRpcFixfingersResponse(FixfingersResponse* fixfingersResponse,
00266                                              double rtt = -1);
00267 
00268     virtual bool handleFailedNode(const TransportAddress& failed);
00269 
00270     friend class ChordSuccessorList;
00271     friend class ChordFingerTable;
00272 
00273 private:
00274     TransportAddress failedSuccessor;
00275 };
00276 
00277 }; //namespace
00278 
00279 #endif
Generated on Wed May 26 16:21:13 2010 for OverSim by  doxygen 1.6.3