24 #include <sys/types.h>
43 Enter_Method_Silent();
46 if (strlen(par(
"traceFile")) == 0)
55 fd = open(par(
"traceFile"), O_RDONLY);
58 throw cRuntimeError((
"Can't open file " + par(
"traceFile").stdstringValue() +
59 std::string(strerror(errno))).c_str());
64 if (fstat(
fd, &filestat)) {
65 throw cRuntimeError((
"Error calling stat: " + std::string(strerror(errno))).c_str());
70 EV <<
"[GlobalTraceManager::initialize()]\n"
71 <<
" Successfully opened trace file " << par(
"traceFile").stdstringValue()
94 throw cRuntimeError(
"GlobalTraceManager::readNextBlock():"
95 "Not available on WIN32 yet!");
112 if (
start == MAP_FAILED) {
113 throw cRuntimeError((
"Error mapping file to memory:" +
114 std::string(strerror(errno))).c_str());
121 time = strtod(
buf, &bufend);
123 throw cRuntimeError(
"Error parsing file: Expected time as double");
127 nodeID = strtol(
buf, &bufend, 0);
129 throw cRuntimeError(
"Error parsing file: Expected ID as long int");
133 while( isspace(
buf[0]) )
buf++;
135 bufend = strchr(
buf,
'\n');
137 throw cRuntimeError(
"Error parsing file: Missing command or no newline at end of line!");
143 while( isspace(
buf[0]) )
buf++;
166 scheduleAt(time, msg);
184 if (!msg->isSelfMessage()) {
194 if (strstr(traceMsg->getName(),
"JOIN") == traceMsg->getName()) {
196 }
else if (strstr(traceMsg->getName(),
"LEAVE") == traceMsg->getName()) {
198 }
else if (strstr(traceMsg->getName(),
"CONNECT_NODETYPES") == traceMsg->getName()) {
199 std::vector<std::string> strVec = cStringTokenizer(msg->getName()).asVector();
201 if (strVec.size() != 3) {
202 throw cRuntimeError(
"GlobalTraceManager::"
203 "handleMessage(): Invalid command");
206 int firstNodeType = atoi(strVec[1].c_str());
207 int secondNodeType = atoi(strVec[2].c_str());
210 }
else if (strstr(traceMsg->getName(),
"DISCONNECT_NODETYPES") == traceMsg->getName()) {
211 std::vector<std::string> strVec = cStringTokenizer(msg->getName()).asVector();
213 if (strVec.size() != 3) {
214 throw cRuntimeError(
"GlobalTraceManager::"
215 "handleMessage(): Invalid command");
218 int firstNodeType = atoi(strVec[1].c_str());
219 int secondNodeType = atoi(strVec[2].c_str());
222 }
else if (strstr(traceMsg->getName(),
"MERGE_BOOTSTRAPNODES") == traceMsg->getName()) {
223 std::vector<std::string> strVec = cStringTokenizer(msg->getName()).asVector();
225 if (strVec.size() != 4) {
226 throw cRuntimeError(
"GlobalTraceManager::"
227 "handleMessage(): Invalid command");
230 int toPartition = atoi(strVec[1].c_str());
231 int fromPartition = atoi(strVec[2].c_str());
232 int numNodes = atoi(strVec[3].c_str());