use of com.yahoo.jdisc.application.MetricConsumer in project vespa by vespa-engine.
the class ForwardingMetricConsumerTest method requireThatAllMethodsAreForwarded.
@Test
public void requireThatAllMethodsAreForwarded() {
MetricConsumer fooConsumer = Mockito.mock(MetricConsumer.class);
Metric.Context fooCtx = Mockito.mock(Metric.Context.class);
Mockito.when(fooConsumer.createContext(Mockito.<Map<String, ?>>any())).thenReturn(fooCtx);
MetricConsumer barConsumer = Mockito.mock(MetricConsumer.class);
Metric.Context barCtx = Mockito.mock(Metric.Context.class);
Mockito.when(barConsumer.createContext(Mockito.<Map<String, ?>>any())).thenReturn(barCtx);
MetricConsumer fwdConsumer = new ForwardingMetricConsumer(new MetricConsumer[] { fooConsumer, barConsumer });
Map<String, ?> properties = new HashMap<>();
Metric.Context ctx = fwdConsumer.createContext(properties);
assertNotNull(ctx);
Mockito.verify(fooConsumer, Mockito.times(1)).createContext(properties);
Mockito.verify(barConsumer, Mockito.times(1)).createContext(properties);
fwdConsumer.add("a", 69, ctx);
Mockito.verify(fooConsumer, Mockito.times(1)).add("a", 69, fooCtx);
Mockito.verify(barConsumer, Mockito.times(1)).add("a", 69, barCtx);
fwdConsumer.set("b", 96, ctx);
Mockito.verify(fooConsumer, Mockito.times(1)).set("b", 96, fooCtx);
Mockito.verify(barConsumer, Mockito.times(1)).set("b", 96, barCtx);
}
use of com.yahoo.jdisc.application.MetricConsumer in project vespa by vespa-engine.
the class MetricConsumerProviderTest method requireThatSingleConsumerIsNotDelegated.
@Test
public void requireThatSingleConsumerIsNotDelegated() {
MetricConsumer consumer = Mockito.mock(MetricConsumer.class);
MetricConsumerProvider provider = MetricConsumerProviders.newSingletonFactories(consumer);
assertSame(consumer, provider.newInstance());
}
use of com.yahoo.jdisc.application.MetricConsumer in project vespa by vespa-engine.
the class StateMonitorBenchmarkTest method requireThatHealthMonitorDoesNotBlockMetricThreads.
@Test
public void requireThatHealthMonitorDoesNotBlockMetricThreads() throws Exception {
StateMonitor monitor = new StateMonitor(new HealthMonitorConfig(new HealthMonitorConfig.Builder()), new SystemTimer());
Provider<MetricConsumer> provider = MetricConsumerProviders.wrap(monitor);
performUpdates(provider, 8);
for (int i = 1; i <= NUM_THREADS; i *= 2) {
long millis = performUpdates(provider, i);
System.err.format("%2d threads, %5d millis => %9d ups\n", i, millis, (int) ((i * NUM_UPDATES) / (millis / 1000.0)));
}
monitor.deconstruct();
}
use of com.yahoo.jdisc.application.MetricConsumer in project vespa by vespa-engine.
the class MetricConsumerProviderTest method requireThatMultipleConsumersAreDelegated.
@Test
public void requireThatMultipleConsumersAreDelegated() {
MetricConsumer foo = Mockito.mock(MetricConsumer.class);
MetricConsumer bar = Mockito.mock(MetricConsumer.class);
MetricConsumerProvider provider = MetricConsumerProviders.newSingletonFactories(foo, bar);
MetricConsumer consumer = provider.newInstance();
assertNotSame(foo, consumer);
assertNotSame(bar, consumer);
consumer.add("foo", 6, null);
Mockito.verify(foo, Mockito.times(1)).add("foo", 6, null);
Mockito.verify(bar, Mockito.times(1)).add("foo", 6, null);
}
use of com.yahoo.jdisc.application.MetricConsumer in project vespa by vespa-engine.
the class MetricConsumerProviderTest method requireThatDefaultConsumerFactoryIsStateMetric.
@Test
public void requireThatDefaultConsumerFactoryIsStateMetric() {
MetricConsumer consumer = MetricConsumerProviders.newDefaultInstance().newInstance();
assertEquals("StateMetricConsumer", consumer.getClass().getSimpleName());
}
Aggregations