Search in sources :

Example 11 with RebalanceTaskInfo

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);
}
Also used : StringReader(java.io.StringReader) JsonReader(voldemort.serialization.json.JsonReader) Map(java.util.Map) RebalanceTaskInfo(voldemort.client.rebalance.RebalanceTaskInfo)

Example 12 with RebalanceTaskInfo

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;
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) RebalanceTaskInfo(voldemort.client.rebalance.RebalanceTaskInfo)

Aggregations

RebalanceTaskInfo (voldemort.client.rebalance.RebalanceTaskInfo)12 VoldemortException (voldemort.VoldemortException)5 List (java.util.List)3 StringReader (java.io.StringReader)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 Cluster (voldemort.cluster.Cluster)2 StoreDefinition (voldemort.store.StoreDefinition)2 StoreDefinitionsMapper (voldemort.xml.StoreDefinitionsMapper)2 File (java.io.File)1 StringWriter (java.io.StringWriter)1 Before (org.junit.Before)1 Test (org.junit.Test)1 ClientConfig (voldemort.client.ClientConfig)1 SocketStoreClientFactory (voldemort.client.SocketStoreClientFactory)1 RebalanceTaskInfoMap (voldemort.client.protocol.pb.VAdminProto.RebalanceTaskInfoMap)1 RebalanceBatchPlan (voldemort.client.rebalance.RebalanceBatchPlan)1 RoutingStrategy (voldemort.routing.RoutingStrategy)1 RoutingStrategyFactory (voldemort.routing.RoutingStrategyFactory)1 SerializerDefinition (voldemort.serialization.SerializerDefinition)1