org.redisson.RedissonNode Java Examples
The following examples show how to use
org.redisson.RedissonNode.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ExecutorServiceExamples.java From redisson-examples with Apache License 2.0 | 6 votes |
public static void main(String[] args) { Config config = new Config(); config.useClusterServers() .addNodeAddress("127.0.0.1:7001", "127.0.0.1:7002", "127.0.0.1:7003"); RedissonClient redisson = Redisson.create(config); RedissonNodeConfig nodeConfig = new RedissonNodeConfig(config); nodeConfig.setExecutorServiceWorkers(Collections.singletonMap("myExecutor", 1)); RedissonNode node = RedissonNode.create(nodeConfig); node.start(); RExecutorService e = redisson.getExecutorService("myExecutor"); e.execute(new RunnableTask()); e.submit(new CallableTask()); e.shutdown(); node.shutdown(); }
Example #2
Source File: SchedulerServiceExamples.java From redisson-examples with Apache License 2.0 | 6 votes |
public static void main(String[] args) { Config config = new Config(); config.useClusterServers() .addNodeAddress("127.0.0.1:7001", "127.0.0.1:7002", "127.0.0.1:7003"); RedissonClient redisson = Redisson.create(config); RedissonNodeConfig nodeConfig = new RedissonNodeConfig(config); nodeConfig.setExecutorServiceWorkers(Collections.singletonMap("myExecutor", 5)); RedissonNode node = RedissonNode.create(nodeConfig); node.start(); RScheduledExecutorService e = redisson.getExecutorService("myExecutor"); e.schedule(new RunnableTask(), 10, TimeUnit.SECONDS); e.schedule(new CallableTask(), 4, TimeUnit.MINUTES); e.schedule(new RunnableTask(), CronSchedule.of("10 0/5 * * * ?")); e.schedule(new RunnableTask(), CronSchedule.dailyAtHourAndMinute(10, 5)); e.schedule(new RunnableTask(), CronSchedule.weeklyOnDayAndHourAndMinute(12, 4, Calendar.MONDAY, Calendar.FRIDAY)); e.shutdown(); node.shutdown(); }
Example #3
Source File: RedissonScheduledExecutorServiceTest.java From redisson with Apache License 2.0 | 6 votes |
@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(); }
Example #4
Source File: RedissonScheduledExecutorServiceTest.java From redisson with Apache License 2.0 | 6 votes |
@Test(timeout = 7000) public void testTaskResume() throws InterruptedException, ExecutionException { RScheduledExecutorService executor = redisson.getExecutorService("test"); ScheduledFuture<Long> future1 = executor.schedule(new ScheduledCallableTask(), 5, TimeUnit.SECONDS); ScheduledFuture<Long> future2 = executor.schedule(new ScheduledCallableTask(), 5, TimeUnit.SECONDS); ScheduledFuture<Long> future3 = executor.schedule(new ScheduledCallableTask(), 5, TimeUnit.SECONDS); node.shutdown(); RedissonNodeConfig nodeConfig = new RedissonNodeConfig(redisson.getConfig()); nodeConfig.setExecutorServiceWorkers(Collections.singletonMap("test", 1)); node = RedissonNode.create(nodeConfig); node.start(); assertThat(future1.get()).isEqualTo(100); assertThat(future2.get()).isEqualTo(100); assertThat(future3.get()).isEqualTo(100); }
Example #5
Source File: RedissonScheduledExecutorServiceTest.java From redisson with Apache License 2.0 | 5 votes |
@Before @Override public void before() throws IOException, InterruptedException { super.before(); Config config = createConfig(); RedissonNodeConfig nodeConfig = new RedissonNodeConfig(config); nodeConfig.setExecutorServiceWorkers(Collections.singletonMap("test", 1)); node = RedissonNode.create(nodeConfig); node.start(); }
Example #6
Source File: RedissonExecutorServiceSpringTest.java From redisson with Apache License 2.0 | 5 votes |
@Bean(destroyMethod = "shutdown") RedissonNode redissonNode(BeanFactory beanFactory) { Config config = BaseTest.createConfig(); RedissonNodeConfig nodeConfig = new RedissonNodeConfig(config); nodeConfig.setExecutorServiceWorkers(Collections.singletonMap(EXECUTOR_NAME, 1)); nodeConfig.setBeanFactory(beanFactory); RedissonNode node = RedissonNode.create(nodeConfig); node.start(); return node; }
Example #7
Source File: RedissonNodeInitializer.java From redisson with Apache License 2.0 | 2 votes |
/** * Invoked during Redisson Node startup * * @param redissonNode - Redisson Node instance */ void onStartup(RedissonNode redissonNode);