use of com.thinkbiganalytics.metadata.jpa.jobrepo.step.JpaBatchStepExecution in project kylo by Teradata.
the class JpaBatchJobExecution method failJob.
/**
* Complete a job and mark it as failed setting its status to {@link com.thinkbiganalytics.metadata.api.jobrepo.job.BatchJobExecution.JobStatus#FAILED}
*/
public void failJob() {
StringBuffer stringBuffer = null;
String stepExecutionFailuresString = "Step Execution Failures:\n";
setStatus(JpaBatchJobExecution.JobStatus.FAILED);
setExitCode(ExecutionConstants.ExitCode.FAILED);
if (endTime == null) {
endTime = DateTimeUtil.getNowUTCTime();
}
Set<BatchStepExecution> steps = getStepExecutions();
String existingExitMessage = getExitMessage();
if (StringUtils.isNotBlank(existingExitMessage)) {
existingExitMessage = StringUtils.substringBefore(existingExitMessage, stepExecutionFailuresString);
}
if (steps != null) {
for (BatchStepExecution se : steps) {
if (BatchStepExecution.StepStatus.FAILED.equals(se.getStatus())) {
if (stringBuffer == null) {
stringBuffer = new StringBuffer(stepExecutionFailuresString);
} else {
stringBuffer.append("\n");
}
stringBuffer.append("Failed Step " + se.getStepName());
}
if (se.getEndTime() == null) {
((JpaBatchStepExecution) se).setEndTime(DateTimeUtil.getNowUTCTime());
}
}
if (stringBuffer != null) {
// append the exit message
String msg = existingExitMessage != null ? existingExitMessage + "\n" : "" + stringBuffer.toString();
setExitMessage(msg);
}
}
}
Aggregations