From f6e995f7850a2048efd9719782e4a858d28831fb Mon Sep 17 00:00:00 2001 From: jiajunwang Date: Fri, 9 Aug 2019 16:25:21 -0700 Subject: [PATCH] Convert all the internal assignment state objects to be ResourceAssignment. This is to avoid unnecessary information being recorded or read. --- .../rebalancer/waged/AssignmentMetadataStore.java | 14 +++++++------- .../rebalancer/waged/ClusterDataProvider.java | 5 +++-- .../rebalancer/waged/RebalanceAlgorithm.java | 3 +-- .../constraints/ConstraintsRebalanceAlgorithm.java | 1 - 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/AssignmentMetadataStore.java b/helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/AssignmentMetadataStore.java index 074ff4b093..cc52dacbf5 100644 --- a/helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/AssignmentMetadataStore.java +++ b/helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/AssignmentMetadataStore.java @@ -19,7 +19,7 @@ * under the License. */ -import org.apache.helix.model.IdealState; +import org.apache.helix.model.ResourceAssignment; import java.util.HashMap; import java.util.Map; @@ -28,23 +28,23 @@ * A placeholder before we have the real assignment metadata store. */ public class AssignmentMetadataStore { - private Map _persistGlobalBaseline = new HashMap<>(); - private Map _persistBestPossibleAssignment = new HashMap<>(); + private Map _persistGlobalBaseline = new HashMap<>(); + private Map _persistBestPossibleAssignment = new HashMap<>(); - public Map getBaseline() { + public Map getBaseline() { return _persistGlobalBaseline; } - public void persistBaseline(Map globalBaseline) { + public void persistBaseline(Map globalBaseline) { // TODO clean up invalid items _persistGlobalBaseline = globalBaseline; } - public Map getBestPossibleAssignment() { + public Map getBestPossibleAssignment() { return _persistBestPossibleAssignment; } - public void persistBestPossibleAssignment(Map bestPossibleAssignment) { + public void persistBestPossibleAssignment(Map bestPossibleAssignment) { // TODO clean up invalid items _persistBestPossibleAssignment.putAll(bestPossibleAssignment); } diff --git a/helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/ClusterDataProvider.java b/helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/ClusterDataProvider.java index feae1dcd49..387666c6db 100644 --- a/helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/ClusterDataProvider.java +++ b/helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/ClusterDataProvider.java @@ -21,7 +21,7 @@ import org.apache.helix.controller.dataproviders.ResourceControllerDataProvider; import org.apache.helix.controller.rebalancer.waged.model.ClusterModel; -import org.apache.helix.model.IdealState; +import org.apache.helix.model.ResourceAssignment; import java.util.Map; import java.util.Set; @@ -46,7 +46,8 @@ public class ClusterDataProvider { */ protected static ClusterModel generateClusterModel(ResourceControllerDataProvider dataProvider, Set activeInstances, Map> clusterChanges, - Map baselineAssignment, Map bestPossibleAssignment) { + Map baselineAssignment, + Map bestPossibleAssignment) { // TODO finish the implementation. return null; } diff --git a/helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/RebalanceAlgorithm.java b/helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/RebalanceAlgorithm.java index ae258ca637..d4221a1c46 100644 --- a/helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/RebalanceAlgorithm.java +++ b/helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/RebalanceAlgorithm.java @@ -21,7 +21,6 @@ import org.apache.helix.controller.rebalancer.waged.constraints.HardConstraint; import org.apache.helix.controller.rebalancer.waged.model.ClusterModel; -import org.apache.helix.model.IdealState; import org.apache.helix.model.ResourceAssignment; import java.util.Map; @@ -39,7 +38,7 @@ public interface RebalanceAlgorithm { * @param clusterModel * @param failureReasons Return the failures > that happen during the rebalance calculation. * If the map is null, no failure will be returned. - * @return A map of the rebalanced resource assignments that are saved in the IdeaStates. + * @return A map of . */ Map rebalance(ClusterModel clusterModel, Map> failureReasons); diff --git a/helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/constraints/ConstraintsRebalanceAlgorithm.java b/helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/constraints/ConstraintsRebalanceAlgorithm.java index a75854a4cc..286fd0738e 100644 --- a/helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/constraints/ConstraintsRebalanceAlgorithm.java +++ b/helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/constraints/ConstraintsRebalanceAlgorithm.java @@ -21,7 +21,6 @@ import org.apache.helix.controller.rebalancer.waged.RebalanceAlgorithm; import org.apache.helix.controller.rebalancer.waged.model.ClusterModel; -import org.apache.helix.model.IdealState; import org.apache.helix.model.ResourceAssignment; import org.slf4j.Logger; import org.slf4j.LoggerFactory;