OverSim
TraceChurn Class Reference

Parse a trace file and schedule node joins/leaves according to trace data. More...

#include <TraceChurn.h>

Inheritance diagram for TraceChurn:
ChurnGenerator

Public Member Functions

void handleMessage (cMessage *msg)
void initializeChurn ()
void createNode (int nodeId)
void deleteNode (int nodeId)
cGate * getAppGateById (int nodeId)
TransportAddressgetTransportAddressById (int nodeId)
- Public Member Functions inherited from ChurnGenerator
virtual int numInitStages () const
virtual void initialize (int stage)
void setNodeType (const NodeType &t)
const NodeTypegetNodeType ()

Protected Member Functions

void updateDisplayString ()

Private Types

typedef std::pair
< TransportAddress *, cGate * > 
nodeMapEntry

Private Attributes

char * maxTier
bool initAddMoreTerminals
 true, if we're still adding more terminals in the init phase
cMessage * nextRead
UNORDERED_MAP< int,
nodeMapEntry * > 
nodeMap

Additional Inherited Members

- Public Attributes inherited from ChurnGenerator
bool init
 still in initialization phase?
int terminalCount
 current number of overlay terminals
- Protected Attributes inherited from ChurnGenerator
UnderlayConfiguratorunderlayConfigurator
int targetOverlayTerminalNum
 final number of overlay terminals
NodeType type
 the nodeType this generator is responsible for

Detailed Description

Parse a trace file and schedule node joins/leaves according to trace data.

If trace includes user action, send actions to application

Definition at line 36 of file TraceChurn.h.

Member Typedef Documentation

typedef std::pair<TransportAddress*, cGate*> TraceChurn::nodeMapEntry
private

Definition at line 54 of file TraceChurn.h.

Member Function Documentation

void TraceChurn::createNode ( int  nodeId)

Definition at line 53 of file TraceChurn.cc.

{
Enter_Method_Silent();
cGate* inGate = simulation.getModule(peer->getModuleID())->getSubmodule(maxTier)->gate("trace_in");
if (!inGate) {
throw cRuntimeError("Application has no trace_in gate. Most probably "
"that means it is not able to handle trace data.");
}
nodeMapEntry* e = new nodeMapEntry(ta, inGate);
nodeMap[nodeId] = e;
}
void TraceChurn::deleteNode ( int  nodeId)

Definition at line 68 of file TraceChurn.cc.

{
Enter_Method_Silent();
UNORDERED_MAP<int, nodeMapEntry*>::iterator it = nodeMap.find(nodeId);
if (it == nodeMap.end()) {
throw cRuntimeError("Trying to delete non-existing node");
}
e = it->second;
nodeMap.erase(it);
delete e->first;
delete e;
}
cGate * TraceChurn::getAppGateById ( int  nodeId)

Definition at line 96 of file TraceChurn.cc.

{
UNORDERED_MAP<int, nodeMapEntry*>::iterator it = nodeMap.find(nodeId);
if (it == nodeMap.end()) {
throw cRuntimeError("Trying to get appGate of nonexisting node");
}
return it->second->second;
}
TransportAddress * TraceChurn::getTransportAddressById ( int  nodeId)

Definition at line 86 of file TraceChurn.cc.

{
UNORDERED_MAP<int, nodeMapEntry*>::iterator it = nodeMap.find(nodeId);
if (it == nodeMap.end()) {
throw cRuntimeError("Trying to get TransportAddress of nonexisting node");
}
return it->second->first;
}
void TraceChurn::handleMessage ( cMessage *  msg)
virtual

Implements ChurnGenerator.

Definition at line 47 of file TraceChurn.cc.

{
delete msg;
return;
}
void TraceChurn::initializeChurn ( )
virtual

Implements ChurnGenerator.

Definition at line 33 of file TraceChurn.cc.

{
Enter_Method_Silent();
// get uppermost tier
// Quick hack. Works fine unless numTiers is > 9 (which should never happen)
maxTier = new char[6];
strcpy(maxTier, "tier0");
maxTier[4] += par("numTiers").longValue();
// FIXME: There should be a tracefile command to decide when init phase has finished
}
void TraceChurn::updateDisplayString ( )
protectedvirtual

Implements ChurnGenerator.

Definition at line 106 of file TraceChurn.cc.

{
char buf[80];
sprintf(buf, "trace churn");
getDisplayString().setTagArg("t", 0, buf);
}

Member Data Documentation

bool TraceChurn::initAddMoreTerminals
private

true, if we're still adding more terminals in the init phase

Definition at line 52 of file TraceChurn.h.

char* TraceChurn::maxTier
private

Definition at line 50 of file TraceChurn.h.

cMessage* TraceChurn::nextRead
private

Definition at line 53 of file TraceChurn.h.

UNORDERED_MAP<int, nodeMapEntry*> TraceChurn::nodeMap
private

Definition at line 55 of file TraceChurn.h.


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