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 __PASTRY_H_ 00025 #define __PASTRY_H_ 00026 00027 #include <vector> 00028 #include <map> 00029 #include <queue> 00030 #include <algorithm> 00031 00032 #include <omnetpp.h> 00033 #include <IPvXAddress.h> 00034 00035 #include <OverlayKey.h> 00036 #include <NodeHandle.h> 00037 #include <BaseOverlay.h> 00038 #include <BasePastry.h> 00039 00040 #include "PastryTypes.h" 00041 #include "PastryMessage_m.h" 00042 #include "PastryRoutingTable.h" 00043 #include "PastryLeafSet.h" 00044 #include "PastryNeighborhoodSet.h" 00045 00046 00047 00054 class Pastry : public BasePastry 00055 { 00056 public: 00057 virtual ~Pastry(); 00058 00059 // see BaseOverlay.h 00060 virtual void initializeOverlay(int stage); 00061 00062 // see BaseOverlay.h 00063 virtual void handleTimerEvent(cMessage* msg); 00064 00065 // see BaseOverlay.h 00066 virtual void handleUDPMessage(BaseOverlayMessage* msg); 00067 00068 void handleStateMessage(PastryStateMessage* msg); 00069 00070 virtual void pingResponse(PingResponse* pingResponse, 00071 cPolymorphic* context, int rpcId, 00072 simtime_t rtt); 00073 00074 protected: 00075 00076 virtual void purgeVectors(void); 00077 00083 virtual void changeState(int toState); 00084 00085 00086 virtual bool recursiveRoutingHook(const TransportAddress& dest, 00087 BaseRouteMessage* msg); 00088 00089 void iterativeJoinHook(BaseOverlayMessage* msg, bool incrHopCount); 00093 std::vector<PastryStateMsgHandle> stReceived; 00094 std::vector<PastryStateMsgHandle>::iterator stReceivedPos; 00095 00099 std::vector<TransportAddress> notifyList; 00100 00101 private: 00102 00103 void clearVectors(); 00104 00105 simtime_t secondStageInterval; 00106 simtime_t routingTableMaintenanceInterval; 00107 simtime_t discoveryTimeoutAmount; 00108 bool partialJoinPath; 00109 00110 int depth; 00111 00112 int updateCounter; 00113 00114 bool minimalJoinState; 00115 bool useDiscovery; 00116 bool useSecondStage; 00117 bool sendStateAtLeafsetRepair; 00118 bool pingBeforeSecondStage; 00119 00120 bool overrideOldPastry; 00121 bool overrideNewPastry; 00122 00123 cMessage* secondStageWait; 00124 cMessage* ringCheck; 00125 cMessage* discoveryTimeout; 00126 cMessage* repairTaskTimeout; 00127 00131 void doSecondStage(void); 00132 00133 00139 void doRoutingTableMaintenance(); 00140 00149 bool handleFailedNode(const TransportAddress& failed); 00150 00155 void checkProxCache(void); 00156 00157 void processState(void); 00158 00159 bool mergeState(void); 00160 00161 void endProcessingState(void); 00162 00166 void doJoinUpdate(void); 00167 00168 // see BaseOverlay.h 00169 virtual void joinOverlay(); 00170 00171 }; 00172 00173 00174 00175 #endif