本文整理了Java中com.netflix.spinnaker.orca.pipeline.model.Stage.getContext()
方法的一些代码示例,展示了Stage.getContext()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Stage.getContext()
方法的具体详情如下:
包路径:com.netflix.spinnaker.orca.pipeline.model.Stage
类名称:Stage
方法名:getContext
暂无
代码示例来源:origin: spinnaker/kayenta
@Nonnull
@Override
public TaskResult execute(@Nonnull Stage stage) {
Map<String, Object> context = stage.getContext();
Map judge1Result = (Map)context.get("judge1Result");
Map judge2Result = (Map)context.get("judge2Result");
// TODO: Now that the plumbing works, perform some kind of actual comparison.
Map<String, Map> comparisonResult =
ImmutableMap.<String, Map>builder()
.put("judge1Result", judge1Result)
.put("judge2Result", judge2Result)
.build();
Map<String, Map> outputs = Collections.singletonMap("comparisonResult", comparisonResult);
return new TaskResult(ExecutionStatus.SUCCEEDED, Collections.emptyMap(), outputs);
}
}
代码示例来源: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
@Nonnull
@Override
public TaskResult execute(@Nonnull Stage stage) {
Map<String, Object> context = stage.getContext();
String metricsAccountName = (String)context.get("metricsAccountName");
String storageAccountName = (String)context.get("storageAccountName");
Map<String, Object> canaryConfigMap = (Map<String, Object>)context.get("canaryConfig");
CanaryConfig canaryConfig = kayentaObjectMapper.convertValue(canaryConfigMap, CanaryConfig.class);
int metricIndex = (Integer)stage.getContext().get("metricIndex");
CanaryScope canaryScope;
try {
canaryScope = kayentaObjectMapper.readValue((String)stage.getContext().get("canaryScope"), PrometheusCanaryScope.class);
} catch (IOException e) {
log.warn("Unable to parse JSON scope", e);
throw new RuntimeException(e);
}
String resolvedMetricsAccountName = CredentialsHelper.resolveAccountByNameOrType(metricsAccountName,
AccountCredentials.Type.METRICS_STORE,
accountCredentialsRepository);
String resolvedStorageAccountName = CredentialsHelper.resolveAccountByNameOrType(storageAccountName,
AccountCredentials.Type.OBJECT_STORE,
accountCredentialsRepository);
return synchronousQueryProcessor.executeQueryAndProduceTaskResult(resolvedMetricsAccountName,
resolvedStorageAccountName,
canaryConfig,
metricIndex,
canaryScope);
}
}
代码示例来源:origin: spinnaker/kayenta
@Nonnull
@Override
public TaskResult execute(@Nonnull Stage stage) {
Map<String, Object> context = stage.getContext();
CanaryScope canaryScope;
canaryScope = kayentaObjectMapper.readValue((String)stage.getContext().get("canaryScope"), CanaryScope.class);
} catch (IOException e) {
log.warn("Unable to parse JSON scope", e);
resolvedStorageAccountName,
kayentaObjectMapper.convertValue(context.get("canaryConfig"), CanaryConfig.class),
(Integer)stage.getContext().get("metricIndex"),
canaryScope
);
代码示例来源:origin: spinnaker/kayenta
@Nonnull
@Override
public TaskResult execute(@Nonnull Stage stage) {
Map<String, Object> context = stage.getContext();
String metricsAccountName = (String)context.get("metricsAccountName");
String storageAccountName = (String)context.get("storageAccountName");
Map<String, Object> canaryConfigMap = (Map<String, Object>)context.get("canaryConfig");
CanaryConfig canaryConfig = kayentaObjectMapper.convertValue(canaryConfigMap, CanaryConfig.class);
int metricIndex = (Integer)stage.getContext().get("metricIndex");
StackdriverCanaryScope stackdriverCanaryScope;
try {
stackdriverCanaryScope = kayentaObjectMapper.readValue((String)stage.getContext().get("canaryScope"), StackdriverCanaryScope.class);
} catch (IOException e) {
log.warn("Unable to parse JSON scope", e);
throw new RuntimeException(e);
}
String resolvedMetricsAccountName = CredentialsHelper.resolveAccountByNameOrType(metricsAccountName,
AccountCredentials.Type.METRICS_STORE,
accountCredentialsRepository);
String resolvedStorageAccountName = CredentialsHelper.resolveAccountByNameOrType(storageAccountName,
AccountCredentials.Type.OBJECT_STORE,
accountCredentialsRepository);
return synchronousQueryProcessor.executeQueryAndProduceTaskResult(resolvedMetricsAccountName,
resolvedStorageAccountName,
canaryConfig,
metricIndex,
stackdriverCanaryScope);
}
}
代码示例来源:origin: spinnaker/kayenta
@Nonnull
@Override
public TaskResult execute(@Nonnull Stage stage) {
Map<String, Object> context = stage.getContext();
CanaryScope canaryScope;
canaryScope = kayentaObjectMapper.readValue((String) stage.getContext().get("canaryScope"),
CanaryScope.class);
} catch (IOException e) {
resolvedStorageAccountName,
kayentaObjectMapper.convertValue(context.get("canaryConfig"), CanaryConfig.class),
(Integer) stage.getContext().get("metricIndex"),
canaryScope
);
代码示例来源:origin: spinnaker/kayenta
@Nonnull
@Override
public TaskResult execute(@Nonnull Stage stage) {
Map<String, Object> context = stage.getContext();
CanaryScope canaryScope;
canaryScope = kayentaObjectMapper.readValue((String)stage.getContext().get("canaryScope"), CanaryScope.class);
} catch (IOException e) {
log.warn("Unable to parse JSON scope", e);
resolvedStorageAccountName,
kayentaObjectMapper.convertValue(context.get("canaryConfig"), CanaryConfig.class),
(Integer)stage.getContext().get("metricIndex"),
canaryScope
);
代码示例来源:origin: spinnaker/kayenta
@Override
public TaskResult execute(@Nonnull Stage stage) {
Map<String, Object> context = stage.getContext();
SignalFxCanaryScope canaryScope;
try {
canaryScope = kayentaObjectMapper.readValue((String) stage.getContext().get("canaryScope"), SignalFxCanaryScope.class);
} catch (IOException e) {
log.warn("Unable to parse JSON scope", e);
resolvedStorageAccountName,
kayentaObjectMapper.convertValue(context.get("canaryConfig"), CanaryConfig.class),
(Integer) stage.getContext().get("metricIndex"),
canaryScope
);
代码示例来源: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
@Nonnull
@Override
public TaskResult execute(@Nonnull Stage stage) {
Map<String, Object> context = stage.getContext();
Map<String, ?> outputs;
if (context.containsKey("canaryConfig")) {
Map<String, ?> canaryConfigMap = (Map<String, ?>)context.get("canaryConfig");
outputs = Collections.singletonMap("canaryConfig", canaryConfigMap);
} else {
String canaryConfigId = (String) context.get("canaryConfigId");
String configurationAccountName = (String) context.get("configurationAccountName");
String resolvedConfigurationAccountName = CredentialsHelper.resolveAccountByNameOrType(configurationAccountName,
AccountCredentials.Type.CONFIGURATION_STORE,
accountCredentialsRepository);
StorageService configurationService =
storageServiceRepository
.getOne(resolvedConfigurationAccountName)
.orElseThrow(() -> new IllegalArgumentException("No configuration service was configured; unable to load configurations."));
CanaryConfig canaryConfig = configurationService.loadObject(resolvedConfigurationAccountName, ObjectType.CANARY_CONFIG, canaryConfigId);
outputs = Collections.singletonMap("canaryConfig", canaryConfig);
}
return new TaskResult(ExecutionStatus.SUCCEEDED, Collections.emptyMap(), outputs);
}
}
代码示例来源:origin: spinnaker/kayenta
@Nonnull
@Override
public TaskResult execute(@Nonnull Stage stage) {
Map<String, Object> context = stage.getContext();
String metricsAccountName = (String)context.get("metricsAccountName");
String storageAccountName = (String)context.get("storageAccountName");
代码示例来源:origin: spinnaker/kayenta
@Nonnull
@Override
public TaskResult execute(@Nonnull Stage stage) {
Map<String, Object> context = stage.getContext();
CanaryScope canaryScope;
kayentaObjectMapper
.convertValue(context.get("canaryConfig"), CanaryConfig.class),
(Integer) stage.getContext().get("metricIndex"),
canaryScope
);
代码示例来源:origin: spinnaker/kayenta
/**
* Always run the GenerateCanaryAnalysisResultStage.
*/
private void addAlwaysRunResultStage(@Nonnull Stage parent, @Nonnull StageGraphBuilder graph) {
graph.append(stage -> {
stage.setType(GenerateCanaryAnalysisResultStage.STAGE_TYPE);
stage.setName(GenerateCanaryAnalysisResultStage.STAGE_DESCRIPTION);
stage.setContext(parent.getContext());
});
}
代码示例来源:origin: spinnaker/kayenta
.filter(stage -> stage.getContext().containsKey("exception"))
.collect(Collectors.toList());
.stream()
.collect(
Collectors.toMap(s -> s.getName(), s -> s.getContext().get("exception"))
));
代码示例来源:origin: spinnaker/kayenta
@Nonnull
@Override
public TaskResult execute(@Nonnull Stage stage) {
Map<String, Object> context = stage.getContext();
String storageAccountName = (String)context.get("storageAccountName");
List<String> controlMetricSetListIds = getMetricSetListIds(stage.getExecution(), (String)context.get("controlRefidPrefix"));
代码示例来源:origin: spinnaker/kayenta
@Override
public Result cancel(Stage stage) {
Map<String, Object> context = stage.getContext();
String canaryPipelineExecutionId = (String) context.getOrDefault("canaryPipelineExecutionId", null);
stage.getId(), stage.getExecution().getId(), canaryPipelineExecutionId, stage.getContext());
stage.getId(), stage.getExecution().getId(), stage.getContext());
代码示例来源: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
@Override
public void beforeStages(@Nonnull Stage parent, @Nonnull StageGraphBuilder graph) {
CanaryAnalysisConfig canaryAnalysisConfig = kayentaObjectMapper
.convertValue(parent.getContext().get(CANARY_ANALYSIS_CONFIG_CONTEXT_KEY), CanaryAnalysisConfig.class);
stage.setType(WaitStage.STAGE_TYPE);
stage.setName("Warmup Wait");
stage.getContext().put("waitTime", canaryAnalysisExecutionRequest.getBeginCanaryAnalysisAfterAsDuration().getSeconds());
});
stage.setType(WaitStage.STAGE_TYPE);
stage.setName("Interval Wait #" + index);
stage.getContext().put("waitTime", analysisInterval.getSeconds());
});
stage.setType(RunCanaryStage.STAGE_TYPE);
stage.setName(RunCanaryStage.STAGE_NAME_PREFIX + index);
stage.getContext().putAll(kayentaObjectMapper.convertValue(runCanaryContext,
new TypeReference<HashMap<String,Object>>() {}));
});
内容来源于网络,如有侵权,请联系作者删除!