-
Notifications
You must be signed in to change notification settings - Fork 4
Add support to enable top state downward ST message as recovery rebalance #67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: release-1.4.6-dev-202509091230
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -353,6 +353,9 @@ private PartitionStateMap computeIntermediatePartitionState(ResourceControllerDa | |||||
| chargePendingTransition(resource, currentStateOutput, throttleController, cache, | ||||||
| preferenceLists, stateModelDef); | ||||||
|
|
||||||
| boolean recoveryRebalanceForTopStateDownwardTransition = | ||||||
| clusterConfig.isRecoveryBalanceForTopStateDownwardTransitionEnabled(); | ||||||
|
|
||||||
| // Sort partitions in case of urgent partition need to take the quota first. | ||||||
| List<Partition> partitions = new ArrayList<>(resource.getPartitions()); | ||||||
| partitions.sort(new PartitionPriorityComparator(bestPossiblePartitionStateMap.getStateMap(), | ||||||
|
|
@@ -375,7 +378,10 @@ private PartitionStateMap computeIntermediatePartitionState(ResourceControllerDa | |||||
| for (Message message : messagesToThrottle) { | ||||||
| RebalanceType rebalanceType = | ||||||
| getRebalanceTypePerMessage(requiredState, message, derivedCurrentStateMap); | ||||||
|
|
||||||
| if(recoveryRebalanceForTopStateDownwardTransition) { | ||||||
| rebalanceType = validateTopStateDownwardTransition(stateModelDef, message) ? RebalanceType.RECOVERY_BALANCE : | ||||||
| rebalanceType; | ||||||
| } | ||||||
| // Number of states required by StateModelDefinition are not satisfied, need recovery | ||||||
| if (rebalanceType.equals(RebalanceType.RECOVERY_BALANCE)) { | ||||||
| message.setSTRebalanceType(Message.STRebalanceType.RECOVERY_REBALANCE); | ||||||
|
|
@@ -435,6 +441,18 @@ private PartitionStateMap computeIntermediatePartitionState(ResourceControllerDa | |||||
| return intermediatePartitionStateMap; | ||||||
| } | ||||||
|
|
||||||
| private boolean validateTopStateDownwardTransition(StateModelDefinition stateModelDef, Message msg) { | ||||||
| String topState = stateModelDef.getTopState(); | ||||||
| if (topState == null) { | ||||||
| return false; | ||||||
| } | ||||||
| String secondTopState = stateModelDef.getNextStateForTransition(topState, stateModelDef.getInitialState()); | ||||||
| if (secondTopState == null) { | ||||||
| return false; | ||||||
| } | ||||||
| return msg.getFromState() == topState && msg.getToState() == secondTopState; | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
This might not work. We should use .equals for String comparision. IIRC == compares object reference and not the content. |
||||||
| } | ||||||
|
|
||||||
| /** | ||||||
| * Determine the message is downward message or not. | ||||||
| * @param message message for load rebalance | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -171,6 +171,10 @@ public enum ClusterConfigProperty { | |||||
|
|
||||||
| // Allow disabled partitions to remain OFFLINE instead of being reassigned in WAGED rebalancer | ||||||
| RELAXED_DISABLED_PARTITION_CONSTRAINT, | ||||||
|
|
||||||
| // If enabled, all downward transitions from TopState (e.g., MASTER→SLAVE or LEADER→STANDBY) | ||||||
| // are classified as RECOVERY_REBALANCE instead of LOAD_BALANCE. | ||||||
| ENABLE_RECOVERY_REBALANCE_FOR_TOPSTATE_DOWNWARD_TRANSITION, | ||||||
| } | ||||||
|
|
||||||
| public enum GlobalRebalancePreferenceKey { | ||||||
|
|
@@ -1309,4 +1313,12 @@ public void setParticipantDeregistrationTimeout(long timeout) { | |||||
| public boolean isParticipantDeregistrationEnabled() { | ||||||
| return getParticipantDeregistrationTimeout() > -1; | ||||||
| } | ||||||
|
|
||||||
| public boolean isRecoveryBalanceForTopStateDownwardTransitionEnabled() { | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Rebalance** |
||||||
| return _record.getBooleanField(ClusterConfigProperty.ENABLE_RECOVERY_REBALANCE_FOR_TOPSTATE_DOWNWARD_TRANSITION.name(), false); | ||||||
| } | ||||||
|
|
||||||
| public void setRecoveryBalanceForTopStateDownwardTransitionEnabled(boolean enabled) { | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Rebalance** |
||||||
| _record.setBooleanField(ClusterConfigProperty.ENABLE_RECOVERY_REBALANCE_FOR_TOPSTATE_DOWNWARD_TRANSITION.name(),enabled); | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| } | ||||||
| } | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can move the logic to getRebalanceTypePerMessage() method itself - instead of overriding the decision here.