HBASE-23203 NPE in RSGroup info (#747)
Signed-off-by: Duo Zhang <zhangduo@apache.org>
This commit is contained in:
parent
65ee17086a
commit
8f92a14cd1
|
@ -124,6 +124,14 @@ public interface Admin extends Abortable, Closeable {
|
|||
*/
|
||||
List<TableDescriptor> listTableDescriptors() throws IOException;
|
||||
|
||||
/**
|
||||
* List all userspace tables and whether or not include system tables.
|
||||
*
|
||||
* @return a list of TableDescriptors
|
||||
* @throws IOException if a remote or network exception occurs
|
||||
*/
|
||||
List<TableDescriptor> listTableDescriptors(boolean includeSysTables) throws IOException;
|
||||
|
||||
/**
|
||||
* List all the userspace tables that match the given pattern.
|
||||
*
|
||||
|
|
|
@ -131,6 +131,12 @@ class AdminOverAsyncAdmin implements Admin {
|
|||
return get(admin.listTableDescriptors());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TableDescriptor> listTableDescriptors(boolean includeSysTables)
|
||||
throws IOException {
|
||||
return get(admin.listTableDescriptors(includeSysTables));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TableDescriptor> listTableDescriptors(Pattern pattern, boolean includeSysTables)
|
||||
throws IOException {
|
||||
|
|
|
@ -493,7 +493,8 @@ class RawAsyncHBaseAdmin implements AsyncAdmin {
|
|||
public CompletableFuture<List<TableDescriptor>> listTableDescriptors(Pattern pattern,
|
||||
boolean includeSysTables) {
|
||||
Preconditions.checkNotNull(pattern,
|
||||
"pattern is null. If you don't specify a pattern, use listTables(boolean) instead");
|
||||
"pattern is null. If you don't specify a pattern, "
|
||||
+ "use listTableDescriptors(boolean) instead");
|
||||
return getTableDescriptors(RequestConverter.buildGetTableDescriptorsRequest(pattern,
|
||||
includeSysTables));
|
||||
}
|
||||
|
@ -501,7 +502,8 @@ class RawAsyncHBaseAdmin implements AsyncAdmin {
|
|||
@Override
|
||||
public CompletableFuture<List<TableDescriptor>> listTableDescriptors(List<TableName> tableNames) {
|
||||
Preconditions.checkNotNull(tableNames,
|
||||
"tableNames is null. If you don't specify tableNames, " + "use listTables(boolean) instead");
|
||||
"tableNames is null. If you don't specify tableNames, "
|
||||
+ "use listTableDescriptors(boolean) instead");
|
||||
if (tableNames.isEmpty()) {
|
||||
return CompletableFuture.completedFuture(Collections.emptyList());
|
||||
}
|
||||
|
|
|
@ -437,7 +437,7 @@
|
|||
<% if (rsGroupTables != null && rsGroupTables.size() > 0) {
|
||||
List<TableDescriptor> tables;
|
||||
try (Admin admin = master.getConnection().getAdmin()) {
|
||||
tables = master.isInitialized() ? admin.listTableDescriptors((Pattern)null, true) : null;
|
||||
tables = master.isInitialized() ? admin.listTableDescriptors(true) : null;
|
||||
}
|
||||
Map<TableName, HTableDescriptor> tableDescriptors
|
||||
= tables.stream().collect(Collectors.toMap(TableDescriptor::getTableName, p -> new HTableDescriptor(p)));
|
||||
|
|
|
@ -57,6 +57,18 @@ public class TestAdmin extends TestAdminBase {
|
|||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(TestAdmin.class);
|
||||
|
||||
@Test
|
||||
public void testListTableDescriptors() throws IOException{
|
||||
TableDescriptor metaTableDescriptor = TEST_UTIL.getAdmin().
|
||||
getDescriptor(TableName.META_TABLE_NAME);
|
||||
List<TableDescriptor> tableDescriptors = TEST_UTIL.getAdmin().
|
||||
listTableDescriptors(true);
|
||||
assertTrue(tableDescriptors.contains(metaTableDescriptor));
|
||||
tableDescriptors = TEST_UTIL.getAdmin().
|
||||
listTableDescriptors(false);
|
||||
assertFalse(tableDescriptors.contains(metaTableDescriptor));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateTable() throws IOException {
|
||||
List<TableDescriptor> tables = ADMIN.listTableDescriptors();
|
||||
|
|
|
@ -139,6 +139,11 @@ public class ThriftAdmin implements Admin {
|
|||
return listTableDescriptors((Pattern) null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TableDescriptor> listTableDescriptors(boolean includeSysTables) throws IOException {
|
||||
return listTableDescriptors(null, includeSysTables);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TableDescriptor> listTableDescriptors(Pattern pattern) throws IOException {
|
||||
return listTableDescriptors(pattern, false);
|
||||
|
|
Loading…
Reference in New Issue