MCPcopy Create free account
hub / github.com/dmtcp/dmtcp / handleUserCommand

Method handleUserCommand

src/dmtcp_coordinator.cpp:321–409  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

319static string replyData = "";
320
321void
322DmtcpCoordinator::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 }

Callers 1

signalHandlerFunction · 0.80

Calls 7

getStatusFunction · 0.85
preExitCleanupFunction · 0.85
hostnameMethod · 0.80
endMethod · 0.80
beginMethod · 0.80
closeMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected