本文整理了Java中org.redisson.config.Config.useMasterSlaveServers()
方法的一些代码示例,展示了Config.useMasterSlaveServers()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Config.useMasterSlaveServers()
方法的具体详情如下:
包路径:org.redisson.config.Config
类名称:Config
方法名:useMasterSlaveServers
[英]Init master/slave servers configuration.
[中]初始化主/从服务器配置。
代码示例来源:origin: redisson/redisson
/**
* Init master/slave servers configuration.
*
* @return MasterSlaveServersConfig
*/
public MasterSlaveServersConfig useMasterSlaveServers() {
return useMasterSlaveServers(new MasterSlaveServersConfig());
}
代码示例来源:origin: redisson/redisson
/**
* Init master/slave servers configuration.
*
* @return MasterSlaveServersConfig
*/
public MasterSlaveServersConfig useMasterSlaveServers() {
return useMasterSlaveServers(new MasterSlaveServersConfig());
}
代码示例来源:origin: zhegexiaohuozi/SeimiCrawler
/**
* Init master/slave servers configuration.
*
* config.useMasterSlaveServers()
* //可以用"rediss://"来启用SSL连接
* .setMasterAddress("redis://127.0.0.1:6379")
* .addSlaveAddress("redis://127.0.0.1:6389", "redis://127.0.0.1:6332", "redis://127.0.0.1:6419")
* .addSlaveAddress("redis://127.0.0.1:6399");
*
* @return MasterSlaveServersConfig
*/
public MasterSlaveServersConfig redisMasterSlaveServers() {
enableDistributedQueue();
return redissonConfig.useMasterSlaveServers();
}
/**
代码示例来源:origin: org.redisson/redisson
/**
* Init master/slave servers configuration.
*
* @return MasterSlaveServersConfig
*/
public MasterSlaveServersConfig useMasterSlaveServers() {
return useMasterSlaveServers(new MasterSlaveServersConfig());
}
代码示例来源:origin: TaXueWWL/redis-distributed-lock
@Override
public Config createRedissonConfig(String address) {
Config config = new Config();
try {
String[] addrTokens = address.split(",");
String masterNodeAddr = addrTokens[0];
/**设置主节点ip*/
config.useMasterSlaveServers().setMasterAddress(masterNodeAddr);
/**设置从节点,移除第一个节点,默认第一个为主节点*/
List<String> slaveList = new ArrayList<>();
for (String addrToken : addrTokens) {
slaveList.add(GlobalConstant.REDIS_CONNECTION_PREFIX.getConstant_value() + addrToken);
}
slaveList.remove(0);
config.useMasterSlaveServers().addSlaveAddress((String[]) slaveList.toArray());
LOGGER.info("初始化[MASTERSLAVE]方式Config,redisAddress:" + address);
} catch (Exception e) {
LOGGER.error("MASTERSLAVE Redisson init error", e);
e.printStackTrace();
}
return config;
}
代码示例来源:origin: huangjian888/jeeweb-mybatis-springboot
public RedissonClient getRedissonClient() {
Config config = new Config();
if (StringUtils.isNotBlank(address)) {
SingleServerConfig serverConfig = config.useSingleServer().setAddress(address);
if (StringUtils.isNotBlank(password)) {
serverConfig.setPassword(password);
}
serverConfig.setTimeout(timeout);
} else if (!nodeAddresses.isEmpty()) {
ClusterServersConfig serverConfig = config.useClusterServers()
.addNodeAddress(nodeAddresses.toArray(new String[] {}));
if (StringUtils.isNotBlank(password)) {
serverConfig.setPassword(password);
}
serverConfig.setTimeout(timeout);
} else if (masterAddress != null && !slaveAddresses.isEmpty()) {
MasterSlaveServersConfig serverConfig = config.useMasterSlaveServers().setMasterAddress(masterAddress)
.addSlaveAddress(slaveAddresses.toArray(new String[] {}));
if (StringUtils.isNotBlank(password)) {
serverConfig.setPassword(password);
}
serverConfig.setTimeout(timeout);
}
return Redisson.create(config);
}
代码示例来源:origin: youngMen1/JAVA-
slaveAddresses.add(redisNode.getHost() + ":" + redisNode.getPort());
MasterSlaveServersConfig serverConfig = config.useMasterSlaveServers()
.setMasterAddress(slaveAddresses.get(0));
slaveAddresses.remove(0);
代码示例来源:origin: justlive1/earth-frost
/**
* 主从模式
*
* @param redissonProperties
* @return client
*/
private RedissonClient redissonuseMasterSlaveServers(RedissonProperties redissonProperties) {
Config config = new Config();
MasterSlaveServersConfig serverConfig =
config.useMasterSlaveServers().setMasterAddress(redissonProperties.getMasterAddress())
.addSlaveAddress(redissonProperties.getSlaveAddresses())
.setTimeout(redissonProperties.getTimeout())
.setDnsMonitoringInterval(redissonProperties.getDnsMonitoringInterval())
.setSlaveConnectionPoolSize(redissonProperties.getSlaveConnectionPoolSize())
.setMasterConnectionPoolSize(redissonProperties.getMasterConnectionPoolSize());
if (redissonProperties.getPassword() != null && redissonProperties.getPassword().length() > 0) {
serverConfig.setPassword(redissonProperties.getPassword());
}
return Redisson.create(config);
}
内容来源于网络,如有侵权,请联系作者删除!