Search in sources :

Example 6 with LocalQueueStats

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

the class QueueStatisticsTest method testAge.

@Test
public void testAge() {
    IQueue<String> queue = newQueue();
    queue.offer("maxAgeItem");
    queue.offer("minAgeItem");
    LocalQueueStats stats = queue.getLocalQueueStats();
    long maxAge = stats.getMaxAge();
    long minAge = stats.getMinAge();
    long testAge = (maxAge + minAge) / 2;
    long avgAge = stats.getAvgAge();
    assertEquals(testAge, avgAge);
}
Also used : LocalQueueStats(com.hazelcast.monitor.LocalQueueStats) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 7 with LocalQueueStats

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

the class QueueStatisticsTest method testPollOperationCount.

@Test
public void testPollOperationCount() throws Exception {
    IQueue<String> queue = newQueue();
    for (int i = 0; i < 30; i++) {
        queue.offer("item" + i);
    }
    for (int i = 0; i < 10; i++) {
        queue.remove();
    }
    for (int i = 0; i < 10; i++) {
        queue.take();
    }
    for (int i = 0; i < 10; i++) {
        queue.poll();
    }
    final LocalQueueStats stats = queue.getLocalQueueStats();
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() throws Exception {
            assertEquals(30, stats.getPollOperationCount());
        }
    });
}
Also used : LocalQueueStats(com.hazelcast.monitor.LocalQueueStats) AssertTask(com.hazelcast.test.AssertTask) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 8 with LocalQueueStats

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

the class QueueStatisticsTest method testEmptyPollOperationCount.

@Test
public void testEmptyPollOperationCount() {
    IQueue<String> queue = newQueue();
    for (int i = 0; i < 10; i++) {
        queue.poll();
    }
    final LocalQueueStats stats = queue.getLocalQueueStats();
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() throws Exception {
            assertEquals(10, stats.getEmptyPollOperationCount());
        }
    });
}
Also used : LocalQueueStats(com.hazelcast.monitor.LocalQueueStats) AssertTask(com.hazelcast.test.AssertTask) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 9 with LocalQueueStats

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

the class QueueStatisticsTest method testRejectedOfferOperationCount.

@Test
public void testRejectedOfferOperationCount() {
    IQueue<String> queue = newQueue_WithMaxSizeConfig(30);
    for (int i = 0; i < 30; i++) {
        queue.offer("item" + i);
    }
    for (int i = 0; i < 10; i++) {
        queue.offer("item" + i);
    }
    final LocalQueueStats stats = queue.getLocalQueueStats();
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() throws Exception {
            assertEquals(10, stats.getRejectedOfferOperationCount());
        }
    });
}
Also used : LocalQueueStats(com.hazelcast.monitor.LocalQueueStats) AssertTask(com.hazelcast.test.AssertTask) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 10 with LocalQueueStats

use of com.hazelcast.monitor.LocalQueueStats in project Activiti by Activiti.

the class HazelCastDistributedQueueBasedAsyncExecutor method shutdown.

@Override
public void shutdown() {
    super.shutdown();
    // Shut down local execution service
    try {
        logger.info("Shutting down local executor service");
        executorService.shutdown();
        executorService.awaitTermination(secondsToWaitOnShutdown, TimeUnit.SECONDS);
    } catch (InterruptedException e) {
        logger.warn("Exception while waiting for executor service shutdown", e);
    }
    // Shut down hazelcast
    try {
        LocalQueueStats localQueueStats = jobQueue.getLocalQueueStats();
        logger.info("This async job executor has processed " + localQueueStats.getPollOperationCount());
        hazelcastInstance.shutdown();
    } catch (HazelcastInstanceNotActiveException e) {
    // Nothing to do
    }
    // Shut down listener thread
    isActive = false;
    try {
        logger.info("Shutting down jobQueueListenerThread");
        jobQueueListenerThread.interrupt();
        jobQueueListenerThread.join();
    } catch (InterruptedException e) {
        logger.warn("jobQueueListenerThread join was interrupted", e);
    }
}
Also used : LocalQueueStats(com.hazelcast.monitor.LocalQueueStats) HazelcastInstanceNotActiveException(com.hazelcast.core.HazelcastInstanceNotActiveException)

Aggregations

LocalQueueStats (com.hazelcast.monitor.LocalQueueStats)10 QuickTest (com.hazelcast.test.annotation.QuickTest)8 Test (org.junit.Test)8 AssertTask (com.hazelcast.test.AssertTask)6 HazelcastInstanceNotActiveException (com.hazelcast.core.HazelcastInstanceNotActiveException)1 ArrayList (java.util.ArrayList)1