Module with a global view on all currently stored DHT records (used by DHTTestApp). More...
#include <GlobalDhtTestMap.h>
Public Member Functions | |
| GlobalDhtTestMap () | |
| ~GlobalDhtTestMap () | |
| void | insertEntry (const OverlayKey &key, const DHTEntry &entry) |
| const DHTEntry * | findEntry (const OverlayKey &key) |
| void | eraseEntry (const OverlayKey &key) |
| const OverlayKey & | getRandomKey () |
| size_t | size () |
Public Attributes | |
| uint32_t | p2pnsNameCount |
Private Member Functions | |
| void | initialize () |
| void | handleMessage (cMessage *msg) |
| void | finish () |
Private Attributes | |
| GlobalStatistics * | globalStatistics |
| pointer to GlobalStatistics module in this node | |
| std::map< OverlayKey, DHTEntry > | dataMap |
| The map contains all currently stored DHT records. | |
| cMessage * | periodicTimer |
| timer self-message for writing periodic statistical information | |
Static Private Attributes | |
| static const int | TEST_MAP_INTERVAL = 10 |
| interval in seconds for writing periodic statistical information | |
Module with a global view on all currently stored DHT records (used by DHTTestApp).
Definition at line 49 of file GlobalDhtTestMap.h.
| GlobalDhtTestMap::GlobalDhtTestMap | ( | ) |
Definition at line 42 of file GlobalDhtTestMap.cc.
{
periodicTimer = NULL;
}
| GlobalDhtTestMap::~GlobalDhtTestMap | ( | ) |
Definition at line 47 of file GlobalDhtTestMap.cc.
{
cancelAndDelete(periodicTimer);
dataMap.clear();
}
| void GlobalDhtTestMap::eraseEntry | ( | const OverlayKey & | key | ) |
Definition at line 99 of file GlobalDhtTestMap.cc.
Referenced by DHTTestApp::handleGetResponse().
{
dataMap.erase(key);
}
| const DHTEntry * GlobalDhtTestMap::findEntry | ( | const OverlayKey & | key | ) |
Definition at line 104 of file GlobalDhtTestMap.cc.
Referenced by DHTTestApp::handleGetResponse().
| void GlobalDhtTestMap::finish | ( | ) | [private] |
Definition at line 64 of file GlobalDhtTestMap.cc.
{
}
| const OverlayKey & GlobalDhtTestMap::getRandomKey | ( | ) |
Definition at line 115 of file GlobalDhtTestMap.cc.
Referenced by DHTTestApp::handleTimerEvent().
{
if (dataMap.size() == 0) {
return OverlayKey::UNSPECIFIED_KEY;
}
// return random OverlayKey in O(log n)
std::map<OverlayKey, DHTEntry>::iterator it = dataMap.end();
DHTEntry tempEntry = {BinaryValue::UNSPECIFIED_VALUE, 0};
OverlayKey randomKey = OverlayKey::random();
it = dataMap.find(randomKey);
if (it == dataMap.end()) {
it = dataMap.insert(make_pair(randomKey, tempEntry)).first;
dataMap.erase(it++);
}
if (it == dataMap.end()) {
it = dataMap.begin();
}
return it->first;
}
| void GlobalDhtTestMap::handleMessage | ( | cMessage * | msg | ) | [private] |
Definition at line 68 of file GlobalDhtTestMap.cc.
{
//cleanupDataMap();
DhtTestEntryTimer *entryTimer = NULL;
if (msg == periodicTimer) {
RECORD_STATS(globalStatistics->recordOutVector(
"GlobalDhtTestMap: Number of stored DHT entries", dataMap.size()));
scheduleAt(simTime() + TEST_MAP_INTERVAL, msg);
} else if ((entryTimer = dynamic_cast<DhtTestEntryTimer*>(msg)) != NULL) {
dataMap.erase(entryTimer->getKey());
delete msg;
} else {
throw cRuntimeError("GlobalDhtTestMap::handleMessage(): "
"Unknown message type!");
}
}
| void GlobalDhtTestMap::initialize | ( | ) | [private] |
Definition at line 53 of file GlobalDhtTestMap.cc.
{
p2pnsNameCount = 0;
globalStatistics = GlobalStatisticsAccess().get();
WATCH_MAP(dataMap);
periodicTimer = new cMessage("dhtTestMapTimer");
scheduleAt(simTime(), periodicTimer);
}
| void GlobalDhtTestMap::insertEntry | ( | const OverlayKey & | key, | |
| const DHTEntry & | entry | |||
| ) |
Definition at line 86 of file GlobalDhtTestMap.cc.
Referenced by DHTTestApp::handlePutResponse().
{
Enter_Method_Silent();
dataMap.erase(key);
dataMap.insert(make_pair(key, entry));
DhtTestEntryTimer* msg = new DhtTestEntryTimer("dhtEntryTimer");
msg->setKey(key);
scheduleAt(entry.endtime, msg);
}
| size_t GlobalDhtTestMap::size | ( | ) | [inline] |
Definition at line 90 of file GlobalDhtTestMap.h.
{ return dataMap.size(); };
std::map<OverlayKey, DHTEntry> GlobalDhtTestMap::dataMap [private] |
The map contains all currently stored DHT records.
Definition at line 101 of file GlobalDhtTestMap.h.
Referenced by eraseEntry(), findEntry(), getRandomKey(), handleMessage(), initialize(), insertEntry(), size(), and ~GlobalDhtTestMap().
pointer to GlobalStatistics module in this node
Definition at line 100 of file GlobalDhtTestMap.h.
Referenced by handleMessage(), and initialize().
| uint32_t GlobalDhtTestMap::p2pnsNameCount |
Definition at line 90 of file GlobalDhtTestMap.h.
Referenced by DHTTestApp::handleTimerEvent(), and initialize().
cMessage* GlobalDhtTestMap::periodicTimer [private] |
timer self-message for writing periodic statistical information
Definition at line 102 of file GlobalDhtTestMap.h.
Referenced by GlobalDhtTestMap(), handleMessage(), initialize(), and ~GlobalDhtTestMap().
const int GlobalDhtTestMap::TEST_MAP_INTERVAL = 10 [static, private] |
interval in seconds for writing periodic statistical information
Definition at line 98 of file GlobalDhtTestMap.h.
Referenced by handleMessage().
1.7.1