use of org.redisson.RedissonNode in project redisson by redisson.
the class RedissonScheduledExecutorServiceTest method testLoad.
@Test
public void testLoad() throws InterruptedException {
Config config = createConfig();
RedissonNodeConfig nodeConfig = new RedissonNodeConfig(config);
nodeConfig.setExecutorServiceWorkers(Collections.singletonMap("test2", Runtime.getRuntime().availableProcessors() * 2));
RedissonNode node = RedissonNode.create(nodeConfig);
node.start();
List<RScheduledFuture<?>> futures = new ArrayList<>();
for (int i = 0; i < 10000; i++) {
RScheduledFuture<?> future = redisson.getExecutorService("test2").scheduleAsync(new RunnableTask(), 5, TimeUnit.SECONDS);
futures.add(future);
}
for (RScheduledFuture<?> future : futures) {
try {
future.toCompletableFuture().get(5100, TimeUnit.MILLISECONDS);
} catch (TimeoutException e) {
Assertions.fail(e);
} catch (ExecutionException e) {
// skip
}
}
node.shutdown();
}
use of org.redisson.RedissonNode in project redisson by redisson.
the class RedissonScheduledExecutorServiceTest method testSingleWorker.
@Test
public void testSingleWorker() throws InterruptedException {
Config config = createConfig();
RedissonNodeConfig nodeConfig = new RedissonNodeConfig(config);
nodeConfig.getExecutorServiceWorkers().put("JobA", 1);
RedissonNode node = RedissonNode.create(nodeConfig);
node.start();
RedissonClient client = Redisson.create(config);
RScheduledExecutorService executorService = client.getExecutorService("JobA");
executorService.schedule(new TestTask(), CronSchedule.of("0/1 * * * * ?"));
TimeUnit.MILLISECONDS.sleep(4900);
assertThat(client.getAtomicLong("counter").get()).isEqualTo(4);
client.shutdown();
node.shutdown();
}
Aggregations