OverSim
GlobalDhtTestMap Class Reference

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 DHTEntryfindEntry (const OverlayKey &key)
void eraseEntry (const OverlayKey &key)
const OverlayKeygetRandomKey ()
size_t size ()

Public Attributes

uint32_t p2pnsNameCount

Private Member Functions

void initialize ()
void handleMessage (cMessage *msg)
void finish ()

Private Attributes

GlobalStatisticsglobalStatistics
 pointer to GlobalStatistics module in this node
std::map< OverlayKey, DHTEntrydataMap
 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

Detailed Description

Module with a global view on all currently stored DHT records (used by DHTTestApp).

Author
Ingmar Baumgart

Definition at line 50 of file GlobalDhtTestMap.h.

Constructor & Destructor Documentation

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();
}

Member Function Documentation

void GlobalDhtTestMap::eraseEntry ( const OverlayKey key)

Definition at line 99 of file GlobalDhtTestMap.cc.

{
dataMap.erase(key);
}
const DHTEntry * GlobalDhtTestMap::findEntry ( const OverlayKey key)

Definition at line 104 of file GlobalDhtTestMap.cc.

{
std::map<OverlayKey, DHTEntry>::iterator it = dataMap.find(key);
if (it == dataMap.end()) {
return NULL;
} else {
return &(it->second);
}
}
void GlobalDhtTestMap::finish ( )
private

Definition at line 64 of file GlobalDhtTestMap.cc.

{
}
const OverlayKey & GlobalDhtTestMap::getRandomKey ( )

Definition at line 115 of file GlobalDhtTestMap.cc.

{
if (dataMap.size() == 0) {
}
// return random OverlayKey in O(log n)
std::map<OverlayKey, DHTEntry>::iterator it = dataMap.end();
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) {
"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.

{
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.

{
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 91 of file GlobalDhtTestMap.h.

{ return dataMap.size(); };

Member Data Documentation

std::map<OverlayKey, DHTEntry> GlobalDhtTestMap::dataMap
private

The map contains all currently stored DHT records.

Definition at line 102 of file GlobalDhtTestMap.h.

Referenced by size().

GlobalStatistics* GlobalDhtTestMap::globalStatistics
private

pointer to GlobalStatistics module in this node

Definition at line 101 of file GlobalDhtTestMap.h.

uint32_t GlobalDhtTestMap::p2pnsNameCount

Definition at line 91 of file GlobalDhtTestMap.h.

cMessage* GlobalDhtTestMap::periodicTimer
private

timer self-message for writing periodic statistical information

Definition at line 103 of file GlobalDhtTestMap.h.

const int GlobalDhtTestMap::TEST_MAP_INTERVAL = 10
staticprivate

interval in seconds for writing periodic statistical information

Definition at line 99 of file GlobalDhtTestMap.h.


The documentation for this class was generated from the following files: