本文整理了Java中org.apache.hadoop.hbase.client.Table.getName()
方法的一些代码示例,展示了Table.getName()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Table.getName()
方法的具体详情如下:
包路径:org.apache.hadoop.hbase.client.Table
类名称:Table
方法名:getName
[英]Gets the fully qualified table name instance of this table.
[中]获取此表的完全限定表名实例。
代码示例来源:origin: apache/hbase
@Override
public List<LoadQueueItem> call() throws Exception {
List<LoadQueueItem> toRetry =
tryAtomicRegionLoad(serviceCallable, table.getName(), first, lqis);
return toRetry;
}
};
代码示例来源:origin: apache/hbase
/**
* Invokes Table#delete to delete test data (i.e. the row)
*
* @param table Standard Table object
* @throws IOException If IO problem is encountered
*/
static void deleteRow(final Table table) throws IOException {
System.out.println("Deleting row [" + Bytes.toString(MY_ROW_ID)
+ "] from Table ["
+ table.getName().getNameAsString() + "].");
table.delete(new Delete(MY_ROW_ID));
}
代码示例来源:origin: apache/hbase
/**
* Invokes Table#delete to delete test data (i.e. the row)
*
* @param table Standard Table object
* @throws IOException If IO problem is encountered
*/
static void deleteRow(final Table table) throws IOException {
System.out.println("Deleting row [" + Bytes.toString(MY_ROW_ID)
+ "] from Table ["
+ table.getName().getNameAsString() + "].");
table.delete(new Delete(MY_ROW_ID));
}
代码示例来源:origin: apache/hbase
@Override
public Table getTable(TableName tableName) throws IOException {
Table table = Mockito.mock(Table.class);
Mockito.when(table.getName()).thenReturn(tableName);
return table;
}
代码示例来源:origin: apache/hbase
@Override
public Table getTable(TableName tableName) throws IOException {
Table table = mock(Table.class);
when(table.getName()).thenReturn(tableName);
return table;
}
代码示例来源:origin: apache/hbase
@Override
protected void closeHTable() {
if (table != null) {
try {
table.close();
} catch (Exception e) {
LOG.error("Error in closing the table "+table.getName(), e);
}
}
}
代码示例来源:origin: apache/hbase
@Override
protected void closeTable() {
for (Table table : userVsTable.values()) {
try {
table.close();
} catch (Exception e) {
LOG.error("Error while closing the table " + table.getName(), e);
}
}
}
代码示例来源:origin: apache/hbase
@Override
public void loadData(final Table table, byte[]... families) throws Exception {
SnapshotTestingUtils.loadData(UTIL, table.getName(), 1000, families);
}
代码示例来源:origin: apache/hbase
private void verify(Table t, IOThrowingRunnable test) throws IOException {
admin.disableTable(t.getName());
admin.truncateTable(t.getName(), false);
test.run();
}
代码示例来源:origin: apache/hbase
private static void waitOnSplit(Connection c, final Table t, int originalCount) throws Exception {
for (int i = 0; i < 200; i++) {
Threads.sleepWithoutInterrupt(500);
try (RegionLocator locator = c.getRegionLocator(t.getName())) {
if (locator.getAllRegionLocations().size() > originalCount) {
return;
}
}
}
throw new Exception("Split did not increase the number of regions");
}
代码示例来源:origin: apache/hbase
RegionSplitter(Table table) throws IOException {
this.table = table;
this.tableName = table.getName();
this.family = table.getTableDescriptor().getFamiliesKeys().iterator().next();
admin = TEST_UTIL.getAdmin();
rs = TEST_UTIL.getMiniHBaseCluster().getRegionServer(0);
connection = TEST_UTIL.getConnection();
}
代码示例来源: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 testOpeningReadOnlyRegionBasic() throws Exception {
String snapshotDir = client.createSnapshot(baseDir, SNAPSHOT_NAME);
RegionInfo firstRegion = TEST_UTIL.getConnection().getRegionLocator(
table.getName()).getAllRegionLocations().stream().findFirst().get().getRegion();
Path tableDir = FSUtils.getTableDir(new Path(snapshotDir), TABLE_NAME);
HRegion snapshottedRegion = openSnapshotRegion(firstRegion, tableDir);
Assert.assertNotNull(snapshottedRegion);
snapshottedRegion.close();
}
代码示例来源:origin: apache/hbase
@Override
public Void run() throws Exception {
Get g = new Get(row1);
g.setAuthorizations(new Authorizations(SECRET, CONFIDENTIAL));
try (Connection connection = ConnectionFactory.createConnection(conf);
Table t = connection.getTable(table.getName())) {
Result result = t.get(g);
assertTrue(!result.isEmpty());
}
return null;
}
};
代码示例来源:origin: apache/hbase
@Override
public Void run() throws Exception {
Get g = new Get(row1);
g.setAuthorizations(new Authorizations(SECRET, CONFIDENTIAL));
try (Connection connection = ConnectionFactory.createConnection(conf);
Table t = connection.getTable(table.getName())) {
Result result = t.get(g);
assertTrue(result.isEmpty());
}
return null;
}
};
代码示例来源:origin: apache/hbase
private void moveRegion(Table table, int index) throws IOException{
List<Pair<RegionInfo, ServerName>> regions = MetaTableAccessor
.getTableRegionsAndLocations(TEST_UTIL.getConnection(),
table.getName());
assertEquals(1, regions.size());
RegionInfo regionInfo = regions.get(0).getFirst();
ServerName name = TEST_UTIL.getHBaseCluster().getRegionServer(index).getServerName();
TEST_UTIL.getAdmin().move(regionInfo.getEncodedNameAsBytes(),
Bytes.toBytes(name.getServerName()));
}
代码示例来源:origin: apache/hbase
@Override
public Void run() throws Exception {
Scan s = new Scan();
s.setAuthorizations(new Authorizations(SECRET, CONFIDENTIAL));
try (Connection connection = ConnectionFactory.createConnection(conf);
Table t = connection.getTable(table.getName())) {
ResultScanner scanner = t.getScanner(s);
Result[] result = scanner.next(5);
assertTrue(result.length == 2);
}
return null;
}
};
代码示例来源:origin: apache/hbase
@Override
protected String rpcCall() throws Exception {
byte[] regionName = getLocation().getRegionInfo().getRegionName();
RegionSpecifier region =
RequestConverter.buildRegionSpecifier(RegionSpecifierType.REGION_NAME, regionName);
PrepareBulkLoadRequest request = PrepareBulkLoadRequest.newBuilder()
.setTableName(ProtobufUtil.toProtoTableName(table.getName()))
.setRegion(region).build();
PrepareBulkLoadResponse response = getStub().prepareBulkLoad(null, request);
return response.getBulkToken();
}
};
代码示例来源:origin: apache/hbase
private void assertAllOnLine(final Table t) throws IOException {
List<HRegionLocation> regions;
try(RegionLocator rl = TEST_UTIL.getConnection().getRegionLocator(t.getName())) {
regions = rl.getAllRegionLocations();
}
for (HRegionLocation e: regions) {
byte [] startkey = e.getRegionInfo().getStartKey();
Scan s = new Scan(startkey);
ResultScanner scanner = t.getScanner(s);
Result r = scanner.next();
org.junit.Assert.assertTrue(r != null && r.size() > 0);
scanner.close();
}
}
}
代码示例来源:origin: apache/hbase
@Test(expected = TableNotEnabledException.class)
public void testWritingToDisabledTable() throws IOException {
try (Admin admin = UTIL.getConnection().getAdmin();
Table table = UTIL.getConnection().getTable(TABLE_FOR_NEGATIVE_TESTS)) {
admin.disableTable(table.getName());
runTestOnTable(table);
fail("Should not have reached here, should have thrown an exception");
}
}
内容来源于网络,如有侵权,请联系作者删除!