本文整理汇总了C++中TmpDir::Cd2TmpDir方法的典型用法代码示例。如果您正苦于以下问题:C++ TmpDir::Cd2TmpDir方法的具体用法?C++ TmpDir::Cd2TmpDir怎么用?C++ TmpDir::Cd2TmpDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TmpDir
的用法示例。
在下文中一共展示了TmpDir::Cd2TmpDir方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getParamFromSubmitLine
MyString
MultiLogFiles::loadValueFromSubFile(const MyString &strSubFilename,
const MyString &directory, const char *keyword)
{
dprintf( D_FULLDEBUG, "MultiLogFiles::loadValueFromSubFile(%s, %s, %s)\n",
strSubFilename.Value(), directory.Value(), keyword );
TmpDir td;
if ( directory != "" ) {
MyString errMsg;
if ( !td.Cd2TmpDir(directory.Value(), errMsg) ) {
dprintf(D_ALWAYS, "Error from Cd2TmpDir: %s\n", errMsg.Value());
return "";
}
}
StringList logicalLines;
if ( fileNameToLogicalLines( strSubFilename, logicalLines ) != "" ) {
return "";
}
MyString value("");
// Now look through the submit file logical lines to find the
// value corresponding to the keyword.
const char *logicalLine;
while( (logicalLine = logicalLines.next()) != NULL ) {
MyString submitLine(logicalLine);
MyString tmpValue = getParamFromSubmitLine(submitLine, keyword);
if ( tmpValue != "" ) {
value = tmpValue;
}
}
//
// Check for macros in the value -- we currently don't
// handle those.
//
if ( value != "" ) {
if ( strchr(value.Value(), '$') ) {
dprintf(D_ALWAYS, "MultiLogFiles: macros not allowed "
"in %s in DAG node submit files\n", keyword);
value = "";
}
}
if ( directory != "" ) {
MyString errMsg;
if ( !td.Cd2MainDir(errMsg) ) {
dprintf(D_ALWAYS, "Error from Cd2MainDir: %s\n", errMsg.Value());
return "";
}
}
return value;
}
示例2: writePreSkipEvent
bool writePreSkipEvent( CondorID& condorID, Job* job, const char* DAGNodeName,
const char* directory, const char *logFile )
{
TmpDir tmpDir;
MyString errMsg;
if ( !tmpDir.Cd2TmpDir( directory, errMsg ) ) {
debug_printf( DEBUG_QUIET,
"Could not change to node directory %s: %s\n",
directory, errMsg.Value() );
return false;
}
// Special HTCondorID for NOOP jobs -- actually indexed by
// otherwise-unused subprocID.
condorID._cluster = 0;
condorID._proc = Job::NOOP_NODE_PROCID;
condorID._subproc = 1+get_fake_condorID();
// Increment this value
set_fake_condorID(condorID._subproc);
if( job ) {
job->SetCondorID( condorID );
}
WriteUserLog ulog;
ulog.setEnableGlobalLog( false );
ulog.setUseXML( false );
ulog.initialize( std::vector<const char*>(1,logFile), condorID._cluster,
condorID._proc, condorID._subproc, NULL );
PreSkipEvent pEvent;
pEvent.cluster = condorID._cluster;
pEvent.proc = condorID._proc;
pEvent.subproc = condorID._subproc;
MyString pEventNotes("DAG Node: " );
pEventNotes += DAGNodeName;
// skipEventLogNotes gets deleted in PreSkipEvent destructor.
pEvent.skipEventLogNotes = strnewp( pEventNotes.Value() );
if ( !ulog.writeEvent( &pEvent ) ) {
EXCEPT( "Error: writing PRESKIP event failed!" );
return false;
}
return true;
}
示例3: subEventNotes
//-------------------------------------------------------------------------
bool
fake_condor_submit( CondorID& condorID, Job* job, const char* DAGNodeName,
const char* directory, const char *logFile )
{
TmpDir tmpDir;
MyString errMsg;
if ( !tmpDir.Cd2TmpDir( directory, errMsg ) ) {
debug_printf( DEBUG_QUIET,
"Could not change to node directory %s: %s\n",
directory, errMsg.Value() );
return false;
}
_subprocID++;
// Special HTCondorID for NOOP jobs -- actually indexed by
// otherwise-unused subprocID.
condorID._cluster = 0;
condorID._proc = Job::NOOP_NODE_PROCID;
condorID._subproc = _subprocID;
// Make sure that this job gets marked as a NOOP
if( job ) {
job->SetCondorID( condorID );
}
WriteUserLog ulog;
ulog.setEnableGlobalLog( false );
ulog.setUseXML( false );
ulog.initialize( logFile, condorID._cluster,
condorID._proc, condorID._subproc, NULL );
SubmitEvent subEvent;
subEvent.cluster = condorID._cluster;
subEvent.proc = condorID._proc;
subEvent.subproc = condorID._subproc;
// We need some value for submitHost for the event to be read
// correctly.
subEvent.setSubmitHost( "<dummy-submit-for-noop-job>" );
MyString subEventNotes("DAG Node: " );
subEventNotes += DAGNodeName;
// submitEventLogNotes get deleted in SubmitEvent destructor.
subEvent.submitEventLogNotes = strnewp( subEventNotes.Value() );
if ( !ulog.writeEvent( &subEvent ) ) {
EXCEPT( "Error: writing dummy submit event for NOOP node failed!" );
return false;
}
JobTerminatedEvent termEvent;
termEvent.cluster = condorID._cluster;
termEvent.proc = condorID._proc;
termEvent.subproc = condorID._subproc;
termEvent.normal = true;
termEvent.returnValue = 0;
termEvent.signalNumber = 0;
if ( !ulog.writeEvent( &termEvent ) ) {
EXCEPT( "Error: writing dummy terminated event for NOOP node failed!" );
return false;
}
return true;
}
示例4: dlog
//-------------------------------------------------------------------------
bool
condor_submit( const Dagman &dm, const char* cmdFile, CondorID& condorID,
const char* DAGNodeName, MyString &DAGParentNodeNames,
List<Job::NodeVar> *vars, int retry,
const char* directory, const char *workflowLogFile,
bool hold_claim )
{
TmpDir tmpDir;
MyString errMsg;
if ( !tmpDir.Cd2TmpDir( directory, errMsg ) ) {
debug_printf( DEBUG_QUIET,
"Could not change to node directory %s: %s\n",
directory, errMsg.Value() );
return false;
}
ArgList args;
// construct arguments to condor_submit to add attributes to the
// job classad which identify the job's node name in the DAG, the
// node names of its parents in the DAG, and the job ID of DAGMan
// itself; then, define submit_event_notes to print the job's node
// name inside the submit event in the userlog
// NOTE: we specify the job ID of DAGMan using only its cluster ID
// so that it may be referenced by jobs in their priority
// attribute (which needs an int, not a string). Doing so allows
// users to effectively "batch" jobs by DAG so that when they
// submit many DAGs to the same schedd, all the ready jobs from
// one DAG complete before any jobs from another begin.
args.AppendArg( dm.condorSubmitExe );
args.AppendArg( "-a" );
MyString nodeName = MyString(ATTR_DAG_NODE_NAME_ALT) + " = " + DAGNodeName;
args.AppendArg( nodeName.Value() );
// append a line adding the parent DAGMan's cluster ID to the job ad
args.AppendArg( "-a" );
MyString dagJobId = MyString( "+" ) + ATTR_DAGMAN_JOB_ID + " = " +
dm.DAGManJobId._cluster;
args.AppendArg( dagJobId.Value() );
// now we append a line setting the same thing as a submit-file macro
// (this is necessary so the user can reference it in the priority)
args.AppendArg( "-a" );
MyString dagJobIdMacro = MyString( "" ) + ATTR_DAGMAN_JOB_ID + " = " +
dm.DAGManJobId._cluster;
args.AppendArg( dagJobIdMacro.Value() );
args.AppendArg( "-a" );
MyString submitEventNotes = MyString(
"submit_event_notes = DAG Node: " ) + DAGNodeName;
args.AppendArg( submitEventNotes.Value() );
ASSERT( workflowLogFile );
// We need to append the DAGman default log file to
// the log file list
args.AppendArg( "-a" );
std::string dlog( "dagman_log = " );
dlog += workflowLogFile;
args.AppendArg( dlog.c_str() );
debug_printf( DEBUG_VERBOSE, "Adding a DAGMan workflow log %s\n",
workflowLogFile );
// Now append the mask
debug_printf( DEBUG_VERBOSE, "Masking the events recorded in the DAGMAN workflow log\n" );
args.AppendArg( "-a" );
std::string dmask("+");
dmask += ATTR_DAGMAN_WORKFLOW_MASK;
dmask += " = \"";
const char *eventMask = getEventMask();
debug_printf( DEBUG_VERBOSE, "Mask for workflow log is %s\n",
eventMask );
dmask += eventMask;
dmask += "\"";
args.AppendArg( dmask.c_str() );
// Suppress the job's log file if that option is enabled.
if ( dm._suppressJobLogs ) {
debug_printf( DEBUG_VERBOSE, "Suppressing node job log file\n" );
args.AppendArg( "-a" );
args.AppendArg( "log = ''" );
}
ArgList parentNameArgs;
parentNameArgs.AppendArg( "-a" );
MyString parentNodeNames = MyString( "+DAGParentNodeNames = " ) +
"\"" + DAGParentNodeNames + "\"";
parentNameArgs.AppendArg( parentNodeNames.Value() );
// set any VARS specified in the DAG file
MyString anotherLine;
ListIterator<Job::NodeVar> varsIter(*vars);
Job::NodeVar nodeVar;
while ( varsIter.Next(nodeVar) ) {
// Substitute the node retry count if necessary. Note that
//.........这里部分代码省略.........
示例5:
//---------------------------------------------------------------------------
int
runSubmitDag( const SubmitDagDeepOptions &deepOpts,
const char *dagFile, const char *directory, int priority,
bool isRetry )
{
int result = 0;
// Change to the appropriate directory if necessary.
TmpDir tmpDir;
MyString errMsg;
if ( directory ) {
if ( !tmpDir.Cd2TmpDir( directory, errMsg ) ) {
fprintf( stderr, "Error (%s) changing to node directory\n",
errMsg.Value() );
result = 1;
return result;
}
}
// Build up the command line for the recursive run of
// condor_submit_dag. We need -no_submit so we don't
// actually run the subdag now; we need -update_submit
// so the lower-level .condor.sub file will get
// updated, in case it came from an earlier version
// of condor_submit_dag.
ArgList args;
args.AppendArg( "condor_submit_dag" );
args.AppendArg( "-no_submit" );
args.AppendArg( "-update_submit" );
// Add in arguments we're passing along.
if ( deepOpts.bVerbose ) {
args.AppendArg( "-verbose" );
}
if ( deepOpts.bForce && !isRetry ) {
args.AppendArg( "-force" );
}
if (deepOpts.strNotification != "" ) {
args.AppendArg( "-notification" );
if(deepOpts.suppress_notification) {
args.AppendArg( "never" );
} else {
args.AppendArg( deepOpts.strNotification.Value() );
}
}
if ( deepOpts.strDagmanPath != "" ) {
args.AppendArg( "-dagman" );
args.AppendArg( deepOpts.strDagmanPath.Value() );
}
if ( deepOpts.useDagDir ) {
args.AppendArg( "-usedagdir" );
}
if ( deepOpts.strOutfileDir != "" ) {
args.AppendArg( "-outfile_dir" );
args.AppendArg( deepOpts.strOutfileDir.Value() );
}
args.AppendArg( "-autorescue" );
args.AppendArg( deepOpts.autoRescue );
if ( deepOpts.doRescueFrom != 0 ) {
args.AppendArg( "-dorescuefrom" );
args.AppendArg( deepOpts.doRescueFrom );
}
if ( deepOpts.allowVerMismatch ) {
args.AppendArg( "-allowver" );
}
if ( deepOpts.importEnv ) {
args.AppendArg( "-import_env" );
}
if ( deepOpts.recurse ) {
args.AppendArg( "-do_recurse" );
}
if ( deepOpts.updateSubmit ) {
args.AppendArg( "-update_submit" );
}
if( priority != 0) {
args.AppendArg( "-Priority" );
args.AppendArg( priority );
}
if( deepOpts.suppress_notification ) {
args.AppendArg( "-suppress_notification" );
} else {
args.AppendArg( "-dont_suppress_notification" );
}
args.AppendArg( dagFile );
//.........这里部分代码省略.........
示例6:
/* Helper function: write the input files mime encode in the inputAd into iwd */
bool
write_input_files(const ClassAd* inputAd, const char *iwd)
{
bool return_value = true;
char *file_name, *file_data;
unsigned char *output;
char buf[60];
int i, output_length, fd;
int flags = O_WRONLY | O_CREAT | O_TRUNC | O_APPEND | O_LARGEFILE;
TmpDir tmpdir;
MyString tmpdir_error;
if (tmpdir.Cd2TmpDir(iwd,tmpdir_error) == false ) {
// We failed to cd to our iwd. This should NEVER happen.
EXCEPT("write_input_files iwd failure: %s",tmpdir_error.Value());
}
i=0; file_name=NULL; file_data=NULL;output=NULL;
while (return_value==true) { // keep looping until break or failure
i++;
sprintf(buf,"INPUT_FILE_NAME_%d",i);
inputAd->LookupString(buf,&file_name);
if (!file_name) break; // no more files
sprintf(buf,"INPUT_FILE_DATA_%d",i);
inputAd->LookupString(buf,&file_data);
if ( file_data ) {
// Caller needs to free *output if non-NULL
condor_base64_decode(file_data,&output,&output_length);
if ( output ) {
fd = safe_open_wrapper_follow( condor_basename(file_name), flags, 0666 );
if ( fd > -1 ) {
write(fd,output,output_length);
close(fd);
dprintf(D_FULLDEBUG,"Wrote %d bytes to file %s%c%s\n",
output_length, iwd, DIR_DELIM_CHAR,
condor_basename(file_name));
} else {
return_value = false;
}
free(output);
output = NULL;
} else {
dprintf(D_ALWAYS,"Failed to decode base64 in attribute %s for file %s\n",
buf,condor_basename(file_name));
return_value = false;
}
free(file_data);
file_data = NULL;
} else {
// INPUT_FILE_NAME specified, but no data... so just touch the file
fd = safe_open_wrapper_follow( condor_basename(file_name), flags, 0666 );
if ( fd > -1 ) {
close(fd);
dprintf(D_FULLDEBUG,"Wrote empty file %s%c%s\n",
iwd, DIR_DELIM_CHAR,
condor_basename(file_name));
}
}
free(file_name);
file_name = NULL;
}
if ( return_value ) {
dprintf(D_ALWAYS,"Wrote %d files to subdir %s\n",i-1,iwd);
} else {
dprintf(D_ALWAYS,"Failed to write file %d to subdir %s\n",i,iwd);
}
return return_value;
}