|
|
|
@ -161,7 +161,7 @@ public class RedissonScheduledExecutorServiceTest extends BaseTest {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testDelay() throws InterruptedException {
|
|
|
|
|
public void testDelay() {
|
|
|
|
|
RScheduledExecutorService executor = redisson.getExecutorService("test", ExecutorOptions.defaults().taskRetryInterval(5, TimeUnit.SECONDS));
|
|
|
|
|
long start = System.currentTimeMillis();
|
|
|
|
|
RScheduledFuture<?> f = executor.schedule(new ScheduledCallableTask(), 11, TimeUnit.SECONDS);
|
|
|
|
@ -281,9 +281,9 @@ public class RedissonScheduledExecutorServiceTest extends BaseTest {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testCronExpression() throws InterruptedException, ExecutionException {
|
|
|
|
|
public void testCronExpression() throws InterruptedException {
|
|
|
|
|
RScheduledExecutorService executor = redisson.getExecutorService("test");
|
|
|
|
|
executor.schedule(new ScheduledRunnableTask("executed"), CronSchedule.of("0/2 * * * * ?”"));
|
|
|
|
|
executor.schedule(new ScheduledRunnableTask("executed"), CronSchedule.of("0/2 * * * * ?"));
|
|
|
|
|
Thread.sleep(4000);
|
|
|
|
|
assertThat(redisson.getAtomicLong("executed").get()).isEqualTo(2);
|
|
|
|
|
}
|
|
|
|
@ -307,7 +307,7 @@ public class RedissonScheduledExecutorServiceTest extends BaseTest {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testWrongCronExpression() throws InterruptedException, ExecutionException {
|
|
|
|
|
public void testWrongCronExpression() {
|
|
|
|
|
Assertions.assertThrows(IllegalArgumentException.class, () -> {
|
|
|
|
|
RScheduledExecutorService executor = redisson.getExecutorService("test");
|
|
|
|
|
executor.schedule(new ScheduledRunnableTask("executed"), CronSchedule.of("0 44 12 19 JUN ? 2018"));
|
|
|
|
@ -315,7 +315,7 @@ public class RedissonScheduledExecutorServiceTest extends BaseTest {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testCronExpressionMultipleTasks() throws InterruptedException, ExecutionException {
|
|
|
|
|
public void testCronExpressionMultipleTasks() throws InterruptedException {
|
|
|
|
|
RScheduledExecutorService executor = redisson.getExecutorService("test", ExecutorOptions.defaults().taskRetryInterval(2, TimeUnit.SECONDS));
|
|
|
|
|
executor.schedule(new ScheduledRunnableTask("executed1"), CronSchedule.of("0/5 * * * * ?"));
|
|
|
|
|
executor.schedule(new ScheduledRunnableTask("executed2"), CronSchedule.of("0/1 * * * * ?"));
|
|
|
|
@ -338,7 +338,7 @@ public class RedissonScheduledExecutorServiceTest extends BaseTest {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testCancel2() throws InterruptedException {
|
|
|
|
|
public void testCancel2() {
|
|
|
|
|
Assertions.assertTimeout(Duration.ofSeconds(15), () -> {
|
|
|
|
|
RScheduledExecutorService e = redisson.getExecutorService("myExecutor");
|
|
|
|
|
e.registerWorkers(WorkerOptions.defaults());
|
|
|
|
@ -481,7 +481,7 @@ public class RedissonScheduledExecutorServiceTest extends BaseTest {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testCancelAtFixedDelay2() throws InterruptedException, ExecutionException {
|
|
|
|
|
public void testCancelAtFixedDelay2() throws InterruptedException {
|
|
|
|
|
RScheduledExecutorService executor = redisson.getExecutorService("test", ExecutorOptions.defaults().taskRetryInterval(30, TimeUnit.MINUTES));
|
|
|
|
|
executor.registerWorkers(WorkerOptions.defaults().workers(5));
|
|
|
|
|
RScheduledFuture<?> future1 = executor.scheduleWithFixedDelay(new ScheduledRunnableTask2("executed1"), 1, 2, TimeUnit.SECONDS);
|
|
|
|
|