use of com.hazelcast.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());
}
Aggregations