@VisibleForTesting protected void tick() { LongTaskTimer timer = registry.longTaskTimer(timerId); long timerId = timer.start(); log.info("Starting cleanup"); try { executionRepository.retrieveAllApplicationNames(ORCHESTRATION, threshold).forEach(app -> { log.info("Cleaning up orchestration executions (application: {}, threshold: {})", app, threshold); ExecutionCriteria executionCriteria = new ExecutionCriteria(); executionCriteria.setPageSize(Integer.MAX_VALUE); cleanup(executionRepository.retrieveOrchestrationsForApplication(app, executionCriteria), app, "orchestration"); }); } catch (Exception e) { log.error("Cleanup failed", e); } finally { timer.stop(timerId); } }
/** * If {@code executionId} is set, it will be retrieved. Otherwise, {@code pipelineConfigId} will be used to find the * newest pipeline execution for that configuration. * @param executionId An explicit pipeline execution id. * @param pipelineConfigId A pipeline configuration id. Ignored if {@code executionId} is set. * @return The pipeline * @throws IllegalArgumentException if neither executionId or pipelineConfigId are provided * @throws ExecutionNotFoundException if no execution could be found */ public Execution retrievePipelineOrNewestExecution(@Nullable String executionId, @Nullable String pipelineConfigId) throws ExecutionNotFoundException { if (executionId != null) { // Use an explicit execution return executionRepository.retrieve(PIPELINE, executionId); } else if (pipelineConfigId != null) { // No executionId set - use last execution ExecutionRepository.ExecutionCriteria criteria = new ExecutionRepository.ExecutionCriteria().setPageSize(1); try { return executionRepository.retrievePipelinesForPipelineConfigId(pipelineConfigId, criteria) .toSingle() .toBlocking() .value(); } catch (NoSuchElementException e) { throw new ExecutionNotFoundException("No pipeline execution could be found for config id " + pipelineConfigId + ": " + e.getMessage()); } } else { throw new IllegalArgumentException("Either executionId or pipelineConfigId have to be set."); } }