Search in sources :

Example 6 with LongProbeFunction

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);
    }
}
Also used : LongProbeFunction(com.hazelcast.internal.metrics.LongProbeFunction) HashSet(java.util.HashSet) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 7 with LongProbeFunction

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());
}
Also used : LongProbeFunction(com.hazelcast.internal.metrics.LongProbeFunction) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 8 with LongProbeFunction

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");
}
Also used : LongProbeFunction(com.hazelcast.internal.metrics.LongProbeFunction) IOException(java.io.IOException) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 9 with LongProbeFunction

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);
}
Also used : LongProbeFunction(com.hazelcast.internal.metrics.LongProbeFunction) DoubleGauge(com.hazelcast.internal.metrics.DoubleGauge) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 10 with LongProbeFunction

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());
}
Also used : LongProbeFunction(com.hazelcast.internal.metrics.LongProbeFunction) LongGauge(com.hazelcast.internal.metrics.LongGauge) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

LongProbeFunction (com.hazelcast.internal.metrics.LongProbeFunction)11 QuickTest (com.hazelcast.test.annotation.QuickTest)8 Test (org.junit.Test)8 DoubleProbeFunction (com.hazelcast.internal.metrics.DoubleProbeFunction)3 LongGauge (com.hazelcast.internal.metrics.LongGauge)3 ProbeFunction (com.hazelcast.internal.metrics.ProbeFunction)3 IOException (java.io.IOException)2 DoubleGauge (com.hazelcast.internal.metrics.DoubleGauge)1 AssertTask (com.hazelcast.test.AssertTask)1 File (java.io.File)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1