本文整理汇总了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);
}