use of org.springframework.data.redis.connection.RedisStandaloneConfiguration in project thingsboard by thingsboard.
the class TBRedisStandaloneConfiguration method loadFactory.
public JedisConnectionFactory loadFactory() {
RedisStandaloneConfiguration standaloneConfiguration = new RedisStandaloneConfiguration();
standaloneConfiguration.setHostName(host);
standaloneConfiguration.setPort(port);
standaloneConfiguration.setDatabase(db);
standaloneConfiguration.setPassword(password);
if (useDefaultClientConfig) {
return new JedisConnectionFactory(standaloneConfiguration);
} else {
return new JedisConnectionFactory(standaloneConfiguration, buildClientConfig());
}
}
use of org.springframework.data.redis.connection.RedisStandaloneConfiguration in project spring-integration by spring-projects.
the class RedisAvailableRule method apply.
public Statement apply(final Statement base, final FrameworkMethod method, Object target) {
RedisAvailable redisAvailable = method.getAnnotation(RedisAvailable.class);
if (redisAvailable != null) {
JedisConnectionFactory connectionFactory = null;
try {
RedisStandaloneConfiguration redisStandaloneConfiguration = new RedisStandaloneConfiguration();
redisStandaloneConfiguration.setPort(REDIS_PORT);
JedisClientConfiguration clientConfiguration = JedisClientConfiguration.builder().connectTimeout(Duration.ofSeconds(20)).readTimeout(Duration.ofSeconds(20)).build();
connectionFactory = new JedisConnectionFactory(redisStandaloneConfiguration, clientConfiguration);
connectionFactory.afterPropertiesSet();
connectionFactory.getConnection();
connectionFactoryResource.set(connectionFactory);
} catch (Exception e) {
if (connectionFactory != null) {
connectionFactory.destroy();
}
return new Statement() {
@Override
public void evaluate() throws Throwable {
Assume.assumeTrue("Skipping test due to Redis not being available on port: " + REDIS_PORT, false);
}
};
}
return new Statement() {
@Override
public void evaluate() throws Throwable {
try {
base.evaluate();
} finally {
JedisConnectionFactory connectionFactory = connectionFactoryResource.get();
connectionFactoryResource.remove();
if (connectionFactory != null) {
connectionFactory.destroy();
}
}
}
};
}
return new Statement() {
@Override
public void evaluate() throws Throwable {
base.evaluate();
}
};
}
use of org.springframework.data.redis.connection.RedisStandaloneConfiguration in project spring-boot by spring-projects.
the class RedisConnectionConfiguration method getStandaloneConfig.
protected final RedisStandaloneConfiguration getStandaloneConfig() {
if (this.standaloneConfiguration != null) {
return this.standaloneConfiguration;
}
RedisStandaloneConfiguration config = new RedisStandaloneConfiguration();
if (StringUtils.hasText(this.properties.getUrl())) {
ConnectionInfo connectionInfo = parseUrl(this.properties.getUrl());
config.setHostName(connectionInfo.getHostName());
config.setPort(connectionInfo.getPort());
config.setUsername(connectionInfo.getUsername());
config.setPassword(RedisPassword.of(connectionInfo.getPassword()));
} else {
config.setHostName(this.properties.getHost());
config.setPort(this.properties.getPort());
config.setUsername(this.properties.getUsername());
config.setPassword(RedisPassword.of(this.properties.getPassword()));
}
config.setDatabase(this.properties.getDatabase());
return config;
}
use of org.springframework.data.redis.connection.RedisStandaloneConfiguration 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);
}
use of org.springframework.data.redis.connection.RedisStandaloneConfiguration in project cas by apereo.
the class RedisObjectFactory method getStandaloneConfig.
private static RedisConfiguration getStandaloneConfig(final BaseRedisProperties redis) {
LOGGER.debug("Setting Redis standalone configuration on host [{}] and port [{}]", redis.getHost(), redis.getPort());
val standaloneConfig = new RedisStandaloneConfiguration(redis.getHost(), redis.getPort());
standaloneConfig.setDatabase(redis.getDatabase());
if (StringUtils.hasText(redis.getPassword())) {
standaloneConfig.setPassword(RedisPassword.of(redis.getPassword()));
}
return standaloneConfig;
}
Aggregations