Search in sources :

Example 6 with MetricStores

use of com.netflix.spinnaker.halyard.config.model.v1.node.MetricStores in project halyard by spinnaker.

the class MetricStoresService method getMetricStore.

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());
    }
}
Also used : MetricStore(com.netflix.spinnaker.halyard.config.model.v1.node.MetricStore) ConfigProblemBuilder(com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder) HalException(com.netflix.spinnaker.halyard.core.error.v1.HalException) NodeFilter(com.netflix.spinnaker.halyard.config.model.v1.node.NodeFilter)

Aggregations

MetricStores (com.netflix.spinnaker.halyard.config.model.v1.node.MetricStores)4 NodeFilter (com.netflix.spinnaker.halyard.config.model.v1.node.NodeFilter)2 OperationHandler (com.netflix.spinnaker.halyard.cli.services.v1.OperationHandler)1 DatadogStore (com.netflix.spinnaker.halyard.config.model.v1.metricStores.datadog.DatadogStore)1 PrometheusStore (com.netflix.spinnaker.halyard.config.model.v1.metricStores.prometheus.PrometheusStore)1 StackdriverStore (com.netflix.spinnaker.halyard.config.model.v1.metricStores.stackdriver.StackdriverStore)1 DeploymentConfiguration (com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentConfiguration)1 MetricStore (com.netflix.spinnaker.halyard.config.model.v1.node.MetricStore)1 ConfigProblemBuilder (com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder)1 UpdateRequestBuilder (com.netflix.spinnaker.halyard.core.DaemonResponse.UpdateRequestBuilder)1 HalException (com.netflix.spinnaker.halyard.core.error.v1.HalException)1 ProblemSet (com.netflix.spinnaker.halyard.core.problem.v1.ProblemSet)1 SpinnakerRuntimeSettings (com.netflix.spinnaker.halyard.deploy.spinnaker.v1.SpinnakerRuntimeSettings)1 ServiceSettings (com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.ServiceSettings)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1