Search in sources :

Example 6 with ClientStatistics

use of com.hazelcast.client.impl.statistics.ClientStatistics in project hazelcast by hazelcast.

the class ClientStatisticsTest method testNoUpdateWhenDisabled.

@Test
public void testNoUpdateWhenDisabled() {
    HazelcastInstance hazelcastInstance = hazelcastFactory.newHazelcastInstance();
    final ClientEngineImpl clientEngine = getClientEngineImpl(hazelcastInstance);
    ClientConfig clientConfig = new ClientConfig();
    clientConfig.getMetricsConfig().setEnabled(false).setCollectionFrequencySeconds(STATS_PERIOD_SECONDS);
    hazelcastFactory.newHazelcastClient(clientConfig);
    assertTrueAllTheTime(() -> {
        Map<UUID, ClientStatistics> statistics = clientEngine.getClientStatistics();
        assertEquals(0, statistics.size());
    }, STATS_PERIOD_SECONDS * 3);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) ClientEngineImpl(com.hazelcast.client.impl.ClientEngineImpl) Accessors.getClientEngineImpl(com.hazelcast.test.Accessors.getClientEngineImpl) ClientStatistics(com.hazelcast.client.impl.statistics.ClientStatistics) ClientConfig(com.hazelcast.client.config.ClientConfig) UUID(java.util.UUID) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 7 with ClientStatistics

use of com.hazelcast.client.impl.statistics.ClientStatistics in project hazelcast by hazelcast.

the class ClientStatisticsTest method testStatisticsTwoClients.

@Test
public void testStatisticsTwoClients() {
    HazelcastInstance hazelcastInstance = hazelcastFactory.newHazelcastInstance();
    final HazelcastClientInstanceImpl client1 = createHazelcastClient();
    final HazelcastClientInstanceImpl client2 = createHazelcastClient();
    final ClientEngineImpl clientEngine = getClientEngineImpl(hazelcastInstance);
    assertTrueEventually(() -> {
        Map<UUID, ClientStatistics> clientStatistics = clientEngine.getClientStatistics();
        assertNotNull(clientStatistics);
        assertEquals(2, clientStatistics.size());
        List<UUID> expectedUUIDs = new ArrayList<>(2);
        expectedUUIDs.add(client1.getClientClusterService().getLocalClient().getUuid());
        expectedUUIDs.add(client2.getClientClusterService().getLocalClient().getUuid());
        for (Map.Entry<UUID, ClientStatistics> clientEntry : clientStatistics.entrySet()) {
            assertTrue(expectedUUIDs.contains(clientEntry.getKey()));
            String clientAttributes = clientEntry.getValue().clientAttributes();
            assertNotNull(clientAttributes);
        }
    });
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) ClientEngineImpl(com.hazelcast.client.impl.ClientEngineImpl) Accessors.getClientEngineImpl(com.hazelcast.test.Accessors.getClientEngineImpl) ClientStatistics(com.hazelcast.client.impl.statistics.ClientStatistics) ArrayList(java.util.ArrayList) HazelcastClientInstanceImpl(com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl) UUID(java.util.UUID) HashMap(java.util.HashMap) Map(java.util.Map) IMap(com.hazelcast.map.IMap) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

ClientStatistics (com.hazelcast.client.impl.statistics.ClientStatistics)7 UUID (java.util.UUID)5 ClientEngineImpl (com.hazelcast.client.impl.ClientEngineImpl)2 HazelcastInstance (com.hazelcast.core.HazelcastInstance)2 MetricDescriptor (com.hazelcast.internal.metrics.MetricDescriptor)2 Accessors.getClientEngineImpl (com.hazelcast.test.Accessors.getClientEngineImpl)2 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)2 QuickTest (com.hazelcast.test.annotation.QuickTest)2 Map (java.util.Map)2 Test (org.junit.Test)2 Client (com.hazelcast.client.Client)1 ClientConfig (com.hazelcast.client.config.ClientConfig)1 ClientEngine (com.hazelcast.client.impl.ClientEngine)1 HazelcastClientInstanceImpl (com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl)1 MetricConsumer (com.hazelcast.internal.metrics.MetricConsumer)1 CapturingCollector (com.hazelcast.internal.metrics.impl.CapturingCollector)1 MapUtil.createHashMap (com.hazelcast.internal.util.MapUtil.createHashMap)1 IMap (com.hazelcast.map.IMap)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1