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

x33g5p2x  于2022-01-29 转载在 其他  
字(6.8k)|赞(0)|评价(0)|浏览(198)

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

Table.getName介绍

[英]Gets the fully qualified table name instance of this table.
[中]获取此表的完全限定表名实例。

代码示例

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

  1. @Override
  2. public List<LoadQueueItem> call() throws Exception {
  3. List<LoadQueueItem> toRetry =
  4. tryAtomicRegionLoad(serviceCallable, table.getName(), first, lqis);
  5. return toRetry;
  6. }
  7. };

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

  1. /**
  2. * Invokes Table#delete to delete test data (i.e. the row)
  3. *
  4. * @param table Standard Table object
  5. * @throws IOException If IO problem is encountered
  6. */
  7. static void deleteRow(final Table table) throws IOException {
  8. System.out.println("Deleting row [" + Bytes.toString(MY_ROW_ID)
  9. + "] from Table ["
  10. + table.getName().getNameAsString() + "].");
  11. table.delete(new Delete(MY_ROW_ID));
  12. }

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

  1. /**
  2. * Invokes Table#delete to delete test data (i.e. the row)
  3. *
  4. * @param table Standard Table object
  5. * @throws IOException If IO problem is encountered
  6. */
  7. static void deleteRow(final Table table) throws IOException {
  8. System.out.println("Deleting row [" + Bytes.toString(MY_ROW_ID)
  9. + "] from Table ["
  10. + table.getName().getNameAsString() + "].");
  11. table.delete(new Delete(MY_ROW_ID));
  12. }

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

  1. @Override
  2. public Table getTable(TableName tableName) throws IOException {
  3. Table table = Mockito.mock(Table.class);
  4. Mockito.when(table.getName()).thenReturn(tableName);
  5. return table;
  6. }

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

  1. @Override
  2. public Table getTable(TableName tableName) throws IOException {
  3. Table table = mock(Table.class);
  4. when(table.getName()).thenReturn(tableName);
  5. return table;
  6. }

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

  1. @Override
  2. protected void closeHTable() {
  3. if (table != null) {
  4. try {
  5. table.close();
  6. } catch (Exception e) {
  7. LOG.error("Error in closing the table "+table.getName(), e);
  8. }
  9. }
  10. }

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

  1. @Override
  2. protected void closeTable() {
  3. for (Table table : userVsTable.values()) {
  4. try {
  5. table.close();
  6. } catch (Exception e) {
  7. LOG.error("Error while closing the table " + table.getName(), e);
  8. }
  9. }
  10. }

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

  1. @Override
  2. public void loadData(final Table table, byte[]... families) throws Exception {
  3. SnapshotTestingUtils.loadData(UTIL, table.getName(), 1000, families);
  4. }

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

  1. private void verify(Table t, IOThrowingRunnable test) throws IOException {
  2. admin.disableTable(t.getName());
  3. admin.truncateTable(t.getName(), false);
  4. test.run();
  5. }

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

  1. private static void waitOnSplit(Connection c, final Table t, int originalCount) throws Exception {
  2. for (int i = 0; i < 200; i++) {
  3. Threads.sleepWithoutInterrupt(500);
  4. try (RegionLocator locator = c.getRegionLocator(t.getName())) {
  5. if (locator.getAllRegionLocations().size() > originalCount) {
  6. return;
  7. }
  8. }
  9. }
  10. throw new Exception("Split did not increase the number of regions");
  11. }

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

  1. RegionSplitter(Table table) throws IOException {
  2. this.table = table;
  3. this.tableName = table.getName();
  4. this.family = table.getTableDescriptor().getFamiliesKeys().iterator().next();
  5. admin = TEST_UTIL.getAdmin();
  6. rs = TEST_UTIL.getMiniHBaseCluster().getRegionServer(0);
  7. connection = TEST_UTIL.getConnection();
  8. }

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

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

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

  1. @Test
  2. public void testOpeningReadOnlyRegionBasic() throws Exception {
  3. String snapshotDir = client.createSnapshot(baseDir, SNAPSHOT_NAME);
  4. RegionInfo firstRegion = TEST_UTIL.getConnection().getRegionLocator(
  5. table.getName()).getAllRegionLocations().stream().findFirst().get().getRegion();
  6. Path tableDir = FSUtils.getTableDir(new Path(snapshotDir), TABLE_NAME);
  7. HRegion snapshottedRegion = openSnapshotRegion(firstRegion, tableDir);
  8. Assert.assertNotNull(snapshottedRegion);
  9. snapshottedRegion.close();
  10. }

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

  1. @Override
  2. public Void run() throws Exception {
  3. Get g = new Get(row1);
  4. g.setAuthorizations(new Authorizations(SECRET, CONFIDENTIAL));
  5. try (Connection connection = ConnectionFactory.createConnection(conf);
  6. Table t = connection.getTable(table.getName())) {
  7. Result result = t.get(g);
  8. assertTrue(!result.isEmpty());
  9. }
  10. return null;
  11. }
  12. };

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

  1. @Override
  2. public Void run() throws Exception {
  3. Get g = new Get(row1);
  4. g.setAuthorizations(new Authorizations(SECRET, CONFIDENTIAL));
  5. try (Connection connection = ConnectionFactory.createConnection(conf);
  6. Table t = connection.getTable(table.getName())) {
  7. Result result = t.get(g);
  8. assertTrue(result.isEmpty());
  9. }
  10. return null;
  11. }
  12. };

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

  1. private void moveRegion(Table table, int index) throws IOException{
  2. List<Pair<RegionInfo, ServerName>> regions = MetaTableAccessor
  3. .getTableRegionsAndLocations(TEST_UTIL.getConnection(),
  4. table.getName());
  5. assertEquals(1, regions.size());
  6. RegionInfo regionInfo = regions.get(0).getFirst();
  7. ServerName name = TEST_UTIL.getHBaseCluster().getRegionServer(index).getServerName();
  8. TEST_UTIL.getAdmin().move(regionInfo.getEncodedNameAsBytes(),
  9. Bytes.toBytes(name.getServerName()));
  10. }

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

  1. @Override
  2. public Void run() throws Exception {
  3. Scan s = new Scan();
  4. s.setAuthorizations(new Authorizations(SECRET, CONFIDENTIAL));
  5. try (Connection connection = ConnectionFactory.createConnection(conf);
  6. Table t = connection.getTable(table.getName())) {
  7. ResultScanner scanner = t.getScanner(s);
  8. Result[] result = scanner.next(5);
  9. assertTrue(result.length == 2);
  10. }
  11. return null;
  12. }
  13. };

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

  1. @Override
  2. protected String rpcCall() throws Exception {
  3. byte[] regionName = getLocation().getRegionInfo().getRegionName();
  4. RegionSpecifier region =
  5. RequestConverter.buildRegionSpecifier(RegionSpecifierType.REGION_NAME, regionName);
  6. PrepareBulkLoadRequest request = PrepareBulkLoadRequest.newBuilder()
  7. .setTableName(ProtobufUtil.toProtoTableName(table.getName()))
  8. .setRegion(region).build();
  9. PrepareBulkLoadResponse response = getStub().prepareBulkLoad(null, request);
  10. return response.getBulkToken();
  11. }
  12. };

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

  1. private void assertAllOnLine(final Table t) throws IOException {
  2. List<HRegionLocation> regions;
  3. try(RegionLocator rl = TEST_UTIL.getConnection().getRegionLocator(t.getName())) {
  4. regions = rl.getAllRegionLocations();
  5. }
  6. for (HRegionLocation e: regions) {
  7. byte [] startkey = e.getRegionInfo().getStartKey();
  8. Scan s = new Scan(startkey);
  9. ResultScanner scanner = t.getScanner(s);
  10. Result r = scanner.next();
  11. org.junit.Assert.assertTrue(r != null && r.size() > 0);
  12. scanner.close();
  13. }
  14. }
  15. }

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

  1. @Test(expected = TableNotEnabledException.class)
  2. public void testWritingToDisabledTable() throws IOException {
  3. try (Admin admin = UTIL.getConnection().getAdmin();
  4. Table table = UTIL.getConnection().getTable(TABLE_FOR_NEGATIVE_TESTS)) {
  5. admin.disableTable(table.getName());
  6. runTestOnTable(table);
  7. fail("Should not have reached here, should have thrown an exception");
  8. }
  9. }

相关文章