Java Code Examples for org.redisson.config.Config#useClusterServers()
The following examples show how to use
org.redisson.config.Config#useClusterServers() .
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: TioRedisClusterProperties.java From tio-starters with MIT License | 6 votes |
public Config getClusterOrSentinelConfig() { Config config = new Config(); if( CLUSTER.equals(mode) ) { ClusterServersConfig clusterServersConfig = config.useClusterServers(); BeanUtils.copyProperties(this.cluster, clusterServersConfig, ClusterServersConfig.class); this.cluster.getNodeAddresses().parallelStream().forEach( node -> { clusterServersConfig.addNodeAddress( node.toString() ); }); } else if( SENTINEL.equals(mode) ) { SentinelServersConfig sentinelServersConfig = config.useSentinelServers(); BeanUtils.copyProperties(this.sentinel, sentinelServersConfig, SentinelServersConfig.class); this.sentinel.getSentinelAddresses().parallelStream().forEach( node -> { sentinelServersConfig.addSentinelAddress( node.toString() ); }); } return config; }
Example 2
Source File: RedissonManager.java From game-server with MIT License | 6 votes |
/** * 连接服务器 * * @author JiangZhiYong * @QQ 359135103 2017年9月15日 下午3:36:06 * @param configPath */ public static void connectRedis(String configPath) { if (redisson != null) { LOGGER.warn("Redisson客户端已经连接"); } redissonClusterConfig = FileUtil.getConfigXML(configPath, "redissonClusterConfig.xml", RedissonClusterConfig.class); if (redissonClusterConfig == null) { LOGGER.warn("{}/redissonClusterConfig.xml文件不存在", configPath); System.exit(0); } Config config = new Config(); config.setCodec(new FastJsonCodec()); ClusterServersConfig clusterServersConfig = config.useClusterServers(); clusterServersConfig.setScanInterval(redissonClusterConfig.getScanInterval()); // 集群状态扫描间隔时间,单位是毫秒 // 可以用"rediss://"来启用SSL连接 redissonClusterConfig.getNodes().forEach(url -> clusterServersConfig.addNodeAddress(url)); clusterServersConfig.setReadMode(redissonClusterConfig.getReadMode()); clusterServersConfig.setSubscriptionMode(redissonClusterConfig.getSubscriptionMode()); redisson = Redisson.create(config); }
Example 3
Source File: TioRedisClusterProperties.java From t-io with Apache License 2.0 | 6 votes |
public Config getClusterOrSentinelConfig() { Config config = new Config(); if( CLUSTER.equals(mode) ) { ClusterServersConfig clusterServersConfig = config.useClusterServers(); BeanUtils.copyProperties(this.cluster, clusterServersConfig, ClusterServersConfig.class); this.cluster.getNodeAddresses().parallelStream().forEach( node -> { clusterServersConfig.addNodeAddress( node.toString() ); }); } else if( SENTINEL.equals(mode) ) { SentinelServersConfig sentinelServersConfig = config.useSentinelServers(); BeanUtils.copyProperties(this.sentinel, sentinelServersConfig, SentinelServersConfig.class); this.sentinel.getSentinelAddresses().parallelStream().forEach( node -> { sentinelServersConfig.addSentinelAddress( node.toString() ); }); } return config; }
Example 4
Source File: RedisAtomConfig.java From Milkomeda with MIT License | 5 votes |
@Bean @ConditionalOnProperty(prefix = "milkomeda.atom.redis", name = "use-cluster", havingValue = "true") public RedissonClient clusterRedissonClient() { Config config = new Config(); ClusterServersConfig clusterServersConfig = config.useClusterServers(); for (String node : redisProperties.getCluster().getNodes()) { clusterServersConfig.addNodeAddress(String.format("redis://%s", node)); } clusterServersConfig.setPassword(redisProperties.getPassword()); if (redisProperties.getTimeout() != null) { clusterServersConfig.setTimeout((int) redisProperties.getTimeout().toMillis()); } return Redisson.create(config); }