.filter(s -> !StringUtils.isEmpty(s)) .collect(Collectors.toList()); ExecutionRepository.ExecutionCriteria executionCriteria = new ExecutionRepository.ExecutionCriteria() .setLimit(limit) .setStatuses(statusesList);
List<Artifact> priorArtifacts = getArtifactsForPipelineId((String) pipeline.get("id"), new ExecutionCriteria()); Set<Artifact> resolvedArtifacts = resolveExpectedArtifacts(expectedArtifacts, receivedArtifacts, priorArtifacts, true); Set<Artifact> allArtifacts = new HashSet<>(receivedArtifacts);
ExecutionCriteria toCriteria() { List<String> statuses = new ArrayList<>(); if (succeeded) { statuses.add("SUCCEEDED"); } if (terminal) { statuses.add("TERMINAL"); } if (running) { statuses.add("RUNNING"); } return new ExecutionCriteria().setStatuses(statuses); } }
/** * 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."); } }
@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); } }