org.apache.hadoop.hbase.client.Admin.split()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(8.0k)|赞(0)|评价(0)|浏览(126)

本文整理了Java中org.apache.hadoop.hbase.client.Admin.split()方法的一些代码示例,展示了Admin.split()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Admin.split()方法的具体详情如下:
包路径:org.apache.hadoop.hbase.client.Admin
类名称:Admin
方法名:split

Admin.split介绍

[英]Split a table. Asynchronous operation.
[中]分开一张桌子。异步操作。

代码示例

代码示例来源:origin: apache/hbase

@Override
 public void perform() throws Exception {
  HBaseTestingUtility util = context.getHBaseIntegrationTestingUtility();
  Admin admin = util.getAdmin();
  // Don't try the split if we're stopping
  if (context.isStopping()) {
   return;
  }

  // Don't always split. This should allow splitting of a full table later in the run
  if (ThreadLocalRandom.current().nextDouble()
    < (((double) splits) / ((double) maxFullTableSplits)) / ((double) 2)) {
   splits++;
   LOG.info("Performing action: Split all regions of  " + tableName);
   admin.split(tableName);
  } else {
   LOG.info("Skipping split of all regions.");
  }
 }
}

代码示例来源:origin: apache/hbase

private List<HRegionLocation> splitTable(final Table t)
throws IOException, InterruptedException {
 // Split this table in two.
 Admin admin = TEST_UTIL.getAdmin();
 admin.split(t.getName());
 admin.close();
 List<HRegionLocation> regions = waitOnSplit(t);
 assertTrue(regions.size() > 1);
 return regions;
}

代码示例来源:origin: apache/hbase

@Test
public void testSplitShouldNotHappenIfSplitIsDisabledForTable()
  throws Exception {
 final TableName tableName = TableName.valueOf(name.getMethodName());
 HTableDescriptor htd = new HTableDescriptor(tableName);
 htd.addFamily(new HColumnDescriptor("f"));
 htd.setRegionSplitPolicyClassName(DisabledRegionSplitPolicy.class.getName());
 Table table = TEST_UTIL.createTable(htd, null);
 for(int i = 0; i < 10; i++) {
  Put p = new Put(Bytes.toBytes("row"+i));
  byte[] q1 = Bytes.toBytes("q1");
  byte[] v1 = Bytes.toBytes("v1");
  p.addColumn(Bytes.toBytes("f"), q1, v1);
  table.put(p);
 }
 this.admin.flush(tableName);
 try {
  this.admin.split(tableName, Bytes.toBytes("row5"));
  Threads.sleep(10000);
 } catch (Exception e) {
  // Nothing to do.
 }
 // Split should not happen.
 List<RegionInfo> allRegions = MetaTableAccessor.getTableRegions(
   this.admin.getConnection(), tableName, true);
 assertEquals(1, allRegions.size());
}

代码示例来源:origin: apache/hbase

private void splitRegion(final RegionInfo regionInfo) throws IOException {
 byte[][] splitPoints = Bytes.split(regionInfo.getStartKey(), regionInfo.getEndKey(), 1);
 admin.split(regionInfo.getTable(), splitPoints[1]);
}

代码示例来源:origin: apache/hbase

protected final void splitRegion(RegionInfo regionInfo) throws IOException {
 byte[][] splitPoints = Bytes.split(regionInfo.getStartKey(), regionInfo.getEndKey(), 1);
 admin.split(regionInfo.getTable(), splitPoints[1]);
}

代码示例来源:origin: apache/hbase

for (byte[] splitPoint : SPLIT_KEYS) {
 int oldRegionCount = admin.getRegions(TABLE_NAME).size();
 admin.split(TABLE_NAME, splitPoint);
 TEST_UTIL.waitFor(30000, new ExplainingPredicate<Exception>() {
  @Override

代码示例来源:origin: apache/hbase

@Test
public void testRestoreSnapshot() throws Exception {
 String nsp = prefix + "_testRestoreSnapshot";
 NamespaceDescriptor nspDesc =
   NamespaceDescriptor.create(nsp)
     .addConfiguration(TableNamespaceManager.KEY_MAX_REGIONS, "10").build();
 ADMIN.createNamespace(nspDesc);
 assertNotNull("Namespace descriptor found null.", ADMIN.getNamespaceDescriptor(nsp));
 TableName tableName1 = TableName.valueOf(nsp + TableName.NAMESPACE_DELIM + "table1");
 HTableDescriptor tableDescOne = new HTableDescriptor(tableName1);
 HColumnDescriptor fam1 = new HColumnDescriptor("fam1");
 tableDescOne.addFamily(fam1);
 ADMIN.createTable(tableDescOne, Bytes.toBytes("AAA"), Bytes.toBytes("ZZZ"), 4);
 NamespaceTableAndRegionInfo nstate = getNamespaceState(nsp);
 assertEquals("Intial region count should be 4.", 4, nstate.getRegionCount());
 String snapshot = "snapshot_testRestoreSnapshot";
 ADMIN.snapshot(snapshot, tableName1);
 List<HRegionInfo> regions = ADMIN.getTableRegions(tableName1);
 Collections.sort(regions);
 ADMIN.split(tableName1, Bytes.toBytes("JJJ"));
 Thread.sleep(2000);
 assertEquals("Total regions count should be 5.", 5, nstate.getRegionCount());
 ADMIN.disableTable(tableName1);
 ADMIN.restoreSnapshot(snapshot);
 assertEquals("Total regions count should be 4 after restore.", 4, nstate.getRegionCount());
 ADMIN.enableTable(tableName1);
 ADMIN.deleteSnapshot(snapshot);
}

代码示例来源:origin: apache/hbase

@Test
public void testSplitFlushCompactUnknownTable() throws InterruptedException {
 final TableName unknowntable = TableName.valueOf(name.getMethodName());
 Exception exception = null;
 try {
  this.admin.compact(unknowntable);
 } catch (IOException e) {
  exception = e;
 }
 assertTrue(exception instanceof TableNotFoundException);
 exception = null;
 try {
  this.admin.flush(unknowntable);
 } catch (IOException e) {
  exception = e;
 }
 assertTrue(exception instanceof TableNotFoundException);
 exception = null;
 try {
  this.admin.split(unknowntable);
 } catch (IOException e) {
  exception = e;
 }
 assertTrue(exception instanceof TableNotFoundException);
}

代码示例来源:origin: apache/hbase

TEST_UTIL.getAdmin().split(TABLENAME);

代码示例来源:origin: apache/hbase

admin.split(tableName);
TEST_UTIL.waitFor(60000, new Waiter.Predicate<Exception>() {
 @Override

代码示例来源:origin: apache/hbase

@Test
public void testSplitSwitch() throws Exception {
 final TableName tableName = TableName.valueOf(name.getMethodName());
 Table t = TEST_UTIL.createTable(tableName, FAMILY);
 TEST_UTIL.loadTable(t, FAMILY, false);
 RegionLocator locator = TEST_UTIL.getConnection().getRegionLocator(t.getName());
 int originalCount = locator.getAllRegionLocations().size();
 Admin admin = TEST_UTIL.getAdmin();
 initSwitchStatus(admin);
 boolean[] results = admin.setSplitOrMergeEnabled(false, false, MasterSwitchType.SPLIT);
 assertEquals(1, results.length);
 assertTrue(results[0]);
 admin.split(t.getName());
 int count = admin.getTableRegions(tableName).size();
 assertTrue(originalCount == count);
 results = admin.setSplitOrMergeEnabled(true, false, MasterSwitchType.SPLIT);
 assertEquals(1, results.length);
 assertFalse(results[0]);
 admin.split(t.getName());
 while ((count = admin.getTableRegions(tableName).size()) == originalCount) {
  Threads.sleep(1);
 }
 count = admin.getTableRegions(tableName).size();
 assertTrue(originalCount < count);
 admin.close();
}

代码示例来源:origin: apache/hbase

region.flush(true);
LOG.info("About to SPLIT on " + Bytes.toString(ROW1));
TEST_UTIL.getAdmin().split(tableName, ROW1);

代码示例来源:origin: apache/hbase

int originalCount = admin.getTableRegions(tableName).size();
initSwitchStatus(admin);
admin.split(t.getName());
int postSplitCount = -1;
while ((postSplitCount = admin.getTableRegions(tableName).size()) == originalCount) {

代码示例来源:origin: apache/hbase

Admin admin = UTIL.getAdmin();
try {
 admin.split(TEST_TABLE);

代码示例来源:origin: apache/hbase

private void splitAndTruncate(TableName tableName, RegionInfo[] regions, int regionReplication)
   throws IOException, InterruptedException {
  // split a region
  UTIL.getAdmin().split(tableName, new byte[] { '0' });

  // wait until split really happens
  UTIL.waitFor(60000,
   () -> UTIL.getAdmin().getRegions(tableName).size() > regions.length * regionReplication);

  // disable the table
  UTIL.getAdmin().disableTable(tableName);

  // truncate the table
  ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();
  long procId = ProcedureTestingUtility.submitAndWait(procExec,
   new TruncateTableProcedure(procExec.getEnvironment(), tableName, true));
  ProcedureTestingUtility.assertProcNotFailed(procExec, procId);

  UTIL.waitUntilAllRegionsAssigned(tableName);
  // confirm that we have the correct number of regions
  assertEquals((regions.length + 1) * regionReplication,
   UTIL.getAdmin().getRegions(tableName).size());
 }
}

代码示例来源:origin: apache/hbase

UTIL.getAdmin().createTable(td, new byte[][] { Bytes.toBytes(1) });
UTIL.waitTableAvailable(tableName);
UTIL.getAdmin().split(tableName, Bytes.toBytes(2));
UTIL.waitFor(30000, new ExplainingPredicate<Exception>() {

代码示例来源:origin: apache/hbase

admin.split(tableName, splitPoint);

代码示例来源:origin: apache/hbase

admin.split(tableName, Bytes.toBytes("eee"));
TestTableSnapshotScanner.blockUntilSplitFinished(UTIL, tableName, 2);

代码示例来源:origin: apache/hbase

admin.split(tableName, Bytes.toBytes("eee"));
blockUntilSplitFinished(UTIL, tableName, 2);

代码示例来源:origin: apache/hbase

HTU.getAdmin().split(table.getName(), Bytes.toBytes(1));
int count = 0;
while (true) {

相关文章

Admin类方法