Package io.kroxylicious.proxy.internal
Class VirtualClusterLifecycle
java.lang.Object
io.kroxylicious.proxy.internal.VirtualClusterLifecycle
Manages the lifecycle state of a single virtual cluster.
Thread-safe: state transitions and connection registration share the same monitor,
so the state transition → connection snapshot sequence in startDraining()
is atomic with respect to registerConnection(ClientConnectionStateMachine).
This closes the TOCTOU window where a connection could be registered after the
drain snapshot is taken and therefore missed by graceful drain.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidTransitions fromVirtualClusterLifecycleState.DrainingtoVirtualClusterLifecycleState.Stopped.Returns the future that completes when all connections have drained.voidinitializationFailed(Throwable cause) Transitions fromVirtualClusterLifecycleState.InitializingtoVirtualClusterLifecycleState.Failed, recording the cause.voidTransitions fromVirtualClusterLifecycleState.InitializingtoVirtualClusterLifecycleState.Serving.booleanTransitions fromVirtualClusterLifecycleState.ServingtoVirtualClusterLifecycleState.Drainingand initiates close on all active connections.state()voidstop()
-
Constructor Details
-
VirtualClusterLifecycle
-
-
Method Details
-
initializationSucceeded
public void initializationSucceeded()Transitions fromVirtualClusterLifecycleState.InitializingtoVirtualClusterLifecycleState.Serving. -
initializationFailed
Transitions fromVirtualClusterLifecycleState.InitializingtoVirtualClusterLifecycleState.Failed, recording the cause. -
startDraining
Transitions fromVirtualClusterLifecycleState.ServingtoVirtualClusterLifecycleState.Drainingand initiates close on all active connections.- Returns:
- future that completes when all connections have closed
-
drainFuture
Returns the future that completes when all connections have drained. Only valid to call when the cluster is inVirtualClusterLifecycleState.Drainingstate. -
drainComplete
public void drainComplete()Transitions fromVirtualClusterLifecycleState.DrainingtoVirtualClusterLifecycleState.Stopped. -
stop
public void stop()Transitions toVirtualClusterLifecycleState.StoppedfromVirtualClusterLifecycleState.FailedorVirtualClusterLifecycleState.Initializing. Idempotent: a call when alreadyVirtualClusterLifecycleState.Stoppedis a silent no-op, so two concurrent shutdown paths that both observe a non-terminal state and race to callstop()cannot fail — the second caller's transition simply finds the state already terminal. -
state
-
clusterName
-
registerConnection
-
deregisterConnection
-
activeConnections
-