summaryrefslogtreecommitdiffstats
path: root/configserver
diff options
context:
space:
mode:
authorOla Aunrønning <olaa@verizonmedia.com>2019-07-31 16:29:38 +0200
committerOla Aunrønning <olaa@verizonmedia.com>2019-07-31 16:29:38 +0200
commite0693dd7e1713cd25c4813216e5c1b4df7cc0e7c (patch)
treeec46a987506a47a2b91f6c9f5f9a69020b4a04f3 /configserver
parentd6a378f4acd925a0d79608c979718d4b1e438238 (diff)
Correctly fetch cluster info. Ignore NaN metrics
Diffstat (limited to 'configserver')
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java28
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/metrics/MetricsAggregator.java4
2 files changed, 19 insertions, 13 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java b/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java
index 970b0e080d6..bbae38aa0a4 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java
@@ -791,26 +791,32 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
/** Finds the hosts of an application, grouped by cluster name */
private Collection<ClusterInfo> getClustersOfApplication(ApplicationId applicationId) {
Application application = getApplication(applicationId);
- Map<String, List<URI>> clusterHosts = new HashMap<>();
Map<String, ClusterInfo> clusters = new HashMap<>();
application.getModel().getHosts().stream()
.filter(host -> host.getServices().stream().noneMatch(serviceInfo -> serviceInfo.getServiceType().equalsIgnoreCase("logserver")))
.forEach(hostInfo -> {
- log.info(hostInfo.getHostname() + ": " + hostInfo.getServices().stream().map(ServiceInfo::getServiceType).collect(Collectors.joining(", ")));
- ServiceInfo serviceInfo = hostInfo.getServices().stream().filter(service -> METRICS_PROXY_CONTAINER.serviceName.equals(service.getServiceType()))
- .findFirst().orElseThrow(() -> new IllegalArgumentException("Unable to find service " + METRICS_PROXY_CONTAINER.serviceName.toString()));
- String clusterName = serviceInfo.getProperty("clusterid").orElse("");
- String clusterTypeString = serviceInfo.getProperty("clustertype").orElse("");
- if (!ClusterInfo.ClusterType.isValidType(clusterTypeString)) return;
- ClusterInfo.ClusterType clusterType = ClusterInfo.ClusterType.valueOf(clusterTypeString);
- URI host = URI.create("http://" + hostInfo.getHostname() + ":" + servicePort(serviceInfo) + "/metrics/v1/values?consumer=Vespa");
- clusterHosts.computeIfAbsent(clusterName, l -> new ArrayList<URI>()).add(host);
- clusters.computeIfAbsent(clusterName, c -> new ClusterInfo(clusterName, clusterType)).addHost(host);
+ ServiceInfo metricsService = getServiceInfoByType(hostInfo, METRICS_PROXY_CONTAINER.serviceName);
+ ServiceInfo clusterServiceInfo = getServiceInfoByType(hostInfo, "container", "searchnode");
+ ClusterInfo clusterInfo = createClusterInfo(clusterServiceInfo);
+ URI host = URI.create("http://" + hostInfo.getHostname() + ":" + servicePort(metricsService) + "/metrics/v1/values?consumer=Vespa");
+ clusters.computeIfAbsent(clusterInfo.getClusterId(), c -> clusterInfo).addHost(host);
}
);
return clusters.values();
}
+
+ private ServiceInfo getServiceInfoByType(HostInfo hostInfo, String... types) {
+ List<String> type = List.of(types);
+ return hostInfo.getServices().stream().filter(serviceInfo -> type.contains(serviceInfo.getServiceType())).findFirst().orElseThrow();
+ }
+
+ private ClusterInfo createClusterInfo(ServiceInfo serviceInfo) {
+ String clusterName = serviceInfo.getServiceName();
+ ClusterInfo.ClusterType clusterType = serviceInfo.getServiceType().equals("searchnode") ? ClusterInfo.ClusterType.content : ClusterInfo.ClusterType.container;
+ return new ClusterInfo(clusterName, clusterType);
+ }
+
/** Returns version to use when deploying application in given environment */
static Version decideVersion(ApplicationId application, Environment environment, Version sessionVersion, boolean bootstrap) {
if ( environment.isManuallyDeployed()
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/metrics/MetricsAggregator.java b/configserver/src/main/java/com/yahoo/vespa/config/server/metrics/MetricsAggregator.java
index c6b2131863d..8fa08275ad5 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/metrics/MetricsAggregator.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/metrics/MetricsAggregator.java
@@ -42,7 +42,7 @@ public class MetricsAggregator {
}
public Optional<Double> aggregateFeedLatency() {
- return Optional.ofNullable(feed).map(m -> m.latencySum / m.latencyCount);
+ return Optional.ofNullable(feed).map(m -> m.latencySum / m.latencyCount).filter(num -> !num.isNaN());
}
@@ -54,7 +54,7 @@ public class MetricsAggregator {
if (container == null && qr == null) return Optional.empty();
var c = Optional.ofNullable(container).orElseGet(LatencyMetrics::new);
var q = Optional.ofNullable(qr).orElseGet(LatencyMetrics::new);
- return Optional.of((c.latencySum + q.latencySum) / (c.latencyCount + q.latencyCount));
+ return Optional.of((c.latencySum + q.latencySum) / (c.latencyCount + q.latencyCount)).filter(num -> !num.isNaN());
}
public Optional<Double> aggregateQueryRate() {