Search in sources :

Example 1 with ScheduledTaskStatistics

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);
}
Also used : IScheduledFuture(com.hazelcast.scheduledexecutor.IScheduledFuture) HazelcastInstance(com.hazelcast.core.HazelcastInstance) IScheduledExecutorService(com.hazelcast.scheduledexecutor.IScheduledExecutorService) ScheduledTaskStatistics(com.hazelcast.scheduledexecutor.ScheduledTaskStatistics) ICountDownLatch(com.hazelcast.cp.ICountDownLatch) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) Test(org.junit.Test) SlowTest(com.hazelcast.test.annotation.SlowTest)

Example 2 with ScheduledTaskStatistics

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));
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) IScheduledExecutorService(com.hazelcast.scheduledexecutor.IScheduledExecutorService) ScheduledTaskStatistics(com.hazelcast.scheduledexecutor.ScheduledTaskStatistics) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 3 with ScheduledTaskStatistics

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));
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) IScheduledExecutorService(com.hazelcast.scheduledexecutor.IScheduledExecutorService) ScheduledTaskStatistics(com.hazelcast.scheduledexecutor.ScheduledTaskStatistics) Member(com.hazelcast.cluster.Member) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 4 with ScheduledTaskStatistics

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);
}
Also used : IScheduledFuture(com.hazelcast.scheduledexecutor.IScheduledFuture) HazelcastInstance(com.hazelcast.core.HazelcastInstance) IScheduledExecutorService(com.hazelcast.scheduledexecutor.IScheduledExecutorService) ScheduledTaskStatistics(com.hazelcast.scheduledexecutor.ScheduledTaskStatistics) ICountDownLatch(com.hazelcast.cp.ICountDownLatch) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) Test(org.junit.Test) SlowTest(com.hazelcast.test.annotation.SlowTest)

Aggregations

HazelcastInstance (com.hazelcast.core.HazelcastInstance)4 IScheduledExecutorService (com.hazelcast.scheduledexecutor.IScheduledExecutorService)4 ScheduledTaskStatistics (com.hazelcast.scheduledexecutor.ScheduledTaskStatistics)4 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)4 Test (org.junit.Test)4 ICountDownLatch (com.hazelcast.cp.ICountDownLatch)2 IScheduledFuture (com.hazelcast.scheduledexecutor.IScheduledFuture)2 QuickTest (com.hazelcast.test.annotation.QuickTest)2 SlowTest (com.hazelcast.test.annotation.SlowTest)2 Member (com.hazelcast.cluster.Member)1