CBR-DHT.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 __CBRDHT_H_
00025 #define __CBRDHT_H_
00026
00027 #include <omnetpp.h>
00028
00029 #include <OverlayKey.h>
00030 #include <SHA1.h>
00031 #include <CommonMessages_m.h>
00032
00033 #include "CBR-DHTMessage_m.h"
00034 #include "DHTMessage_m.h"
00035 #include "DHTDataStorage.h"
00036
00037 #include "BaseApp.h"
00038 #include <RpcMacros.h>
00039
00040 class CoordBasedRouting;
00041 class NeighborCache;
00042
00048 class CBRDHT : public BaseApp
00049 {
00050 public:
00051 CBRDHT();
00052 virtual ~CBRDHT();
00053
00054 protected:
00055 typedef std::vector<NodeHandle> ReplicaVector;
00056
00057 struct GetMapEntry
00058 {
00059 ReplicaVector replica;
00060 std::map<BinaryValue, ReplicaVector> hashes;
00061 int numSent;
00062 int numAvailableReplica;
00063 int numResponses;
00064 int teamNumber;
00065 DHTgetCAPICall* callMsg;
00066 ReplicaVector* hashVector;
00067 };
00068
00069 struct PutMapEntry
00070 {
00071 int numSent;
00072 int numFailed;
00073 int numResponses;
00074 DHTputCAPICall* callMsg;
00075 };
00076
00077 void initializeApp(int stage);
00078 void finishApp();
00079 void handleTimerEvent(cMessage* msg);
00080
00081 bool handleRpcCall(BaseCallMessage* msg);
00082 void handleRpcResponse(BaseResponseMessage* msg, cPolymorphic *context,
00083 int rpcId, simtime_t rtt);
00084 void handleRpcTimeout(BaseCallMessage* msg, const TransportAddress& dest,
00085 cPolymorphic* context, int rpcId,
00086 const OverlayKey& destKey);
00087 void handleUpperMessage(cMessage* msg);
00088 void handlePutRequest(DHTPutCall* dhtMsg);
00089 void handleGetRequest(CBRDHTGetCall* dhtMsg);
00090 void handlePutResponse(DHTPutResponse* dhtMsg, int rpcId);
00091 void handleGetResponse(CBRDHTGetResponse* dhtMsg, int rpcId);
00092 void handlePutCAPIRequest(DHTputCAPICall* capiPutMsg);
00093 void handleGetCAPIRequest(DHTgetCAPICall* capiGetMsg, int teamnum = 0);
00094
00095 void handleDumpDhtRequest(DHTdumpCall* call);
00096 void update(const NodeHandle& node, bool joined);
00097 void handleLookupResponse(LookupResponse* lookupMsg);
00098
00099 int resultValuesBitLength(DHTGetResponse* msg);
00100
00101
00102 int numReplica;
00103 uint8_t numReplicaTeams;
00104
00105 double maintenanceMessages;
00106 double normalMessages;
00107 double numBytesMaintenance;
00108 double numBytesNormal;
00109 double lastGetCall;
00110 std::map<unsigned int, BaseCallMessage*> rpcIdMap;
00111 std::map<int, GetMapEntry> getMap;
00112 std::map<int, PutMapEntry> putMap;
00113
00114
00115 DHTDataStorage* dataStorage;
00116 CoordBasedRouting* coordBasedRouting;
00117 NeighborCache* neighborCache;
00118 };
00119
00120 #endif