public String getStarted() { OffsetDateTime started = job.getStarted(); return formatDateTime(started); }
/** * Returns additional information like job uri, running state, started and stopped timestamps. * * @param jobInfo the job information of the last job * @return map containing uri, starting, and running or stopped entries. */ protected Map<String, String> runningDetailsFor(final JobInfo jobInfo) { final Map<String, String> details = new HashMap<>(); details.put("Started", ISO_DATE_TIME.format(jobInfo.getStarted())); if (jobInfo.getStopped().isPresent()) { details.put("Stopped", ISO_DATE_TIME.format(jobInfo.getStopped().get())); } return details; }
public String getRuntime() { return job.isStopped() ? formatRuntime(job.getStarted(), job.getStopped().get()) : formatRuntime(job.getStarted(), OffsetDateTime.now()); }
private JobInfo someStoppedJob(final JobInfo.JobStatus jobStatus, int startedSecondsAgo) { OffsetDateTime now = now(); JobInfo someJob = mock(JobInfo.class); when(someJob.getJobType()).thenReturn("someJobType"); when(someJob.getJobId()).thenReturn("someId"); when(someJob.getStarted()).thenReturn(now.minusSeconds(startedSecondsAgo)); when(someJob.getStopped()).thenReturn(of(now.minusSeconds(startedSecondsAgo-1))); when(someJob.getStatus()).thenReturn(jobStatus); return someJob; }
private JobInfo someRunningJob(final JobInfo.JobStatus jobStatus, int startedSecondsAgo) { OffsetDateTime now = now(); JobInfo someJob = mock(JobInfo.class); when(someJob.getJobType()).thenReturn("someJobType"); when(someJob.getJobId()).thenReturn("someJobId"); when(someJob.getStarted()).thenReturn(now.minusSeconds(startedSecondsAgo)); when(someJob.getStopped()).thenReturn(empty()); when(someJob.getStatus()).thenReturn(jobStatus); return someJob; } }
@Override protected final Document encode(final JobInfo job) { final Document document = new Document() .append(JobStructure.ID.key(), job.getJobId()) .append(JobStructure.JOB_TYPE.key(), job.getJobType()) .append(JobStructure.STARTED.key(), Date.from(job.getStarted().toInstant())) .append(JobStructure.LAST_UPDATED.key(), Date.from(job.getLastUpdated().toInstant())) .append(JobStructure.MESSAGES.key(), job.getMessages().stream() .map(MongoJobRepository::encodeJobMessage) .collect(toList())) .append(JobStructure.STATUS.key(), job.getStatus().name()) .append(JobStructure.HOSTNAME.key(), job.getHostname()); if (job.isStopped()) { document.append(JobStructure.STOPPED.key(), Date.from(job.getStopped().get().toInstant())); } return document; }
@Override protected final Document encode(final JobInfo job) { final Document document = new Document() .append(JobStructure.ID.key(), job.getJobId()) .append(JobStructure.JOB_TYPE.key(), job.getJobType()) .append(JobStructure.STARTED.key(), DateTimeConverters.toDate(job.getStarted())) .append(JobStructure.LAST_UPDATED.key(), DateTimeConverters.toDate(job.getLastUpdated())) .append(JobStructure.MESSAGES.key(), job.getMessages().stream() .map(MongoJobRepository::encodeJobMessage) .collect(toList())) .append(JobStructure.STATUS.key(), job.getStatus().name()) .append(JobStructure.HOSTNAME.key(), job.getHostname()); if (job.isStopped()) { document.append(JobStructure.STOPPED.key(), DateTimeConverters.toDate(job.getStopped().get())); } return document; }