use of redis.clients.jedis.JedisClusterInfoCache in project LinkAgent by shulieTech.
the class JedisClusterConnectionInterceptor method attachment.
void attachment(Advice advice) {
try {
if (Pradar.isClusterTest()) {
return;
}
JedisSlotBasedConnectionHandler handler = (JedisSlotBasedConnectionHandler) advice.getTarget();
JedisClusterInfoCache cache = Reflect.on(handler).get("cache");
String password = Reflect.on(cache).get("password");
Map hashmap = Reflect.on(cache).get("nodes");
StringBuilder builder = new StringBuilder();
for (Object node : hashmap.keySet()) {
model.setClusterMode(String.valueOf(node));
builder.append(node).append(",");
}
builder.deleteCharAt(builder.length() - 1);
ResourceManager.set(new Attachment(new ArrayList(hashmap.keySet()), RedisConstants.PLUGIN_NAME, new String[] { RedisConstants.MIDDLEWARE_NAME }, new RedisTemplate.JedisClusterTemplate().setNodes(builder.toString()).setPassword(password)));
} catch (Throwable t) {
}
}
use of redis.clients.jedis.JedisClusterInfoCache in project spring-data-redis by spring-projects.
the class JedisConnectionFactoryUnitTests method shouldApplySslConfigWhenCreatingClusterClient.
// DATAREDIS-974, GH-2017
@Test
void shouldApplySslConfigWhenCreatingClusterClient() throws NoSuchAlgorithmException {
SSLParameters sslParameters = new SSLParameters();
SSLContext context = SSLContext.getDefault();
SSLSocketFactory socketFactory = context.getSocketFactory();
JedisPoolConfig poolConfig = new JedisPoolConfig();
HostnameVerifier hostNameVerifier = HttpsURLConnection.getDefaultHostnameVerifier();
JedisClientConfiguration configuration = //
JedisClientConfiguration.builder().useSsl().hostnameVerifier(//
hostNameVerifier).sslParameters(//
sslParameters).sslSocketFactory(socketFactory).and().clientName(//
"my-client").connectTimeout(//
Duration.ofMinutes(1)).readTimeout(//
Duration.ofMinutes(5)).usePooling().poolConfig(//
poolConfig).build();
connectionFactory = new JedisConnectionFactory(new RedisClusterConfiguration(), configuration);
connectionFactory.afterPropertiesSet();
RedisClusterConnection connection = connectionFactory.getClusterConnection();
assertThat(connection).isInstanceOf(JedisClusterConnection.class);
JedisCluster cluster = ((JedisClusterConnection) connection).getCluster();
JedisClusterConnectionHandler connectionHandler = (JedisClusterConnectionHandler) ReflectionTestUtils.getField(cluster, "connectionHandler");
JedisClusterInfoCache cache = (JedisClusterInfoCache) ReflectionTestUtils.getField(connectionHandler, "cache");
JedisClientConfig clientConfig = (JedisClientConfig) ReflectionTestUtils.getField(cache, "clientConfig");
assertThat(clientConfig.getConnectionTimeoutMillis()).isEqualTo(60000);
assertThat(clientConfig.getSocketTimeoutMillis()).isEqualTo(300000);
assertThat(clientConfig.getPassword()).isNull();
assertThat(clientConfig.getClientName()).isEqualTo("my-client");
assertThat(clientConfig.isSsl()).isEqualTo(true);
assertThat(clientConfig.getSslSocketFactory()).isEqualTo(socketFactory);
assertThat(clientConfig.getSslParameters()).isEqualTo(sslParameters);
assertThat(clientConfig.getHostnameVerifier()).isEqualTo(hostNameVerifier);
assertThat(clientConfig.getHostAndPortMapper()).isNull();
}
Aggregations