Github user lahirug commented on a diff in the pull request:
https://github.com/apache/airavata/pull/52#discussion_r82008856
--- Diff:
modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/task/LocalJobSubmissionTask.java
---
@@ -56,78 +61,85 @@ public void init(Map<String, String> propertyMap)
throws TaskException {
@Override
public TaskStatus execute(TaskContext taskContext) {
- /* try {
+ TaskStatus taskStatus = new TaskStatus(TaskState.CREATED);
+ try {
ProcessContext processContext =
taskContext.getParentProcessContext();
- // build command with all inputs
- List<String> cmdList = buildCommand(processContext);
-
initProcessBuilder(processContext.getApplicationDeploymentDescription(),
cmdList);
+ JobModel jobModel = processContext.getJobModel();
+ jobModel.setTaskId(taskContext.getTaskId());
- // extra environment variables
-
builder.environment().put(GFacConstants.INPUT_DATA_DIR_VAR_NAME,
processContext.getInputDir());
-
builder.environment().put(GFacConstants.OUTPUT_DATA_DIR_VAR_NAME,
processContext.getOutputDir());
+ RemoteCluster remoteCluster =
processContext.getJobSubmissionRemoteCluster();
+ GroovyMap groovyMap =
GFacUtils.creatGroovyMap(processContext,taskContext);
- // set working directory
- builder.directory(new File(processContext.getWorkingDir()));
+ String jobId = AiravataUtils.getId("JOB_ID_");
+ jobModel.setJobName(groovyMap.get(Script.JOB_NAME).toString());
+ jobModel.setJobId(jobId);
- // log info
- log.info("Command = " + InputUtils.buildCommand(cmdList));
- log.info("Working dir = " + builder.directory());
- JobModel jobModel = processContext.getJobModel();
- if (jobModel == null) {
- jobModel = new JobModel();
+ ResourceJobManager resourceJobManager =
GFacUtils.getResourceJobManager(processContext);
+ JobManagerConfiguration jConfig = null;
+
+ if (resourceJobManager != null) {
+ jConfig =
Factory.getJobManagerConfiguration(resourceJobManager);
}
- String jobId = taskContext.getTaskModel().getTaskId();
- jobModel.setJobId(jobId);
- jobModel.setJobDescription("sample local job");
- processContext.setJobModel(jobModel);
- GFacUtils.saveJobStatus(taskContext, jobModel,
JobState.SUBMITTED);
- // running cmd
- Process process = builder.start();
-
- Thread standardOutWriter = new
InputStreamToFileWriter(process.getInputStream(),
processContext.getStdoutLocation());
- Thread standardErrorWriter = new
InputStreamToFileWriter(process.getErrorStream(),
processContext.getStderrLocation());
-
- // start output threads
- standardOutWriter.setDaemon(true);
- standardErrorWriter.setDaemon(true);
- standardOutWriter.start();
- standardErrorWriter.start();
-
- int returnValue = process.waitFor();
-
- // make sure other two threads are done
- standardOutWriter.join();
- standardErrorWriter.join();
-
- *//*
- * check return value. usually not very helpful to draw
conclusions based on return values so don't bother.
- * just provide warning in the log messages
- *//*
- if (returnValue != 0) {
- log.error("Process finished with non zero return value.
Process may have failed");
+
--- End diff --
Do you think this has to split in to few methods ? Looks bit long for a
single method.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---