use of com.hazelcast.monitor.LocalQueueStats in project hazelcast by hazelcast.
the class QueueService method getStats.
@Override
public Map<String, LocalQueueStats> getStats() {
Map<String, LocalQueueStats> queueStats = MapUtil.createHashMap(containerMap.size());
for (Entry<String, QueueContainer> entry : containerMap.entrySet()) {
String name = entry.getKey();
LocalQueueStats queueStat = createLocalQueueStats(name);
queueStats.put(name, queueStat);
}
return queueStats;
}
use of com.hazelcast.monitor.LocalQueueStats in project hazelcast by hazelcast.
the class QueueStatisticsTest method testEventOperationCount.
@Test
public void testEventOperationCount() {
IQueue<String> queue = newQueue();
TestListener listener = new TestListener(30);
queue.addItemListener(listener, true);
for (int i = 0; i < 30; i++) {
queue.offer("item" + i);
}
for (int i = 0; i < 30; i++) {
queue.poll();
}
final LocalQueueStats stats = queue.getLocalQueueStats();
assertOpenEventually(listener.addedLatch);
assertOpenEventually(listener.removedLatch);
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertEquals(60, stats.getEventOperationCount());
}
});
}
use of com.hazelcast.monitor.LocalQueueStats in project hazelcast by hazelcast.
the class QueueStatisticsTest method testItemCount.
@Test
public void testItemCount() {
IQueue<String> queue = newQueue();
int items = 20;
for (int i = 0; i < items; i++) {
queue.offer("item" + i);
}
LocalQueueStats stats = queue.getLocalQueueStats();
assertEquals(20, stats.getOwnedItemCount());
assertEquals(0, stats.getBackupItemCount());
}
use of com.hazelcast.monitor.LocalQueueStats in project hazelcast by hazelcast.
the class QueueStatisticsTest method testOfferOperationCount.
@Test
public void testOfferOperationCount() throws Exception {
IQueue<String> queue = newQueue();
for (int i = 0; i < 10; i++) {
queue.offer("item" + i);
}
for (int i = 0; i < 10; i++) {
queue.add("item" + i);
}
for (int i = 0; i < 10; i++) {
queue.put("item" + i);
}
final LocalQueueStats stats = queue.getLocalQueueStats();
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertEquals(30, stats.getOfferOperationCount());
}
});
}
use of com.hazelcast.monitor.LocalQueueStats in project hazelcast by hazelcast.
the class QueueStatisticsTest method testOtherOperationCount.
@Test
public void testOtherOperationCount() {
IQueue<String> queue = newQueue();
for (int i = 0; i < 30; i++) {
queue.offer("item" + i);
}
ArrayList<String> list = new ArrayList<String>();
queue.drainTo(list);
queue.addAll(list);
queue.removeAll(list);
final LocalQueueStats stats = queue.getLocalQueueStats();
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertEquals(3, stats.getOtherOperationsCount());
}
});
}
Aggregations