ChordFingerTable.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
00024 #ifndef __CHORDFINGERTABLE_H_
00025 #define __CHORDFINGERTABLE_H_
00026
00027 #include <deque>
00028 #include <map>
00029
00030 #include <omnetpp.h>
00031
00032 #include <NodeVector.h>
00033 #include <InitStages.h>
00034
00035 class BaseOverlay;
00036
00037 namespace oversim {
00038
00039 typedef std::multimap<simtime_t, NodeHandle> Successors;
00040 typedef std::pair<NodeHandle, Successors> FingerEntry;
00041
00042 class Chord;
00043
00052 class ChordFingerTable : public cSimpleModule
00053 {
00054 public:
00055
00056 virtual int numInitStages() const
00057 {
00058 return MAX_STAGE_OVERLAY + 1;
00059 }
00060
00061 virtual void initialize(int stage);
00062 virtual void handleMessage(cMessage* msg);
00063
00075 virtual void initializeTable(uint32_t size, const NodeHandle& owner,
00076 Chord* overlay);
00077
00086 virtual void setFinger(uint32_t pos, const NodeHandle& node,
00087 Successors const* sucNodes = NULL);
00088 virtual void setFinger(uint32_t pos, const Successors& nodes);
00089
00090 virtual bool updateFinger(uint32_t pos, const NodeHandle& node, simtime_t rtt);
00091
00098 virtual const NodeHandle& getFinger(uint32_t pos);
00099
00100 virtual NodeVector* getFinger(uint32_t pos, const OverlayKey& key);
00101
00102 bool handleFailedNode(const TransportAddress& failed);
00103
00109 void removeFinger(uint32_t pos);
00110
00116 virtual uint32_t getSize();
00117
00118 private:
00119
00120 uint32_t maxSize;
00121 std::deque<FingerEntry> fingerTable;
00122 Chord* overlay;
00123 };
00124
00125 };
00126
00127 std::ostream& operator<<(std::ostream& os, const oversim::Successors& suc);
00128 std::ostream& operator<<(std::ostream& os, const oversim::FingerEntry& entry);
00129
00130 #endif