use of com.hazelcast.scheduledexecutor.ScheduledTaskStatistics in project hazelcast by hazelcast.
the class ScheduledExecutorServiceSlowTest method stats_longRunningTask_durable.
@Test
public void stats_longRunningTask_durable() throws Exception {
HazelcastInstance[] instances = createClusterWithCount(4);
String key = generateKeyOwnedBy(instances[1]);
ICountDownLatch firstLatch = instances[0].getCPSubsystem().getCountDownLatch("firstLatch");
firstLatch.trySetCount(2);
ICountDownLatch lastLatch = instances[0].getCPSubsystem().getCountDownLatch("lastLatch");
lastLatch.trySetCount(6);
IScheduledExecutorService executorService = getScheduledExecutor(instances, "s");
IScheduledFuture future = executorService.scheduleOnKeyOwnerAtFixedRate(new ICountdownLatchRunnableTask("firstLatch", "lastLatch"), key, 0, 10, SECONDS);
firstLatch.await(12, SECONDS);
instances[1].getLifecycleService().shutdown();
lastLatch.await(70, SECONDS);
// wait for run-cycle to finish before cancelling, in order for stats to get updated
sleepSeconds(4);
future.cancel(false);
ScheduledTaskStatistics stats = future.getStats();
assertEquals(6, stats.getTotalRuns(), 1);
}
use of com.hazelcast.scheduledexecutor.ScheduledTaskStatistics in project hazelcast by hazelcast.
the class ScheduledExecutorServiceBasicTest method stats.
@Test
public void stats() throws Exception {
double delay = 2.0;
HazelcastInstance[] instances = createClusterWithCount(2);
Object key = generateKeyOwnedBy(instances[1]);
IScheduledExecutorService executorService = getScheduledExecutor(instances, ANY_EXECUTOR_NAME);
IScheduledFuture<Double> future = executorService.scheduleOnKeyOwner(new PlainCallableTask(), key, (int) delay, SECONDS);
future.get();
ScheduledTaskStatistics stats = future.getStats();
assertEquals(1, stats.getTotalRuns());
assertEquals(0, stats.getLastRunDuration(SECONDS));
assertEquals(0, stats.getTotalRunTime(SECONDS));
assertNotEquals(0, stats.getLastIdleTime(SECONDS));
assertNotEquals(0, stats.getTotalIdleTime(SECONDS));
}
use of com.hazelcast.scheduledexecutor.ScheduledTaskStatistics in project hazelcast by hazelcast.
the class ScheduledExecutorServiceBasicTest method stats_whenMemberOwned.
@Test
public void stats_whenMemberOwned() throws Exception {
double delay = 2.0;
HazelcastInstance[] instances = createClusterWithCount(2);
Member localMember = instances[0].getCluster().getLocalMember();
IScheduledExecutorService executorService = getScheduledExecutor(instances, ANY_EXECUTOR_NAME);
IScheduledFuture<Double> future = executorService.scheduleOnMember(new PlainCallableTask(), localMember, (int) delay, SECONDS);
future.get();
ScheduledTaskStatistics stats = future.getStats();
assertEquals(1, stats.getTotalRuns());
assertEquals(0, stats.getLastRunDuration(SECONDS));
assertEquals(0, stats.getTotalRunTime(SECONDS));
assertNotEquals(0, stats.getLastIdleTime(SECONDS));
assertNotEquals(0, stats.getTotalIdleTime(SECONDS));
}
use of com.hazelcast.scheduledexecutor.ScheduledTaskStatistics in project hazelcast by hazelcast.
the class ScheduledExecutorServiceSlowTest method stats_manyRepetitionsTask.
@Test
public void stats_manyRepetitionsTask() throws Exception {
HazelcastInstance[] instances = createClusterWithCount(4);
ICountDownLatch latch = instances[0].getCPSubsystem().getCountDownLatch("latch");
latch.trySetCount(6);
IScheduledExecutorService executorService = getScheduledExecutor(instances, "s");
IScheduledFuture future = executorService.scheduleAtFixedRate(new ICountdownLatchRunnableTask("latch"), 0, 10, SECONDS);
latch.await(120, SECONDS);
future.cancel(false);
ScheduledTaskStatistics stats = future.getStats();
assertEquals(6, stats.getTotalRuns(), 1);
}
Aggregations