public static Supplier<MetricStore> getMetricStore(String deploymentName, String metricStoreType, boolean validate) { return () -> { Object rawMetricStore = ResponseUnwrapper.get(getService().getMetricStore(deploymentName, metricStoreType, validate)); return getObjectMapper().convertValue(rawMetricStore, MetricStores.translateMetricStoreType(metricStoreType)); }; }
public MetricStores getMetricStores(String deploymentName) { NodeFilter filter = new NodeFilter().setDeployment(deploymentName).setMetricStores(); List<MetricStores> matching = lookupService.getMatchingNodesOfType(filter, MetricStores.class); switch (matching.size()) { case 0: MetricStores metricStores = new MetricStores(); setMetricStores(deploymentName, metricStores); return metricStores; case 1: return matching.get(0); default: throw new RuntimeException("It shouldn't be possible to have multiple metricStores nodes. This is a bug."); } }
@Override public boolean isEnabled(DeploymentConfiguration deploymentConfiguration) { return deploymentConfiguration.getMetricStores().isEnabled(); }
public void setMetricStore(String deploymentName, MetricStore metricStore) { MetricStores metricStores = getMetricStores(deploymentName); switch (metricStore.getMetricStoreType()) { case DATADOG: metricStores.setDatadog((DatadogStore) metricStore); break; case PROMETHEUS: metricStores.setPrometheus((PrometheusStore) metricStore); break; case STACKDRIVER: metricStores.setStackdriver((StackdriverStore) metricStore); break; default: throw new RuntimeException("Unknown Metric Store " + metricStore.getMetricStoreType()); } }
List<String> files = new ArrayList<>(); DatadogStore datadogStore = metricStores.getDatadog(); if (datadogStore.isEnabled()) { enabledMetricStores.add("datadog"); PrometheusStore prometheusStore = metricStores.getPrometheus(); if (prometheusStore.isEnabled()) { enabledMetricStores.add("prometheus"); StackdriverStore stackdriverStore = metricStores.getStackdriver(); if (stackdriverStore.isEnabled()) { enabledMetricStores.add("stackdriver"); .setPeriod(metricStores.getPeriod()) .setMetricStore(enabledMetricStores);
@Override protected void executeThis() { String currentDeployment = getCurrentDeployment(); MetricStores metricStores = new OperationHandler<MetricStores>() .setOperation(Daemon.getMetricStores(currentDeployment, false)) .setFailureMesssage("Failed to load metric stores.") .get(); int originalHash = metricStores.hashCode(); metricStores.setPeriod(isSet(period) ? period : metricStores.getPeriod()); if (originalHash == metricStores.hashCode()) { AnsiUi.failure("No changes supplied."); return; } new OperationHandler<Void>() .setOperation(Daemon.setMetricStores(currentDeployment, !noValidate, metricStores)) .setFailureMesssage("Failed to edit metric stores.") .setSuccessMessage("Successfully updated metric stores.") .get(); } }
List<String> files = new ArrayList<>(); DatadogStore datadogStore = metricStores.getDatadog(); if (datadogStore.isEnabled()) { enabledMetricStores.add("datadog"); PrometheusStore prometheusStore = metricStores.getPrometheus(); if (prometheusStore.isEnabled()) { enabledMetricStores.add("prometheus"); StackdriverStore stackdriverStore = metricStores.getStackdriver(); if (stackdriverStore.isEnabled()) { enabledMetricStores.add("stackdriver"); .setPeriod(metricStores.getPeriod()) .setMetricStore(enabledMetricStores);
@Override protected void executeThis() { String currentDeployment = getCurrentDeployment(); MetricStores metricStores = new OperationHandler<MetricStores>() .setOperation(Daemon.getMetricStores(currentDeployment, false)) .setFailureMesssage("Failed to load metric stores.") .get(); int originalHash = metricStores.hashCode(); metricStores.setPeriod(isSet(period) ? period : metricStores.getPeriod()); if (originalHash == metricStores.hashCode()) { AnsiUi.failure("No changes supplied."); return; } new OperationHandler<Void>() .setOperation(Daemon.setMetricStores(currentDeployment, !noValidate, metricStores)) .setFailureMesssage("Failed to edit metric stores.") .setSuccessMessage("Successfully updated metric stores.") .get(); } }
public void setMetricStore(String deploymentName, MetricStore metricStore) { MetricStores metricStores = getMetricStores(deploymentName); switch (metricStore.getMetricStoreType()) { case DATADOG: metricStores.setDatadog((DatadogStore) metricStore); break; case PROMETHEUS: metricStores.setPrometheus((PrometheusStore) metricStore); break; case STACKDRIVER: metricStores.setStackdriver((StackdriverStore) metricStore); break; default: throw new RuntimeException("Unknown Metric Store " + metricStore.getMetricStoreType()); } }
public static Supplier<MetricStore> getMetricStore(String deploymentName, String metricStoreType, boolean validate) { return () -> { Object rawMetricStore = ResponseUnwrapper.get(getService().getMetricStore(deploymentName, metricStoreType, validate)); return getObjectMapper().convertValue(rawMetricStore, MetricStores.translateMetricStoreType(metricStoreType)); }; }
@Override public boolean isEnabled(DeploymentConfiguration deploymentConfiguration) { return deploymentConfiguration.getMetricStores().isEnabled(); }
public MetricStores getMetricStores(String deploymentName) { NodeFilter filter = new NodeFilter().setDeployment(deploymentName).setMetricStores(); List<MetricStores> matching = lookupService.getMatchingNodesOfType(filter, MetricStores.class); switch (matching.size()) { case 0: MetricStores metricStores = new MetricStores(); setMetricStores(deploymentName, metricStores); return metricStores; case 1: return matching.get(0); default: throw new RuntimeException("It shouldn't be possible to have multiple metricStores nodes. This is a bug."); } }
@RequestMapping(value = "/{metricStoreType:.+}", method = RequestMethod.PUT) DaemonTask<Halconfig, Void> setMetricStore(@PathVariable String deploymentName, @PathVariable String metricStoreType, @ModelAttribute ValidationSettings validationSettings, @RequestBody Object rawMetricStore) { MetricStore metricStore = objectMapper.convertValue( rawMetricStore, MetricStores.translateMetricStoreType(metricStoreType) ); return GenericUpdateRequest.<MetricStore>builder(halconfigParser) .stagePath(halconfigDirectoryStructure.getStagingPath(deploymentName)) .updater(m -> metricStoresService.setMetricStore(deploymentName, m)) .validator(() -> metricStoresService.validateMetricStore(deploymentName, metricStoreType)) .description("Edit " + metricStoreType + " metric store") .build() .execute(validationSettings, metricStore); }
@Override public Settings buildServiceSettings(DeploymentConfiguration deploymentConfiguration) { Settings settings = new Settings(); settings.setArtifactId(getArtifactId(deploymentConfiguration.getName())) .setEnabled(deploymentConfiguration.getMetricStores().isEnabled()); return settings; }
public MetricStore getMetricStore(String deploymentName, String metricStoreType) { NodeFilter filter = new NodeFilter().setDeployment(deploymentName).setMetricStores().setMetricStore(metricStoreType); List<MetricStore> matching = lookupService.getMatchingNodesOfType(filter, MetricStore.class); try { switch (matching.size()) { case 0: MetricStore metricStores = MetricStores.translateMetricStoreType(metricStoreType).newInstance(); setMetricStore(deploymentName, metricStores); return metricStores; case 1: return matching.get(0); default: throw new RuntimeException("It shouldn't be possible to have multiple metricStore nodes of the same type. This is a bug."); } } catch (InstantiationException | IllegalAccessException e) { throw new HalException(new ConfigProblemBuilder(Severity.FATAL, "Can't create an empty metric store node " + "for metricStore type \"" + metricStoreType + "\"").build() ); } }
@Override public Settings buildServiceSettings(DeploymentConfiguration deploymentConfiguration) { Settings settings = new Settings(); settings.setArtifactId(getArtifactId(deploymentConfiguration.getName())) .setEnabled(deploymentConfiguration.getMetricStores().isEnabled()); return settings; }
public MetricStore getMetricStore(String deploymentName, String metricStoreType) { NodeFilter filter = new NodeFilter().setDeployment(deploymentName).setMetricStores().setMetricStore(metricStoreType); List<MetricStore> matching = lookupService.getMatchingNodesOfType(filter, MetricStore.class); try { switch (matching.size()) { case 0: MetricStore metricStores = MetricStores.translateMetricStoreType(metricStoreType).newInstance(); setMetricStore(deploymentName, metricStores); return metricStores; case 1: return matching.get(0); default: throw new RuntimeException("It shouldn't be possible to have multiple metricStore nodes of the same type. This is a bug."); } } catch (InstantiationException | IllegalAccessException e) { throw new HalException(new ConfigProblemBuilder(Severity.FATAL, "Can't create an empty metric store node " + "for metricStore type \"" + metricStoreType + "\"").build() ); } }
@Override protected void setProfile(Profile profile, DeploymentConfiguration deploymentConfiguration, SpinnakerRuntimeSettings endpoints) { SpectatorConfig spectatorConfig = new SpectatorConfig(); spectatorConfig .getSpectator() .getWebEndpoint() .setEnabled(deploymentConfiguration.getMetricStores().isEnabled()); profile.appendContents(yamlToString(spectatorConfig)); }
@Override protected void setProfile(Profile profile, DeploymentConfiguration deploymentConfiguration, SpinnakerRuntimeSettings endpoints) { SpectatorConfig spectatorConfig = new SpectatorConfig(); spectatorConfig .getSpectator() .getWebEndpoint() .setEnabled(deploymentConfiguration.getMetricStores().isEnabled()); profile.appendContents(yamlToString(spectatorConfig)); }
@Override public ServiceSettings buildServiceSettings(DeploymentConfiguration deploymentConfiguration) { return new Settings().setArtifactId(getArtifactId(deploymentConfiguration.getName())) .setHost(getDefaultHost()) .setEnabled(deploymentConfiguration.getMetricStores().isEnabled()); }