| 319 | static string replyData = ""; |
| 320 | |
| 321 | void |
| 322 | DmtcpCoordinator::handleUserCommand(string cmd, DmtcpMessage *reply /*= NULL*/) |
| 323 | { |
| 324 | if (reply != NULL) { |
| 325 | reply->coordCmdStatus = CoordCmdStatus::NOERROR; |
| 326 | } |
| 327 | |
| 328 | if (cmd == "bc" || cmd == "kc" || cmd == "ck" || cmd == "K" || cmd == "c") { |
| 329 | if (cmd == "bc") { |
| 330 | blockUntilDone = true; |
| 331 | JTRACE("blocking checkpoint beginning..."); |
| 332 | } else if (cmd == "kc" || cmd == "ck" || cmd == "K") { |
| 333 | // dmtcp_command encodes this as 'cmd == "K"; '-kc' is the user flag. |
| 334 | JTRACE("Will kill peers after creating the checkpoint..."); |
| 335 | killAfterCkptOnce = true; |
| 336 | } else { |
| 337 | JTRACE("checkpointing..."); |
| 338 | } |
| 339 | |
| 340 | if (startCheckpoint()) { |
| 341 | if (reply != NULL) { |
| 342 | reply->numPeers = getStatus().numPeers; |
| 343 | } |
| 344 | } else { |
| 345 | if (reply != NULL) { |
| 346 | reply->coordCmdStatus = CoordCmdStatus::ERROR_NOT_RUNNING_STATE; |
| 347 | } |
| 348 | } |
| 349 | } else if (cmd == "l" || cmd == "t") { |
| 350 | if (reply != NULL) { |
| 351 | replyData = printList(); |
| 352 | reply->extraBytes = replyData.length(); |
| 353 | } else { |
| 354 | JASSERT_STDERR << printList(); |
| 355 | } |
| 356 | } else if (cmd == "u") { |
| 357 | JASSERT_STDERR << "Host List:\n"; |
| 358 | JASSERT_STDERR << "HOST => # connected clients \n"; |
| 359 | dmtcp::map<string, int>clientHosts; |
| 360 | for (size_t i = 0; i < clients.size(); i++) { |
| 361 | if (clientHosts.find(clients[i]->hostname()) == clientHosts.end()) { |
| 362 | clientHosts[clients[i]->hostname()] = 1; |
| 363 | } else { |
| 364 | clientHosts[clients[i]->hostname()] += 1; |
| 365 | } |
| 366 | } |
| 367 | for (dmtcp::map<string, int>::iterator it = clientHosts.begin(); |
| 368 | it != clientHosts.end(); |
| 369 | ++it) { |
| 370 | JASSERT_STDERR << it->first << " => " << it->second << '\n'; |
| 371 | } |
| 372 | } else if (cmd == "q") { |
| 373 | JNOTE("killing all connected peers and quitting ..."); |
| 374 | broadcastMessage(DMT_KILL_PEER); |
| 375 | JASSERT_STDERR << "DMTCP coordinator exiting... (per request)\n"; |
| 376 | for (size_t i = 0; i < clients.size(); i++) { |
| 377 | clients[i]->sock().close(); |
| 378 | } |
no test coverage detected