Search in sources :

Example 1 with LocalQueueStats

use of com.hazelcast.collection.LocalQueueStats in project hazelcast by hazelcast.

the class QueueStatisticsTest method testOtherOperationCount.

@Test
public void testOtherOperationCount() {
    IQueue<VersionedObject<String>> queue = newQueue();
    for (int i = 0; i < 30; i++) {
        queue.offer(new VersionedObject<>("item" + i, i));
    }
    ArrayList<VersionedObject<String>> list = new ArrayList<>();
    queue.drainTo(list);
    queue.addAll(list);
    queue.removeAll(list);
    final LocalQueueStats stats = queue.getLocalQueueStats();
    assertTrueEventually(() -> assertEquals(3, stats.getOtherOperationsCount()));
}
Also used : LocalQueueStats(com.hazelcast.collection.LocalQueueStats) VersionedObject(com.hazelcast.collection.impl.queue.model.VersionedObject) ArrayList(java.util.ArrayList) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 2 with LocalQueueStats

use of com.hazelcast.collection.LocalQueueStats in project hazelcast by hazelcast.

the class QueueStatisticsTest method testOfferOperationCount.

@Test
public void testOfferOperationCount() throws Exception {
    IQueue<VersionedObject<String>> queue = newQueue();
    for (int i = 0; i < 10; i++) {
        queue.offer(new VersionedObject<>("item" + i, i));
    }
    for (int i = 0; i < 10; i++) {
        queue.add(new VersionedObject<>("item" + i, i));
    }
    for (int i = 0; i < 10; i++) {
        queue.put(new VersionedObject<>("item" + i, i));
    }
    final LocalQueueStats stats = queue.getLocalQueueStats();
    assertTrueEventually(() -> assertEquals(30, stats.getOfferOperationCount()));
}
Also used : LocalQueueStats(com.hazelcast.collection.LocalQueueStats) VersionedObject(com.hazelcast.collection.impl.queue.model.VersionedObject) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 3 with LocalQueueStats

use of com.hazelcast.collection.LocalQueueStats in project hazelcast by hazelcast.

the class QueueStatisticsTest method testEventOperationCount.

@Test
public void testEventOperationCount() {
    IQueue<VersionedObject<String>> queue = newQueue();
    TestListener listener = new TestListener(30);
    queue.addItemListener(listener, true);
    for (int i = 0; i < 30; i++) {
        queue.offer(new VersionedObject<>("item" + i, i));
    }
    for (int i = 0; i < 30; i++) {
        queue.poll();
    }
    final LocalQueueStats stats = queue.getLocalQueueStats();
    assertOpenEventually(listener.addedLatch);
    assertOpenEventually(listener.removedLatch);
    assertTrueEventually(() -> assertEquals(60, stats.getEventOperationCount()));
}
Also used : LocalQueueStats(com.hazelcast.collection.LocalQueueStats) VersionedObject(com.hazelcast.collection.impl.queue.model.VersionedObject) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 4 with LocalQueueStats

use of com.hazelcast.collection.LocalQueueStats in project hazelcast by hazelcast.

the class QueueStatisticsTest method testItemCount.

@Test
public void testItemCount() {
    IQueue<VersionedObject<String>> queue = newQueue();
    int items = 20;
    for (int i = 0; i < items; i++) {
        queue.offer(new VersionedObject<>("item" + i, i));
    }
    LocalQueueStats stats = queue.getLocalQueueStats();
    assertEquals(20, stats.getOwnedItemCount());
    assertEquals(0, stats.getBackupItemCount());
}
Also used : LocalQueueStats(com.hazelcast.collection.LocalQueueStats) VersionedObject(com.hazelcast.collection.impl.queue.model.VersionedObject) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 5 with LocalQueueStats

use of com.hazelcast.collection.LocalQueueStats in project hazelcast by hazelcast.

the class QueueService method getStats.

@Override
public Map<String, LocalQueueStats> getStats() {
    Map<String, LocalQueueStats> queueStats = createHashMap(containerMap.size());
    for (Entry<String, QueueContainer> entry : containerMap.entrySet()) {
        String name = entry.getKey();
        QueueContainer queueContainer = entry.getValue();
        if (queueContainer.getConfig().isStatisticsEnabled()) {
            LocalQueueStats queueStat = createLocalQueueStats(name);
            queueStats.put(name, queueStat);
        }
    }
    return queueStats;
}
Also used : LocalQueueStats(com.hazelcast.collection.LocalQueueStats)

Aggregations

LocalQueueStats (com.hazelcast.collection.LocalQueueStats)10 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)9 QuickTest (com.hazelcast.test.annotation.QuickTest)9 Test (org.junit.Test)9 VersionedObject (com.hazelcast.collection.impl.queue.model.VersionedObject)8 ClientMessage (com.hazelcast.client.impl.protocol.ClientMessage)1 ClientInvocation (com.hazelcast.client.impl.spi.impl.ClientInvocation)1 ArrayList (java.util.ArrayList)1