csudharsanan commented on code in PR #3043:
URL: https://github.com/apache/helix/pull/3043#discussion_r2155094046
##########
helix-core/src/main/java/org/apache/helix/controller/stages/MessageGenerationPhase.java:
##########
@@ -290,7 +327,151 @@ private void generateMessage(final Resource resource,
final BaseControllerDataPr
} // end of for-each-partition
}
- private boolean shouldCreateSTCancellation(Message pendingMessage, String
desiredState,
+ /**
+ * Calculate the current active replica count based on state model type.
+ * This method determines how many replicas are currently serving traffic
for a partition by
+ * analyzing the current state distribution and applying state
model-specific rules. The count includes
+ * replicas in top states, secondary top states (where applicable), and
ERROR states since helix considers
+ * them active.
+ * State model handling:
+ * - Single-top state models: Differentiates between patterns with and
without secondary top
+ * states
+ * - ONLINE-OFFLINE: Counts ONLINE + ERROR states only
+ * - MASTER-SLAVE-OFFLINE: Counts MASTER + SLAVE + ERROR states
+ * - ONLINE-STANDBY-OFFLINE: Counts ONLINE + STANDBY + ERROR states
+ * - Multi-top state models: Counts only top states + ERROR states
+ * @param currentStateMap Map of instance name to current state for this
partition, representing
+ * the actual state of each replica before any pending transitions
+ * @param stateModelDef State model definition containing the state
hierarchy and transition rules
+ * used to determine which states are considered active
+ * @return The number of replicas currently in active states, used to
determine the
+ * currentActiveReplicaNumber for the partition.
+ */
+ private int calculateCurrentActiveReplicaCount(Map<String, String>
currentStateMap,
+ StateModelDefinition stateModelDef) {
+ if (stateModelDef.isSingleTopStateModel()) {
+ return calculateSingleTopStateActiveCount(currentStateMap,
stateModelDef);
Review Comment:
agreed, removing the if else checks.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]