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 
00029 #include "ChordMessage_m.h"
00030 
00031 namespace oversim {
00032 
00033 class ChordSuccessorList;
00034 class ChordFingerTable;
00035 
00046 class Chord : public BaseOverlay
00047 {
00048 public:
00049     Chord();
00050     virtual ~Chord();
00051 
00052     // see BaseOverlay.h
00053     virtual void initializeOverlay(int stage);
00054 
00055     // see BaseOverlay.h
00056     virtual void handleTimerEvent(cMessage* msg);
00057 
00058     // see BaseOverlay.h
00059     virtual void handleUDPMessage(BaseOverlayMessage* msg);
00060 
00061     // see BaseOverlay.h
00062     virtual void recordOverlaySentStats(BaseOverlayMessage* msg);
00063 
00064     // see BaseOverlay.h
00065     virtual void finishOverlay();
00066 
00067     // see BaseOverlay.h
00068     OverlayKey distance(const OverlayKey& x, const OverlayKey& y) const;
00069 
00073     virtual void updateTooltip();
00074 
00075 protected:
00076     int joinRetry; 
00077     int stabilizeRetry; 
00078     double joinDelay; 
00079     double stabilizeDelay; 
00080     double fixfingersDelay; 
00081     double checkPredecessorDelay;
00082     int successorListSize; 
00083     bool aggressiveJoinMode; 
00084     bool extendedFingerTable;
00085     unsigned int numFingerCandidates;
00086     bool proximityRouting;
00087     bool memorizeFailedSuccessor;
00088     bool newChordFingerTable;
00089     bool mergeOptimizationL1;
00090     bool mergeOptimizationL2;
00091     bool mergeOptimizationL3;
00092     bool mergeOptimizationL4;
00093 
00094 
00095     // timer messages
00096     cMessage* join_timer; 
00097     cMessage* stabilize_timer; 
00098     cMessage* fixfingers_timer; 
00099     cMessage* checkPredecessor_timer;
00100 
00101     // statistics
00102     int joinCount; 
00103     int stabilizeCount; 
00104     int fixfingersCount; 
00105     int notifyCount; 
00106     int newsuccessorhintCount; 
00107     int joinBytesSent; 
00108     int stabilizeBytesSent; 
00109     int notifyBytesSent; 
00110     int fixfingersBytesSent; 
00111     int newsuccessorhintBytesSent; 
00113     int keyLength; 
00114     int missingPredecessorStabRequests; 
00121     virtual void changeState(int toState);
00122 
00123     // node references
00124     NodeHandle predecessorNode; 
00125     TransportAddress bootstrapNode; 
00127     // module references
00128     ChordFingerTable* fingerTable; 
00129     ChordSuccessorList* successorList; 
00131     // chord routines
00132 
00138     virtual void handleJoinTimerExpired(cMessage* msg);
00139 
00145     virtual void handleStabilizeTimerExpired(cMessage* msg);
00146 
00152     virtual void handleFixFingersTimerExpired(cMessage* msg);
00153 
00159     virtual void handleNewSuccessorHint(ChordMessage* chordMsg);
00160 
00167     virtual NodeVector* closestPreceedingNode(const OverlayKey& key);
00168 
00169 
00173     virtual void findFriendModules();
00174 
00178     virtual void initializeFriendModules();
00179 
00180     // see BaseOverlay.h
00181     virtual bool handleRpc( BaseCallMessage* msg );
00182 
00183     // see BaseOverlay.h
00184     NodeVector* findNode(const OverlayKey& key,
00185                          int numRedundantNodes,
00186                          int numSiblings,
00187                          BaseOverlayMessage* msg);
00188 
00189     // see BaseOverlay.h
00190     virtual void joinOverlay();
00191 
00192     // see BaseOverlay.h
00193     virtual void joinForeignPartition(const NodeHandle &node);
00194 
00195     // see BaseOverlay.h
00196     virtual bool isSiblingFor(const NodeHandle& node,
00197                               const OverlayKey& key,
00198                               int numSiblings, bool* err);
00199 
00200     // see BaseOverlay.h
00201     int getMaxNumSiblings();
00202 
00203     // see BaseOverlay.h
00204     int getMaxNumRedundantNodes();
00205 
00211     void rpcFixfingers( FixfingersCall* call );
00212 
00218     virtual void rpcJoin( JoinCall* call );
00219 
00225     virtual void rpcNotify( NotifyCall* call );
00226 
00232     void rpcStabilize( StabilizeCall* call );
00233 
00234     // see BaseOverlay.h
00235     virtual void handleRpcResponse(BaseResponseMessage* msg,
00236                                    cPolymorphic* context, int rpcId,
00237                                    simtime_t rtt);
00238 
00239     // see BaseOverlay.h
00240     virtual void handleRpcTimeout(BaseCallMessage* msg,
00241                                   const TransportAddress& dest,
00242                                   cPolymorphic* context,
00243                                   int rpcId, const OverlayKey& destKey);
00244 
00245     // see BaseRpc.h
00246     virtual void pingResponse(PingResponse* pingResponse,
00247                               cPolymorphic* context, int rpcId,
00248                               simtime_t rtt);
00249 
00250     // see BaseRpc.h
00251     virtual void pingTimeout(PingCall* pingCall,
00252                              const TransportAddress& dest,
00253                              cPolymorphic* context,
00254                              int rpcId);
00255 
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     bool handleFailedNode(const TransportAddress& failed);
00267 
00268     virtual void predecessorIsDead();
00269     virtual void successorIsDead();
00270 
00271     friend class ChordSuccessorList;
00272     friend class ChordFingerTable;
00273 
00274 private:
00275     TransportAddress failedSuccessor;
00276 };
00277 
00278 }; //namespace
00279 
00280 #endif

Generated on Wed Mar 25 16:32:48 2009 for OverSim by  doxygen 1.5.5