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

List of all members.

Public Member Functions

void handleMessage (cMessage *msg)
void initializeChurn ()
void createNode (int nodeId)
void deleteNode (int nodeId)
cGate * getAppGateById (int nodeId)

Protected Member Functions

void updateDisplayString ()
TransportAddressgetTransportAddressById (int nodeId)

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

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 55 of file TraceChurn.h.


Member Function Documentation

void TraceChurn::createNode ( int  nodeId  ) 

Definition at line 53 of file TraceChurn.cc.

00054 {
00055     Enter_Method_Silent();
00056 
00057     TransportAddress* ta = underlayConfigurator->createNode(type);
00058     PeerInfo* peer = GlobalNodeListAccess().get()->getPeerInfo(*ta);
00059     cGate* inGate = simulation.getModule(peer->getModuleID())->getSubmodule(maxTier)->gate("trace_in");
00060     if (!inGate) {
00061         throw cRuntimeError("Application has no trace_in gate. Most probably "
00062                              "that means it is not able to handle trace data.");
00063     }
00064     nodeMapEntry* e = new nodeMapEntry(ta, inGate);
00065     nodeMap[nodeId] = e;
00066 }

void TraceChurn::deleteNode ( int  nodeId  ) 

Definition at line 68 of file TraceChurn.cc.

00069 {
00070     Enter_Method_Silent();
00071 
00072     nodeMapEntry* e;
00073     UNORDERED_MAP<int, nodeMapEntry*>::iterator it = nodeMap.find(nodeId);
00074 
00075     if (it == nodeMap.end()) {
00076         throw cRuntimeError("Trying to delete non-existing node");
00077     }
00078 
00079     e = it->second;
00080     underlayConfigurator->preKillNode(NodeType(), e->first);
00081     nodeMap.erase(it);
00082     delete e->first;
00083     delete e;
00084 }

cGate * TraceChurn::getAppGateById ( int  nodeId  ) 

Definition at line 96 of file TraceChurn.cc.

00096                                             {
00097     UNORDERED_MAP<int, nodeMapEntry*>::iterator it = nodeMap.find(nodeId);
00098 
00099     if (it == nodeMap.end()) {
00100         throw cRuntimeError("Trying to get appGate of nonexisting node");
00101     }
00102 
00103     return it->second->second;
00104 }

TransportAddress * TraceChurn::getTransportAddressById ( int  nodeId  )  [protected]

Definition at line 86 of file TraceChurn.cc.

00086                                                                 {
00087     UNORDERED_MAP<int, nodeMapEntry*>::iterator it = nodeMap.find(nodeId);
00088 
00089     if (it == nodeMap.end()) {
00090         throw cRuntimeError("Trying to get TransportAddress of nonexisting node");
00091     }
00092 
00093     return it->second->first;
00094 }

void TraceChurn::handleMessage ( cMessage *  msg  )  [virtual]

Implements ChurnGenerator.

Definition at line 47 of file TraceChurn.cc.

00048 {
00049     delete msg;
00050     return;
00051 }

void TraceChurn::initializeChurn (  )  [virtual]

Implements ChurnGenerator.

Definition at line 33 of file TraceChurn.cc.

00034 {
00035     Enter_Method_Silent();
00036 
00037     // get uppermost tier
00038     // Quick hack. Works fine unless numTiers is > 9 (which should never happen)
00039     maxTier = new char[6];
00040     strcpy(maxTier, "tier0");
00041     maxTier[4] += par("numTiers").longValue();
00042 
00043     // FIXME: There should be a tracefile command to decide when init phase has finished
00044     underlayConfigurator->initFinished();
00045 }

void TraceChurn::updateDisplayString (  )  [protected, virtual]

Implements ChurnGenerator.

Definition at line 106 of file TraceChurn.cc.

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


Member Data Documentation

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

Definition at line 53 of file TraceChurn.h.

char* TraceChurn::maxTier [private]

Definition at line 51 of file TraceChurn.h.

Referenced by createNode(), and initializeChurn().

cMessage* TraceChurn::nextRead [private]

Definition at line 54 of file TraceChurn.h.

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

Definition at line 56 of file TraceChurn.h.

Referenced by createNode(), deleteNode(), getAppGateById(), and getTransportAddressById().


The documentation for this class was generated from the following files:
Generated on Wed May 26 16:21:19 2010 for OverSim by  doxygen 1.6.3