Class OrderedGracefulLeaveHandler
When multiple nodes leave simultaneously (e.g., Kubernetes scaling down a StatefulSet), each leave triggers a rebalance that redistributes data to surviving nodes. Without serializing the operations, all leaves execute before any rebalance completes, causing segments to lose all owners.
This handler maintains a per-cache chain of CompletableFutures. Each leave waits for the previous leave's rebalance
to finish before proceeding:
Leave B --(doLeave + wait rebalance)--> Leave C --(doLeave + wait rebalance)--> ...
Only used when the leaving node requests a graceful stop with a positive timeout (via
CacheLeaveCommand). Abrupt leaves (view change, kill) bypass this handler
entirely.
- Since:
- 16.2
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected BlockingManagerprotected TimeServiceprotected org.infinispan.statetransfer.StateTransferTracker -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanWaits for all in-flight graceful leave chains to complete.enqueue(String cacheName, Address leaver, long timeout, TimeUnit unit, ClusterCacheStatus status) Enqueues a graceful leave for the given cache, serialized behind any pending leaves.voidRemoves the leave chain for a cache.
-
Field Details
-
blockingManager
-
timeService
-
tracker
protected org.infinispan.statetransfer.StateTransferTracker tracker
-
-
Constructor Details
-
OrderedGracefulLeaveHandler
public OrderedGracefulLeaveHandler()
-
-
Method Details
-
enqueue
public CompletionStage<Void> enqueue(String cacheName, Address leaver, long timeout, TimeUnit unit, ClusterCacheStatus status) Enqueues a graceful leave for the given cache, serialized behind any pending leaves.- Parameters:
cacheName- the cache the node is leavingleaver- the address of the leaving nodetimeout- maximum time to wait for the rebalance triggered by this leaveunit- time unit for the timeoutstatus- the coordinator-side cache status, used to execute the leave and read topology state- Returns:
- a stage that completes when this leave's rebalance finishes (or the timeout expires)
-
remove
Removes the leave chain for a cache. Called when the last member leaves and the cache status is removed.- Parameters:
cacheName- the cache to clean up
-
drainAll
Waits for all in-flight graceful leave chains to complete.The method ensures that all currently pending leave requests are consumed before returning. Concurrent leave requests included while draining are also included in the consuming list. The method waits until all the requests and associated state transfer complete, or a timeout elapses.
- Parameters:
timeout- maximum time to wait for all chains to completeunit- time unit for the timeout- Returns:
trueif all chains completed before the deadline;falseif the timeout expired- Throws:
InterruptedException- if the calling thread is interrupted while waiting
-