Search in sources :

Example 1 with MANDATORY

use of com.hazelcast.internal.metrics.ProbeLevel.MANDATORY in project hazelcast by hazelcast.

the class LongGaugeImplTest method whenDoubleProbe.

@Test
public void whenDoubleProbe() {
    metricsRegistry.registerStaticProbe(this, "foo", MANDATORY, (DoubleProbeFunction<LongGaugeImplTest>) source -> 10);
    LongGauge gauge = metricsRegistry.newLongGauge("foo");
    long actual = gauge.read();
    assertEquals(10, actual);
}
Also used : QuickTest(com.hazelcast.test.annotation.QuickTest) MANDATORY(com.hazelcast.internal.metrics.ProbeLevel.MANDATORY) RunWith(org.junit.runner.RunWith) HazelcastSerialClassRunner(com.hazelcast.test.HazelcastSerialClassRunner) MetricDescriptor(com.hazelcast.internal.metrics.MetricDescriptor) Math.round(java.lang.Math.round) DoubleProbeFunction(com.hazelcast.internal.metrics.DoubleProbeFunction) LongGauge(com.hazelcast.internal.metrics.LongGauge) DynamicMetricsProvider(com.hazelcast.internal.metrics.DynamicMetricsProvider) WeakReference(java.lang.ref.WeakReference) LongProbeFunction(com.hazelcast.internal.metrics.LongProbeFunction) Before(org.junit.Before) INFO(com.hazelcast.internal.metrics.ProbeLevel.INFO) Logger(com.hazelcast.logging.Logger) COUNT(com.hazelcast.internal.metrics.ProbeUnit.COUNT) Probe(com.hazelcast.internal.metrics.Probe) HazelcastTestSupport(com.hazelcast.test.HazelcastTestSupport) MetricsCollectionContext(com.hazelcast.internal.metrics.MetricsCollectionContext) MetricsCollector(com.hazelcast.internal.metrics.collectors.MetricsCollector) Test(org.junit.Test) Category(org.junit.experimental.categories.Category) Assert.assertNull(org.junit.Assert.assertNull) BYTES(com.hazelcast.internal.metrics.ProbeUnit.BYTES) Assert.assertEquals(org.junit.Assert.assertEquals) Mockito.mock(org.mockito.Mockito.mock) LongGauge(com.hazelcast.internal.metrics.LongGauge) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 2 with MANDATORY

use of com.hazelcast.internal.metrics.ProbeLevel.MANDATORY in project hazelcast by hazelcast.

the class LongGaugeImplTest method whenProbeThrowsException.

@Test
public void whenProbeThrowsException() {
    metricsRegistry.registerStaticProbe(this, "foo", MANDATORY, (LongProbeFunction) o -> {
        throw new RuntimeException();
    });
    LongGauge gauge = metricsRegistry.newLongGauge("foo");
    long actual = gauge.read();
    assertEquals(0, actual);
}
Also used : QuickTest(com.hazelcast.test.annotation.QuickTest) MANDATORY(com.hazelcast.internal.metrics.ProbeLevel.MANDATORY) RunWith(org.junit.runner.RunWith) HazelcastSerialClassRunner(com.hazelcast.test.HazelcastSerialClassRunner) MetricDescriptor(com.hazelcast.internal.metrics.MetricDescriptor) Math.round(java.lang.Math.round) DoubleProbeFunction(com.hazelcast.internal.metrics.DoubleProbeFunction) LongGauge(com.hazelcast.internal.metrics.LongGauge) DynamicMetricsProvider(com.hazelcast.internal.metrics.DynamicMetricsProvider) WeakReference(java.lang.ref.WeakReference) LongProbeFunction(com.hazelcast.internal.metrics.LongProbeFunction) Before(org.junit.Before) INFO(com.hazelcast.internal.metrics.ProbeLevel.INFO) Logger(com.hazelcast.logging.Logger) COUNT(com.hazelcast.internal.metrics.ProbeUnit.COUNT) Probe(com.hazelcast.internal.metrics.Probe) HazelcastTestSupport(com.hazelcast.test.HazelcastTestSupport) MetricsCollectionContext(com.hazelcast.internal.metrics.MetricsCollectionContext) MetricsCollector(com.hazelcast.internal.metrics.collectors.MetricsCollector) Test(org.junit.Test) Category(org.junit.experimental.categories.Category) Assert.assertNull(org.junit.Assert.assertNull) BYTES(com.hazelcast.internal.metrics.ProbeUnit.BYTES) Assert.assertEquals(org.junit.Assert.assertEquals) Mockito.mock(org.mockito.Mockito.mock) LongGauge(com.hazelcast.internal.metrics.LongGauge) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 3 with MANDATORY

use of com.hazelcast.internal.metrics.ProbeLevel.MANDATORY in project hazelcast by hazelcast.

the class DoubleGaugeImplTest method whenDoubleProbe.

@Test
public void whenDoubleProbe() {
    metricsRegistry.registerStaticProbe(this, "foo", MANDATORY, (DoubleProbeFunction) o -> 10);
    DoubleGauge gauge = metricsRegistry.newDoubleGauge("foo");
    double actual = gauge.read();
    assertEquals(10, actual, 0.1);
}
Also used : INFO(com.hazelcast.internal.metrics.ProbeLevel.INFO) Logger(com.hazelcast.logging.Logger) COUNT(com.hazelcast.internal.metrics.ProbeUnit.COUNT) QuickTest(com.hazelcast.test.annotation.QuickTest) Probe(com.hazelcast.internal.metrics.Probe) HazelcastTestSupport(com.hazelcast.test.HazelcastTestSupport) MANDATORY(com.hazelcast.internal.metrics.ProbeLevel.MANDATORY) RunWith(org.junit.runner.RunWith) MetricsCollectionContext(com.hazelcast.internal.metrics.MetricsCollectionContext) MetricsCollector(com.hazelcast.internal.metrics.collectors.MetricsCollector) Test(org.junit.Test) DoubleGauge(com.hazelcast.internal.metrics.DoubleGauge) Category(org.junit.experimental.categories.Category) HazelcastSerialClassRunner(com.hazelcast.test.HazelcastSerialClassRunner) MetricDescriptor(com.hazelcast.internal.metrics.MetricDescriptor) Assert.assertNull(org.junit.Assert.assertNull) BYTES(com.hazelcast.internal.metrics.ProbeUnit.BYTES) DoubleProbeFunction(com.hazelcast.internal.metrics.DoubleProbeFunction) DynamicMetricsProvider(com.hazelcast.internal.metrics.DynamicMetricsProvider) WeakReference(java.lang.ref.WeakReference) Assert.assertEquals(org.junit.Assert.assertEquals) LongProbeFunction(com.hazelcast.internal.metrics.LongProbeFunction) Before(org.junit.Before) Mockito.mock(org.mockito.Mockito.mock) DoubleGauge(com.hazelcast.internal.metrics.DoubleGauge) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 4 with MANDATORY

use of com.hazelcast.internal.metrics.ProbeLevel.MANDATORY in project hazelcast by hazelcast.

the class DoubleGaugeImplTest method whenProbeThrowsException.

@Test
public void whenProbeThrowsException() {
    metricsRegistry.registerStaticProbe(this, "foo", MANDATORY, (DoubleProbeFunction) o -> {
        throw new RuntimeException();
    });
    DoubleGauge gauge = metricsRegistry.newDoubleGauge("foo");
    double actual = gauge.read();
    assertEquals(0, actual, 0.1);
}
Also used : INFO(com.hazelcast.internal.metrics.ProbeLevel.INFO) Logger(com.hazelcast.logging.Logger) COUNT(com.hazelcast.internal.metrics.ProbeUnit.COUNT) QuickTest(com.hazelcast.test.annotation.QuickTest) Probe(com.hazelcast.internal.metrics.Probe) HazelcastTestSupport(com.hazelcast.test.HazelcastTestSupport) MANDATORY(com.hazelcast.internal.metrics.ProbeLevel.MANDATORY) RunWith(org.junit.runner.RunWith) MetricsCollectionContext(com.hazelcast.internal.metrics.MetricsCollectionContext) MetricsCollector(com.hazelcast.internal.metrics.collectors.MetricsCollector) Test(org.junit.Test) DoubleGauge(com.hazelcast.internal.metrics.DoubleGauge) Category(org.junit.experimental.categories.Category) HazelcastSerialClassRunner(com.hazelcast.test.HazelcastSerialClassRunner) MetricDescriptor(com.hazelcast.internal.metrics.MetricDescriptor) Assert.assertNull(org.junit.Assert.assertNull) BYTES(com.hazelcast.internal.metrics.ProbeUnit.BYTES) DoubleProbeFunction(com.hazelcast.internal.metrics.DoubleProbeFunction) DynamicMetricsProvider(com.hazelcast.internal.metrics.DynamicMetricsProvider) WeakReference(java.lang.ref.WeakReference) Assert.assertEquals(org.junit.Assert.assertEquals) LongProbeFunction(com.hazelcast.internal.metrics.LongProbeFunction) Before(org.junit.Before) Mockito.mock(org.mockito.Mockito.mock) DoubleGauge(com.hazelcast.internal.metrics.DoubleGauge) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 5 with MANDATORY

use of com.hazelcast.internal.metrics.ProbeLevel.MANDATORY in project hazelcast by hazelcast.

the class LongGaugeImplTest method whenLongProbe.

@Test
public void whenLongProbe() {
    metricsRegistry.registerStaticProbe(this, "foo", MANDATORY, (LongProbeFunction) o -> 10);
    LongGauge gauge = metricsRegistry.newLongGauge("foo");
    assertEquals(10, gauge.read());
}
Also used : QuickTest(com.hazelcast.test.annotation.QuickTest) MANDATORY(com.hazelcast.internal.metrics.ProbeLevel.MANDATORY) RunWith(org.junit.runner.RunWith) HazelcastSerialClassRunner(com.hazelcast.test.HazelcastSerialClassRunner) MetricDescriptor(com.hazelcast.internal.metrics.MetricDescriptor) Math.round(java.lang.Math.round) DoubleProbeFunction(com.hazelcast.internal.metrics.DoubleProbeFunction) LongGauge(com.hazelcast.internal.metrics.LongGauge) DynamicMetricsProvider(com.hazelcast.internal.metrics.DynamicMetricsProvider) WeakReference(java.lang.ref.WeakReference) LongProbeFunction(com.hazelcast.internal.metrics.LongProbeFunction) Before(org.junit.Before) INFO(com.hazelcast.internal.metrics.ProbeLevel.INFO) Logger(com.hazelcast.logging.Logger) COUNT(com.hazelcast.internal.metrics.ProbeUnit.COUNT) Probe(com.hazelcast.internal.metrics.Probe) HazelcastTestSupport(com.hazelcast.test.HazelcastTestSupport) MetricsCollectionContext(com.hazelcast.internal.metrics.MetricsCollectionContext) MetricsCollector(com.hazelcast.internal.metrics.collectors.MetricsCollector) Test(org.junit.Test) Category(org.junit.experimental.categories.Category) Assert.assertNull(org.junit.Assert.assertNull) BYTES(com.hazelcast.internal.metrics.ProbeUnit.BYTES) Assert.assertEquals(org.junit.Assert.assertEquals) Mockito.mock(org.mockito.Mockito.mock) LongGauge(com.hazelcast.internal.metrics.LongGauge) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

DoubleProbeFunction (com.hazelcast.internal.metrics.DoubleProbeFunction)7 DynamicMetricsProvider (com.hazelcast.internal.metrics.DynamicMetricsProvider)7 LongProbeFunction (com.hazelcast.internal.metrics.LongProbeFunction)7 MetricDescriptor (com.hazelcast.internal.metrics.MetricDescriptor)7 MetricsCollectionContext (com.hazelcast.internal.metrics.MetricsCollectionContext)7 Probe (com.hazelcast.internal.metrics.Probe)7 INFO (com.hazelcast.internal.metrics.ProbeLevel.INFO)7 MANDATORY (com.hazelcast.internal.metrics.ProbeLevel.MANDATORY)7 BYTES (com.hazelcast.internal.metrics.ProbeUnit.BYTES)7 COUNT (com.hazelcast.internal.metrics.ProbeUnit.COUNT)7 MetricsCollector (com.hazelcast.internal.metrics.collectors.MetricsCollector)7 Logger (com.hazelcast.logging.Logger)7 HazelcastSerialClassRunner (com.hazelcast.test.HazelcastSerialClassRunner)7 HazelcastTestSupport (com.hazelcast.test.HazelcastTestSupport)7 QuickTest (com.hazelcast.test.annotation.QuickTest)7 WeakReference (java.lang.ref.WeakReference)7 Assert.assertEquals (org.junit.Assert.assertEquals)7 Assert.assertNull (org.junit.Assert.assertNull)7 Before (org.junit.Before)7 Test (org.junit.Test)7