TraceChurn Class Reference

#include <TraceChurn.h>

Inheritance diagram for TraceChurn:

ChurnGenerator

List of all members.


Detailed Description

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

If trace includes user action, send actions to application

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


Member Typedef Documentation

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


Member Function Documentation

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

Implements ChurnGenerator.

00048 {
00049     delete msg;
00050     return;
00051 }

void TraceChurn::initializeChurn (  )  [virtual]

Implements ChurnGenerator.

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::createNode ( int  nodeId  ) 

00054 {
00055     Enter_Method_Silent();
00056 
00057     TransportAddress* ta = underlayConfigurator->createNode(type);
00058     PeerInfo* peer = BootstrapOracleAccess().get()->getPeerInfo(*ta);
00059     cGate* inGate = simulation.module(peer->getModuleID())->submodule(maxTier)->gate("trace_in");
00060     if (!inGate) {
00061         throw new cException("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  ) 

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 new cException("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;
00083 }

cGate * TraceChurn::getAppGateById ( int  nodeId  ) 

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

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

Implements ChurnGenerator.

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

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

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


Member Data Documentation

char* TraceChurn::maxTier [private]

Referenced by createNode(), and initializeChurn().

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

cMessage* TraceChurn::nextRead [private]

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


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

Generated on Fri Sep 19 13:05:08 2008 for ITM OverSim by  doxygen 1.5.5