public abstract class ClusterClientBuilder<C extends JedisCluster> extends AbstractClientBuilder<ClusterClientBuilder<C>,C>
This builder provides methods specific to Redis Cluster deployments, including cluster nodes configuration, retry settings, and topology refresh configuration.
cache, cacheConfig, clientConfig, commandExecutor, commandObjects, connectionProvider, jsonObjectMapper, keyPreProcessor, poolConfig, searchDialect| Constructor and Description |
|---|
ClusterClientBuilder() |
| Modifier and Type | Method and Description |
|---|---|
protected CommandExecutor |
createDefaultCommandExecutor()
Creates a default command executor based on the current configuration.
|
protected CommandObjects |
createDefaultCommandObjects()
Factory method for creating CommandObjects.
|
protected ConnectionProvider |
createDefaultConnectionProvider()
Creates a default connection provider based on the current configuration.
|
ClusterClientBuilder<C> |
maxAttempts(int maxAttempts)
Sets the maximum number of attempts for cluster operations.
|
ClusterClientBuilder<C> |
maxTotalRetriesDuration(java.time.Duration maxTotalRetriesDuration)
Sets the maximum total duration for retries across all attempts.
|
ClusterClientBuilder<C> |
nodes(java.util.Set<HostAndPort> nodes)
Sets the cluster nodes to connect to.
|
protected ClusterClientBuilder<C> |
self()
Returns the concrete builder instance for method chaining.
|
ClusterClientBuilder<C> |
topologyRefreshPeriod(java.time.Duration topologyRefreshPeriod)
Sets the topology refresh period for cluster slot mapping updates.
|
protected void |
validateSpecificConfiguration()
Validates the builder-specific configuration.
|
applyCommandObjectsConfiguration, build, cache, cacheConfig, clientConfig, commandExecutor, connectionProvider, createClient, createDefaultClientConfig, jsonObjectMapper, keyPreProcessor, poolConfig, searchDialect, validateCommonConfigurationpublic ClusterClientBuilder<C> nodes(java.util.Set<HostAndPort> nodes)
At least one node must be specified. The client will discover other nodes in the cluster automatically.
nodes - the set of cluster nodespublic ClusterClientBuilder<C> maxAttempts(int maxAttempts)
When a cluster operation fails (e.g., due to node failure or slot migration), the client will retry up to this many times before giving up.
maxAttempts - the maximum number of attempts (must be positive)public ClusterClientBuilder<C> maxTotalRetriesDuration(java.time.Duration maxTotalRetriesDuration)
This provides a time-based limit on retries in addition to the attempt-based limit. If not set, it will be calculated as socketTimeout * maxAttempts.
maxTotalRetriesDuration - the maximum total retry durationpublic ClusterClientBuilder<C> topologyRefreshPeriod(java.time.Duration topologyRefreshPeriod)
The client will periodically refresh its view of the cluster topology to handle slot migrations and node changes. A shorter period provides faster adaptation to cluster changes but increases overhead.
topologyRefreshPeriod - the topology refresh periodprotected ClusterClientBuilder<C> self()
AbstractClientBuilderself in class AbstractClientBuilder<ClusterClientBuilder<C extends JedisCluster>,C extends JedisCluster>protected ConnectionProvider createDefaultConnectionProvider()
AbstractClientBuildercreateDefaultConnectionProvider in class AbstractClientBuilder<ClusterClientBuilder<C extends JedisCluster>,C extends JedisCluster>protected CommandExecutor createDefaultCommandExecutor()
AbstractClientBuildercreateDefaultCommandExecutor in class AbstractClientBuilder<ClusterClientBuilder<C extends JedisCluster>,C extends JedisCluster>protected CommandObjects createDefaultCommandObjects()
AbstractClientBuildercreateDefaultCommandObjects in class AbstractClientBuilder<ClusterClientBuilder<C extends JedisCluster>,C extends JedisCluster>protected void validateSpecificConfiguration()
AbstractClientBuilderThis method is called by the generic build() method to validate configuration specific to each builder type. Implementations should call validateCommonConfiguration() and then perform their own specific validation.
validateSpecificConfiguration in class AbstractClientBuilder<ClusterClientBuilder<C extends JedisCluster>,C extends JedisCluster>Copyright © 2025. All rights reserved.