PastryLeafSet.h
Go to the documentation of this file.00001 #ifndef __PASTRYLEAFSET_H
00002 #define __PASTRYLEAFSET_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00027 #include <vector>
00028
00029 #include <omnetpp.h>
00030
00031 #include <NodeHandle.h>
00032 #include <NodeVector.h>
00033
00034 #include "PastryStateObject.h"
00035 #include "PastryTypes.h"
00036 #include "PastryMessage_m.h"
00037
00038 #include "BasePastry.h"
00039
00040 class BasePastry;
00041
00045 struct PLSRepairData
00046 {
00047 simtime_t ts;
00048 bool left;
00049 PLSRepairData(simtime_t ts = 0, bool left = true) : ts(ts), left(left) {};
00050 };
00051
00060 class PastryLeafSet : public PastryStateObject
00061 {
00062 public:
00063
00073 void initializeSet(uint32_t numberOfLeaves,
00074 uint32_t bitsPerDigit,
00075 simtime_t repairTimeout,
00076 const NodeHandle& owner,
00077 BasePastry* overlay);
00078
00086 virtual const NodeHandle& getDestinationNode(const OverlayKey& destination);
00087
00099 virtual const NodeHandle& findCloserNode(const OverlayKey& destination,
00100 bool optimize = false);
00101
00102 void findCloserNodes(const OverlayKey& destination,
00103 NodeVector* nodes);
00110 virtual const TransportAddress& failedNode(const TransportAddress& failed);
00111
00120 virtual const TransportAddress& repair(const PastryStateMessage* msg,
00121 const PastryStateMsgProximity* prox);
00122
00129 bool isClosestNode(const OverlayKey& destination) const;
00130
00136 virtual void dumpToStateMessage(PastryStateMessage* msg) const;
00137
00143 virtual void dumpToStateMessage(PastryLeafsetMessage* msg) const;
00144
00150 virtual const TransportAddress& getRandomNode();
00151
00159 bool mergeNode(const NodeHandle& node, simtime_t prox);
00160
00164 const NodeHandle& getPredecessor(void) const;
00165
00169 const NodeHandle& getSuccessor(void) const;
00170
00174 bool isValid(void) const;
00175
00182 virtual void dumpToVector(std::vector<TransportAddress>& affected) const;
00183
00184 NodeVector* createSiblingVector(const OverlayKey& key, int numSiblings) const;
00185
00186
00193 PastryNewLeafsMessage* getNewLeafsMessage(void);
00194
00195 private:
00196 uint32_t numberOfLeaves;
00197 simtime_t repairTimeout;
00198 BasePastry* overlay;
00199 std::vector<NodeHandle> leaves;
00200 std::vector<NodeHandle>::iterator smaller;
00201 std::vector<NodeHandle>::iterator bigger;
00202
00203 std::map<TransportAddress, PLSRepairData> awaitingRepair;
00204
00205 bool newLeafs;
00206
00207 bool isFull;
00208 bool wasFull;
00209
00210 virtual void earlyInit(void);
00211
00218 const NodeHandle& getBiggestNode(void) const;
00219
00226 const OverlayKey& getBiggestKey(void) const;
00227
00234 const NodeHandle& getSmallestNode(void) const;
00235
00242 const OverlayKey& getSmallestKey(void) const;
00243
00251 bool isLeft(const OverlayKey& key) const;
00252
00259 void insertLeaf(std::vector<NodeHandle>::iterator& it,
00260 const NodeHandle& node);
00261
00262 bool balanceLeafSet();
00263 };
00264
00265 #endif