#include <TraceChurn.h>
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 () |
TransportAddress * | getTransportAddressById (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 |
typedef std::pair<TransportAddress*, cGate*> TraceChurn::nodeMapEntry [private] |
void TraceChurn::handleMessage | ( | cMessage * | msg | ) | [virtual] |
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 | ) |
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] |
char* TraceChurn::maxTier [private] |
Referenced by createNode(), and initializeChurn().
bool TraceChurn::initAddMoreTerminals [private] |
true, if we're still adding more terminals in the init phase
cMessage* TraceChurn::nextRead [private] |
UNORDERED_MAP<int, nodeMapEntry*> TraceChurn::nodeMap [private] |
Referenced by createNode(), deleteNode(), getAppGateById(), and getTransportAddressById().