org.apache.hadoop.hbase.TableName.getNameAsString()方法的使用及代码示例

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

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

TableName.getNameAsString介绍

暂无

代码示例

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

  1. @Override
  2. public int run(String[] args) throws Exception {
  3. if (args.length != 1) {
  4. String message = "When there are multiple HBase clusters are sharing a common root dir, "
  5. + "especially for read replica cluster (see detail in HBASE-18477), please consider to "
  6. + "use this tool manually sync the flushed HFiles from the source cluster.";
  7. message += "\nUsage: " + this.getClass().getName() + " tableName";
  8. System.out.println(message);
  9. return -1;
  10. }
  11. final TableName tableName = TableName.valueOf(args[0]);
  12. try {
  13. refreshHFiles(tableName);
  14. } catch (Throwable t) {
  15. LOG.error("Refresh HFiles from table " + tableName.getNameAsString() + " failed: ", t);
  16. return -1;
  17. }
  18. return 0;
  19. }

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

  1. @Test
  2. public void testLegalHTableNamesRegex() {
  3. for (String tn : legalTableNames) {
  4. TableName tName = TableName.valueOf(tn);
  5. assertTrue("Testing: '" + tn + "'", Pattern.matches(TableName.VALID_USER_TABLE_REGEX,
  6. tName.getNameAsString()));
  7. }
  8. }

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

  1. @Test
  2. public void testLocalDistributedColumnSelect() throws Exception {
  3. String planName = "/hbase/hbase_scan_screen_physical_column_select.json";
  4. runHBasePhysicalVerifyCount(planName, HBaseTestsSuite.TEST_TABLE_1.getNameAsString(), 3);
  5. }

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

  1. @Test
  2. public void testLocalDistributedFamilySelect() throws Exception {
  3. String planName = "/hbase/hbase_scan_screen_physical_family_select.json";
  4. runHBasePhysicalVerifyCount(planName, HBaseTestsSuite.TEST_TABLE_1.getNameAsString(), 4);
  5. }

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

  1. @Test
  2. public void testCloneTableSchemaPreservingSplits() throws Exception {
  3. final TableName newTableName = TableName.valueOf(tableName.getNameAsString() + "_new");
  4. testCloneTableSchema(tableName, newTableName, true);
  5. }

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

  1. @Override
  2. public void addToBackupSet(String name, TableName[] tables) throws IOException {
  3. String[] tableNames = new String[tables.length];
  4. try (final BackupSystemTable table = new BackupSystemTable(conn);
  5. final Admin admin = conn.getAdmin()) {
  6. for (int i = 0; i < tables.length; i++) {
  7. tableNames[i] = tables[i].getNameAsString();
  8. if (!admin.tableExists(TableName.valueOf(tableNames[i]))) {
  9. throw new IOException("Cannot add " + tableNames[i] + " because it doesn't exist");
  10. }
  11. }
  12. table.addToBackupSet(name, tableNames);
  13. LOG.info("Added tables [" + StringUtils.join(tableNames, " ") + "] to '" + name
  14. + "' backup set");
  15. }
  16. }

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

  1. @Test
  2. public void testLocalDistributed() throws Exception {
  3. String planName = "/hbase/hbase_scan_screen_physical.json";
  4. runHBasePhysicalVerifyCount(planName, HBaseTestsSuite.TEST_TABLE_1.getNameAsString(), 8);
  5. }

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

  1. @Test
  2. public void testLegalTableNamesRegex() {
  3. for (String tn : legalTableNames) {
  4. TableName tName = TableName.valueOf(tn);
  5. assertTrue("Testing: '" + tn + "'", Pattern.matches(TableName.VALID_USER_TABLE_REGEX,
  6. tName.getNameAsString()));
  7. }
  8. }

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

  1. protected void runVerifyCommonTable(String outputDir, int numReducers, long expectedNumNodes,
  2. int index) throws Exception {
  3. LOG.info("Verifying common table with index " + index);
  4. sleep(SLEEP_IN_MS);
  5. Path outputPath = new Path(outputDir);
  6. UUID uuid = UUID.randomUUID(); // create a random UUID.
  7. Path iterationOutput = new Path(outputPath, uuid.toString());
  8. Verify verify = new VisibilityVerify(TableName.valueOf(COMMON_TABLE_NAME).getNameAsString(),
  9. index);
  10. verify(numReducers, expectedNumNodes, iterationOutput, verify);
  11. }

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

  1. @Test
  2. public void testSkipEmptyColumns() throws Exception {
  3. Path bulkOutputPath = new Path(util.getDataTestDirOnTestFS(tn.getNameAsString()), "hfiles");
  4. args.put(ImportTsv.BULK_OUTPUT_CONF_KEY, bulkOutputPath.toString());
  5. args.put(ImportTsv.COLUMNS_CONF_KEY, "HBASE_ROW_KEY,HBASE_TS_KEY,FAM:A,FAM:B");
  6. args.put(ImportTsv.SEPARATOR_CONF_KEY, ",");
  7. args.put(ImportTsv.SKIP_EMPTY_COLUMNS, "true");
  8. // 2 Rows of data as input. Both rows are valid and only 3 columns are no-empty among 4
  9. String data = "KEY,1234,VALUE1,VALUE2\nKEY,1235,,VALUE2\n";
  10. doMROnTableTest(util, tn, FAMILY, data, args, 1, 3);
  11. util.deleteTable(tn);
  12. }

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

  1. @Test
  2. public void testCloneTableSchema() throws Exception {
  3. final TableName newTableName = TableName.valueOf(tableName.getNameAsString() + "_new");
  4. testCloneTableSchema(tableName, newTableName, false);
  5. }

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

  1. private SnapshotDescription toSnapshotDescription(ProcedureDescription desc)
  2. throws IOException {
  3. SnapshotDescription.Builder builder = SnapshotDescription.newBuilder();
  4. if (!desc.hasInstance()) {
  5. throw new IOException("Snapshot name is not defined: " + desc.toString());
  6. }
  7. String snapshotName = desc.getInstance();
  8. List<NameStringPair> props = desc.getConfigurationList();
  9. String table = null;
  10. for (NameStringPair prop : props) {
  11. if ("table".equalsIgnoreCase(prop.getName())) {
  12. table = prop.getValue();
  13. }
  14. }
  15. if (table == null) {
  16. throw new IOException("Snapshot table is not defined: " + desc.toString());
  17. }
  18. TableName tableName = TableName.valueOf(table);
  19. builder.setTable(tableName.getNameAsString());
  20. builder.setName(snapshotName);
  21. builder.setType(SnapshotDescription.Type.FLUSH);
  22. return builder.build();
  23. }
  24. }

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

  1. @Test
  2. public void testExecProcedureWithRet() throws Exception {
  3. verifyAdminCheckForAction((admin) -> {
  4. // Using existing table instead of creating a new one.
  5. admin.execProcedureWithReturn("flush-table-proc", TableName.META_TABLE_NAME.getNameAsString(),
  6. new HashMap<>());
  7. });
  8. }

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

  1. @Test
  2. public void testCloneSnapshot() throws Exception {
  3. byte[] FAMILY = Bytes.toBytes("test");
  4. String snapshotName = tableName.getNameAsString() + "_snap";
  5. TableName clonedTableName = TableName.valueOf(tableName.getNameAsString() + "_clone");
  6. // create base table
  7. TEST_UTIL.createTable(tableName, FAMILY);
  8. // create snapshot
  9. admin.snapshot(snapshotName, tableName);
  10. // clone
  11. admin.cloneSnapshot(snapshotName, clonedTableName);
  12. }

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

  1. private HRegion createHRegion(WALFactory wals, Durability durability) throws IOException {
  2. TableName tableName = TableName.valueOf(name.getMethodName().replaceAll("[^A-Za-z0-9-_]", "_"));
  3. TableDescriptor htd = TableDescriptorBuilder.newBuilder(tableName)
  4. .setColumnFamily(ColumnFamilyDescriptorBuilder.of(FAMILY)).build();
  5. RegionInfo info = RegionInfoBuilder.newBuilder(tableName).build();
  6. Path path = new Path(DIR, tableName.getNameAsString());
  7. if (FS.exists(path)) {
  8. if (!FS.delete(path, true)) {
  9. throw new IOException("Failed delete of " + path);
  10. }
  11. }
  12. ChunkCreator.initialize(MemStoreLABImpl.CHUNK_SIZE_DEFAULT, false, 0, 0, 0, null);
  13. return HRegion.createHRegion(info, path, CONF, htd, wals.getWAL(info));
  14. }

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

  1. @Test
  2. public void testExecProcedure() throws Exception {
  3. verifyAdminCheckForAction((admin) -> {
  4. // Using existing table instead of creating a new one.
  5. admin.execProcedure("flush-table-proc", TableName.META_TABLE_NAME.getNameAsString(),
  6. new HashMap<>());
  7. });
  8. }

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

  1. @Test
  2. public void testCloneTableSchemaPreservingSplits() throws Exception {
  3. final TableName tableName = TableName.valueOf(name.getMethodName());
  4. final TableName newTableName = TableName.valueOf(tableName.getNameAsString() + "_new");
  5. testCloneTableSchema(tableName, newTableName, true);
  6. }

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

  1. private static void setupTables() throws IOException {
  2. // Get the table name.
  3. tableName = TableName.valueOf(util.getConfiguration()
  4. .get("hbase.IntegrationTestMTTR.tableName", "IntegrationTestMTTR"));
  5. loadTableName = TableName.valueOf(util.getConfiguration()
  6. .get("hbase.IntegrationTestMTTR.loadTableName", "IntegrationTestMTTRLoadTestTool"));
  7. if (util.getAdmin().tableExists(tableName)) {
  8. util.deleteTable(tableName);
  9. }
  10. if (util.getAdmin().tableExists(loadTableName)) {
  11. util.deleteTable(loadTableName);
  12. }
  13. // Create the table. If this fails then fail everything.
  14. TableDescriptor tableDescriptor = util.getAdmin().getDescriptor(tableName);
  15. TableDescriptorBuilder builder = TableDescriptorBuilder.newBuilder(tableDescriptor);
  16. // Make the max file size huge so that splits don't happen during the test.
  17. builder.setMaxFileSize(Long.MAX_VALUE);
  18. ColumnFamilyDescriptorBuilder colDescriptorBldr =
  19. ColumnFamilyDescriptorBuilder.newBuilder(FAMILY);
  20. colDescriptorBldr.setMaxVersions(1);
  21. builder.setColumnFamily(colDescriptorBldr.build());
  22. util.getAdmin().createTable(builder.build());
  23. // Setup the table for LoadTestTool
  24. int ret = loadTool.run(new String[]{"-tn", loadTableName.getNameAsString(), "-init_only"});
  25. assertEquals("Failed to initialize LoadTestTool", 0, ret);
  26. }

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

  1. /**
  2. * Verify that full backup fails on tableset containing real and fake tables.
  3. *
  4. * @throws Exception if doing the full backup fails
  5. */
  6. @Test(expected = IOException.class)
  7. public void testFullBackupMixExistAndDNE() throws Exception {
  8. LOG.info("create full backup fails on tableset containing real and fake table");
  9. List<TableName> tables = toList(table1.getNameAsString(), "tabledne");
  10. fullTableBackup(tables);
  11. }
  12. }

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

  1. @Test
  2. public void testCloneTableSchema() throws Exception {
  3. final TableName tableName = TableName.valueOf(name.getMethodName());
  4. final TableName newTableName = TableName.valueOf(tableName.getNameAsString() + "_new");
  5. testCloneTableSchema(tableName, newTableName, false);
  6. }

相关文章