use of com.hazelcast.internal.metrics.MetricsRegistry in project hazelcast by hazelcast.
the class MetricsPropertiesTest method testDebugMetricsSysPropEnabled.
@Test
public void testDebugMetricsSysPropEnabled() {
System.setProperty(ClusterProperty.METRICS_DEBUG.getName(), "true");
HazelcastInstance instance = createHazelcastInstance();
MetricsRegistry metricsRegistry = getNodeEngineImpl(instance).getMetricsRegistry();
assertEquals(DEBUG, metricsRegistry.minimumLevel());
}
use of com.hazelcast.internal.metrics.MetricsRegistry in project hazelcast by hazelcast.
the class MetricsPropertiesTest method testDebugMetricsSysPropNotSet.
@Test
public void testDebugMetricsSysPropNotSet() {
HazelcastInstance instance = createHazelcastInstance();
MetricsRegistry metricsRegistry = getNodeEngineImpl(instance).getMetricsRegistry();
assertEquals(INFO, metricsRegistry.minimumLevel());
}
use of com.hazelcast.internal.metrics.MetricsRegistry in project hazelcast by hazelcast.
the class DynamicMetricsCollectionTest method testDirectLong.
@Test
public void testDirectLong() {
CapturingCollector capturingCollector = new CapturingCollector();
MetricsRegistry metricsRegistry = new MetricsRegistryImpl(Logger.getLogger(MetricsRegistryImpl.class), INFO);
metricsRegistry.registerDynamicMetricsProvider((descriptor, context) -> context.collect(descriptor.withPrefix("test"), "someMetric", INFO, BYTES, 42));
metricsRegistry.collect(capturingCollector);
MetricDescriptor expectedDescriptor = metricsRegistry.newMetricDescriptor().withPrefix("test").withUnit(BYTES).withMetric("someMetric");
Number number = capturingCollector.captures().get(expectedDescriptor).singleCapturedValue();
assertInstanceOf(Long.class, number);
assertEquals(42, number.longValue());
}
use of com.hazelcast.internal.metrics.MetricsRegistry in project hazelcast by hazelcast.
the class DynamicMetricsCollectionTest method testExtractingFromObjectProveLevelFilters.
@Test
public void testExtractingFromObjectProveLevelFilters() {
SourceObject source = new SourceObject();
source.longField = 42;
source.doubleField = 42.42D;
MetricsCollector collectorMock = mock(MetricsCollector.class);
MetricsRegistry registry = new MetricsRegistryImpl(Logger.getLogger(MetricsRegistryImpl.class), MANDATORY);
registry.registerDynamicMetricsProvider((descriptor, context) -> context.collect(descriptor.withPrefix("test"), source));
registry.collect(collectorMock);
verify(collectorMock, never()).collectLong(registry.newMetricDescriptor().withPrefix("test").withMetric("longField"), 42);
verify(collectorMock, never()).collectDouble(registry.newMetricDescriptor().withPrefix("test").withMetric("doubleField"), 42.42D);
verify(collectorMock, never()).collectLong(registry.newMetricDescriptor().withPrefix("test").withMetric("longMethod"), 43);
verify(collectorMock, never()).collectDouble(registry.newMetricDescriptor().withPrefix("test").withMetric("doubleMethod"), 43.52D);
}
use of com.hazelcast.internal.metrics.MetricsRegistry in project hazelcast by hazelcast.
the class MigrationManagerTest method setupMocks.
private void setupMocks() {
node = mock(Node.class);
NodeEngineImpl nodeEngine = mock(NodeEngineImpl.class);
HazelcastInstance instance = mock(HazelcastInstance.class);
MetricsRegistry metricsRegistry = mock(MetricsRegistry.class);
ExecutionService executionService = mock(ExecutionService.class);
ManagedExecutorService asyncExecutor = mock(ManagedExecutorService.class);
clusterService = mock(ClusterServiceImpl.class);
when(node.getProperties()).thenReturn(new HazelcastProperties(new Config()));
when(node.getNodeEngine()).thenReturn(nodeEngine);
when(node.getClusterService()).thenReturn(clusterService);
when(instance.getName()).thenReturn("dev");
when(nodeEngine.getHazelcastInstance()).thenReturn(instance);
when(nodeEngine.getMetricsRegistry()).thenReturn(metricsRegistry);
when(executionService.getExecutor(any(String.class))).thenReturn(asyncExecutor);
when(nodeEngine.getExecutionService()).thenReturn(executionService);
when(clusterService.getClusterVersion()).thenReturn(Versions.CURRENT_CLUSTER_VERSION);
partitionStateManager = mock(PartitionStateManager.class);
partitionService = mock(InternalPartitionServiceImpl.class);
when(partitionService.getPartitionStateManager()).thenReturn(partitionStateManager);
when(node.getConfig()).thenReturn(new Config());
}
Aggregations