Skip to content
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

Convert all the internal assignment state objects to be ResourceAssignment #399

Merged
merged 1 commit into from
Aug 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -28,23 +28,23 @@
* 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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down