Search in sources :

Example 1 with DoubleGauge

use of com.hazelcast.internal.metrics.DoubleGauge in project hazelcast by hazelcast.

the class OperatingSystemMetricSetTest method registerMethod_whenDouble.

@Test
public void registerMethod_whenDouble() {
    FakeOperatingSystemBean fakeOperatingSystemBean = new FakeOperatingSystemBean();
    registerMethod(metricsRegistry, fakeOperatingSystemBean, "doubleMethod", "doubleMethod");
    DoubleGauge gauge = metricsRegistry.newDoubleGauge("doubleMethod");
    assertEquals(fakeOperatingSystemBean.doubleMethod(), gauge.read(), 0.1);
}
Also used : DoubleGauge(com.hazelcast.internal.metrics.DoubleGauge) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 2 with DoubleGauge

use of com.hazelcast.internal.metrics.DoubleGauge in project hazelcast by hazelcast.

the class DoubleGaugeImplTest method whenDoubleProbe.

@Test
public void whenDoubleProbe() {
    metricsRegistry.register(this, "foo", MANDATORY, new DoubleProbeFunction() {

        @Override
        public double get(Object o) {
            return 10;
        }
    });
    DoubleGauge gauge = metricsRegistry.newDoubleGauge("foo");
    double actual = gauge.read();
    assertEquals(10, actual, 0.1);
}
Also used : DoubleGauge(com.hazelcast.internal.metrics.DoubleGauge) DoubleProbeFunction(com.hazelcast.internal.metrics.DoubleProbeFunction) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 3 with DoubleGauge

use of com.hazelcast.internal.metrics.DoubleGauge in project hazelcast by hazelcast.

the class DoubleGaugeImplTest method whenLongGaugeField.

@Test
public void whenLongGaugeField() {
    SomeObject someObject = new SomeObject();
    metricsRegistry.scanAndRegister(someObject, "foo");
    DoubleGauge gauge = metricsRegistry.newDoubleGauge("foo.longField");
    assertEquals(someObject.longField, gauge.read(), 0.1);
}
Also used : DoubleGauge(com.hazelcast.internal.metrics.DoubleGauge) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 4 with DoubleGauge

use of com.hazelcast.internal.metrics.DoubleGauge in project hazelcast by hazelcast.

the class DoubleGaugeImplTest method whenProbeThrowsException.

@Test
public void whenProbeThrowsException() {
    metricsRegistry.register(this, "foo", MANDATORY, new DoubleProbeFunction() {

        @Override
        public double get(Object o) {
            throw new RuntimeException();
        }
    });
    DoubleGauge gauge = metricsRegistry.newDoubleGauge("foo");
    double actual = gauge.read();
    assertEquals(0, actual, 0.1);
}
Also used : DoubleGauge(com.hazelcast.internal.metrics.DoubleGauge) DoubleProbeFunction(com.hazelcast.internal.metrics.DoubleProbeFunction) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 5 with DoubleGauge

use of com.hazelcast.internal.metrics.DoubleGauge in project hazelcast by hazelcast.

the class DoubleGaugeImplTest method whenDoubleGaugeField.

@Test
public void whenDoubleGaugeField() {
    SomeObject someObject = new SomeObject();
    metricsRegistry.scanAndRegister(someObject, "foo");
    DoubleGauge gauge = metricsRegistry.newDoubleGauge("foo.doubleField");
    assertEquals(someObject.doubleField, gauge.read(), 0.1);
}
Also used : DoubleGauge(com.hazelcast.internal.metrics.DoubleGauge) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

DoubleGauge (com.hazelcast.internal.metrics.DoubleGauge)10 QuickTest (com.hazelcast.test.annotation.QuickTest)10 Test (org.junit.Test)10 DoubleProbeFunction (com.hazelcast.internal.metrics.DoubleProbeFunction)2 LongProbeFunction (com.hazelcast.internal.metrics.LongProbeFunction)1