StringList *NordugridJob::buildStageOutList() { StringList *stage_list = NULL; std::string buf; bool transfer = TRUE; jobAd->LookupString( ATTR_TRANSFER_OUTPUT_FILES, buf ); stage_list = new StringList( buf.c_str(), "," ); jobAd->LookupBool( ATTR_TRANSFER_OUTPUT, transfer ); if ( transfer && jobAd->LookupString( ATTR_JOB_OUTPUT, buf ) == 1) { // only add to list if not NULL_FILE (i.e. /dev/null) if ( ! nullFile(buf.c_str()) ) { if ( !stage_list->file_contains( REMOTE_STDOUT_NAME ) ) { stage_list->append( REMOTE_STDOUT_NAME ); } } } transfer = TRUE; jobAd->LookupBool( ATTR_TRANSFER_ERROR, transfer ); if ( transfer && jobAd->LookupString( ATTR_JOB_ERROR, buf ) == 1) { // only add to list if not NULL_FILE (i.e. /dev/null) if ( ! nullFile(buf.c_str()) ) { if ( !stage_list->file_contains( REMOTE_STDERR_NAME ) ) { stage_list->append( REMOTE_STDERR_NAME ); } } } return stage_list; }
// In rare instances, the ad this function returns will need to be // deleted by the caller. In those cases, delete_ad will be set to true. // Otherwise, delete_ad will be set to false and the returned ad should // not be deleted. int pseudo_get_job_info(ClassAd *&ad, bool &delete_ad) { ClassAd * the_ad; delete_ad = false; the_ad = thisRemoteResource->getJobAd(); ASSERT( the_ad ); thisRemoteResource->initFileTransfer(); Shadow->publishShadowAttrs( the_ad ); ad = the_ad; // If we're dealing with an old starter (pre 7.7.2) and file transfer // may be used, we need to rename the stdout/err files to // StdoutRemapName and StderrRemapName. Otherwise, they won't transfer // back correctly if they contain any path information. // If we don't know what version the starter is and we know file // transfer will be used, do the rename. It won't harm a new starter // and allows us to work correctly with old starters in more cases. const CondorVersionInfo *vi = syscall_sock->get_peer_version(); if ( vi == NULL || !vi->built_since_version(7,7,2) ) { std::string value; ad->LookupString( ATTR_SHOULD_TRANSFER_FILES, value ); ShouldTransferFiles_t should_transfer = getShouldTransferFilesNum( value.c_str() ); if ( should_transfer == STF_YES || ( vi != NULL && should_transfer == STF_IF_NEEDED ) ) { ad = new ClassAd( *ad ); delete_ad = true; // This is the same modification a modern starter will do when // using file transfer in JICShadow::initWithFileTransfer() bool stream; std::string stdout_name; std::string stderr_name; ad->LookupString( ATTR_JOB_OUTPUT, stdout_name ); ad->LookupString( ATTR_JOB_ERROR, stderr_name ); if ( ad->LookupBool( ATTR_STREAM_OUTPUT, stream ) && !stream && !nullFile( stdout_name.c_str() ) ) { ad->Assign( ATTR_JOB_OUTPUT, StdoutRemapName ); } if ( ad->LookupBool( ATTR_STREAM_ERROR, stream ) && !stream && !nullFile( stderr_name.c_str() ) ) { if ( stdout_name == stderr_name ) { ad->Assign( ATTR_JOB_ERROR, StdoutRemapName ); } else { ad->Assign( ATTR_JOB_ERROR, StderrRemapName ); } } } } return 0; }
char* JICLocal::getJobStdFile( const char* attr_name ) { char* tmp = NULL; MyString filename; // the only magic here is to make sure we have full paths for // these, by prepending the job's iwd if the filename doesn't // start with a '/' job_ad->LookupString( attr_name, &tmp ); if( ! tmp ) { return NULL; } if ( !nullFile(tmp) ) { if( ! fullpath(tmp) ) { filename.formatstr( "%s%c", job_iwd, DIR_DELIM_CHAR ); } filename += tmp; } free( tmp ); if( filename[0] ) { return strdup( filename.Value() ); } return NULL; }
StringList *NordugridJob::buildStageInList() { StringList *tmp_list = NULL; StringList *stage_list = NULL; char *filename = NULL; std::string buf; std::string iwd; int transfer = TRUE; if ( jobAd->LookupString( ATTR_JOB_IWD, iwd ) ) { if ( iwd.length() > 1 && iwd[iwd.length() - 1] != '/' ) { iwd += '/'; } } jobAd->LookupString( ATTR_TRANSFER_INPUT_FILES, buf ); tmp_list = new StringList( buf.c_str(), "," ); jobAd->LookupBool( ATTR_TRANSFER_EXECUTABLE, transfer ); if ( transfer ) { jobAd->LookupString( ATTR_JOB_CMD, buf ); if ( !tmp_list->file_contains( buf.c_str() ) ) { tmp_list->append( buf.c_str() ); } } transfer = TRUE; jobAd->LookupBool( ATTR_TRANSFER_INPUT, transfer ); if ( transfer && jobAd->LookupString( ATTR_JOB_INPUT, buf ) == 1) { // only add to list if not NULL_FILE (i.e. /dev/null) if ( ! nullFile(buf.c_str()) ) { if ( !tmp_list->file_contains( buf.c_str() ) ) { tmp_list->append( buf.c_str() ); } } } stage_list = new StringList; tmp_list->rewind(); while ( ( filename = tmp_list->next() ) ) { if ( filename[0] == '/' || IsUrl( filename ) ) { formatstr( buf, "%s", filename ); } else { formatstr( buf, "%s%s", iwd.c_str(), filename ); } stage_list->append( buf.c_str() ); } delete tmp_list; return stage_list; }
std::string *NordugridJob::buildSubmitRSL() { int transfer_exec = TRUE; std::string *rsl = new std::string; StringList *stage_list = NULL; StringList *stage_local_list = NULL; char *attr_value = NULL; std::string rsl_suffix; std::string iwd; std::string executable; if ( jobAd->LookupString( ATTR_NORDUGRID_RSL, rsl_suffix ) && rsl_suffix[0] == '&' ) { *rsl = rsl_suffix; return rsl; } if ( jobAd->LookupString( ATTR_JOB_IWD, iwd ) != 1 ) { errorString = "ATTR_JOB_IWD not defined"; delete rsl; return NULL; } //Start off the RSL attr_value = param( "FULL_HOSTNAME" ); formatstr( *rsl, "&(savestate=yes)(action=request)(hostname=%s)", attr_value ); free( attr_value ); attr_value = NULL; //We're assuming all job clasads have a command attribute jobAd->LookupString( ATTR_JOB_CMD, executable ); jobAd->LookupBool( ATTR_TRANSFER_EXECUTABLE, transfer_exec ); *rsl += "(executable="; // If we're transferring the executable, strip off the path for the // remote machine, since it refers to the submit machine. if ( transfer_exec ) { *rsl += condor_basename( executable.c_str() ); } else { *rsl += executable; } { ArgList args; MyString arg_errors; MyString rsl_args; if(!args.AppendArgsFromClassAd(jobAd,&arg_errors)) { dprintf(D_ALWAYS,"(%d.%d) Failed to read job arguments: %s\n", procID.cluster, procID.proc, arg_errors.Value()); formatstr(errorString,"Failed to read job arguments: %s\n", arg_errors.Value()); delete rsl; return NULL; } if(args.Count() != 0) { if(args.InputWasV1()) { // In V1 syntax, the user's input _is_ RSL if(!args.GetArgsStringV1Raw(&rsl_args,&arg_errors)) { dprintf(D_ALWAYS, "(%d.%d) Failed to get job arguments: %s\n", procID.cluster,procID.proc,arg_errors.Value()); formatstr(errorString,"Failed to get job arguments: %s\n", arg_errors.Value()); delete rsl; return NULL; } } else { // In V2 syntax, we convert the ArgList to RSL for(int i=0;i<args.Count();i++) { if(i) { rsl_args += ' '; } rsl_args += rsl_stringify(args.GetArg(i)); } } *rsl += ")(arguments="; *rsl += rsl_args; } } // If we're transferring the executable, tell Nordugrid to set the // execute bit on the transferred executable. if ( transfer_exec ) { *rsl += ")(executables="; *rsl += condor_basename( executable.c_str() ); } if ( jobAd->LookupString( ATTR_JOB_INPUT, &attr_value ) == 1) { // only add to list if not NULL_FILE (i.e. /dev/null) if ( ! nullFile(attr_value) ) { *rsl += ")(stdin="; *rsl += condor_basename(attr_value); } free( attr_value ); attr_value = NULL; } stage_list = buildStageInList(); if ( stage_list->isEmpty() == false ) { char *file; stage_list->rewind(); *rsl += ")(inputfiles="; while ( (file = stage_list->next()) != NULL ) { *rsl += "("; *rsl += condor_basename(file); if ( IsUrl( file ) ) { formatstr_cat( *rsl, " \"%s\")", file ); } else { *rsl += " \"\")"; } } } delete stage_list; stage_list = NULL; if ( jobAd->LookupString( ATTR_JOB_OUTPUT, &attr_value ) == 1) { // only add to list if not NULL_FILE (i.e. /dev/null) if ( ! nullFile(attr_value) ) { *rsl += ")(stdout=" REMOTE_STDOUT_NAME; } free( attr_value ); attr_value = NULL; } if ( jobAd->LookupString( ATTR_JOB_ERROR, &attr_value ) == 1) { // only add to list if not NULL_FILE (i.e. /dev/null) if ( ! nullFile(attr_value) ) { *rsl += ")(stderr=" REMOTE_STDERR_NAME; } free( attr_value ); } stage_list = buildStageOutList(); stage_local_list = buildStageOutLocalList( stage_list ); if ( stage_list->isEmpty() == false ) { char *file; char *local_file; stage_list->rewind(); stage_local_list->rewind(); *rsl += ")(outputfiles="; while ( (file = stage_list->next()) != NULL ) { local_file = stage_local_list->next(); *rsl += "("; *rsl += condor_basename(file); if ( IsUrl( local_file ) ) { formatstr_cat( *rsl, " \"%s\")", local_file ); } else { *rsl += " \"\")"; } } } delete stage_list; stage_list = NULL; delete stage_local_list; stage_local_list = NULL; *rsl += ')'; if ( !rsl_suffix.empty() ) { *rsl += rsl_suffix; } dprintf(D_FULLDEBUG,"*** RSL='%s'\n",rsl->c_str()); return rsl; }