You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@helix.apache.org by ji...@apache.org on 2019/10/07 21:12:08 UTC

[helix] 05/37: Convert all the internal assignment state objects to be ResourceAssignment. (#399)

This is an automated email from the ASF dual-hosted git repository.

jiajunwang pushed a commit to branch wagedRebalancer2
in repository https://gitbox.apache.org/repos/asf/helix.git

commit 912ed34b0cb16dba350c480c6e962e557189528b
Author: Jiajun Wang <18...@users.noreply.github.com>
AuthorDate: Fri Aug 9 16:36:46 2019 -0700

    Convert all the internal assignment state objects to be ResourceAssignment. (#399)
    
    This is to avoid unnecessary information being recorded or read.
---
 .../rebalancer/waged/AssignmentMetadataStore.java          | 14 +++++++-------
 .../controller/rebalancer/waged/ClusterDataProvider.java   |  5 +++--
 .../controller/rebalancer/waged/RebalanceAlgorithm.java    |  3 +--
 .../waged/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 074ff4b..cc52dac 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 @@ package org.apache.helix.controller.rebalancer.waged;
  * 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 @@ import java.util.Map;
  * A placeholder before we have the real assignment metadata store.
  */
 public class AssignmentMetadataStore {
-  private Map<String, IdealState> _persistGlobalBaseline = new HashMap<>();
-  private Map<String, IdealState> _persistBestPossibleAssignment = new HashMap<>();
+  private Map<String, ResourceAssignment> _persistGlobalBaseline = new HashMap<>();
+  private Map<String, ResourceAssignment> _persistBestPossibleAssignment = new HashMap<>();
 
-  public Map<String, IdealState> getBaseline() {
+  public Map<String, ResourceAssignment> getBaseline() {
     return _persistGlobalBaseline;
   }
 
-  public void persistBaseline(Map<String, IdealState> globalBaseline) {
+  public void persistBaseline(Map<String, ResourceAssignment> globalBaseline) {
     // TODO clean up invalid items
     _persistGlobalBaseline = globalBaseline;
   }
 
-  public Map<String, IdealState> getBestPossibleAssignment() {
+  public Map<String, ResourceAssignment> getBestPossibleAssignment() {
     return _persistBestPossibleAssignment;
   }
 
-  public void persistBestPossibleAssignment(Map<String, IdealState> bestPossibleAssignment) {
+  public void persistBestPossibleAssignment(Map<String, ResourceAssignment> 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 feae1dc..387666c 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 @@ package org.apache.helix.controller.rebalancer.waged;
 
 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<String> activeInstances, Map<ClusterDataDetector.ChangeType, Set<String>> clusterChanges,
-      Map<String, IdealState> baselineAssignment, Map<String, IdealState> bestPossibleAssignment) {
+      Map<String, ResourceAssignment> baselineAssignment,
+      Map<String, ResourceAssignment> 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 ae258ca..d4221a1 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 @@ package org.apache.helix.controller.rebalancer.waged;
 
 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 <ResourceName, <FailureReason, Count>> that happen during the rebalance calculation.
    *                       If the map is null, no failure will be returned.
-   * @return A map <ResourceName, FailureReason> of the rebalanced resource assignments that are saved in the IdeaStates.
+   * @return A map of <ResourceName, ResourceAssignment>.
    */
   Map<String, ResourceAssignment> rebalance(ClusterModel clusterModel,
       Map<String, Map<HardConstraint.FailureReason, Integer>> 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 a75854a..286fd07 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 @@ package org.apache.helix.controller.rebalancer.waged.constraints;
 
 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;