public void setStatus(Status value) { set(STATUS, value.toString().toUpperCase()); }
/** * Cleans up successful IndexJobExecutions that finished longer than five minutes ago. delay for a * minute to allow the transaction manager to become available */ @Scheduled(initialDelay = 1 * 60 * 1000, fixedRate = 5 * 60 * 1000) public void cleanupJobExecutions() { runAsSystem( () -> { LOG.trace("Clean up Index job executions..."); Instant fiveMinutesAgo = Instant.now().minus(5, ChronoUnit.MINUTES); boolean indexJobExecutionExists = dataService.hasRepository(IndexJobExecutionMeta.INDEX_JOB_EXECUTION); if (indexJobExecutionExists) { Stream<Entity> executions = dataService .getRepository(IndexJobExecutionMeta.INDEX_JOB_EXECUTION) .query() .lt(END_DATE, fiveMinutesAgo) .and() .eq(STATUS, SUCCESS.toString()) .findAll(); dataService.delete(IndexJobExecutionMeta.INDEX_JOB_EXECUTION, executions); LOG.debug("Cleaned up Index job executions."); } else { LOG.warn("{} does not exist", IndexJobExecutionMeta.INDEX_JOB_EXECUTION); } }); } }
private void setFailed(Entity jobExecutionEntity) { jobExecutionEntity.set(STATUS, FAILED.toString()); jobExecutionEntity.set(PROGRESS_MESSAGE, "Application terminated unexpectedly"); StringBuilder log = new StringBuilder(); if (!isEmpty(jobExecutionEntity.get(LOG))) { log.append(jobExecutionEntity.get(LOG)); log.append('\n'); } log.append("FAILED - Application terminated unexpectedly"); String abbreviatedLog = abbreviateMiddle(log.toString(), "...\n" + TRUNCATION_BANNER + "\n...", MAX_LOG_LENGTH); jobExecutionEntity.set(LOG, abbreviatedLog); dataService.update(jobExecutionEntity.getEntityType().getId(), jobExecutionEntity); }
public Status getStatus() { return Status.valueOf(getString(STATUS)); }