Search in sources :

Example 16 with MetricConsumer

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

the class MetricsCompressorTest method testTwoMetrics_sameExcludedTargets.

@Test
public void testTwoMetrics_sameExcludedTargets() {
    DefaultMetricDescriptorSupplier supplier = new DefaultMetricDescriptorSupplier();
    MetricsCompressor compressor = new MetricsCompressor();
    MetricDescriptor metric1 = supplier.get().withPrefix("prefix").withMetric("metricName").withExcludedTarget(JMX).withExcludedTarget(MANAGEMENT_CENTER);
    MetricDescriptor metric2 = metric1.copy();
    compressor.addLong(metric1, 42L);
    compressor.addLong(metric2, 43L);
    byte[] blob = compressor.getBlobAndReset();
    MetricConsumer metricConsumerMock = mock(MetricConsumer.class);
    MetricsCompressor.extractMetrics(blob, metricConsumerMock, supplierSpy);
    verify(metricConsumerMock).consumeLong(metric1, 42L);
    verify(metricConsumerMock).consumeLong(metric2, 43L);
    verifyNoMoreInteractions(metricConsumerMock);
    verify(supplierSpy, times(2)).get();
}
Also used : MetricConsumer(com.hazelcast.internal.metrics.MetricConsumer) MetricDescriptor(com.hazelcast.internal.metrics.MetricDescriptor) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 17 with MetricConsumer

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

the class MetricsCompressorTest method testSingleLongMetric.

@Test
public void testSingleLongMetric() {
    MetricDescriptor originalMetric = supplier.get().withPrefix("prefix").withMetric("metricName").withDiscriminator("ds", "dsName1").withUnit(COUNT).withTag("tag0", "tag0Value");
    compressor.addLong(originalMetric, 42L);
    byte[] blob = compressor.getBlobAndReset();
    MetricConsumer metricConsumerMock = mock(MetricConsumer.class);
    MetricsCompressor.extractMetrics(blob, metricConsumerMock, supplierSpy);
    verify(metricConsumerMock).consumeLong(originalMetric, 42L);
    verifyNoMoreInteractions(metricConsumerMock);
    verify(supplierSpy, only()).get();
}
Also used : MetricConsumer(com.hazelcast.internal.metrics.MetricConsumer) MetricDescriptor(com.hazelcast.internal.metrics.MetricDescriptor) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 18 with MetricConsumer

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

the class MetricsCompressorTest method testSingleDoubleMetric.

@Test
public void testSingleDoubleMetric() {
    MetricDescriptor originalMetric = supplier.get().withPrefix("prefix").withMetric("metricName").withDiscriminator("ds", "dsName1").withUnit(COUNT).withTag("tag0", "tag0Value");
    compressor.addDouble(originalMetric, 42.42D);
    byte[] blob = compressor.getBlobAndReset();
    MetricConsumer metricConsumerMock = mock(MetricConsumer.class);
    MetricsCompressor.extractMetrics(blob, metricConsumerMock, supplierSpy);
    verify(metricConsumerMock).consumeDouble(originalMetric, 42.42D);
    verifyNoMoreInteractions(metricConsumerMock);
    verify(supplierSpy, only()).get();
}
Also used : MetricConsumer(com.hazelcast.internal.metrics.MetricConsumer) MetricDescriptor(com.hazelcast.internal.metrics.MetricDescriptor) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 19 with MetricConsumer

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

the class MetricsCompressorTest method testTwoMetrics_withDelta.

@Test
public void testTwoMetrics_withDelta() {
    DefaultMetricDescriptorSupplier supplier = new DefaultMetricDescriptorSupplier();
    MetricsCompressor compressor = new MetricsCompressor();
    MetricDescriptor metric1 = supplier.get().withPrefix("prefix").withMetric("metricName").withDiscriminator("ds", "dsName1").withUnit(COUNT).withTag("tag0", "tag0Value");
    MetricDescriptor metric2 = metric1.copy().withMetric("metricName2");
    compressor.addLong(metric1, 42L);
    compressor.addLong(metric2, 43L);
    byte[] blob = compressor.getBlobAndReset();
    MetricConsumer metricConsumerMock = mock(MetricConsumer.class);
    MetricsCompressor.extractMetrics(blob, metricConsumerMock, supplierSpy);
    verify(metricConsumerMock).consumeLong(metric1, 42L);
    verify(metricConsumerMock).consumeLong(metric2, 43L);
    verifyNoMoreInteractions(metricConsumerMock);
    verify(supplierSpy, times(2)).get();
}
Also used : MetricConsumer(com.hazelcast.internal.metrics.MetricConsumer) MetricDescriptor(com.hazelcast.internal.metrics.MetricDescriptor) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

MetricConsumer (com.hazelcast.internal.metrics.MetricConsumer)19 MetricDescriptor (com.hazelcast.internal.metrics.MetricDescriptor)18 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)16 QuickTest (com.hazelcast.test.annotation.QuickTest)16 Test (org.junit.Test)16 InOrder (org.mockito.InOrder)2 ClientStatistics (com.hazelcast.client.impl.statistics.ClientStatistics)1 ProbeUnit (com.hazelcast.internal.metrics.ProbeUnit)1 Date (java.util.Date)1