Package io.lettuce.core.cluster
Class ClusterTopologyRefreshOptions
- java.lang.Object
-
- io.lettuce.core.cluster.ClusterTopologyRefreshOptions
-
public class ClusterTopologyRefreshOptions extends Object
Options to control the Cluster topology refreshing ofRedisClusterClient
.- Since:
- 4.2
- Author:
- Mark Paluch
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ClusterTopologyRefreshOptions.Builder
Builder forClusterTopologyRefreshOptions
.static class
ClusterTopologyRefreshOptions.RefreshTrigger
Available refresh triggers to signal early topology refreshing.
-
Field Summary
Fields Modifier and Type Field Description static long
DEFAULT_ADAPTIVE_REFRESH_TIMEOUT
static Duration
DEFAULT_ADAPTIVE_REFRESH_TIMEOUT_DURATION
static TimeUnit
DEFAULT_ADAPTIVE_REFRESH_TIMEOUT_UNIT
static Set<ClusterTopologyRefreshOptions.RefreshTrigger>
DEFAULT_ADAPTIVE_REFRESH_TRIGGERS
static boolean
DEFAULT_CLOSE_STALE_CONNECTIONS
static boolean
DEFAULT_DYNAMIC_REFRESH_SOURCES
static boolean
DEFAULT_PERIODIC_REFRESH_ENABLED
static long
DEFAULT_REFRESH_PERIOD
static Duration
DEFAULT_REFRESH_PERIOD_DURATION
static TimeUnit
DEFAULT_REFRESH_PERIOD_UNIT
static int
DEFAULT_REFRESH_TRIGGERS_RECONNECT_ATTEMPTS
-
Constructor Summary
Constructors Modifier Constructor Description protected
ClusterTopologyRefreshOptions(ClusterTopologyRefreshOptions original)
protected
ClusterTopologyRefreshOptions(ClusterTopologyRefreshOptions.Builder builder)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ClusterTopologyRefreshOptions.Builder
builder()
Returns a newClusterTopologyRefreshOptions.Builder
to constructClusterTopologyRefreshOptions
.static ClusterTopologyRefreshOptions
copyOf(ClusterTopologyRefreshOptions options)
Create a copy of options.static ClusterTopologyRefreshOptions
create()
Create a newClusterTopologyRefreshOptions
using default settings.static ClusterTopologyRefreshOptions
enabled()
Create a newClusterTopologyRefreshOptions
using default settings with enabled periodic and adaptive refresh.Duration
getAdaptiveRefreshTimeout()
Timeout between adaptive cluster topology updates.Set<ClusterTopologyRefreshOptions.RefreshTrigger>
getAdaptiveRefreshTriggers()
Returns the set oftriggers
.Duration
getRefreshPeriod()
Period between the regular cluster topology updates.int
getRefreshTriggersReconnectAttempts()
boolean
isCloseStaleConnections()
Flag, whether to close stale connections when refreshing the cluster topology.boolean
isPeriodicRefreshEnabled()
Flag, whether regular cluster topology updates are updated.boolean
useDynamicRefreshSources()
Discover cluster nodes from topology and use the discovered nodes as source for the cluster topology.
-
-
-
Field Detail
-
DEFAULT_ADAPTIVE_REFRESH_TRIGGERS
public static final Set<ClusterTopologyRefreshOptions.RefreshTrigger> DEFAULT_ADAPTIVE_REFRESH_TRIGGERS
-
DEFAULT_ADAPTIVE_REFRESH_TIMEOUT
public static final long DEFAULT_ADAPTIVE_REFRESH_TIMEOUT
- See Also:
- Constant Field Values
-
DEFAULT_ADAPTIVE_REFRESH_TIMEOUT_UNIT
public static final TimeUnit DEFAULT_ADAPTIVE_REFRESH_TIMEOUT_UNIT
-
DEFAULT_ADAPTIVE_REFRESH_TIMEOUT_DURATION
public static final Duration DEFAULT_ADAPTIVE_REFRESH_TIMEOUT_DURATION
-
DEFAULT_CLOSE_STALE_CONNECTIONS
public static final boolean DEFAULT_CLOSE_STALE_CONNECTIONS
- See Also:
- Constant Field Values
-
DEFAULT_DYNAMIC_REFRESH_SOURCES
public static final boolean DEFAULT_DYNAMIC_REFRESH_SOURCES
- See Also:
- Constant Field Values
-
DEFAULT_PERIODIC_REFRESH_ENABLED
public static final boolean DEFAULT_PERIODIC_REFRESH_ENABLED
- See Also:
- Constant Field Values
-
DEFAULT_REFRESH_PERIOD
public static final long DEFAULT_REFRESH_PERIOD
- See Also:
- Constant Field Values
-
DEFAULT_REFRESH_PERIOD_UNIT
public static final TimeUnit DEFAULT_REFRESH_PERIOD_UNIT
-
DEFAULT_REFRESH_PERIOD_DURATION
public static final Duration DEFAULT_REFRESH_PERIOD_DURATION
-
DEFAULT_REFRESH_TRIGGERS_RECONNECT_ATTEMPTS
public static final int DEFAULT_REFRESH_TRIGGERS_RECONNECT_ATTEMPTS
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ClusterTopologyRefreshOptions
protected ClusterTopologyRefreshOptions(ClusterTopologyRefreshOptions.Builder builder)
-
ClusterTopologyRefreshOptions
protected ClusterTopologyRefreshOptions(ClusterTopologyRefreshOptions original)
-
-
Method Detail
-
copyOf
public static ClusterTopologyRefreshOptions copyOf(ClusterTopologyRefreshOptions options)
Create a copy of options.- Parameters:
options
- the original- Returns:
- A new instance of
ClusterTopologyRefreshOptions
containing the values of options
-
builder
public static ClusterTopologyRefreshOptions.Builder builder()
Returns a newClusterTopologyRefreshOptions.Builder
to constructClusterTopologyRefreshOptions
.- Returns:
- a new
ClusterTopologyRefreshOptions.Builder
to constructClusterTopologyRefreshOptions
.
-
create
public static ClusterTopologyRefreshOptions create()
Create a newClusterTopologyRefreshOptions
using default settings.- Returns:
- a new instance of default cluster client options.
-
enabled
public static ClusterTopologyRefreshOptions enabled()
Create a newClusterTopologyRefreshOptions
using default settings with enabled periodic and adaptive refresh.- Returns:
- a new instance of default cluster client options.
-
getAdaptiveRefreshTriggers
public Set<ClusterTopologyRefreshOptions.RefreshTrigger> getAdaptiveRefreshTriggers()
Returns the set oftriggers
. Adaptive refresh triggers initiate topology view updates based on events happened during Redis Cluster operations. Adaptive triggers lead to an immediate topology refresh. Adaptive triggered refreshes are rate-limited using a timeout since events can happen on a large scale. Adaptive refresh triggers are disabled by default.- Returns:
- the set of
triggers
-
getAdaptiveRefreshTimeout
public Duration getAdaptiveRefreshTimeout()
Timeout between adaptive cluster topology updates. Defaults to 30.- Returns:
- the period between the regular cluster topology updates
-
isCloseStaleConnections
public boolean isCloseStaleConnections()
Flag, whether to close stale connections when refreshing the cluster topology. Defaults totrue
. Comes only into effect ifisPeriodicRefreshEnabled()
istrue
.- Returns:
true
if stale connections are cleaned up after cluster topology updates
-
useDynamicRefreshSources
public boolean useDynamicRefreshSources()
Discover cluster nodes from topology and use the discovered nodes as source for the cluster topology. Using dynamic refresh will query all discovered nodes for the cluster topology and calculate the number of clients for each node. If set tofalse
, only the initial seed nodes will be used as sources for topology discovery and the number of clients including response latency will be obtained only for the initial seed nodes. This can be useful when using Redis Cluster with many nodes. Defaults totrue
. SeeDEFAULT_DYNAMIC_REFRESH_SOURCES
.- Returns:
true
if dynamic refresh sources are enabled
-
isPeriodicRefreshEnabled
public boolean isPeriodicRefreshEnabled()
Flag, whether regular cluster topology updates are updated. The client starts updating the cluster topology in the intervals ofgetRefreshPeriod()
. Defaults tofalse
.- Returns:
true
it the cluster topology view is updated periodically
-
getRefreshPeriod
public Duration getRefreshPeriod()
Period between the regular cluster topology updates. Defaults to 60.- Returns:
- the period between the regular cluster topology updates
-
getRefreshTriggersReconnectAttempts
public int getRefreshTriggersReconnectAttempts()
Threshold forClusterTopologyRefreshOptions.RefreshTrigger.PERSISTENT_RECONNECTS
. Topology updates based on persistent reconnects lead only to a refresh if the reconnect process tries at leastrefreshTriggersReconnectAttempts
. SeeDEFAULT_REFRESH_TRIGGERS_RECONNECT_ATTEMPTS
.- Returns:
- number of reconnect attempts for a connection before an adaptive topology refresh is triggered
-
-