Java Code Examples for org.springframework.data.redis.connection.RedisClusterConfiguration

The following examples show how to use org.springframework.data.redis.connection.RedisClusterConfiguration. These examples are extracted from open source projects. 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 Project: soul   Source File: RateLimiterPluginDataHandler.java    License: Apache License 2.0 5 votes vote down vote up
private RedisClusterConfiguration redisClusterConfiguration(final RateLimiterConfig rateLimiterConfig) {
    RedisClusterConfiguration config = new RedisClusterConfiguration();
    config.setClusterNodes(createRedisNode(rateLimiterConfig.getUrl()));
    if (rateLimiterConfig.getPassword() != null) {
        config.setPassword(RedisPassword.of(rateLimiterConfig.getPassword()));
    }
    return config;
}
 
Example 2
Source Project: spring-fu   Source File: JedisRedisInitializer.java    License: Apache License 2.0 5 votes vote down vote up
private JedisConnectionFactory getJedisConnectionFactory(GenericApplicationContext context) {
    final JedisConnectionConfiguration configuration = new JedisConnectionConfiguration(redisProperties, context.getBeanProvider(RedisSentinelConfiguration.class), context.getBeanProvider(RedisClusterConfiguration.class));
    try {
        return configuration.redisConnectionFactory(context.getBeanProvider(JedisClientConfigurationBuilderCustomizer.class));
    } catch (UnknownHostException e) {
        throw new IllegalStateException(e);
    }
}
 
Example 3
Source Project: spring-fu   Source File: LettuceRedisInitializer.java    License: Apache License 2.0 5 votes vote down vote up
private LettuceConnectionFactory getLettuceConnectionFactory(GenericApplicationContext context) {
    final LettuceConnectionConfiguration configuration = new LettuceConnectionConfiguration(redisProperties, context.getBeanProvider(RedisSentinelConfiguration.class), context.getBeanProvider(RedisClusterConfiguration.class));
    final ClientResources clientResources = DefaultClientResources.create();
    try {
        return configuration.redisConnectionFactory(context.getBeanProvider(LettuceClientConfigurationBuilderCustomizer.class), clientResources);
    } catch (UnknownHostException e) {
        throw new IllegalStateException(e);
    }
}
 
Example 4
Source Project: gateway-helper   Source File: MultiCacheAutoConfig.java    License: Apache License 2.0 5 votes vote down vote up
public RedisConfig(RedisProperties properties,
                   ObjectProvider<RedisSentinelConfiguration> sentinelConfiguration,
                   ObjectProvider<RedisClusterConfiguration> clusterConfiguration) {
    this.properties = properties;
    this.sentinelConfiguration = sentinelConfiguration.getIfAvailable();
    this.clusterConfiguration = clusterConfiguration.getIfAvailable();
}
 
Example 5
Source Project: api-gateway-old   Source File: MultiCacheAutoConfig.java    License: Apache License 2.0 5 votes vote down vote up
public RedisConfig(RedisProperties properties,
                   ObjectProvider<RedisSentinelConfiguration> sentinelConfiguration,
                   ObjectProvider<RedisClusterConfiguration> clusterConfiguration) {
    this.properties = properties;
    this.sentinelConfiguration = sentinelConfiguration.getIfAvailable();
    this.clusterConfiguration = clusterConfiguration.getIfAvailable();
}
 
Example 6
Source Project: tx-lcn   Source File: JedisClusterConfig.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * redisCluster配置
 * @return
 */
@Bean
public RedisClusterConfiguration redisClusterConfiguration() {
    Map<String, Object> source = new HashMap<String, Object>();
    source.put("spring.redis.cluster.nodes", redisProperties.getNodes());
    source.put("spring.redis.cluster.timeout", redisProperties.getCommandTimeout());
    return new RedisClusterConfiguration(new MapPropertySource("RedisClusterConfiguration", source));
}
 
Example 7
Source Project: pcc-like   Source File: AppConfig.java    License: Apache License 2.0 5 votes vote down vote up
public RedisClusterConfiguration redisClusterConfiguration() {
	RedisClusterConfiguration clusterConfig = new RedisClusterConfiguration();
	clusterConfig.clusterNode(env.getProperty("spring.redis.host"),
			Integer.parseInt(env.getProperty("spring.redis.port")));
	clusterConfig.setMaxRedirects(10000);
	return clusterConfig;
}
 
Example 8
Source Project: storm_spring_boot_demo   Source File: RedisConfUtils.java    License: MIT License 5 votes vote down vote up
/**
 * {@link org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration#getClusterConfiguration}
 * @param redisProperties
 * @return
 */
public static RedisClusterConfiguration  getClusterConfiguration(RedisProperties redisProperties) {
    if (redisProperties.getCluster() == null) {
        return null;
    }
    RedisProperties.Cluster clusterProperties = redisProperties.getCluster();
    RedisClusterConfiguration config = new RedisClusterConfiguration(
            clusterProperties.getNodes());

    if (clusterProperties.getMaxRedirects() != null) {
        config.setMaxRedirects(clusterProperties.getMaxRedirects());
    }
    return config;
}
 
Example 9
Source Project: spring-fu   Source File: ClusterInitializer.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void initialize(GenericApplicationContext context) {
    if (cluster != null) {
        context.registerBean(RedisClusterConfiguration.class, this::getRedisClusterConfiguration);
    }
}
 
Example 10
Source Project: spring-fu   Source File: ClusterInitializer.java    License: Apache License 2.0 4 votes vote down vote up
@NotNull
private RedisClusterConfiguration getRedisClusterConfiguration() {
    final RedisClusterConfiguration configuration = new RedisClusterConfiguration(cluster.getNodes());
    configuration.setMaxRedirects(cluster.getMaxRedirects());
    return configuration;
}
 
Example 11
public RedisClusterConfiguration getConfig() {
  RedisClusterConfiguration configuration = new RedisClusterConfiguration(
      getClusterNodes());
  configuration.setPassword(RedisPassword.of(getPassword()));
  return configuration;
}
 
Example 12
Source Project: dew   Source File: MultiConnectionConfiguration.java    License: Apache License 2.0 4 votes vote down vote up
public MultiConnectionConfiguration(RedisProperties properties,
                                    ObjectProvider<RedisSentinelConfiguration> sentinelConfigurationProvider,
                                    ObjectProvider<RedisClusterConfiguration> clusterConfigurationProvider) {
    super(properties, sentinelConfigurationProvider, clusterConfigurationProvider);
}