diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Admin.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Admin.java index 233935d9e94..5419c169830 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Admin.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Admin.java @@ -124,6 +124,14 @@ public interface Admin extends Abortable, Closeable { */ List 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 listTableDescriptors(boolean includeSysTables) throws IOException; + /** * List all the userspace tables that match the given pattern. * diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AdminOverAsyncAdmin.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AdminOverAsyncAdmin.java index 530fb04b077..f1f5b2ae2d0 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AdminOverAsyncAdmin.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AdminOverAsyncAdmin.java @@ -131,6 +131,12 @@ class AdminOverAsyncAdmin implements Admin { return get(admin.listTableDescriptors()); } + @Override + public List listTableDescriptors(boolean includeSysTables) + throws IOException { + return get(admin.listTableDescriptors(includeSysTables)); + } + @Override public List listTableDescriptors(Pattern pattern, boolean includeSysTables) throws IOException { diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RawAsyncHBaseAdmin.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RawAsyncHBaseAdmin.java index 2c51ef4dc8f..8c6ec0de8a3 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RawAsyncHBaseAdmin.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RawAsyncHBaseAdmin.java @@ -493,7 +493,8 @@ class RawAsyncHBaseAdmin implements AsyncAdmin { public CompletableFuture> 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> listTableDescriptors(List 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()); } diff --git a/hbase-server/src/main/resources/hbase-webapps/master/rsgroup.jsp b/hbase-server/src/main/resources/hbase-webapps/master/rsgroup.jsp index 0e5d6ac49ef..86260347d17 100644 --- a/hbase-server/src/main/resources/hbase-webapps/master/rsgroup.jsp +++ b/hbase-server/src/main/resources/hbase-webapps/master/rsgroup.jsp @@ -437,7 +437,7 @@ <% if (rsGroupTables != null && rsGroupTables.size() > 0) { List tables; try (Admin admin = master.getConnection().getAdmin()) { - tables = master.isInitialized() ? admin.listTableDescriptors((Pattern)null, true) : null; + tables = master.isInitialized() ? admin.listTableDescriptors(true) : null; } Map tableDescriptors = tables.stream().collect(Collectors.toMap(TableDescriptor::getTableName, p -> new HTableDescriptor(p))); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java index 6ff5dfa7a9b..d1ba1a71075 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java @@ -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 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 tables = ADMIN.listTableDescriptors(); diff --git a/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/client/ThriftAdmin.java b/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/client/ThriftAdmin.java index 2f4ce92b33a..f3fdde72667 100644 --- a/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/client/ThriftAdmin.java +++ b/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/client/ThriftAdmin.java @@ -139,6 +139,11 @@ public class ThriftAdmin implements Admin { return listTableDescriptors((Pattern) null); } + @Override + public List listTableDescriptors(boolean includeSysTables) throws IOException { + return listTableDescriptors(null, includeSysTables); + } + @Override public List listTableDescriptors(Pattern pattern) throws IOException { return listTableDescriptors(pattern, false);