Search in sources :

Example 6 with MetricsRegistry

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

Example 7 with MetricsRegistry

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

Example 8 with MetricsRegistry

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

Example 9 with MetricsRegistry

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

Example 10 with MetricsRegistry

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());
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) ManagedExecutorService(com.hazelcast.internal.util.executor.ManagedExecutorService) HazelcastProperties(com.hazelcast.spi.properties.HazelcastProperties) MetricsRegistry(com.hazelcast.internal.metrics.MetricsRegistry) HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config) Node(com.hazelcast.instance.impl.Node) ClusterServiceImpl(com.hazelcast.internal.cluster.impl.ClusterServiceImpl) ExecutionService(com.hazelcast.spi.impl.executionservice.ExecutionService)

Aggregations

MetricsRegistry (com.hazelcast.internal.metrics.MetricsRegistry)29 QuickTest (com.hazelcast.test.annotation.QuickTest)16 Test (org.junit.Test)16 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)10 HazelcastInstance (com.hazelcast.core.HazelcastInstance)6 MetricDescriptor (com.hazelcast.internal.metrics.MetricDescriptor)6 MetricsCollector (com.hazelcast.internal.metrics.collectors.MetricsCollector)4 Config (com.hazelcast.config.Config)2 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)2 ExecutionService (com.hazelcast.spi.impl.executionservice.ExecutionService)2 CacheConfig (com.hazelcast.config.CacheConfig)1 ConfigAccessor.getActiveMemberNetworkConfig (com.hazelcast.config.ConfigAccessor.getActiveMemberNetworkConfig)1 MemberAddressProviderConfig (com.hazelcast.config.MemberAddressProviderConfig)1 HazelcastThreadGroup (com.hazelcast.instance.HazelcastThreadGroup)1 Node (com.hazelcast.instance.Node)1 ProtocolType (com.hazelcast.instance.ProtocolType)1 Node (com.hazelcast.instance.impl.Node)1 ClusterServiceImpl (com.hazelcast.internal.cluster.impl.ClusterServiceImpl)1 IOThreadingModel (com.hazelcast.internal.networking.IOThreadingModel)1 Networking (com.hazelcast.internal.networking.Networking)1