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


Java HMaster.balanceSwitch方法代码示例

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


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

示例1: testMasterFailoverWhenDisablingTableRegionsInRITOnDeadRS

import org.apache.hadoop.hbase.master.HMaster; //导入方法依赖的package包/类
@Test (timeout=180000)
public void testMasterFailoverWhenDisablingTableRegionsInRITOnDeadRS() throws Exception {
  MiniHBaseCluster cluster = TESTUTIL.getHBaseCluster();
  HMaster master = cluster.getMaster();
  // disable load balancing on this master
  master.balanceSwitch(false);

  final String table = "testMasterFailoverWhenDisablingTableRegionsInRITOnDeadRS";
  byte [] FAMILY = Bytes.toBytes("family");
  byte[][] SPLIT_KEYS =
      new byte[][] {Bytes.toBytes("a"), Bytes.toBytes("b"), Bytes.toBytes("c"),
          Bytes.toBytes("d") };
  HTableDescriptor htd = new HTableDescriptor(table);
  HColumnDescriptor hcd = new HColumnDescriptor(FAMILY);
  htd.addFamily(hcd);
  TESTUTIL.getHBaseAdmin().createTable(htd, SPLIT_KEYS);
  AssignmentManager am = cluster.getMaster().getAssignmentManager();
  List<HRegionInfo> regionsOfTable = null;
  while ((regionsOfTable = am.getRegionsOfTable(table.getBytes())).size()
      != (SPLIT_KEYS.length + 1)) {
    Thread.sleep(10);
  }
  HRegionInfo closingRegion = regionsOfTable.get(0);
  ServerName serverName = am.getRegionServerOfRegion(closingRegion);
  HRegionServer deadRS = null;
  for (int i = 0; i < cluster.getRegionServerThreads().size(); i++) {
    deadRS = cluster.getRegionServer(i);
    if (deadRS.getServerName().equals(serverName)) {
      break;
    }
  }

  // Disable the table in ZK
  ZKTable zkTable = am.getZKTable();
  zkTable.setDisablingTable(table);
  ZKAssign.createNodeClosing(master.getZooKeeper(), closingRegion, serverName);

  // Stop the master
  abortMaster(cluster);
  master = startMasterAndWaitTillMetaRegionAssignment(cluster);
  deadRS.kill();
  deadRS.join();
  waitUntilMasterIsInitialized(master);
  am = cluster.getMaster().getAssignmentManager();
  zkTable = am.getZKTable();
  // wait for no more RIT
  ZKAssign.blockUntilNoRIT(master.getZooKeeper());
  while (!master.getAssignmentManager().getZKTable().isDisabledTable(table)) {
    Thread.sleep(10);
  }
  assertTrue("Table should be disabled state.", zkTable.isDisabledTable(table));
  HBaseAdmin admin = new HBaseAdmin(master.getConfiguration());
  admin.deleteTable(table);
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:55,代码来源:TestRSKilledWhenMasterInitializing.java


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