Ejemplo n.º 1
0
  protected void testWithCluster(
      Map<ServerName, List<HRegionInfo>> serverMap,
      RackManager rackManager,
      boolean assertFullyBalanced,
      boolean assertFullyBalancedForReplicas) {
    List<ServerAndLoad> list = convertToList(serverMap);
    LOG.info("Mock Cluster : " + printMock(list) + " " + printStats(list));

    loadBalancer.setRackManager(rackManager);
    // Run the balancer.
    List<RegionPlan> plans = loadBalancer.balanceCluster(serverMap);
    assertNotNull(plans);

    // Check to see that this actually got to a stable place.
    if (assertFullyBalanced || assertFullyBalancedForReplicas) {
      // Apply the plan to the mock cluster.
      List<ServerAndLoad> balancedCluster = reconcile(list, plans, serverMap);

      // Print out the cluster loads to make debugging easier.
      LOG.info("Mock Balance : " + printMock(balancedCluster));

      if (assertFullyBalanced) {
        assertClusterAsBalanced(balancedCluster);
        List<RegionPlan> secondPlans = loadBalancer.balanceCluster(serverMap);
        assertNull(secondPlans);
      }

      if (assertFullyBalancedForReplicas) {
        assertRegionReplicaPlacement(serverMap, rackManager);
      }
    }
  }
Ejemplo n.º 2
0
 @BeforeClass
 public static void beforeAllTests() throws Exception {
   conf = HBaseConfiguration.create();
   conf.setClass("hbase.util.ip.to.rack.determiner", MockMapping.class, DNSToSwitchMapping.class);
   conf.setFloat("hbase.master.balancer.stochastic.maxMovePercent", 0.75f);
   conf.setFloat("hbase.regions.slop", 0.0f);
   conf.setFloat("hbase.master.balancer.stochastic.localityCost", 0);
   conf.setFloat("hbase.master.balancer.stochastic.minCostNeedBalance", 0.0f);
   loadBalancer = new StochasticLoadBalancer();
   loadBalancer.setConf(conf);
 }