org.redisson.config.Config.useSentinelServers()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(5.4k)|赞(0)|评价(0)|浏览(5503)

本文整理了Java中org.redisson.config.Config.useSentinelServers()方法的一些代码示例,展示了Config.useSentinelServers()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Config.useSentinelServers()方法的具体详情如下:
包路径:org.redisson.config.Config
类名称:Config
方法名:useSentinelServers

Config.useSentinelServers介绍

[英]Init sentinel servers configuration.
[中]初始化sentinel服务器配置。

代码示例

代码示例来源:origin: redisson/redisson

/**
 * Init sentinel servers configuration.
 *
 * @return SentinelServersConfig
 */
public SentinelServersConfig useSentinelServers() {
  return useSentinelServers(new SentinelServersConfig());
}

代码示例来源:origin: redisson/redisson

/**
 * Init sentinel servers configuration.
 *
 * @return SentinelServersConfig
 */
public SentinelServersConfig useSentinelServers() {
  return useSentinelServers(new SentinelServersConfig());
}

代码示例来源:origin: zhegexiaohuozi/SeimiCrawler

/**
 * Init sentinel servers configuration.
 *
 * config.useSentinelServers()
 *     .setMasterName("mymaster")
 *     //可以用"rediss://"来启用SSL连接
 *     .addSentinelAddress("redis://127.0.0.1:26389", "redis://127.0.0.1:26379")
 *     .addSentinelAddress("redis://127.0.0.1:26319");
 *
 * @return SentinelServersConfig
 */
public SentinelServersConfig redisSentinelServers() {
  enableDistributedQueue();
  return redissonConfig.useSentinelServers();
}

代码示例来源:origin: redisson/redisson

config.useSentinelServers()
  .setMasterName(redisProperties.getSentinel().getMaster())
  .addSentinelAddress(nodes)

代码示例来源:origin: org.redisson/redisson

/**
 * Init sentinel servers configuration.
 *
 * @return SentinelServersConfig
 */
public SentinelServersConfig useSentinelServers() {
  return useSentinelServers(new SentinelServersConfig());
}

代码示例来源:origin: TaXueWWL/redis-distributed-lock

@Override
  public Config createRedissonConfig(String address) {
    Config config = new Config();
    try {
      String[] addrTokens = address.split(",");
      String sentinelAliasName = addrTokens[0];
      /**设置redis配置文件sentinel.conf配置的sentinel别名*/
      config.useSentinelServers()
          .setMasterName(sentinelAliasName);
      /**设置sentinel节点的服务IP和端口*/
      for (int i = 1; i < addrTokens.length; i++) {
        config.useSentinelServers().addSentinelAddress(GlobalConstant.REDIS_CONNECTION_PREFIX.getConstant_value() + addrTokens[i]);
      }
      LOGGER.info("初始化[sentinel]方式Config,redisAddress:" + address);
    } catch (Exception e) {
      LOGGER.error("sentinel Redisson init error", e);
      e.printStackTrace();
    }
    return config;
  }
}

代码示例来源:origin: dufyun/learn-tech-collection

/**
 * 初始化Redisson,使用哨兵模式
 */
public static void init(){
  try {
    config.useSentinelServers()
        .setMasterName("mymaster")
        .addSentinelAddress("127.0.0.1:26379","127.0.0.1:26479", "127.0.0.1:26579")
        //同任何节点建立连接时的等待超时。时间单位是毫秒。默认:10000
        .setConnectTimeout(30000)
        //当与某个节点的连接断开时,等待与其重新建立连接的时间间隔。时间单位是毫秒。默认:3000
        .setReconnectionTimeout(10000)
        //等待节点回复命令的时间。该时间从命令发送成功时开始计时。默认:3000
        .setTimeout(10000)
        //如果尝试达到 retryAttempts(命令失败重试次数) 仍然不能将命令发送至某个指定的节点时,将抛出错误。如果尝试在此限制之内发送成功,则开始启用 timeout(命令等待超时) 计时。默认值:3
        .setRetryAttempts(5)
        //在一条命令发送失败以后,等待重试发送的时间间隔。时间单位是毫秒。     默认值:1500
        .setRetryInterval(3000)
    ;
    redissonClient = Redisson.create(config);
  }catch (Exception e){
    e.printStackTrace();
  }
}
/**

代码示例来源:origin: justlive1/earth-frost

/**
 * 哨兵模式
 * 
 * @param redissonProperties
 * @return client
 */
private RedissonClient redissonuseSentinelServers(RedissonProperties redissonProperties) {
 Config config = new Config();
 SentinelServersConfig serverConfig =
   config.useSentinelServers().addSentinelAddress(redissonProperties.getSentinelAddresses())
     .setTimeout(redissonProperties.getTimeout())
     .setScanInterval(redissonProperties.getScanInterval())
     .setMasterName(redissonProperties.getMasterName())
     .setSlaveConnectionPoolSize(redissonProperties.getSlaveConnectionPoolSize())
     .setMasterConnectionPoolSize(redissonProperties.getMasterConnectionPoolSize());
 if (redissonProperties.getPassword() != null && redissonProperties.getPassword().length() > 0) {
  serverConfig.setPassword(redissonProperties.getPassword());
 }
 return Redisson.create(config);
}

代码示例来源:origin: linux-china/spring-boot-starter-redisson

@Bean
  public RedissonClient redissonClient() {
    Config config = new Config();
    //sentinel
    if (redisProperties.getSentinel() != null) {
      SentinelServersConfig sentinelServersConfig = config.useSentinelServers();
      sentinelServersConfig.setMasterName(redisProperties.getSentinel().getMaster());
      redisProperties.getSentinel().getNodes();
      sentinelServersConfig.addSentinelAddress(redisProperties.getSentinel().getNodes().split(","));
      sentinelServersConfig.setDatabase(redisProperties.getDatabase());
      if (redisProperties.getPassword() != null) {
        sentinelServersConfig.setPassword(redisProperties.getPassword());
      }
    } else { //single server
      SingleServerConfig singleServerConfig = config.useSingleServer();
      // format as redis://127.0.0.1:7181 or rediss://127.0.0.1:7181 for SSL
      String schema = redisProperties.isSsl() ? "rediss://" : "redis://";
      singleServerConfig.setAddress(schema + redisProperties.getHost() + ":" + redisProperties.getPort());
      singleServerConfig.setDatabase(redisProperties.getDatabase());
      if (redisProperties.getPassword() != null) {
        singleServerConfig.setPassword(redisProperties.getPassword());
      }
    }
    return Redisson.create(config);
  }
}

代码示例来源:origin: io.lsn.spring/utilities

SentinelServersConfig sentinelServersConfig = config.useSentinelServers();
sentinelServersConfig.setMasterName(redisProperties.getSentinel().getMaster());
redisProperties.getSentinel().getNodes();

代码示例来源:origin: io.lsn/spring-core

SentinelServersConfig sentinelServersConfig = config.useSentinelServers();
sentinelServersConfig.setMasterName(redisProperties.getSentinel().getMaster());
redisProperties.getSentinel().getNodes();

相关文章