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;
}
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());
}
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;
}
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());
});
}
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());
});
}
Aggregations