public void doPersist(JobInfos jobInfos, JobInfo jobInfo) { File file = jobInfo.getJobsFile(); synchronized (file) { if (jobInfos == null) { jobInfos = new JobInfos(); } try { JAXBContext jaxbContext = JAXBContext.newInstance(JobInfos.class); jaxbMarshaller = jaxbContext.createMarshaller(); jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); CopyOnWriteArrayList<JobInfo> jobList = new CopyOnWriteArrayList<JobInfo>(jobInfos.getJobInfoList()); jobInfos.setJobInfoList(jobList); jobList.add(jobInfo); jaxbMarshaller.marshal(jobInfos, file); jobManager.addToCompletedJobs(new CompletedJob(jobInfo.jobId,jobInfo.commandCompletionDate,jobInfo.getJobsFile())); jobManager.purgeJob(jobInfo.jobId); } catch (JAXBException e) { throw new RuntimeException(adminStrings.getLocalString("error.persisting.jobs","Error while persisting jobs",jobInfo.jobId,e.getLocalizedMessage()),e); } } }
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));
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);
protected void reapCompletedJobs(File file) { if (file != null && file.exists()) { JobInfos jobInfos = getCompletedJobs(file); if (jobInfos != null) { for (JobInfo jobInfo: jobInfos.getJobInfoList()) { addToCompletedJobs(new CompletedJob(jobInfo.jobId,jobInfo.commandCompletionDate,jobInfo.getJobsFile())); } } } }