* @see AbstractStep#doExecute(StepExecution)
*/
@Override
protected void doExecute(StepExecution stepExecution) throws Exception {
ExecutionContext executionContext = stepExecution.getExecutionContext();
JobParameters jobParameters;
if (executionContext.containsKey(subJobParametersKey)) {
jobParameters =
(JobParameters) executionContext.get(subJobParametersKey);
} else {
jobParameters =
jobParametersExtractor.getJobParameters(job, stepExecution);
executionContext.put(subJobParametersKey, jobParameters);
}
JobExecution subJobExecution = jobLauncher.run(job, jobParameters);
//Wait for job completion
while (true) {
if (subJobExecution.getStatus().isRunning()) {
double subJobProgress =
jobExecutionStatusHolder.getCurrentProgress(subJobExecution
.getId());
mainJobExecutionStatusHolder.setCurrentStepProgress(stepExecution
.getJobExecution().getId(), subJobProgress);
Thread.sleep(3000);
} else {
break;
}
}
String nodeName = null;
if (subJobExecution.getJobInstance().getJobParameters().getParameters()
.containsKey(JobConstants.SUB_JOB_NODE_NAME)) {
nodeName =
subJobExecution.getJobInstance().getJobParameters()
.getString(JobConstants.SUB_JOB_NODE_NAME);
} else {
String stepName = stepExecution.getStepName();
nodeName = stepName.substring(stepName.lastIndexOf("-") + 1);
}
ExecutionContext mainJobExecutionContext =
stepExecution.getJobExecution().getExecutionContext();
updateExecutionStatus(subJobExecution, nodeName, mainJobExecutionContext);
}