aboutsummaryrefslogtreecommitdiffstats
path: root/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/builder/Metrics.java
blob: a173c7eb87cf8ce9de2ea1396f429569e5b52406 (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
32
// Copyright Vespa.ai. 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.id(), consumer);
    }

    public Map<String, MetricsConsumer> getConsumers() {
        return Collections.unmodifiableMap(consumers);
    }

    public boolean hasConsumerIgnoreCase(String id) {
        return consumers.keySet().stream()
                .anyMatch(existing -> existing.equalsIgnoreCase(id));
    }

}