blob: 9b0d9dbfadc60d1838901085bd3623451c7eb483 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.model.admin.monitoring.builder;
import com.yahoo.vespa.model.admin.monitoring.MetricsConsumer;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* A mutable helper class representing the user defined metrics and consumers.
*
* @author gjoranv
*/
public class Metrics {
private final Map<String, MetricsConsumer> consumers = new LinkedHashMap<>();
public void addConsumer(MetricsConsumer consumer) {
consumers.put(consumer.getId(), consumer);
}
public Map<String, MetricsConsumer> getConsumers() {
return Collections.unmodifiableMap(consumers);
}
public boolean hasConsumerIgnoreCase(String id) {
return consumers.keySet().stream()
.anyMatch(existing -> existing.equalsIgnoreCase(id));
}
}
|