use of voldemort.client.rebalance.RebalanceTaskInfo in project voldemort by voldemort.
the class RebalancerState method create.
public static RebalancerState create(String json) {
List<RebalanceTaskInfo> stealInfoList = Lists.newLinkedList();
JsonReader reader = new JsonReader(new StringReader(json));
for (Object o : reader.readArray()) {
Map<?, ?> m = (Map<?, ?>) o;
stealInfoList.add(RebalanceTaskInfo.create(m));
}
return new RebalancerState(stealInfoList);
}
use of voldemort.client.rebalance.RebalanceTaskInfo in project voldemort by voldemort.
the class RebalanceUtils method filterTaskPlanWithStores.
/**
* Given a list of partition plans and a set of stores, copies the store
* names to every individual plan and creates a new list
*
* @param existingPlanList Existing partition plan list
* @param storeDefs List of store names we are rebalancing
* @return List of updated partition plan
*/
public static List<RebalanceTaskInfo> filterTaskPlanWithStores(List<RebalanceTaskInfo> existingPlanList, List<StoreDefinition> storeDefs) {
List<RebalanceTaskInfo> plans = Lists.newArrayList();
List<String> storeNames = StoreDefinitionUtils.getStoreNames(storeDefs);
for (RebalanceTaskInfo existingPlan : existingPlanList) {
RebalanceTaskInfo info = RebalanceTaskInfo.create(existingPlan.toJsonString());
// Filter the plans only for stores given
HashMap<String, List<Integer>> storeToPartitions = info.getStoreToPartitionIds();
HashMap<String, List<Integer>> newStoreToPartitions = Maps.newHashMap();
for (String storeName : storeNames) {
if (storeToPartitions.containsKey(storeName))
newStoreToPartitions.put(storeName, storeToPartitions.get(storeName));
}
info.setStoreToPartitionList(newStoreToPartitions);
plans.add(info);
}
return plans;
}
Aggregations