Search in sources :

Example 1 with LettuceClientConfiguration

use of org.springframework.data.redis.connection.lettuce.LettuceClientConfiguration in project dhis2-core by dhis2.

the class RedisConfiguration method lettuceConnectionFactory.

@Bean
public LettuceConnectionFactory lettuceConnectionFactory() {
    LettuceClientConfigurationBuilder builder = LettuceClientConfiguration.builder();
    if (DhisConfigurationProvider.isOn((String) redisSslEnabled().getObject())) {
        builder.useSsl();
    }
    LettuceClientConfiguration clientConfiguration = builder.build();
    RedisStandaloneConfiguration standaloneConfig = new RedisStandaloneConfiguration();
    standaloneConfig.setHostName((String) redisHost().getObject());
    standaloneConfig.setPassword((String) redisPassword().getObject());
    standaloneConfig.setPort(Integer.parseInt((String) redisPort().getObject()));
    return new LettuceConnectionFactory(standaloneConfig, clientConfiguration);
}
Also used : LettuceClientConfiguration(org.springframework.data.redis.connection.lettuce.LettuceClientConfiguration) LettuceConnectionFactory(org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory) RedisStandaloneConfiguration(org.springframework.data.redis.connection.RedisStandaloneConfiguration) LettuceClientConfigurationBuilder(org.springframework.data.redis.connection.lettuce.LettuceClientConfiguration.LettuceClientConfigurationBuilder) ConfigurationPropertyFactoryBean(org.hisp.dhis.external.conf.ConfigurationPropertyFactoryBean) Bean(org.springframework.context.annotation.Bean)

Example 2 with LettuceClientConfiguration

use of org.springframework.data.redis.connection.lettuce.LettuceClientConfiguration in project spring-cloud-connectors by spring-cloud.

the class RedisConnectionFactoryCloudConfigTestHelper method assertPoolProperties.

public static void assertPoolProperties(RedisConnectionFactory connector, int maxActive, int minIdle, long maxWait) {
    GenericObjectPoolConfig poolConfig = null;
    if (connector instanceof JedisConnectionFactory) {
        poolConfig = ((JedisConnectionFactory) connector).getPoolConfig();
    } else if (connector instanceof LettuceConnectionFactory) {
        LettuceClientConfiguration config = ((LettuceConnectionFactory) connector).getClientConfiguration();
        assertThat(config, instanceOf(LettucePoolingClientConfiguration.class));
        poolConfig = ((LettucePoolingClientConfiguration) config).getPoolConfig();
    }
    assertCommonsPoolProperties(poolConfig, maxActive, minIdle, maxWait);
}
Also used : GenericObjectPoolConfig(org.apache.commons.pool2.impl.GenericObjectPoolConfig) JedisConnectionFactory(org.springframework.data.redis.connection.jedis.JedisConnectionFactory) LettuceClientConfiguration(org.springframework.data.redis.connection.lettuce.LettuceClientConfiguration) LettuceConnectionFactory(org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory) LettucePoolingClientConfiguration(org.springframework.data.redis.connection.lettuce.LettucePoolingClientConfiguration)

Aggregations

LettuceClientConfiguration (org.springframework.data.redis.connection.lettuce.LettuceClientConfiguration)2 LettuceConnectionFactory (org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory)2 GenericObjectPoolConfig (org.apache.commons.pool2.impl.GenericObjectPoolConfig)1 ConfigurationPropertyFactoryBean (org.hisp.dhis.external.conf.ConfigurationPropertyFactoryBean)1 Bean (org.springframework.context.annotation.Bean)1 RedisStandaloneConfiguration (org.springframework.data.redis.connection.RedisStandaloneConfiguration)1 JedisConnectionFactory (org.springframework.data.redis.connection.jedis.JedisConnectionFactory)1 LettuceClientConfigurationBuilder (org.springframework.data.redis.connection.lettuce.LettuceClientConfiguration.LettuceClientConfigurationBuilder)1 LettucePoolingClientConfiguration (org.springframework.data.redis.connection.lettuce.LettucePoolingClientConfiguration)1