Search in sources :

Example 1 with LocalTopicStatsImpl

use of com.hazelcast.internal.monitor.impl.LocalTopicStatsImpl in project hazelcast by hazelcast.

the class ReliableTopicService method getStats.

@Override
public Map<String, LocalTopicStats> getStats() {
    Map<String, LocalTopicStats> topicStats = MapUtil.createHashMap(statsMap.size());
    Config config = nodeEngine.getConfig();
    for (Map.Entry<String, LocalTopicStatsImpl> queueStat : statsMap.entrySet()) {
        String name = queueStat.getKey();
        if (config.getReliableTopicConfig(name).isStatisticsEnabled()) {
            topicStats.put(name, queueStat.getValue());
        }
    }
    return topicStats;
}
Also used : Config(com.hazelcast.config.Config) ReliableTopicConfig(com.hazelcast.config.ReliableTopicConfig) LocalTopicStatsImpl(com.hazelcast.internal.monitor.impl.LocalTopicStatsImpl) LocalTopicStats(com.hazelcast.topic.LocalTopicStats) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) Map(java.util.Map)

Example 2 with LocalTopicStatsImpl

use of com.hazelcast.internal.monitor.impl.LocalTopicStatsImpl in project hazelcast by hazelcast.

the class TopicTest method testTopicStats.

@Test
public void testTopicStats() throws InterruptedException {
    String topicName = "testTopicStats" + generateRandomString(5);
    HazelcastInstance instance = createHazelcastInstance();
    ITopic<String> topic = instance.getTopic(topicName);
    final CountDownLatch latch1 = new CountDownLatch(1000);
    topic.addMessageListener(new MessageListener<String>() {

        public void onMessage(Message msg) {
            latch1.countDown();
        }
    });
    final CountDownLatch latch2 = new CountDownLatch(1000);
    topic.addMessageListener(new MessageListener<String>() {

        public void onMessage(Message msg) {
            latch2.countDown();
        }
    });
    for (int i = 0; i < 1000; i++) {
        topic.publish("sancar");
    }
    assertTrue(latch1.await(1, TimeUnit.MINUTES));
    assertTrue(latch2.await(1, TimeUnit.MINUTES));
    LocalTopicStatsImpl stats = (LocalTopicStatsImpl) topic.getLocalTopicStats();
    assertEquals(1000, stats.getPublishOperationCount());
    assertEquals(2000, stats.getReceiveOperationCount());
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) LocalTopicStatsImpl(com.hazelcast.internal.monitor.impl.LocalTopicStatsImpl) CountDownLatch(java.util.concurrent.CountDownLatch) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) NightlyTest(com.hazelcast.test.annotation.NightlyTest) Test(org.junit.Test)

Example 3 with LocalTopicStatsImpl

use of com.hazelcast.internal.monitor.impl.LocalTopicStatsImpl in project hazelcast by hazelcast.

the class TopicService method getStats.

@Override
public Map<String, LocalTopicStats> getStats() {
    Map<String, LocalTopicStats> topicStats = MapUtil.createHashMap(statsMap.size());
    Config config = nodeEngine.getConfig();
    for (Map.Entry<String, LocalTopicStatsImpl> statEntry : statsMap.entrySet()) {
        String name = statEntry.getKey();
        if (config.getTopicConfig(name).isStatisticsEnabled()) {
            topicStats.put(name, statEntry.getValue());
        }
    }
    return topicStats;
}
Also used : TopicConfig(com.hazelcast.config.TopicConfig) Config(com.hazelcast.config.Config) LocalTopicStatsImpl(com.hazelcast.internal.monitor.impl.LocalTopicStatsImpl) LocalTopicStats(com.hazelcast.topic.LocalTopicStats) ConcurrentMap(java.util.concurrent.ConcurrentMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Example 4 with LocalTopicStatsImpl

use of com.hazelcast.internal.monitor.impl.LocalTopicStatsImpl in project hazelcast by hazelcast.

the class ClientReliableTopicStatsTest method publish_countStats.

@Test
public void publish_countStats() {
    topic.publish("message1");
    topic.publishAsync("message2");
    assertTrueEventually(() -> {
        ReliableTopicService service = getNode(instance).getNodeEngine().getService(SERVICE_NAME);
        LocalTopicStatsImpl localTopicStats = service.getLocalTopicStats(topic.getName());
        assertEquals(2, localTopicStats.getPublishOperationCount());
        assertEquals(2, localTopicStats.getReceiveOperationCount());
    });
}
Also used : ReliableTopicService(com.hazelcast.topic.impl.reliable.ReliableTopicService) LocalTopicStatsImpl(com.hazelcast.internal.monitor.impl.LocalTopicStatsImpl) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 5 with LocalTopicStatsImpl

use of com.hazelcast.internal.monitor.impl.LocalTopicStatsImpl in project hazelcast by hazelcast.

the class ClientReliableTopicStatsTest method publishAll_countStats.

@Test
public void publishAll_countStats() throws Exception {
    topic.publishAll(asList("message1", "message2", "message3"));
    topic.publishAllAsync(asList("message4", "message5", "message6"));
    assertTrueEventually(() -> {
        ReliableTopicService service = getNode(instance).getNodeEngine().getService(SERVICE_NAME);
        LocalTopicStatsImpl localTopicStats = service.getLocalTopicStats(topic.getName());
        assertEquals(6, localTopicStats.getPublishOperationCount());
        assertEquals(6, localTopicStats.getReceiveOperationCount());
    });
}
Also used : ReliableTopicService(com.hazelcast.topic.impl.reliable.ReliableTopicService) LocalTopicStatsImpl(com.hazelcast.internal.monitor.impl.LocalTopicStatsImpl) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

LocalTopicStatsImpl (com.hazelcast.internal.monitor.impl.LocalTopicStatsImpl)5 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)3 QuickTest (com.hazelcast.test.annotation.QuickTest)3 Test (org.junit.Test)3 Config (com.hazelcast.config.Config)2 LocalTopicStats (com.hazelcast.topic.LocalTopicStats)2 ReliableTopicService (com.hazelcast.topic.impl.reliable.ReliableTopicService)2 Map (java.util.Map)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 ConcurrentMap (java.util.concurrent.ConcurrentMap)2 ReliableTopicConfig (com.hazelcast.config.ReliableTopicConfig)1 TopicConfig (com.hazelcast.config.TopicConfig)1 HazelcastInstance (com.hazelcast.core.HazelcastInstance)1 NightlyTest (com.hazelcast.test.annotation.NightlyTest)1 CountDownLatch (java.util.concurrent.CountDownLatch)1