@Override public void onAdminCommandEvent(String name, Object event) { if (name == null || name.startsWith("client.")) { //Skip nonsence or own events return; } if (AdminCommandStateImpl.EVENT_STATE_CHANGED.equals(name) && (((Job) event).getState().equals(COMPLETED) || ((Job) event).getState().equals(REVERTED))) { synchronized (attached) { attached.notifyAll(); } } else { eventBroker.fireEvent(name, event); //Forward } }
/** * This will return a list of jobs which have crossed the JOBS_RETENTION_PERIOD * and need to be purged * @return list of jobs to be purged */ public ArrayList<JobInfo> getExpiredJobs(File file) { ArrayList<JobInfo> expiredJobs = new ArrayList<JobInfo>(); synchronized (file) { JobInfos jobInfos = getCompletedJobs(file); for(JobInfo job:jobInfos.getJobInfoList()) { long executedTime = job.commandExecutionDate; long currentTime = System.currentTimeMillis(); long jobsRetentionPeriod = 86400000; managedJobConfig = domain.getExtensionByType(ManagedJobConfig.class); jobsRetentionPeriod = convert(managedJobConfig.getJobRetentionPeriod()); if (currentTime - executedTime > jobsRetentionPeriod && (job.state.equals(AdminCommandState.State.COMPLETED.name()) || job.state.equals(AdminCommandState.State.REVERTED.name()))) { expiredJobs.add(job); } } } return expiredJobs; }
while(attached.getState().equals(PREPARED) || attached.getState().equals(RUNNING) || attached.getState().equals(RUNNING_RETRYABLE)) { try { attached.wait(1000*60*5); //5000L just to be sure } catch (InterruptedException ex) {} if (attached.getState().equals(COMPLETED) || attached.getState().equals(REVERTED)) { String commandUser = attached.getSubjectUsernames().get(0); if (jobInfo != null && (jobInfo.state.equals(COMPLETED.toString()) || jobInfo.state.equals(REVERTED.toString()))) {
info = new JobInfo(oneJob.getId(),oneJob.getName(),oneJob.getCommandExecutionDate(),exitCode,userList.get(0),message,oneJob.getJobsFile(),oneJob.getState().name(),0); user = userList.get(0); jobsToReport.add(new JobInfo(job.getId(),job.getName(),job.getCommandExecutionDate(),exitCode,user,message,job.getJobsFile(),job.getState().name(),0));
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)); if (getState().equals(State.REVERTING)) { finalState = State.REVERTED; 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();
@Override public void complete(ActionReport actionReport) { this.actionReport = actionReport; if (getState().equals(State.REVERTING)) { setState(State.REVERTED); } else { setState(State.COMPLETED); } }
public static AdminCommandStateImpl readAdminCommandState(JSONObject json) throws JSONException { String strState = json.optString("state"); AdminCommandState.State state = (strState == null) ? null : AdminCommandState.State.valueOf(strState); boolean emptyPayload = json.optBoolean("empty-payload", true); CliActionReport ar = null; JSONObject jsonReport = json.optJSONObject("action-report"); if (jsonReport != null) { ar = new CliActionReport(); ActionReportJsonProprietaryReader.fillActionReport(ar, jsonReport); } String id = json.optString("id"); return new AdminCommandStateImpl(state, ar, emptyPayload, id); }