com.netflix.spinnaker.orca.pipeline.model.Execution.getStages()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(11.5k)|赞(0)|评价(0)|浏览(157)

本文整理了Java中com.netflix.spinnaker.orca.pipeline.model.Execution.getStages()方法的一些代码示例,展示了Execution.getStages()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Execution.getStages()方法的具体详情如下:
包路径:com.netflix.spinnaker.orca.pipeline.model.Execution
类名称:Execution
方法名:getStages

Execution.getStages介绍

[英]Gets the stages of this execution. Does not serialize the child Execution object from stages. The child Execution object in Stage is a @JsonBackReference.
[中]

代码示例

代码示例来源:origin: spinnaker/kayenta

private List<String> getMetricSetListIds(Execution execution, String stagePrefix) {
 List<Stage> stages = execution.getStages();
 return stages.stream()
  .filter(stage -> {
   String refId = stage.getRefId();
   return refId != null && refId.startsWith(stagePrefix);
  })
  .map(stage -> resolveMetricSetListId(stage))
  .collect(Collectors.toList());
}

代码示例来源:origin: spinnaker/kayenta

/**
 * Gets the run canary stages that contain the results
 */
@NotNull
protected List<Stage> getRunCanaryStages(@Nonnull Stage stage) {
 // Collect the Run Canary Stages where the parent id is itself
 // Sorting by number after the # in the name
 return stage.getExecution().getStages().stream()
   .filter(s -> s.getType().equals(RunCanaryStage.STAGE_TYPE))
   .sorted(Comparator.comparing(s -> Integer.valueOf(StringUtils.substringAfterLast(s.getName(), "#"))))
   .collect(Collectors.toList());
}

代码示例来源:origin: spinnaker/kayenta

public CanaryConfig getCanaryConfig(Execution pipeline) {
 Stage contextStage = pipeline.getStages().stream()
  .filter(stage -> stage.getRefId().equals(CanaryStageNames.REFID_SET_CONTEXT))
  .findFirst()
  .orElseThrow(() -> new IllegalArgumentException("Unable to find stage '" + CanaryStageNames.REFID_SET_CONTEXT + "' in pipeline ID '" + pipeline.getId() + "'"));
 Map<String, Object> context = contextStage.getContext();
 Map<String, Object> canaryConfigMap = (Map<String, Object>)context.get("canaryConfig");
 return objectMapper.convertValue(canaryConfigMap, CanaryConfig.class);
}

代码示例来源:origin: spinnaker/kayenta

public String getCanaryExecutionRequestFromJudgeContext(Execution pipeline) {
 Stage contextStage = pipeline.getStages().stream()
  .filter(stage -> stage.getRefId().equals(CanaryStageNames.REFID_JUDGE))
  .findFirst()
  .orElseThrow(() -> new IllegalArgumentException("Unable to find stage '" + CanaryStageNames.REFID_JUDGE + "' in pipeline ID '" + pipeline.getId() + "'"));
 Map<String, Object> context = contextStage.getContext();
 return (String) context.get("canaryExecutionRequest");
}

代码示例来源:origin: spinnaker/kayenta

public CanaryExecutionStatusResponse fromExecution(Execution pipeline) {
 String canaryExecutionId = pipeline.getId();
 Stage contextStage = pipeline.getStages().stream()
  .filter(stage -> stage.getRefId().equals(CanaryStageNames.REFID_SET_CONTEXT))
  .findFirst()
  .orElseThrow(() -> new IllegalArgumentException("Unable to find stage '" + CanaryStageNames.REFID_SET_CONTEXT + "' in pipeline ID '" + canaryExecutionId + "'"));
 Map<String, Object> contextContext = contextStage.getContext();
 String storageAccountName = (String)contextContext.get("storageAccountName");
 return fromExecution(storageAccountName, pipeline);
}

代码示例来源:origin: spinnaker/kayenta

public CanaryExecutionRequest getCanaryExecutionRequest(Execution pipeline) {
 Stage contextStage = pipeline.getStages().stream()
  .filter(stage -> stage.getRefId().equals(CanaryStageNames.REFID_SET_CONTEXT))
  .findFirst()
  .orElseThrow(() -> new IllegalArgumentException("Unable to find stage '" + CanaryStageNames.REFID_SET_CONTEXT + "' in pipeline ID '" + pipeline.getId() + "'"));
 Map<String, Object> context = contextStage.getContext();
 String canaryExecutionRequestJSON = (String)context.get("canaryExecutionRequest");
 if (canaryExecutionRequestJSON == null) {
  canaryExecutionRequestJSON = getCanaryExecutionRequestFromJudgeContext(pipeline);
 }
 if (canaryExecutionRequestJSON == null) {
  return null;
 }
 CanaryExecutionRequest canaryExecutionRequest = null;
 try {
  canaryExecutionRequest = objectMapper.readValue(canaryExecutionRequestJSON, CanaryExecutionRequest.class);
 } catch (IOException e) {
  log.error("Cannot deserialize canaryExecutionRequest", e);
  throw new IllegalArgumentException("Cannot deserialize canaryExecutionRequest", e);
 }
 return canaryExecutionRequest;
}

代码示例来源:origin: spinnaker/kayenta

Execution pipeline = executionRepository.retrieve(Execution.ExecutionType.PIPELINE, executionId);
String canaryExecutionId = pipeline.getId();
Stage compareJudgeResultsStage = pipeline.getStages().stream()
 .filter(stage -> stage.getRefId().equals("compareJudgeResults"))
 .findFirst()
List<Stage> stagesWithException = pipeline.getStages().stream()
 .filter(stage -> stage.getContext().containsKey("exception"))
 .collect(Collectors.toList());

代码示例来源:origin: spinnaker/kayenta

@Test
public void test_that_getRunCanaryStages_returns_the_expected_sorted_list_of_stages_sorted_by_the_number_in_the_stage_name() {
 Stage stage = mock(Stage.class);
 Execution execution = mock(Execution.class);
 when(stage.getExecution()).thenReturn(execution);
 when(execution.getStages()).thenReturn(ImmutableList.of(
   new Stage(null, STAGE_TYPE, "foo #1", Maps.newHashMap(ImmutableMap.of("index", "0"))),
   new Stage(null, STAGE_TYPE, "foo #3", Maps.newHashMap(ImmutableMap.of("index", "2"))),
   new Stage(null, STAGE_TYPE, "foo #2", Maps.newHashMap(ImmutableMap.of("index", "1"))),
   new Stage(null, STAGE_TYPE, "foo #4", Maps.newHashMap(ImmutableMap.of("index", "3")))
 ));
 List<Stage> actual = task.getRunCanaryStages(stage);
 for (int i = 0; i < 4; i++) {
  assertEquals(String.valueOf(i), actual.get(i).getContext().get("index"));
 }
}

代码示例来源:origin: spinnaker/kayenta

Stage judgeStage = pipeline.getStages().stream()
 .filter(stage -> stage.getRefId().equals(CanaryStageNames.REFID_JUDGE))
 .findFirst()
Map<String, Object> judgeOutputs = judgeStage.getOutputs();
Stage contextStage = pipeline.getStages().stream()
 .filter(stage -> stage.getRefId().equals(CanaryStageNames.REFID_SET_CONTEXT))
 .findFirst()
Map<String, Object> contextContext = contextStage.getContext();
Stage mixerStage = pipeline.getStages().stream()
 .filter(stage -> stage.getRefId().equals(CanaryStageNames.REFID_MIX_METRICS))
 .findFirst()
Map<String, String> stageStatus = pipeline.getStages()
 .stream()
 .collect(Collectors.toMap(Stage::getRefId, s -> s.getStatus().toString().toLowerCase()));
Stage stageWithException = pipeline.getStages().stream()
 .filter(stage -> stage.getContext().containsKey("exception"))
 .findFirst()

代码示例来源:origin: spinnaker/kayenta

.application(pipeline.getApplication())
  .pipelineId(pipeline.getId())
  .stageStatus(pipeline.getStages()
    .stream()
    .map(stage -> new StageMetadata(stage.getType(), stage.getName(), stage.getStatus()))
pipeline.getStages().stream()
  .filter(stage -> stage.getType().equals(SetupAndExecuteCanariesStage.STAGE_TYPE))
  .findFirst()
pipeline.getStages().stream()
  .filter(stage -> stage.getType().equals(GenerateCanaryAnalysisResultStage.STAGE_TYPE))
  .findFirst()
pipeline.getStages().stream()
  .filter(stage -> stage.getContext().containsKey("exception"))
  .findFirst()

代码示例来源:origin: com.netflix.spinnaker.orca/orca-core

public PipelineBuilder withStage(String type, String name, Map<String, Object> context) {
 if (context.get("providerType") != null && !(Arrays.asList("aws", "titus")).contains(context.get("providerType"))) {
  type += "_" + context.get("providerType");
 }
 pipeline.getStages().add(new Stage(pipeline, type, name, context));
 return this;
}

代码示例来源:origin: com.netflix.kayenta/kayenta-core

private List<String> getMetricSetListIds(Execution execution, String stagePrefix) {
 List<Stage> stages = execution.getStages();
 return stages.stream()
  .filter(stage -> {
   String refId = stage.getRefId();
   return refId != null && refId.startsWith(stagePrefix);
  })
  .map(stage -> resolveMetricSetListId(stage))
  .collect(Collectors.toList());
}

代码示例来源:origin: com.netflix.kayenta/kayenta-standalone-canary-analysis

/**
 * Gets the run canary stages that contain the results
 */
@NotNull
protected List<Stage> getRunCanaryStages(@Nonnull Stage stage) {
 // Collect the Run Canary Stages where the parent id is itself
 // Sorting by number after the # in the name
 return stage.getExecution().getStages().stream()
   .filter(s -> s.getType().equals(RunCanaryStage.STAGE_TYPE))
   .sorted(Comparator.comparing(s -> Integer.valueOf(StringUtils.substringAfterLast(s.getName(), "#"))))
   .collect(Collectors.toList());
}

代码示例来源:origin: com.netflix.kayenta/kayenta-core

public CanaryConfig getCanaryConfig(Execution pipeline) {
 Stage contextStage = pipeline.getStages().stream()
  .filter(stage -> stage.getRefId().equals(CanaryStageNames.REFID_SET_CONTEXT))
  .findFirst()
  .orElseThrow(() -> new IllegalArgumentException("Unable to find stage '" + CanaryStageNames.REFID_SET_CONTEXT + "' in pipeline ID '" + pipeline.getId() + "'"));
 Map<String, Object> context = contextStage.getContext();
 Map<String, Object> canaryConfigMap = (Map<String, Object>)context.get("canaryConfig");
 return objectMapper.convertValue(canaryConfigMap, CanaryConfig.class);
}

代码示例来源:origin: com.netflix.kayenta/kayenta-core

public String getCanaryExecutionRequestFromJudgeContext(Execution pipeline) {
 Stage contextStage = pipeline.getStages().stream()
  .filter(stage -> stage.getRefId().equals(CanaryStageNames.REFID_JUDGE))
  .findFirst()
  .orElseThrow(() -> new IllegalArgumentException("Unable to find stage '" + CanaryStageNames.REFID_JUDGE + "' in pipeline ID '" + pipeline.getId() + "'"));
 Map<String, Object> context = contextStage.getContext();
 return (String) context.get("canaryExecutionRequest");
}

代码示例来源:origin: com.netflix.spinnaker.orca/orca-core

@JsonIgnore public List<Stage> downstreamStages() {
 return getExecution()
  .getStages()
  .stream()
  .filter(it -> it.getRequisiteStageRefIds().contains(getRefId()))
  .collect(toList());
}

代码示例来源:origin: com.netflix.kayenta/kayenta-core

public CanaryExecutionStatusResponse fromExecution(Execution pipeline) {
 String canaryExecutionId = pipeline.getId();
 Stage contextStage = pipeline.getStages().stream()
  .filter(stage -> stage.getRefId().equals(CanaryStageNames.REFID_SET_CONTEXT))
  .findFirst()
  .orElseThrow(() -> new IllegalArgumentException("Unable to find stage '" + CanaryStageNames.REFID_SET_CONTEXT + "' in pipeline ID '" + canaryExecutionId + "'"));
 Map<String, Object> contextContext = contextStage.getContext();
 String storageAccountName = (String)contextContext.get("storageAccountName");
 return fromExecution(storageAccountName, pipeline);
}

代码示例来源:origin: com.netflix.spinnaker.orca/orca-core

private void onStageStarted(StageStarted event) {
 Execution execution = retrieve(event);
 List<Stage> stages = execution.getStages();
 stages
  .stream()
  .filter(it -> it.getId().equals(event.getStageId()))
  .findFirst()
  .ifPresent(stage -> delegate.beforeStage(persister, stage));
}

代码示例来源:origin: com.netflix.spinnaker.orca/orca-core

private void onStageComplete(StageComplete event) {
 Execution execution = retrieve(event);
 List<Stage> stages = execution.getStages();
 stages
  .stream()
  .filter(it -> it.getId().equals(event.getStageId()))
  .findFirst()
  .ifPresent(stage -> delegate.afterStage(persister, stage));
}

代码示例来源:origin: com.netflix.spinnaker.orca/orca-core

private String generateRefId() {
 long offset = parent
  .getExecution()
  .getStages()
  .stream()
  .filter(i -> parent.getId().equals(i.getParentStageId()) && type == i.getSyntheticStageOwner())
  .count();
 return format(
  "%s%s%d",
  parent.getRefId(),
  type == STAGE_BEFORE ? "<" : ">",
  offset + graph.nodes().size()
 );
}

相关文章