jobAttr.addEnvVariable(GFacConstants.INPUT_DATA_DIR, appExecContext.getExecutionModel().getInputDataDir());
String outputDataDir = GFacConstants.OUTPUT_DATA_DIR;
if(!outputDataDir.isEmpty()){
jobAttr.addEnvVariable(outputDataDir, appExecContext.getExecutionModel().getOutputDataDir());
}
ApplicationDescriptionType app = appExecContext.getExecutionModel().getAplicationDesc();
WorkflowContextHeader contextHeader = appExecContext.getWorkflowHeader();
ResourceMapping resourceMapping = null;
if (contextHeader != null) {
resourceMapping = contextHeader.getResourceMappings().getResourceMappingArray(0);
}
log.info("Configure using App Desc = " + app.xmlText());
if (resourceMapping != null && resourceMapping.getMaxWallTime() > 0) {
log.info("Header Setting Max Wall Time" + resourceMapping.getMaxWallTime());
jobAttr.setMaxWallTime(resourceMapping.getMaxWallTime());
} else if (app.getMaxWallTime() > 0) {
log.info("Setting max wall clock time to " + app.getMaxWallTime());
if (app.getMaxWallTime() > 30 && app.getQueue() != null && app.getQueue().equals("debug")) {
throw new GfacException("NCSA debug Queue only support jobs < 30 minutes", FaultCode.InvalidConfig);
}
jobAttr.setMaxWallTime(app.getMaxWallTime());
jobAttr.set("proxy_timeout", "1");
} else {
jobAttr.setMaxWallTime(29);
}
if (appExecContext.getExecutionModel().getStdIn() != null) {
jobAttr.setStdin(appExecContext.getExecutionModel().getStdIn());
} else {
Iterator<String> values = appExecContext.getExecutionModel().getInputParameters().iterator();
while (values.hasNext()) {
jobAttr.addArgument(values.next());
}
}
if (resourceMapping != null && resourceMapping.getNodeCount() > 0) {
log.info("Setting number of procs to " + resourceMapping.getNodeCount());
jobAttr.set("hostCount", String.valueOf(resourceMapping.getNodeCount()));
}else if (app.getHostCount() > 1) {
jobAttr.set("hostCount", String.valueOf(app.getHostCount()));
}
if (resourceMapping != null && resourceMapping.getCpuCount() > 0) {
log.info("Setting host count to " + resourceMapping.getCpuCount());
jobAttr.setNumProcs(resourceMapping.getCpuCount());
} else if (app.getCount() > 1) {
log.info("Setting number of procs to " + app.getCount());
jobAttr.setNumProcs(app.getCount());
}
if (app.getProject() != null && app.getProject().getProjectName() != null) {
log.info("Setting project to " + app.getProject());
jobAttr.setProject(app.getProject().getProjectName());
}
if (resourceMapping != null && resourceMapping.getQueueName() != null) {
jobAttr.setQueue(resourceMapping.getQueueName());
} else if (app.getQueue() != null && app.getQueue().getQueueName() != null) {
log.info("Setting job queue to " + app.getQueue());
jobAttr.setQueue(app.getQueue().getQueueName());
}
String jobType = JobType.SINGLE.toString() ;
if (app.getJobType() != null) {
jobType = app.getJobType().toString();
}
if (jobType.equalsIgnoreCase(JobType.SINGLE.toString())) {
log.info("Setting job type to single");
jobAttr.setJobType(GramAttributes.JOBTYPE_SINGLE);
} else if (jobType.equalsIgnoreCase(JobType.MPI.toString())) {
log.info("Setting job type to mpi");
jobAttr.setJobType(GramAttributes.JOBTYPE_MPI);
} else if (jobType.equalsIgnoreCase(JobType.MULTIPLE.toString())) {
log.info("Setting job type to multiple");
jobAttr.setJobType(GramAttributes.JOBTYPE_MULTIPLE);
} else if (jobType.equalsIgnoreCase(JobType.CONDOR.toString())) {
jobAttr.setJobType(GramAttributes.JOBTYPE_CONDOR);
}
// Support to add the Additional RSL parameters
RSLParmType[] rslParams = app.getRslparmArray();
if (rslParams.length > 0) {
for (RSLParmType rslType : rslParams) {
log.info("Adding rsl param of [" + rslType.getName() + "," + rslType.getStringValue() + "]");
if (rslType.getName() != "") {
jobAttr.set(rslType.getName(), rslType.getStringValue());