当前位置: 首页>>代码示例>>Java>>正文


Java StochasticLoadBalancer.balanceCluster方法代码示例

本文整理汇总了Java中org.apache.hadoop.hbase.master.balancer.StochasticLoadBalancer.balanceCluster方法的典型用法代码示例。如果您正苦于以下问题:Java StochasticLoadBalancer.balanceCluster方法的具体用法?Java StochasticLoadBalancer.balanceCluster怎么用?Java StochasticLoadBalancer.balanceCluster使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.hbase.master.balancer.StochasticLoadBalancer的用法示例。


在下文中一共展示了StochasticLoadBalancer.balanceCluster方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: makePlan

import org.apache.hadoop.hbase.master.balancer.StochasticLoadBalancer; //导入方法依赖的package包/类
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);
}
 
开发者ID:kakao,项目名称:hbase-tools,代码行数:20,代码来源:CommandAdapter.java

示例2: testJmxMetrics_EnsembleMode

import org.apache.hadoop.hbase.master.balancer.StochasticLoadBalancer; //导入方法依赖的package包/类
/**
 * In Ensemble mode, there should be only one ensemble table
 */
@Test (timeout=60000)
public void testJmxMetrics_EnsembleMode() throws Exception {
  loadBalancer = new StochasticLoadBalancer();

  conf.setBoolean(HConstants.HBASE_MASTER_LOADBALANCE_BYTABLE, false);
  loadBalancer.setConf(conf);

  TableName tableName = HConstants.ENSEMBLE_TABLE_NAME;
  Map<ServerName, List<RegionInfo>> clusterState = mockClusterServers(mockCluster_ensemble);
  loadBalancer.balanceCluster(tableName, clusterState);

  String[] tableNames = new String[] { tableName.getNameAsString() };
  String[] functionNames = loadBalancer.getCostFunctionNames();
  Set<String> jmxMetrics = readJmxMetricsWithRetry();
  Set<String> expectedMetrics = getExpectedJmxMetrics(tableNames, functionNames);

  // printMetrics(jmxMetrics, "existing metrics in ensemble mode");
  // printMetrics(expectedMetrics, "expected metrics in ensemble mode");

  // assert that every expected is in the JMX
  for (String expected : expectedMetrics) {
    assertTrue("Metric " + expected + " can not be found in JMX in ensemble mode.",
      jmxMetrics.contains(expected));
  }
}
 
开发者ID:apache,项目名称:hbase,代码行数:29,代码来源:TestStochasticBalancerJmxMetrics.java

示例3: testJmxMetrics_PerTableMode

import org.apache.hadoop.hbase.master.balancer.StochasticLoadBalancer; //导入方法依赖的package包/类
/**
 * In per-table mode, each table has a set of metrics
 */
@Test (timeout=60000)
public void testJmxMetrics_PerTableMode() throws Exception {
  loadBalancer = new StochasticLoadBalancer();

  conf.setBoolean(HConstants.HBASE_MASTER_LOADBALANCE_BYTABLE, true);
  loadBalancer.setConf(conf);

  // NOTE the size is normally set in setClusterMetrics, for test purpose, we set it manually
  // Tables: hbase:namespace, table1, table2
  // Functions: costFunctions, overall
  String[] functionNames = loadBalancer.getCostFunctionNames();
  loadBalancer.updateMetricsSize(3 * (functionNames.length + 1));

  // table 1
  TableName tableName = TableName.valueOf(TABLE_NAME_1);
  Map<ServerName, List<RegionInfo>> clusterState = mockClusterServers(mockCluster_pertable_1);
  loadBalancer.balanceCluster(tableName, clusterState);

  // table 2
  tableName = TableName.valueOf(TABLE_NAME_2);
  clusterState = mockClusterServers(mockCluster_pertable_2);
  loadBalancer.balanceCluster(tableName, clusterState);

  // table hbase:namespace
  tableName = TableName.valueOf(TABLE_NAME_NAMESPACE);
  clusterState = mockClusterServers(mockCluster_pertable_namespace);
  loadBalancer.balanceCluster(tableName, clusterState);

  String[] tableNames = new String[] { TABLE_NAME_1, TABLE_NAME_2, TABLE_NAME_NAMESPACE };
  Set<String> jmxMetrics = readJmxMetricsWithRetry();
  Set<String> expectedMetrics = getExpectedJmxMetrics(tableNames, functionNames);

  // printMetrics(jmxMetrics, "existing metrics in per-table mode");
  // printMetrics(expectedMetrics, "expected metrics in per-table mode");

  // assert that every expected is in the JMX
  for (String expected : expectedMetrics) {
    assertTrue("Metric " + expected + " can not be found in JMX in per-table mode.",
      jmxMetrics.contains(expected));
  }
}
 
开发者ID:apache,项目名称:hbase,代码行数:45,代码来源:TestStochasticBalancerJmxMetrics.java


注:本文中的org.apache.hadoop.hbase.master.balancer.StochasticLoadBalancer.balanceCluster方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。