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 pair
< TransportAddress *,
cGate * > 
nodeMapEntry

Private Attributes

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


Member Typedef Documentation

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


Member Function Documentation

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

Implements ChurnGenerator.

00043 {
00044     delete msg;
00045     return;
00046 }

void TraceChurn::initializeChurn (  )  [virtual]

Implements ChurnGenerator.

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

void TraceChurn::createNode ( int  nodeId  ) 

00049 {
00050     Enter_Method_Silent();
00051         
00052     TransportAddress* ta = underlayConfigurator->createNode(type);
00053     PeerInfo* peer = BootstrapOracleAccess().get()->getPeerInfo(*ta);
00054     cGate* inGate = simulation.module(peer->getModuleID())->submodule(maxTier)->gate("trace_in");
00055     if (!inGate) {
00056         throw new cException("Application has no trace_in gate. Most probably "
00057                              "that means it is not able to handle trace data.");
00058     }
00059     nodeMapEntry* e = new nodeMapEntry(ta, inGate);
00060     nodeMap[nodeId] = e;
00061 }

void TraceChurn::deleteNode ( int  nodeId  ) 

00064 {
00065     Enter_Method_Silent();
00066         
00067     nodeMapEntry* e;
00068     __gnu_cxx::hash_map<int, nodeMapEntry*>::iterator it = nodeMap.find(nodeId);
00069     
00070     if (it == nodeMap.end()) {
00071         throw new cException("Trying to delete non-existing node");
00072     }
00073     
00074     e = it->second;
00075     underlayConfigurator->preKillNode(NodeType(), e->first);
00076     nodeMap.erase(it);
00077     delete e;
00078 }

cGate * TraceChurn::getAppGateById ( int  nodeId  ) 

00090                                             {
00091     __gnu_cxx::hash_map<int, nodeMapEntry*>::iterator it = nodeMap.find(nodeId);
00092     
00093     if (it == nodeMap.end()) {
00094         throw new cException("Trying to get appGate of nonexisting node");
00095     }
00096     
00097     return it->second->second;
00098 }

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

Implements ChurnGenerator.

00101 {
00102     char buf[80];
00103     sprintf(buf, "trace churn");
00104     displayString().setTagArg("t", 0, buf);
00105 }

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

00080                                                                 {
00081     __gnu_cxx::hash_map<int, nodeMapEntry*>::iterator it = nodeMap.find(nodeId);
00082     
00083     if (it == nodeMap.end()) {
00084         throw new cException("Trying to get TransportAddress of nonexisting node");
00085     }
00086     
00087     return it->second->first;
00088 }


Member Data Documentation

char* TraceChurn::maxTier [private]

bool TraceChurn::initAddMoreTerminals [private]

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

cMessage* TraceChurn::nextRead [private]

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


The documentation for this class was generated from the following files:
Generated on Thu Apr 17 13:19:30 2008 for ITM OverSim by  doxygen 1.5.3