io.lettuce.core.cluster.ClusterClientOptions Java Examples

The following examples show how to use io.lettuce.core.cluster.ClusterClientOptions. 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 File: Client.java    From sherlock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Initialize the {@code RedisClusterClient} if it has not already been.
 *
 * @param params Store params used to create a Redis URI
 */
public void initializeRedisClusterClient(StoreParams params) {
    if (redisClusterClient != null) {
        return;
    }
    redisClusterClient = RedisClusterClient.create(produceURI(params));
    // Adaptive cluster topology refresh for redis cluster client
    ClusterTopologyRefreshOptions topologyRefreshOptions = ClusterTopologyRefreshOptions.builder()
        .enablePeriodicRefresh(true)
        .enableAllAdaptiveRefreshTriggers()
        .dynamicRefreshSources(true)
        .closeStaleConnections(true)
        .build();

    redisClusterClient.setOptions(ClusterClientOptions.builder()
                                      .validateClusterNodeMembership(true)
                                      .maxRedirects(5)
                                      .topologyRefreshOptions(topologyRefreshOptions)
                                      .build());
}
 
Example #2
Source File: RedisModule.java    From curiostack with MIT License 6 votes vote down vote up
@Provides
@Singleton
static RedisClusterClient redisClusterClient(
    RedisConfig config, MeterRegistry registry, Tracing tracing) {
  RedisClusterClient client =
      RedisClusterClient.create(
          DefaultClientResources.builder()
              .eventExecutorGroup(CommonPools.workerGroup())
              .eventLoopGroupProvider(ArmeriaEventLoopGroupProvider.INSTANCE)
              .commandLatencyCollector(
                  new MicrometerCommandLatencyCollector(DEFAULT_METER_ID_PREFIX, registry))
              .tracing(BraveTracing.create(tracing))
              .build(),
          config.getUrl());
  client.setOptions(ClusterClientOptions.builder().validateClusterNodeMembership(false).build());
  return client;
}