public void setMetricStoreEnabled(String deploymentName, String metricStoreType, boolean enabled) { MetricStore metricStore = getMetricStore(deploymentName, metricStoreType); metricStore.setEnabled(enabled); setMetricStore(deploymentName, metricStore); }
@RequestMapping(value = "/{metricStoreType:.+}/enabled/", method = RequestMethod.PUT) DaemonTask<Halconfig, Void> setMethodEnabled(@PathVariable String deploymentName, @PathVariable String metricStoreType, @ModelAttribute ValidationSettings validationSettings, @RequestBody boolean enabled) { return GenericEnableDisableRequest.builder(halconfigParser) .updater(e -> metricStoresService.setMetricStoreEnabled(deploymentName, metricStoreType, e)) .validator(() -> metricStoresService.validateMetricStore(deploymentName, metricStoreType)) .description("Edit " + metricStoreType + " metric store") .build() .execute(validationSettings, enabled); } }
@RequestMapping(value = "/{metricStoreType:.+}", method = RequestMethod.GET) DaemonTask<Halconfig, MetricStore> getMetricStore(@PathVariable String deploymentName, @PathVariable String metricStoreType, @ModelAttribute ValidationSettings validationSettings) { return GenericGetRequest.<MetricStore>builder() .getter(() -> metricStoresService.getMetricStore(deploymentName, metricStoreType)) .validator(() -> metricStoresService.validateMetricStore(deploymentName, metricStoreType)) .description("Get " + metricStoreType + " metric store") .build() .execute(validationSettings); }
@RequestMapping(value = "/", method = RequestMethod.GET) DaemonTask<Halconfig, MetricStores> getMetricStores(@PathVariable String deploymentName, @ModelAttribute ValidationSettings validationSettings) { return GenericGetRequest.<MetricStores>builder() .getter(() -> metricStoresService.getMetricStores(deploymentName)) .validator(() -> metricStoresService.validateMetricStores(deploymentName)) .description("Get all metric stores") .build() .execute(validationSettings); }
@RequestMapping(value = "/", method = RequestMethod.PUT) DaemonTask<Halconfig, Void> setMetricStores(@PathVariable String deploymentName, @ModelAttribute ValidationSettings validationSettings, @RequestBody MetricStores metricStores) { return GenericUpdateRequest.<MetricStores>builder(halconfigParser) .stagePath(halconfigDirectoryStructure.getStagingPath(deploymentName)) .updater(m -> metricStoresService.setMetricStores(deploymentName, m)) .validator(() -> metricStoresService.validateMetricStores(deploymentName)) .description("Edit all metric stores") .build() .execute(validationSettings, metricStores); }
@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); }
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."); } }
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 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() ); } }
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."); } }
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 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() ); } }
public void setMetricStoreEnabled(String deploymentName, String metricStoreType, boolean enabled) { MetricStore metricStore = getMetricStore(deploymentName, metricStoreType); metricStore.setEnabled(enabled); setMetricStore(deploymentName, metricStore); }