PastryStateObject.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __PASTRYSTATEOBJECT_H
00021 #define __PASTRYSTATEOBJECT_H
00022
00028 #include <vector>
00029
00030 #include <omnetpp.h>
00031
00032 #include <NodeHandle.h>
00033 #include <NodeVector.h>
00034
00035 #include "PastryTypes.h"
00036 #include "PastryMessage_m.h"
00037
00047 class PastryStateObject : public cSimpleModule
00048 {
00049 public:
00050
00051 void handleMessage(cMessage* msg);
00052
00053 int numInitStages(void) const;
00054
00055 void initialize(int stage);
00056
00064 virtual const NodeHandle& getDestinationNode(const OverlayKey& destination);
00065
00077 virtual const NodeHandle& findCloserNode(const OverlayKey& destination,
00078 bool optimize = false) = 0;
00079
00080 virtual void findCloserNodes(const OverlayKey& destination,
00081 NodeVector* nodes) = 0;
00082
00089 virtual const TransportAddress& failedNode(const TransportAddress& failed) = 0;
00090
00099 virtual const TransportAddress& repair(const PastryStateMessage* msg,
00100 const PastryStateMsgProximity& prox);
00101
00107 virtual void dumpToStateMessage(PastryStateMessage* msg) const = 0;
00108
00116 bool mergeState(const PastryStateMessage* msg,
00117 const PastryStateMsgProximity* prox);
00118
00125 virtual void dumpToVector(std::vector<TransportAddress>& affected)
00126 const = 0;
00127
00136 bool isCloser(const NodeHandle& test, const OverlayKey& destination,
00137 const NodeHandle& reference =
00138 NodeHandle::UNSPECIFIED_NODE) const;
00139
00152 bool specialCloserCondition(const NodeHandle& test,
00153 const OverlayKey& destination,
00154 const NodeHandle& reference =
00155 NodeHandle::UNSPECIFIED_NODE) const;
00156
00157 protected:
00158
00163 NodeHandle owner;
00164
00165 uint32_t bitsPerDigit;
00166
00170 private:
00171 static const PastryExtendedNode* _unspecNode;
00172
00173 protected:
00174 static const PastryExtendedNode& unspecNode()
00175 {
00176 if (_unspecNode == NULL)
00177 _unspecNode = new PastryExtendedNode();
00178 return *_unspecNode;
00179 }
00180
00181 private:
00182
00186 virtual void earlyInit(void) = 0;
00187
00195 virtual bool mergeNode(const NodeHandle& node, simtime_t prox) = 0;
00196
00204 const OverlayKey* keyDist(const OverlayKey& a, const OverlayKey& b) const;
00205 };
00206
00207 #endif