Java Code Examples for org.apache.hadoop.hbase.master.balancer.StochasticLoadBalancer#balanceCluster()

The following examples show how to use org.apache.hadoop.hbase.master.balancer.StochasticLoadBalancer#balanceCluster() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CommandAdapter.java    From hbase-tools with Apache License 2.0 6 votes vote down vote up
public static List<RegionPlan> makePlan(HBaseAdmin admin, List<RegionPlan> newRegionPlan) throws IOException {
    // snapshot current region assignment
    Map<HRegionInfo, ServerName> regionAssignmentMap = createRegionAssignmentMap(admin);

    // update with new plan
    for (RegionPlan regionPlan : newRegionPlan) {
        regionAssignmentMap.put(regionPlan.getRegionInfo(), regionPlan.getDestination());
    }

    Map<ServerName, List<HRegionInfo>> clusterState = initializeRegionMap(admin);
    for (Map.Entry<HRegionInfo, ServerName> entry : regionAssignmentMap.entrySet())
        clusterState.get(entry.getValue()).add(entry.getKey());

    StochasticLoadBalancer balancer = new StochasticLoadBalancer();
    Configuration conf = admin.getConfiguration();
    conf.setFloat("hbase.regions.slop", 0.2f);
    balancer.setConf(conf);
    return balancer.balanceCluster(clusterState);
}
 
Example 2
Source File: CommandAdapter.java    From hbase-tools with Apache License 2.0 6 votes vote down vote up
public static List<RegionPlan> makePlan(HBaseAdmin admin, List<RegionPlan> newRegionPlan) throws IOException {
    // snapshot current region assignment
    Map<HRegionInfo, ServerName> regionAssignmentMap = createRegionAssignmentMap(admin);

    // update with new plan
    for (RegionPlan regionPlan : newRegionPlan) {
        regionAssignmentMap.put(regionPlan.getRegionInfo(), regionPlan.getDestination());
    }

    Map<ServerName, List<HRegionInfo>> clusterState = initializeRegionMap(admin);
    for (Map.Entry<HRegionInfo, ServerName> entry : regionAssignmentMap.entrySet())
        clusterState.get(entry.getValue()).add(entry.getKey());

    StochasticLoadBalancer balancer = new StochasticLoadBalancer();
    Configuration conf = admin.getConfiguration();
    conf.setFloat("hbase.regions.slop", 0.2f);
    balancer.setConf(conf);
    return balancer.balanceCluster(clusterState);
}
 
Example 3
Source File: CommandAdapter.java    From hbase-tools with Apache License 2.0 6 votes vote down vote up
public static List<RegionPlan> makePlan(HBaseAdmin admin, List<RegionPlan> newRegionPlan) throws IOException {
    // snapshot current region assignment
    Map<HRegionInfo, ServerName> regionAssignmentMap = createRegionAssignmentMap(admin);

    // update with new plan
    for (RegionPlan regionPlan : newRegionPlan) {
        regionAssignmentMap.put(regionPlan.getRegionInfo(), regionPlan.getDestination());
    }

    Map<ServerName, List<HRegionInfo>> clusterState = initializeRegionMap(admin);
    for (Map.Entry<HRegionInfo, ServerName> entry : regionAssignmentMap.entrySet())
        clusterState.get(entry.getValue()).add(entry.getKey());

    StochasticLoadBalancer balancer = new StochasticLoadBalancer();
    Configuration conf = admin.getConfiguration();
    conf.setFloat("hbase.regions.slop", 0.2f);
    balancer.setConf(conf);
    return balancer.balanceCluster(clusterState);
}
 
Example 4
Source File: CommandAdapter.java    From hbase-tools with Apache License 2.0 6 votes vote down vote up
public static List<RegionPlan> makePlan(HBaseAdmin admin, List<RegionPlan> newRegionPlan) throws IOException {
    // snapshot current region assignment
    Map<HRegionInfo, ServerName> regionAssignmentMap = createRegionAssignmentMap(admin);

    // update with new plan
    for (RegionPlan regionPlan : newRegionPlan) {
        regionAssignmentMap.put(regionPlan.getRegionInfo(), regionPlan.getDestination());
    }

    Map<ServerName, List<HRegionInfo>> clusterState = initializeRegionMap(admin);
    for (Map.Entry<HRegionInfo, ServerName> entry : regionAssignmentMap.entrySet())
        clusterState.get(entry.getValue()).add(entry.getKey());

    StochasticLoadBalancer balancer = new StochasticLoadBalancer();
    Configuration conf = admin.getConfiguration();
    conf.setFloat("hbase.regions.slop", 0.2f);
    balancer.setConf(conf);
    return balancer.balanceCluster(clusterState);
}
 
Example 5
Source File: CommandAdapter.java    From hbase-tools with Apache License 2.0 5 votes vote down vote up
public static List<RegionPlan> makePlan(HBaseAdmin admin,
    Map<ServerName, List<HRegionInfo>> clusterState, Configuration conf) throws IOException {
    StochasticLoadBalancer balancer = new StochasticLoadBalancer() {
        @Override
        protected boolean needsBalance(ClusterLoadState cs) {
            return true;
        }
    };
    balancer.setConf(conf);
    balancer.setClusterStatus(admin.getClusterStatus());
    List<RegionPlan> regionPlanList = balancer.balanceCluster(clusterState);
    return regionPlanList == null ? new ArrayList<RegionPlan>() : regionPlanList;
}
 
Example 6
Source File: CommandAdapter.java    From hbase-tools with Apache License 2.0 5 votes vote down vote up
public static List<RegionPlan> makePlan(HBaseAdmin admin, Map<ServerName, List<HRegionInfo>> clusterState, Configuration conf) throws IOException {
    StochasticLoadBalancer balancer = new StochasticLoadBalancer() {
        @Override
        protected boolean needsBalance(Cluster c) {
            return true;
        }
    };
    balancer.setConf(conf);
    balancer.setClusterStatus(admin.getClusterStatus());
    List<RegionPlan> regionPlanList = balancer.balanceCluster(clusterState);
    return regionPlanList == null ? new ArrayList<RegionPlan>() : regionPlanList;
}
 
Example 7
Source File: CommandAdapter.java    From hbase-tools with Apache License 2.0 5 votes vote down vote up
public static List<RegionPlan> makePlan(HBaseAdmin admin,
    Map<ServerName, List<HRegionInfo>> clusterState, Configuration conf) throws IOException {
    StochasticLoadBalancer balancer = new StochasticLoadBalancer() {
        @Override
        protected boolean needsBalance(ClusterLoadState cs) {
            return true;
        }
    };
    balancer.setConf(conf);
    balancer.setClusterStatus(admin.getClusterStatus());
    List<RegionPlan> regionPlanList = balancer.balanceCluster(clusterState);
    return regionPlanList == null ? new ArrayList<RegionPlan>() : regionPlanList;
}
 
Example 8
Source File: CommandAdapter.java    From hbase-tools with Apache License 2.0 5 votes vote down vote up
public static List<RegionPlan> makePlan(HBaseAdmin admin, Map<ServerName, List<HRegionInfo>> clusterState, Configuration conf) throws IOException {
    StochasticLoadBalancer balancer = new StochasticLoadBalancer() {
        @Override
        protected boolean needsBalance(Cluster c) {
            return true;
        }
    };
    balancer.setConf(conf);
    balancer.setClusterStatus(admin.getClusterStatus());
    List<RegionPlan> regionPlanList = balancer.balanceCluster(clusterState);
    return regionPlanList == null ? new ArrayList<RegionPlan>() : regionPlanList;
}