PastryRoutingTable.h
Go to the documentation of this file.00001 #ifndef __PASTRYROUTINGTABLE_H_
00002 #define __PASTRYROUTINGTABLE_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
00033 #include "PastryStateObject.h"
00034 #include "PastryTypes.h"
00035 #include "PastryMessage_m.h"
00036
00040 typedef std::vector<PastryExtendedNode> PRTRow;
00041
00045 struct PRTTrackRepair
00046 {
00047 TransportAddress node;
00048 simtime_t timestamp;
00049 uint32_t failedRow;
00050 uint32_t failedCol;
00051 uint32_t askedRow;
00052 uint32_t askedCol;
00053 };
00054
00063 class PastryRoutingTable : public PastryStateObject
00064 {
00065
00066 public:
00074 void initializeTable(uint32_t bitsPerDigit, double repairTimeout,
00075 const NodeHandle& owner);
00076
00084 const NodeHandle& lookupNextHop(const OverlayKey& destination);
00085
00097 virtual const NodeHandle& findCloserNode(const OverlayKey& destination,
00098 bool optimize = false);
00099
00100 void findCloserNodes(const OverlayKey& destination,
00101 NodeVector* nodes);
00102
00109 virtual const TransportAddress& failedNode(const TransportAddress& failed);
00110
00119 virtual const TransportAddress& repair(const PastryStateMessage* msg,
00120 const PastryStateMsgProximity* prox);
00121
00127 virtual void dumpToStateMessage(PastryStateMessage* msg) const;
00128
00134 virtual void dumpRowToMessage(PastryRoutingRowMessage* msg, int row) const;
00135
00141 virtual void dumpRowToMessage(PastryStateMessage* msg, int row) const;
00142
00147 int getLastRow();
00148
00155 virtual const TransportAddress& getRandomNode(int row);
00156
00157
00165 bool mergeNode(const NodeHandle& node, simtime_t prox);
00166
00175 bool initStateFromHandleVector(const std::vector<PastryStateMsgHandle>& handles);
00176
00184 virtual void dumpToVector(std::vector<TransportAddress>& affected) const;
00185
00186 uint32_t nodesPerRow;
00187
00188 private:
00189 double repairTimeout;
00190 std::vector<PRTRow> rows;
00191 std::vector<PRTTrackRepair> awaitingRepair;
00192
00193 virtual void earlyInit(void);
00194
00198 void addRow(void);
00199
00207 uint32_t digitAt(uint32_t n, const OverlayKey& key) const;
00208
00215 const PastryExtendedNode& nodeAt(uint32_t row, uint32_t col) const;
00216
00223 void findNextNodeToAsk(PRTTrackRepair& track) const;
00224
00225 };
00226
00231 std::ostream& operator<<(std::ostream& os, const PRTRow& row);
00232
00233 #endif