use of com.hazelcast.internal.metrics.LongProbeFunction in project hazelcast by hazelcast.
the class MetricsRegistryImplTest method getNames.
// ================ getNames ======================
@Test
public void getNames() {
Set<String> expected = new HashSet<String>();
expected.add("first");
expected.add("second");
expected.add("third");
for (String name : expected) {
metricsRegistry.register(this, name, ProbeLevel.MANDATORY, new LongProbeFunction() {
@Override
public long get(Object obj) throws Exception {
return 0;
}
});
}
Set<String> names = metricsRegistry.getNames();
for (String name : expected) {
assertContains(names, name);
}
}
use of com.hazelcast.internal.metrics.LongProbeFunction in project hazelcast by hazelcast.
the class MetricsRegistryImplTest method modCount.
@Test
public void modCount() {
long modCount = metricsRegistry.modCount();
metricsRegistry.register(this, "foo", ProbeLevel.MANDATORY, new LongProbeFunction() {
@Override
public long get(Object obj) throws Exception {
return 1;
}
});
assertEquals(modCount + 1, metricsRegistry.modCount());
metricsRegistry.deregister(this);
assertEquals(modCount + 2, metricsRegistry.modCount());
}
use of com.hazelcast.internal.metrics.LongProbeFunction in project hazelcast by hazelcast.
the class MetricsPluginTest method testRunWithProblematicProbe.
@Test
public void testRunWithProblematicProbe() throws Throwable {
metricsRegistry.register(this, "broken", MANDATORY, new LongProbeFunction() {
@Override
public long get(Object source) throws Exception {
throw new RuntimeException("error");
}
});
plugin.run(logWriter);
assertContains("broken=java.lang.RuntimeException:error");
}
use of com.hazelcast.internal.metrics.LongProbeFunction in project hazelcast by hazelcast.
the class DoubleGaugeImplTest method whenLongProbe.
@Test
public void whenLongProbe() {
metricsRegistry.register(this, "foo", MANDATORY, new LongProbeFunction() {
@Override
public long get(Object o) throws Exception {
return 10;
}
});
DoubleGauge gauge = metricsRegistry.newDoubleGauge("foo");
double actual = gauge.read();
assertEquals(10, actual, 0.1);
}
use of com.hazelcast.internal.metrics.LongProbeFunction in project hazelcast by hazelcast.
the class LongGaugeImplTest method whenReregister.
@Test
public void whenReregister() {
metricsRegistry.register(this, "foo", MANDATORY, new LongProbeFunction() {
@Override
public long get(Object o) throws Exception {
return 10;
}
});
LongGauge gauge = metricsRegistry.newLongGauge("foo");
gauge.read();
metricsRegistry.register(this, "foo", MANDATORY, new LongProbeFunction() {
@Override
public long get(Object o) throws Exception {
return 11;
}
});
assertEquals(11, gauge.read());
}
Aggregations