DHT.h

Go to the documentation of this file.
00001 //
00002 // Copyright (C) 2007 Institut fuer Telematik, Universitaet Karlsruhe (TH)
00003 //
00004 // This program is free software; you can redistribute it and/or
00005 // modify it under the terms of the GNU General Public License
00006 // as published by the Free Software Foundation; either version 2
00007 // of the License, or (at your option) any later version.
00008 //
00009 // This program is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with this program; if not, write to the Free Software
00016 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00017 //
00018 
00024 #ifndef __DHT_H_
00025 #define __DHT_H_
00026 
00027 #include <omnetpp.h>
00028 
00029 #include <OverlayKey.h>
00030 #include <SHA1.h>
00031 #include <CommonMessages_m.h>
00032 
00033 #include "DHTMessage_m.h"
00034 #include "DHTDataStorage.h"
00035 
00036 #include "BaseApp.h"
00037 #include <RpcMacros.h>
00038 
00044 class DHT : public BaseApp
00045 {
00046 public:
00047     DHT();
00048     virtual ~DHT();
00049 
00050 protected:
00051     typedef std::vector<NodeHandle> ReplicaVector;
00052 
00053     struct GetMapEntry
00054     {
00055         ReplicaVector replica;
00056         std::map<BinaryValue, ReplicaVector> hashes;
00057         int numSent;
00058         int numAvailableReplica;
00059         int numResponses;
00060         DHTgetCAPICall* callMsg;
00061         ReplicaVector* hashVector;
00062     };
00063 
00064     struct PutMapEntry
00065     {
00066         int numSent;
00067         int numFailed;
00068         int numResponses;
00069         DHTputCAPICall* callMsg;
00070     };
00071 
00072     void initializeApp(int stage);
00073     void finishApp();
00074     void handleTimerEvent(cMessage* msg);
00075 
00076     bool handleRpcCall(BaseCallMessage* msg);
00077     void handleRpcResponse(BaseResponseMessage* msg, cPolymorphic *context,
00078                            int rpcId, simtime_t rtt);
00079     void handleRpcTimeout(BaseCallMessage* msg, const TransportAddress& dest,
00080                           cPolymorphic* context, int rpcId,
00081                           const OverlayKey& destKey);
00082     void handlePutRequest(DHTPutCall* dhtMsg);
00083     void handleGetRequest(DHTGetCall* dhtMsg);
00084     void handlePutResponse(DHTPutResponse* dhtMsg, int rpcId);
00085     void handleGetResponse(DHTGetResponse* dhtMsg, int rpcId);
00086     void handlePutCAPIRequest(DHTputCAPICall* capiPutMsg);
00087     void handleGetCAPIRequest(DHTgetCAPICall* capiPutMsg);
00088     void handleDumpDhtRequest(DHTdumpCall* call);
00089     void update(const NodeHandle& node, bool joined);
00090     void handleLookupResponse(LookupResponse* lookupMsg);
00091 
00092 
00093     int numReplica;
00094     int numGetRequests;
00095     double ratioIdentical;
00096     double maintenanceMessages;
00097     double normalMessages;
00098     double numBytesMaintenance;
00099     double numBytesNormal;
00100     simtime_t lastGetCall;
00101     std::map<unsigned int, BaseCallMessage*> rpcIdMap; 
00102     std::map<int, GetMapEntry> getMap;
00103     std::map<int, PutMapEntry> putMap;
00104     // module references
00105     DHTDataStorage* dataStorage; 
00107 private:
00108     int resultValuesBitLength(DHTGetResponse* msg);
00109 };
00110 
00111 #endif

Generated on Tue Sep 8 17:26:52 2009 for OverSim by  doxygen 1.5.8