use of org.glassfish.api.admin.progress.JobPersistence in project Payara by payara.
the class AdminCommandInstanceImpl method complete.
@Override
public void complete(ActionReport report, Payload.Outbound outbound) {
if (commandProgress != null && report != null && report.getActionExitCode() == ExitCode.SUCCESS) {
commandProgress.complete();
}
super.actionReport = report;
this.payload = outbound;
this.completionDate = System.currentTimeMillis();
if (isManagedJob) {
if (getState().equals(State.RUNNING_RETRYABLE) && failToRetryable) {
JobManagerService jobManager = Globals.getDefaultHabitat().getService(JobManagerService.class);
jobManager.getRetryableJobsInfo().put(id, CheckpointHelper.CheckpointFilename.createBasic(this));
jobManager.purgeJob(id);
setState(State.FAILED_RETRYABLE);
} else {
JobPersistence jobPersistenceService;
if (scope != null) {
jobPersistenceService = Globals.getDefaultHabitat().getService(JobPersistence.class, scope + "job-persistence");
} else {
jobPersistenceService = Globals.getDefaultHabitat().getService(JobPersistenceService.class);
}
State finalState = State.COMPLETED;
if (getState().equals(State.REVERTING)) {
finalState = State.REVERTED;
}
String user = null;
if (subjectUsernames.size() > 0) {
user = subjectUsernames.get(0);
}
jobPersistenceService.persist(new JobInfo(id, commandName, executionDate, report.getActionExitCode().name(), user, report.getMessage(), getJobsFile(), finalState.name(), completionDate));
if (getState().equals(State.RUNNING_RETRYABLE) || getState().equals(State.REVERTING)) {
JobManagerService jobManager = Globals.getDefaultHabitat().getService(JobManagerService.class);
File jobFile = getJobsFile();
if (jobFile == null) {
jobFile = jobManager.getJobsFile();
}
jobManager.deleteCheckpoint(jobFile.getParentFile(), getId());
}
setState(finalState);
}
} else {
setState(State.COMPLETED);
}
}
Aggregations