private void buildRedisClusterClient() { if (redisClusterClient == null ) { ClientResources res = DefaultClientResources.builder() .ioThreadPoolSize(LETTUCE_IO_THREAD_COUNT) .commandLatencyPublisherOptions( DefaultEventPublisherOptions.builder() .eventEmitInterval(Duration.ofSeconds( 5 )) .build() ) .commandLatencyCollector( new LettuceCommandLatencyCollector(metrics)) .build(); redisClusterClient = RedisClusterClient.create(res, REDIS_CLUSTER_URI); int MAX_REDIRECTS = 99 ; redisClusterClient.setOptions( ClusterClientOptions.builder() .maxRedirects(MAX_REDIRECTS) .socketOptions(SocketOptions.builder().keepAlive( true ).build()) .topologyRefreshOptions( ClusterTopologyRefreshOptions.builder() .enableAllAdaptiveRefreshTriggers() .build()) .build()); redisClusterClient.getResources() .eventBus() .get() .subscribe( new LettuceMetricsSubscriber(buildEventVisitors(metrics))); } } |