本文整理匯總了Java中org.apache.hadoop.hbase.client.HBaseAdmin.balancer方法的典型用法代碼示例。如果您正苦於以下問題:Java HBaseAdmin.balancer方法的具體用法?Java HBaseAdmin.balancer怎麽用?Java HBaseAdmin.balancer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.hadoop.hbase.client.HBaseAdmin
的用法示例。
在下文中一共展示了HBaseAdmin.balancer方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setUpBeforeClass
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
/**
* Spin up a cluster with a bunch of regions on it.
*/
@BeforeClass
public static void setUpBeforeClass() throws Exception {
TEST_UTIL.startMiniCluster(NB_SLAVES);
TEST_UTIL.getConfiguration().setBoolean("hbase.master.enabletable.roundrobin", true);
ZooKeeperWatcher zkw = HBaseTestingUtility.getZooKeeperWatcher(TEST_UTIL);
HTableDescriptor htd = new HTableDescriptor(TABLENAME);
htd.addFamily(new HColumnDescriptor(FAMILY));
TEST_UTIL.createMultiRegionsInMeta(TEST_UTIL.getConfiguration(), htd,
HBaseTestingUtility.KEYS);
// Make a mark for the table in the filesystem.
FileSystem fs = FileSystem.get(TEST_UTIL.getConfiguration());
FSTableDescriptors.
createTableDescriptor(fs, FSUtils.getRootDir(TEST_UTIL.getConfiguration()), htd);
// Assign out the regions we just created.
HBaseAdmin admin = new HBaseAdmin(TEST_UTIL.getConfiguration());
MiniHBaseCluster cluster = TEST_UTIL.getMiniHBaseCluster();
admin.disableTable(TABLENAME);
admin.enableTable(TABLENAME);
boolean ready = false;
while (!ready) {
ZKAssign.blockUntilNoRIT(zkw);
// Assert that every regionserver has some regions on it, else invoke the balancer.
ready = true;
for (int i = 0; i < NB_SLAVES; i++) {
HRegionServer hrs = cluster.getRegionServer(i);
if (hrs.getOnlineRegions().isEmpty()) {
ready = false;
break;
}
}
if (!ready) {
admin.balancer();
Thread.sleep(100);
}
}
}
示例2: perform
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
@Override
public void perform() throws Exception {
LOG.info("Balancing regions");
HBaseAdmin admin = this.context.getHBaseIntegrationTestingUtility().getHBaseAdmin();
boolean result = admin.balancer();
if (!result) {
LOG.error("Balancer didn't succeed");
}
}
示例3: forceBalancer
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
protected void forceBalancer() throws Exception {
HBaseAdmin admin = this.context.getHBaseIntegrationTestingUtility().getHBaseAdmin();
boolean result = admin.balancer();
if (!result) {
LOG.error("Balancer didn't succeed");
}
}