- 1. Overview
- 1. 概述
- 2. Configuration
- 2. 配置方法
- 3. Operations execution
- 3. 程序接口调用方式
- 4. Data serialization
- 4. 数据序列化
- 5. Data partitioning(sharding)
- 5. 单个集合数据分片(Sharding)
- 5.1. Common operations over objects
- 6. Distributed objects
- 6. 分布式对象
- 7. Distributed collections
- 7. 分布式集合
- 8. Distributed locks and synchronizers
- 8. 分布式锁和同步器
- 9. Distributed services
- 9. 分布式服务
- 10. Additional features
- 10. 额外功能
- 11. Redis commands mapping
- 11. Redis 命令和 Redisson 对象匹配列表
- 12. Standalone node
- 12. 独立节点模式
- 13. Tools
- 13. 工具
- 14. Integration with frameworks
- 14. 第三方框架整合
- 15. Dependency list
- 15. 项目依赖列表
- 16. FAQ
- 16. Observability
12. Standalone node
12.1. Overview
Redisson offers ability to run as standalone node and participate in distributed computing. Such Nodes are used to run MapReduce, ExecutorService, ScheduledExecutorService tasks or RemoteService services. All tasks are kept in Redis until their execution moment.
Packaged as a single jar and could be downloaded.
12.2. Configuration
12.2.1. Configuration. Settings
Redisson node uses same configuration as Redisson framework with additional settings. Threads amount available for ExecutorService set through threads
setting
mapReduceWorkers
Default value: 0
MapReduce workers amount. 0 = current_processors_amount
executorServiceWorkers
Default value: null
Map with key as service name and value as workers amount.
redissonNodeInitializer
Default value: null
Listener runs during Redisson node startup.
beanFactory
Default value: null
Defines Spring Bean Factory instance to execute tasks with Spring's '@Autowired', '@Value' or JSR-330's '@Inject' annotation. Please refer to documentation for ExecutorService and [ScheduledExecutorService]
12.2.2. Configuration. YAML config format
Below is the configuration example for cluster mode with appended Redisson node settings in YAML format.
---
clusterServersConfig:
nodeAddresses:
- "//127.0.0.1:7004"
- "//127.0.0.1:7001"
- "//127.0.0.1:7000"
scanInterval: 1000
threads: 0
executorServiceWorkers:
myService1: 123
myService2: 421
redissonNodeInitializer: !<org.mycompany.MyRedissonNodeInitializer> {}
12.3. Initialization listener
Redisson node allows to execute initialization logic during startup via RedissonNodeInitializer
listener. It allows, for example, register your remote service implementations which should be available in Redisson node's classpath, or execute other useful logic. For example, notify all subscribers about new Redisson node is available.
public class MyRedissonNodeInitializer implements RedissonNodeInitializer {
@Override
public void onStartup(RedissonNode redissonNode) {
RMap<String, Integer> map = redissonNode.getRedisson().getMap("myMap");
// ...
// or
redisson.getRemoteService("myRemoteService").register(MyRemoteService.class, new MyRemoteServiceImpl(...));
// or
reidsson.getTopic("myNotificationTopic").publish("New node has joined. id:" + redissonNode.getId() + " remote-server:" + redissonNode.getRemoteAddress());
}
}
12.4. How to run as embedded node
Redisson node can be embedded into your application:
// Redisson config
Config config = ...
// Redisson Node config
RedissonNodeConfig nodeConfig = new RedissonNodeConfig(config);
Map<String, Integer> workers = new HashMap<String, Integer>();
workers.put("test", 1);
nodeConfig.setExecutorServiceWorkers(workers);
// create Redisson node
RedissonNode node = RedissonNode.create(nodeConfig);
// or create Redisson node with existing Redisson instance
RedissonNode node = RedissonNode.create(nodeConfig, redisson);
node.start();
//...
node.shutdown();
12.5. How to run from command-line
- Download Redisson node jar
- Create yaml configuration file
- Run node using follow command line:
java -jar redisson-all.jar config.yaml
don't forget to add -Xmx
and -Xms
params
12.6. How to run using Docker
with Redis instance
- Run Redis
docker run -d --name redis-node redis
Redisson Node
docker run -d --network container:redis-node -e JAVA_OPTS="<java-opts>" -v <path-to-config>:/opt/redisson-node/redisson.conf redisson/redisson-node
<path-to-config>
- path to YAML configuration of Redisson Node<java-opts>
- JVM params
without Redis instance
Redisson Node
docker run -d -e JAVA_OPTS="<java-opts>" -v <path-to-config>:/opt/redisson-node/redisson.conf redisson/redisson-node
<path-to-config>
- path to YAML configuration of Redisson Node<java-opts>
- JVM params
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论