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

Function writeScript

src/restartscript.cpp:342–621  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

340;
341
342string
343writeScript(const string &ckptDir,
344 bool uniqueCkptFilenames,
345 const time_t &ckptTimeStamp,
346 const uint32_t theCheckpointInterval,
347 const int thePort,
348 const UniquePid &compId,
349 const map<string, vector<string> > &restartFilenames,
350 const map<string, vector<string> >& rshCmdFileNames,
351 const map<string, vector<string> >& sshCmdFileNames)
352{
353 ostringstream o;
354 string uniqueFilename;
355
356 o << string(ckptDir) << "/"
357 << RESTART_SCRIPT_BASENAME << "_" << compId;
358 if (uniqueCkptFilenames) {
359 o << "_" << std::setw(5) << std::setfill('0') <<
360 compId.computationGeneration();
361 }
362 o << "." << RESTART_SCRIPT_EXT;
363 uniqueFilename = o.str();
364
365 const bool isSingleHost = ((rshCmdFileNames.size() == 0) && (sshCmdFileNames.size() == 0) && (restartFilenames.size() == 1));
366
367 map<string, vector<string> >::const_iterator host;
368
369 size_t numPeers = 0;
370 for (host = restartFilenames.begin();
371 host != restartFilenames.end();
372 host++) {
373 numPeers += host->second.size();
374 }
375 for (host = rshCmdFileNames.begin();
376 host != rshCmdFileNames.end();
377 host++) {
378 numPeers += host->second.size();
379 }
380 for (host = sshCmdFileNames.begin();
381 host != sshCmdFileNames.end();
382 host++) {
383 numPeers += host->second.size();
384 }
385
386
387 vector<string>::const_iterator file;
388
389 char hostname[80];
390 char timestamp[80];
391 gethostname(hostname, 80);
392
393 JTRACE("writing restart script") (uniqueFilename);
394
395 FILE *fp = fopen(uniqueFilename.c_str(), "w");
396 JASSERT(fp != 0)(JASSERT_ERRNO)(uniqueFilename)
397 .Text("failed to open file");
398
399 fprintf(fp, "%s", header);

Callers 1

recordCkptFilenameMethod · 0.85

Calls 10

computationGenerationMethod · 0.80
beginMethod · 0.80
endMethod · 0.80
fopenFunction · 0.70
fcloseFunction · 0.70
openFunction · 0.70
statClass · 0.70
closeFunction · 0.70
strMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected