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());
}
}
Aggregations