blob: dd96414bbc753f1b45859a78548189aee9cd6e74 (
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
33
34
35
36
37
38
39
40
41
42
43
44
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.container.jdisc.metric;
import com.yahoo.component.ComponentId;
import com.yahoo.component.provider.ComponentRegistry;
import com.yahoo.container.jdisc.MetricConsumerFactory;
import com.yahoo.container.jdisc.state.StateMonitor;
import com.yahoo.jdisc.application.MetricConsumer;
import com.yahoo.metrics.MetricsPresentationConfig;
/**
* @author Simon Thoresen Hult
*/
class MetricConsumerProviders {
public static MetricConsumerProvider newSingletonFactories(MetricConsumer... consumers) {
MetricConsumerFactory[] factories = new MetricConsumerFactory[consumers.length];
for (int i = 0; i < consumers.length; ++i) {
factories[i] = MetricConsumerFactories.newSingleton(consumers[i]);
}
return newInstance(factories);
}
public static MetricConsumerProvider newInstance(MetricConsumerFactory... factories) {
return new MetricConsumerProvider(newComponentRegistry(factories),
new MetricsPresentationConfig(new MetricsPresentationConfig.Builder()),
StateMonitor.createForTesting());
}
public static MetricConsumerProvider newDefaultInstance() {
return new MetricConsumerProvider(newComponentRegistry(),
new MetricsPresentationConfig(new MetricsPresentationConfig.Builder()),
StateMonitor.createForTesting());
}
public static ComponentRegistry<MetricConsumerFactory> newComponentRegistry(MetricConsumerFactory... factories) {
ComponentRegistry<MetricConsumerFactory> registry = new ComponentRegistry<>();
for (MetricConsumerFactory factory : factories) {
registry.register(new ComponentId(String.valueOf(factory.hashCode())), factory);
}
return registry;
}
}
|