Search in sources :

Example 11 with ResourceAssignment

use of org.apache.helix.model.ResourceAssignment in project helix by apache.

the class TaskRebalancer method buildEmptyAssignment.

protected ResourceAssignment buildEmptyAssignment(String name, CurrentStateOutput currStateOutput) {
    ResourceAssignment assignment = new ResourceAssignment(name);
    Set<Partition> partitions = currStateOutput.getCurrentStateMappedPartitions(name);
    for (Partition partition : partitions) {
        Map<String, String> currentStateMap = currStateOutput.getCurrentStateMap(name, partition);
        Map<String, String> replicaMap = Maps.newHashMap();
        for (String instanceName : currentStateMap.keySet()) {
            replicaMap.put(instanceName, HelixDefinedState.DROPPED.toString());
        }
        assignment.addReplicaMap(partition, replicaMap);
    }
    return assignment;
}
Also used : Partition(org.apache.helix.model.Partition) ResourceAssignment(org.apache.helix.model.ResourceAssignment)

Aggregations

ResourceAssignment (org.apache.helix.model.ResourceAssignment)11 Partition (org.apache.helix.model.Partition)8 TreeSet (java.util.TreeSet)4 ImmutableMap (com.google.common.collect.ImmutableMap)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 TreeMap (java.util.TreeMap)3 StateModelDefinition (org.apache.helix.model.StateModelDefinition)3 HashSet (java.util.HashSet)2 SortedSet (java.util.SortedSet)2 HelixDataAccessor (org.apache.helix.HelixDataAccessor)2 PropertyKey (org.apache.helix.PropertyKey)2 ZNRecord (org.apache.helix.ZNRecord)2 Message (org.apache.helix.model.Message)2 BiMap (com.google.common.collect.BiMap)1 HashBiMap (com.google.common.collect.HashBiMap)1 ClusterConfig (org.apache.helix.model.ClusterConfig)1 Test (org.testng.annotations.Test)1