@ThreadSafe public class EvenClusterLoadStateManager extends Object
EvenClusterLoadStateMachine.EvenClusterLoadState.BALANCING_FAILED
or
EvenClusterLoadStateMachine.EvenClusterLoadState.ABORTED
, we update current state to be success and move current failure
to previous.
Also, when self-healing is enabled, if there is no rebalance run on the cluster yet (either
manually or by sbc, current rebalance state is set to EvenClusterLoadStateMachine.EvenClusterLoadState.BALANCED
.
More details - https://confluentinc.atlassian.net/wiki/spaces/~526161938/pages/2717909364/Design+for+EvenClusterLoadStateManager
So here is high level how previous and current states are captured:
1. Current rebalance run gets captured as part of currentStateMachine.
2. When a new rebalance starts, the currentStateMachine is saved to previousStateMachine and
a new currentStateMachine is created to capture state of current run.
3. If rebalance runs into an error, the error is captured in the currentStateMachine
4. If currentStateMachine is in error state (EvenClusterLoadStateMachine.EvenClusterLoadState.BALANCING_FAILED
or
EvenClusterLoadStateMachine.EvenClusterLoadState.ABORTED
states), and a goal violation check returns no violation,
then currentStateMachine is moved to previousStateMachine and a new currentStateMachine is created
with EvenClusterLoadStateMachine.EvenClusterLoadState.BALANCED
state.
Also note that although EvenClusterLoadStateMachine.EvenClusterLoadState.INITIALIZING
is defined as part of
EvenClusterLoadStateMachine.EvenClusterLoadState
state enum, the state machine is never in that state. The
state is checked and returned to the api caller w/o creating a state machine.Constructor and Description |
---|
EvenClusterLoadStateManager(int brokerId,
org.apache.kafka.common.utils.Time time,
ApiStatePersistenceStore persistenceStore,
boolean selfHealingEnabled) |
Modifier and Type | Method and Description |
---|---|
EvenClusterLoadStateMachine.EvenClusterLoadState |
currentState()
Returns null, if self-healing is disabled and no rebalance is run yet.
|
kafka.common.EvenClusterLoadStatusDescriptionInternal |
evenClusterLoadStatusDescription(boolean anyUnevenLoadEnabled) |
boolean |
isCurrentStateNull()
Returns whether current state is null.
|
void |
maybeRegisterEvent(EvenClusterLoadStateMachine.EvenClusterLoadEvent event,
Exception e) |
void |
maybeUpdateStateOnSelfHealingEnabled()
Initialize the current even cluster load status on initial enabling of self-healing.
|
void |
noGoalViolationsFound()
This method is invoked when Goal violation detector performs goal violation checks and doesn't
find any goal violation.
|
void |
registerEvent(EvenClusterLoadStateMachine.EvenClusterLoadEvent event) |
void |
registerEvent(EvenClusterLoadStateMachine.EvenClusterLoadEvent event,
Exception e) |
void |
startRebalancing()
This method is invoked when we have found goal violations and have a list of proposals that
if executed are going to fix the goal violations.
|
public EvenClusterLoadStateManager(int brokerId, org.apache.kafka.common.utils.Time time, ApiStatePersistenceStore persistenceStore, boolean selfHealingEnabled)
public void startRebalancing()
evenClusterLoadStatusDescription(boolean)
method then makes sure to return any
error that is not part of currently running rebalance as "even cluster load balance" api
status.public void noGoalViolationsFound()
public void maybeUpdateStateOnSelfHealingEnabled()
public void maybeRegisterEvent(EvenClusterLoadStateMachine.EvenClusterLoadEvent event, Exception e)
public void registerEvent(EvenClusterLoadStateMachine.EvenClusterLoadEvent event)
public void registerEvent(EvenClusterLoadStateMachine.EvenClusterLoadEvent event, Exception e)
public EvenClusterLoadStateMachine.EvenClusterLoadState currentState()
public boolean isCurrentStateNull()
public kafka.common.EvenClusterLoadStatusDescriptionInternal evenClusterLoadStatusDescription(boolean anyUnevenLoadEnabled)