java.lang.Object
io.lettuce.core.cluster.ClusterTopologyRefreshOptions
public class ClusterTopologyRefreshOptions extends Object
Options to control the Cluster topology refreshing of
RedisClusterClient.- Since:
- 4.2
- Author:
- Mark Paluch
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classClusterTopologyRefreshOptions.BuilderBuilder forClusterTopologyRefreshOptions.static classClusterTopologyRefreshOptions.RefreshTriggerAvailable refresh triggers to signal early topology refreshing. -
Field Summary
Fields Modifier and Type Field Description static longDEFAULT_ADAPTIVE_REFRESH_TIMEOUTstatic DurationDEFAULT_ADAPTIVE_REFRESH_TIMEOUT_DURATIONstatic TimeUnitDEFAULT_ADAPTIVE_REFRESH_TIMEOUT_UNITstatic Set<ClusterTopologyRefreshOptions.RefreshTrigger>DEFAULT_ADAPTIVE_REFRESH_TRIGGERSstatic booleanDEFAULT_CLOSE_STALE_CONNECTIONSstatic booleanDEFAULT_DYNAMIC_REFRESH_SOURCESstatic booleanDEFAULT_PERIODIC_REFRESH_ENABLEDstatic longDEFAULT_REFRESH_PERIODstatic DurationDEFAULT_REFRESH_PERIOD_DURATIONstatic TimeUnitDEFAULT_REFRESH_PERIOD_UNITstatic intDEFAULT_REFRESH_TRIGGERS_RECONNECT_ATTEMPTS -
Constructor Summary
Constructors Modifier Constructor Description protectedClusterTopologyRefreshOptions(ClusterTopologyRefreshOptions original)protectedClusterTopologyRefreshOptions(ClusterTopologyRefreshOptions.Builder builder) -
Method Summary
Modifier and Type Method Description static ClusterTopologyRefreshOptions.Builderbuilder()Returns a newClusterTopologyRefreshOptions.Builderto constructClusterTopologyRefreshOptions.static ClusterTopologyRefreshOptionscopyOf(ClusterTopologyRefreshOptions options)Create a copy of options.static ClusterTopologyRefreshOptionscreate()Create a newClusterTopologyRefreshOptionsusing default settings.static ClusterTopologyRefreshOptionsenabled()Create a newClusterTopologyRefreshOptionsusing default settings with enabled periodic and adaptive refresh.DurationgetAdaptiveRefreshTimeout()Timeout between adaptive cluster topology updates.Set<ClusterTopologyRefreshOptions.RefreshTrigger>getAdaptiveRefreshTriggers()Returns the set oftriggers.DurationgetRefreshPeriod()Period between the regular cluster topology updates.intgetRefreshTriggersReconnectAttempts()booleanisCloseStaleConnections()Flag, whether to close stale connections when refreshing the cluster topology.booleanisPeriodicRefreshEnabled()Flag, whether regular cluster topology updates are updated.booleanuseDynamicRefreshSources()Discover cluster nodes from topology and use the discovered nodes as source for the cluster topology.
-
Field Details
-
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
-
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
-
DEFAULT_REFRESH_PERIOD_DURATION
-
DEFAULT_REFRESH_TRIGGERS_RECONNECT_ATTEMPTS
public static final int DEFAULT_REFRESH_TRIGGERS_RECONNECT_ATTEMPTS- See Also:
- Constant Field Values
-
-
Constructor Details
-
ClusterTopologyRefreshOptions
-
ClusterTopologyRefreshOptions
-
-
Method Details
-
copyOf
Create a copy of options.- Parameters:
options- the original- Returns:
- A new instance of
ClusterTopologyRefreshOptionscontaining the values of options
-
builder
Returns a newClusterTopologyRefreshOptions.Builderto constructClusterTopologyRefreshOptions.- Returns:
- a new
ClusterTopologyRefreshOptions.Builderto constructClusterTopologyRefreshOptions.
-
create
Create a newClusterTopologyRefreshOptionsusing default settings.- Returns:
- a new instance of default cluster client client options.
-
enabled
Create a newClusterTopologyRefreshOptionsusing default settings with enabled periodic and adaptive refresh.- Returns:
- a new instance of default cluster client client options.
-
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
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:
trueif 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 will be obtained only for the initial seed nodes. This can be useful when using Redis Cluster with many nodes.- Returns:
trueif 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:
trueit the cluster topology view is updated periodically
-
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:
- umber of reconnect attempts for a connection before a n adaptive topology refresh is triggered
-