Skip to content

Commit 7045bde

Browse files
jiajunwangJiajun Wang
authored andcommitted
Convert all the internal assignment state objects to be ResourceAssignment. (#399)
This is to avoid unnecessary information being recorded or read.
1 parent 3d7f5c5 commit 7045bde

4 files changed

Lines changed: 11 additions & 12 deletions

File tree

helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/AssignmentMetadataStore.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* under the License.
2020
*/
2121

22-
import org.apache.helix.model.IdealState;
22+
import org.apache.helix.model.ResourceAssignment;
2323

2424
import java.util.HashMap;
2525
import java.util.Map;
@@ -28,23 +28,23 @@
2828
* A placeholder before we have the real assignment metadata store.
2929
*/
3030
public class AssignmentMetadataStore {
31-
private Map<String, IdealState> _persistGlobalBaseline = new HashMap<>();
32-
private Map<String, IdealState> _persistBestPossibleAssignment = new HashMap<>();
31+
private Map<String, ResourceAssignment> _persistGlobalBaseline = new HashMap<>();
32+
private Map<String, ResourceAssignment> _persistBestPossibleAssignment = new HashMap<>();
3333

34-
public Map<String, IdealState> getBaseline() {
34+
public Map<String, ResourceAssignment> getBaseline() {
3535
return _persistGlobalBaseline;
3636
}
3737

38-
public void persistBaseline(Map<String, IdealState> globalBaseline) {
38+
public void persistBaseline(Map<String, ResourceAssignment> globalBaseline) {
3939
// TODO clean up invalid items
4040
_persistGlobalBaseline = globalBaseline;
4141
}
4242

43-
public Map<String, IdealState> getBestPossibleAssignment() {
43+
public Map<String, ResourceAssignment> getBestPossibleAssignment() {
4444
return _persistBestPossibleAssignment;
4545
}
4646

47-
public void persistBestPossibleAssignment(Map<String, IdealState> bestPossibleAssignment) {
47+
public void persistBestPossibleAssignment(Map<String, ResourceAssignment> bestPossibleAssignment) {
4848
// TODO clean up invalid items
4949
_persistBestPossibleAssignment.putAll(bestPossibleAssignment);
5050
}

helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/ClusterDataProvider.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
import org.apache.helix.controller.dataproviders.ResourceControllerDataProvider;
2323
import org.apache.helix.controller.rebalancer.waged.model.ClusterModel;
24-
import org.apache.helix.model.IdealState;
24+
import org.apache.helix.model.ResourceAssignment;
2525

2626
import java.util.Map;
2727
import java.util.Set;
@@ -46,7 +46,8 @@ public class ClusterDataProvider {
4646
*/
4747
protected static ClusterModel generateClusterModel(ResourceControllerDataProvider dataProvider,
4848
Set<String> activeInstances, Map<ClusterDataDetector.ChangeType, Set<String>> clusterChanges,
49-
Map<String, IdealState> baselineAssignment, Map<String, IdealState> bestPossibleAssignment) {
49+
Map<String, ResourceAssignment> baselineAssignment,
50+
Map<String, ResourceAssignment> bestPossibleAssignment) {
5051
// TODO finish the implementation.
5152
return null;
5253
}

helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/RebalanceAlgorithm.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
import org.apache.helix.controller.rebalancer.waged.constraints.HardConstraint;
2323
import org.apache.helix.controller.rebalancer.waged.model.ClusterModel;
24-
import org.apache.helix.model.IdealState;
2524
import org.apache.helix.model.ResourceAssignment;
2625

2726
import java.util.Map;
@@ -39,7 +38,7 @@ public interface RebalanceAlgorithm {
3938
* @param clusterModel
4039
* @param failureReasons Return the failures <ResourceName, <FailureReason, Count>> that happen during the rebalance calculation.
4140
* If the map is null, no failure will be returned.
42-
* @return A map <ResourceName, FailureReason> of the rebalanced resource assignments that are saved in the IdeaStates.
41+
* @return A map of <ResourceName, ResourceAssignment>.
4342
*/
4443
Map<String, ResourceAssignment> rebalance(ClusterModel clusterModel,
4544
Map<String, Map<HardConstraint.FailureReason, Integer>> failureReasons);

helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/constraints/ConstraintsRebalanceAlgorithm.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
import org.apache.helix.controller.rebalancer.waged.RebalanceAlgorithm;
2323
import org.apache.helix.controller.rebalancer.waged.model.ClusterModel;
24-
import org.apache.helix.model.IdealState;
2524
import org.apache.helix.model.ResourceAssignment;
2625
import org.slf4j.Logger;
2726
import org.slf4j.LoggerFactory;

0 commit comments

Comments
 (0)