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

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

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

TableName.valueOf介绍

暂无

代码示例

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

@Test(expected=IllegalArgumentException.class)
public void testModifyInexistentFamily() {
 HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(name.getMethodName()));
 byte[] familyName = Bytes.toBytes("cf");
 HColumnDescriptor hcd = new HColumnDescriptor(familyName);
 htd.modifyFamily(hcd);
}

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

@Test
public void testLegalHTableNamesRegex() {
 for (String tn : legalTableNames) {
  TableName tName = TableName.valueOf(tn);
  assertTrue("Testing: '" + tn + "'", Pattern.matches(TableName.VALID_USER_TABLE_REGEX,
    tName.getNameAsString()));
 }
}

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

@Test
public void testGetter() {
 final TableName tableName = TableName.valueOf("table");
 Map<TableName, SpaceViolationPolicyEnforcement> map = new HashMap<>();
 map.put(tableName, new NoWritesViolationPolicyEnforcement());
 ActivePolicyEnforcement ape = new ActivePolicyEnforcement(map, Collections.emptyMap(), null);
 assertEquals(map.get(tableName), ape.getPolicyEnforcement(tableName));
}

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

/**
 * For HADOOP-2579
 * @throws IOException
 */
@Test (expected=TableNotFoundException.class)
public void testTableNotFoundExceptionWithoutAnyTables() throws IOException {
 TableName tableName = TableName
   .valueOf("testTableNotFoundExceptionWithoutAnyTables");
 Table ht = TEST_UTIL.getConnection().getTable(tableName);
 ht.get(new Get(Bytes.toBytes("e")));
}

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

@Before
public void setUp() throws IOException {
 byte[][] families = new byte[][] { Bytes.toBytes("cf") };
 TableDescriptor htd = getTableDesc(
  TableName.valueOf(name.getMethodName().replaceAll("[^0-9A-Za-z_]", "_")), families);
 region = initHRegion(htd, HConstants.EMPTY_START_ROW, HConstants.EMPTY_END_ROW, 0);
}

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

@Test
public void testSimpleCreateWithSplits() throws Exception {
 final TableName tableName = TableName.valueOf(name.getMethodName());
 final byte[][] splitKeys = new byte[][] {
  Bytes.toBytes("a"), Bytes.toBytes("b"), Bytes.toBytes("c")
 };
 testSimpleCreate(tableName, splitKeys);
}

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

@Test
public void testGetName() {
 TableRegionModel model = buildTestModel();
 String modelName = model.getName();
 HRegionInfo hri = new HRegionInfo(TableName.valueOf(TABLE),
  START_KEY, END_KEY, false, ID);
 assertEquals(modelName, hri.getRegionNameAsString());
}

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

@Test
public void testLegalTableNamesRegex() {
 for (String tn : legalTableNames) {
  TableName tName = TableName.valueOf(tn);
  assertTrue("Testing: '" + tn + "'", Pattern.matches(TableName.VALID_USER_TABLE_REGEX,
    tName.getNameAsString()));
 }
}

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

@Test
public void testSimpleDeleteWithSplits() throws Exception {
 final TableName tableName = TableName.valueOf(name.getMethodName());
 final byte[][] splitKeys = new byte[][] {
  Bytes.toBytes("a"), Bytes.toBytes("b"), Bytes.toBytes("c")
 };
 testSimpleDelete(tableName, splitKeys);
}

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

@Test
public void testIOExceptionOnAssignment() throws Exception {
 // collect AM metrics before test
 collectAssignmentManagerMetrics();
 testFailedOpen(TableName.valueOf("testExceptionOnAssignment"),
  new FaultyRsExecutor(new IOException("test fault")));
 assertEquals(assignSubmittedCount + 1, assignProcMetrics.getSubmittedCounter().getCount());
 assertEquals(assignFailedCount + 1, assignProcMetrics.getFailedCounter().getCount());
}

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

@Test
public void testNoPolicyReturnsNoopEnforcement() {
 ActivePolicyEnforcement ape = new ActivePolicyEnforcement(
   new HashMap<>(), Collections.emptyMap(), mock(RegionServerServices.class));
 SpaceViolationPolicyEnforcement enforcement = ape.getPolicyEnforcement(
   TableName.valueOf("nonexistent"));
 assertNotNull(enforcement);
 assertTrue(
   "Expected an instance of MissingSnapshotViolationPolicyEnforcement, but got "
     + enforcement.getClass(),
   enforcement instanceof MissingSnapshotViolationPolicyEnforcement);
}

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

/**
 * For HADOOP-2579
 * @throws IOException
 */
@Test (expected=TableExistsException.class)
public void testTableExistsExceptionWithATable() throws IOException {
 final TableName name = TableName.valueOf(this.name.getMethodName());
 TEST_UTIL.createTable(name, HConstants.CATALOG_FAMILY).close();
 TEST_UTIL.createTable(name, HConstants.CATALOG_FAMILY);
}

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

@Test
public void testDoNotRetryExceptionOnAssignment() throws Exception {
 // collect AM metrics before test
 collectAssignmentManagerMetrics();
 testFailedOpen(TableName.valueOf("testDoNotRetryExceptionOnAssignment"),
  new FaultyRsExecutor(new DoNotRetryIOException("test do not retry fault")));
 assertEquals(assignSubmittedCount + 1, assignProcMetrics.getSubmittedCounter().getCount());
 assertEquals(assignFailedCount + 1, assignProcMetrics.getFailedCounter().getCount());
}

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

@Test
public void testGetRegionByStateOfTable() throws Exception {
 RegionInfo hri = createTableAndGetOneRegion(tableName);
 RegionStates regionStates =
   TEST_UTIL.getHBaseCluster().getMaster().getAssignmentManager().getRegionStates();
 assertTrue(regionStates.getRegionByStateOfTable(tableName).get(RegionState.State.OPEN)
   .stream().anyMatch(r -> RegionInfo.COMPARATOR.compare(r, hri) == 0));
 assertFalse(regionStates.getRegionByStateOfTable(TableName.valueOf("I_am_the_phantom"))
   .get(RegionState.State.OPEN).stream().anyMatch(r -> RegionInfo.COMPARATOR.compare(r, hri) == 0));
}

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

@Test
public void testTableExist() throws IOException {
 final TableName table = TableName.valueOf(name.getMethodName());
 boolean exist;
 exist = this.admin.tableExists(table);
 assertEquals(false, exist);
 TEST_UTIL.createTable(table, HConstants.CATALOG_FAMILY);
 exist = this.admin.tableExists(table);
 assertEquals(true, exist);
}

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

@Test
public void testCloneTableSchemaWithNonExistentSourceTable() throws Exception {
 final TableName newTableName = TableName.valueOf(tableName.getNameAsString() + "_new");
 // test for non-existent source table
 try {
  admin.cloneTableSchema(tableName, newTableName, false).join();
  fail("Should have failed when source table doesn't exist.");
 } catch (CompletionException e) {
  assertTrue(e.getCause() instanceof TableNotFoundException);
 }
}

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

@Test
public void testSimpleLoadWithFileCopy() throws Exception {
 String testName = tn.getMethodName();
 final byte[] TABLE_NAME = Bytes.toBytes("mytable_" + testName);
 runTest(testName, buildHTD(TableName.valueOf(TABLE_NAME), BloomType.NONE),
   false, null, new byte[][][] { new byte[][] { Bytes.toBytes("aaaa"), Bytes.toBytes("cccc") },
    new byte[][] { Bytes.toBytes("ddd"), Bytes.toBytes("ooo") }, },
  false, true, 2);
}

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

@Test
public void testGetTableDescriptor() throws Exception {
 ThriftHBaseServiceHandler handler = createHandler();
 TTableDescriptor tableDescriptor = handler
   .getTableDescriptor(ThriftUtilities.tableNameFromHBase(TableName.valueOf(tableAname)));
 TableDescriptor table = ThriftUtilities.tableDescriptorFromThrift(tableDescriptor);
 assertTrue(table.getTableName().equals(TableName.valueOf(tableAname)));
 assertTrue(table.getColumnFamilies().length == 2);
 assertTrue(table.getColumnFamily(familyAname).getMaxVersions() == 3);
 assertTrue(table.getColumnFamily(familyBname).getMaxVersions() == 2);
}

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

@Test
 public void testPriority() {
  HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(name.getMethodName()));
  htd.setPriority(42);
  assertEquals(42, htd.getPriority());
 }
}

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

@Test
public void testCreateTableWithOnlyEmptyStartRow() throws IOException {
 final byte[] tableName = Bytes.toBytes(name.getMethodName());
 byte[][] splitKeys = new byte[1][];
 splitKeys[0] = HConstants.EMPTY_BYTE_ARRAY;
 HTableDescriptor desc = new HTableDescriptor(TableName.valueOf(tableName));
 desc.addFamily(new HColumnDescriptor("col"));
 try {
  admin.createTable(desc, splitKeys);
  fail("Test case should fail as empty split key is passed.");
 } catch (IllegalArgumentException e) {
 }
}

相关文章