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