Package voldemort.client.rebalance

Examples of voldemort.client.rebalance.RebalanceTaskInfo


            List<Integer> partitionIds = partition;

            HashMap<String, List<Integer>> storeToReplicaToPartitionList = Maps.newHashMap();
            storeToReplicaToPartitionList.put("test", partitionIds);

            return ByteUtils.getBytes(new RebalancerState(Arrays.asList(new RebalanceTaskInfo(0,
                                                                                              (int) Math.random() * 5,
                                                                                              storeToReplicaToPartitionList,
                                                                                              ServerTestUtils.getLocalCluster(1)))).toJsonString(),
                                      "UTF-8");
        }
View Full Code Here


        HashMap<String, List<Integer>> storeToPartitionIds = Maps.newHashMap();
        storeToPartitionIds.put("test1", Lists.newArrayList(0, 1, 2));
        storeToPartitionIds.put("test2", Lists.newArrayList(3, 4, 5, 6));

        List<RebalanceTaskInfo> rebalanceTaskInfos = Arrays.asList(new RebalanceTaskInfo(2,
                                                                                         0,
                                                                                         storeToPartitionIds,
                                                                                         ServerTestUtils.getLocalCluster(1)),
                                                                   new RebalanceTaskInfo(3,
                                                                                         1,
                                                                                         storeToPartitionIds,
                                                                                         ServerTestUtils.getLocalCluster(2)));

        RebalancerState in = new RebalancerState(rebalanceTaskInfos);
View Full Code Here

     * @param rebalanceTaskInfoMap Proto-buff version of
     *        RebalanceTaskInfoMap
     * @return RebalanceTaskInfo object.
     */
    public static RebalanceTaskInfo decodeRebalanceTaskInfoMap(VAdminProto.RebalanceTaskInfoMap rebalanceTaskInfoMap) {
        RebalanceTaskInfo rebalanceTaskInfo = new RebalanceTaskInfo(
                                                                    rebalanceTaskInfoMap.getStealerId(),
                                                                    rebalanceTaskInfoMap.getDonorId(),
                                                                    decodeStoreToPartitionIds(rebalanceTaskInfoMap.getPerStorePartitionIdsList()),
                                                                    new ClusterMapper().readCluster(new StringReader(rebalanceTaskInfoMap.getInitialCluster())));
        return rebalanceTaskInfo;
View Full Code Here

                                                                   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;
    }
View Full Code Here

     * @param stealInfo Partition info to steal
     * @return Returns a id identifying the async operation
     */
    public int rebalanceNode(final RebalanceTaskInfo stealInfo) {

        final RebalanceTaskInfo info = metadataStore.getRebalancerState()
                                                    .find(stealInfo.getDonorId());

        // Do we have the plan in the state?
        if(info == null) {
            throw new VoldemortException("Could not find plan " + stealInfo
                                         + " in the server state on " + metadataStore.getNodeId());
        } else if(!info.equals(stealInfo)) {
            // If we do have the plan, is it the same
            throw new VoldemortException("The plan in server state " + info
                                         + " is not the same as the process passed " + stealInfo);
        } else if(!acquireRebalancingPermit(stealInfo.getDonorId())) {
            // Both are same, now try to acquire a lock for the donor node
            throw new AlreadyRebalancingException("Node " + metadataStore.getNodeId()
                                                  + " is already rebalancing from donor "
                                                  + info.getDonorId() + " with info " + info);
        }

        // Acquired lock successfully, start rebalancing...
        int requestId = asyncService.getUniqueRequestId();

View Full Code Here

    public boolean isEmpty() {
        return stealInfoMap.isEmpty();
    }

    public boolean remove(RebalanceTaskInfo rebalanceTaskInfo) {
        RebalanceTaskInfo prev = stealInfoMap.remove(rebalanceTaskInfo.getDonorId());
        return prev != null;
    }
View Full Code Here

                int nodeId = request.getNodeId();
                String storeName = request.getStoreName();

                logger.info("Removing rebalancing state for donor node " + nodeId + " and store "
                            + storeName + " from stealer node " + metadataStore.getNodeId());
                RebalanceTaskInfo info = metadataStore.getRebalancerState().find(nodeId);
                if(info == null) {
                    throw new VoldemortException("Could not find state for donor node " + nodeId);
                }

                List<Integer> partitionIds = info.getPartitionIds(storeName);
                if(partitionIds.size() == 0) {
                    throw new VoldemortException("Could not find state for donor node " + nodeId
                                                 + " and store " + storeName);
                }

                info.removeStore(storeName);
                logger.info("Removed rebalancing state for donor node " + nodeId + " and store "
                            + storeName + " from stealer node " + metadataStore.getNodeId());

                if(info.getPartitionStores().isEmpty()) {
                    metadataStore.deleteRebalancingState(info);
                    logger.info("Removed entire rebalancing state for donor node " + nodeId
                                + " from stealer node " + metadataStore.getNodeId());
                }
            } catch(VoldemortException e) {
View Full Code Here

                                                                                + metadataStore.getNodeId()
                                                                                + " not in rebalancing state")));
                return response.build();
            }

            RebalanceTaskInfo rebalanceStealInfo = ProtoUtils.decodeRebalanceTaskInfoMap(request.getRebalanceTaskInfo());

            int requestId = rebalancer.rebalanceNode(rebalanceStealInfo);

            response.setRequestId(requestId)
                    .setDescription(rebalanceStealInfo.toString())
                    .setStatus("Started rebalancing")
                    .setComplete(false);

        } catch(VoldemortException e) {
            response.setError(ProtoUtils.encodeError(errorCodeMapper, e));
View Full Code Here

TOP

Related Classes of voldemort.client.rebalance.RebalanceTaskInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.