diff --git hbase-client/src/main/java/org/apache/hadoop/hbase/client/Admin.java hbase-client/src/main/java/org/apache/hadoop/hbase/client/Admin.java index 930037299a..fd6cc1ef96 100644 --- hbase-client/src/main/java/org/apache/hadoop/hbase/client/Admin.java +++ hbase-client/src/main/java/org/apache/hadoop/hbase/client/Admin.java @@ -99,9 +99,18 @@ public interface Admin extends Abortable, Closeable { * @return - returns an array of read-only HTableDescriptors * @throws IOException if a remote or network exception occurs */ + @Deprecated HTableDescriptor[] listTables() throws IOException; /** + * List all the userspace tables. + * + * @return - returns an array of TableDescriptors + * @throws IOException if a remote or network exception occurs + */ + TableDescriptor[] listTableDescriptors() throws IOException; + + /** * List all the userspace tables matching the given pattern. * * @param pattern The compiled regular expression to match against @@ -109,19 +118,41 @@ public interface Admin extends Abortable, Closeable { * @throws IOException if a remote or network exception occurs * @see #listTables() */ + @Deprecated HTableDescriptor[] listTables(Pattern pattern) throws IOException; /** + * List all the userspace tables matching the given pattern. + * + * @param pattern The compiled regular expression to match against + * @return - returns an array of TableDescriptors + * @throws IOException if a remote or network exception occurs + * @see #listTables() + */ + TableDescriptor[] listTableDescriptors(Pattern pattern) throws IOException; + + /** * List all the userspace tables matching the given regular expression. * * @param regex The regular expression to match against - * @return - returns an array of HTableDescriptors + * @return - returns an array of read-only HTableDescriptors * @throws IOException if a remote or network exception occurs * @see #listTables(java.util.regex.Pattern) */ + @Deprecated HTableDescriptor[] listTables(String regex) throws IOException; /** + * List all the userspace tables matching the given regular expression. + * + * @param regex The regular expression to match against + * @return - returns an array of TableDescriptors + * @throws IOException if a remote or network exception occurs + * @see #listTables(java.util.regex.Pattern) + */ + TableDescriptor[] listTableDescriptors(String regex) throws IOException; + + /** * List all the tables matching the given pattern. * * @param pattern The compiled regular expression to match against @@ -130,22 +161,48 @@ public interface Admin extends Abortable, Closeable { * @throws IOException if a remote or network exception occurs * @see #listTables() */ + @Deprecated HTableDescriptor[] listTables(Pattern pattern, boolean includeSysTables) throws IOException; /** * List all the tables matching the given pattern. * + * @param pattern The compiled regular expression to match against + * @param includeSysTables False to match only against userspace tables + * @return - returns an array of TableDescriptors + * @throws IOException if a remote or network exception occurs + * @see #listTables() + */ + TableDescriptor[] listTableDescriptors(Pattern pattern, boolean includeSysTables) + throws IOException; + + /** + * List all the tables matching the given pattern. + * * @param regex The regular expression to match against * @param includeSysTables False to match only against userspace tables * @return - returns an array of read-only HTableDescriptors * @throws IOException if a remote or network exception occurs * @see #listTables(java.util.regex.Pattern, boolean) */ + @Deprecated HTableDescriptor[] listTables(String regex, boolean includeSysTables) throws IOException; /** + * List all the tables matching the given pattern. + * + * @param regex The regular expression to match against + * @param includeSysTables False to match only against userspace tables + * @return - returns an array of TableDescriptors + * @throws IOException if a remote or network exception occurs + * @see #listTables(java.util.regex.Pattern, boolean) + */ + TableDescriptor[] listTableDescriptors(String regex, boolean includeSysTables) + throws IOException; + + /** * List all of the names of userspace tables. * * @return TableName[] table names @@ -197,10 +254,22 @@ public interface Admin extends Abortable, Closeable { * @throws org.apache.hadoop.hbase.TableNotFoundException * @throws IOException if a remote or network exception occurs */ + @Deprecated HTableDescriptor getTableDescriptor(final TableName tableName) throws TableNotFoundException, IOException; /** + * Method for getting the tableDescriptor + * + * @param tableName as a {@link TableName} + * @return the tableDescriptor + * @throws org.apache.hadoop.hbase.TableNotFoundException + * @throws IOException if a remote or network exception occurs + */ + TableDescriptor listTableDescriptor(final TableName tableName) + throws TableNotFoundException, IOException; + + /** * Creates a new table. Synchronous operation. * * @param desc table descriptor for table @@ -210,7 +279,7 @@ public interface Admin extends Abortable, Closeable { * threads, the table may have been created between test-for-existence and attempt-at-creation). * @throws IOException if a remote or network exception occurs */ - void createTable(HTableDescriptor desc) throws IOException; + void createTable(TableDescriptor desc) throws IOException; /** * Creates a new table with the specified number of regions. The start key specified will become @@ -229,7 +298,7 @@ public interface Admin extends Abortable, Closeable { * threads, the table may have been created between test-for-existence and attempt-at-creation). * @throws IOException */ - void createTable(HTableDescriptor desc, byte[] startKey, byte[] endKey, int numRegions) + void createTable(TableDescriptor desc, byte[] startKey, byte[] endKey, int numRegions) throws IOException; /** @@ -246,7 +315,7 @@ public interface Admin extends Abortable, Closeable { * threads, the table may have been created between test-for-existence and attempt-at-creation). * @throws IOException */ - void createTable(final HTableDescriptor desc, byte[][] splitKeys) throws IOException; + void createTable(final TableDescriptor desc, byte[][] splitKeys) throws IOException; /** * Creates a new table but does not block and wait for it to come online. @@ -263,7 +332,7 @@ public interface Admin extends Abortable, Closeable { * @return the result of the async creation. You can use Future.get(long, TimeUnit) * to wait on the operation to complete. */ - Future createTableAsync(final HTableDescriptor desc, final byte[][] splitKeys) + Future createTableAsync(final TableDescriptor desc, final byte[][] splitKeys) throws IOException; /** @@ -300,6 +369,7 @@ public interface Admin extends Abortable, Closeable { * @see #deleteTables(java.util.regex.Pattern) * @see #deleteTable(org.apache.hadoop.hbase.TableName) */ + @Deprecated HTableDescriptor[] deleteTables(String regex) throws IOException; /** @@ -313,6 +383,7 @@ public interface Admin extends Abortable, Closeable { * The return htds are read-only * @throws IOException */ + @Deprecated HTableDescriptor[] deleteTables(Pattern pattern) throws IOException; /** @@ -381,6 +452,7 @@ public interface Admin extends Abortable, Closeable { * @see #enableTables(java.util.regex.Pattern) * @see #enableTable(org.apache.hadoop.hbase.TableName) */ + @Deprecated HTableDescriptor[] enableTables(String regex) throws IOException; /** @@ -394,6 +466,7 @@ public interface Admin extends Abortable, Closeable { * @return Table descriptors for tables that couldn't be enabled. * The return HTDs are read-only. */ + @Deprecated HTableDescriptor[] enableTables(Pattern pattern) throws IOException; /** @@ -434,6 +507,7 @@ public interface Admin extends Abortable, Closeable { * @see #disableTables(java.util.regex.Pattern) * @see #disableTable(org.apache.hadoop.hbase.TableName) */ + @Deprecated HTableDescriptor[] disableTables(String regex) throws IOException; /** @@ -447,6 +521,7 @@ public interface Admin extends Abortable, Closeable { * The return htds are read-only * @throws IOException */ + @Deprecated HTableDescriptor[] disableTables(Pattern pattern) throws IOException; /** @@ -1015,10 +1090,19 @@ public interface Admin extends Abortable, Closeable { * @param htd modified description of the table * @throws IOException if a remote or network exception occurs */ + @Deprecated void modifyTable(final TableName tableName, final HTableDescriptor htd) throws IOException; /** + * Modify an existing table, more IRB friendly version. + * + * @param td modified description of the table + * @throws IOException if a remote or network exception occurs + */ + void modifyTable(final TableDescriptor td) throws IOException; + + /** * Modify an existing table, more IRB friendly version. Asynchronous operation. This means that * it may be a while before your schema change is updated across all of the table. * You can use Future.get(long, TimeUnit) to wait on the operation to complete. @@ -1032,10 +1116,27 @@ public interface Admin extends Abortable, Closeable { * @return the result of the async modify. You can use Future.get(long, TimeUnit) to wait on the * operation to complete */ + @Deprecated Future modifyTableAsync(final TableName tableName, final HTableDescriptor htd) throws IOException; /** + * Modify an existing table, more IRB friendly version. Asynchronous operation. This means that + * it may be a while before your schema change is updated across all of the table. + * You can use Future.get(long, TimeUnit) to wait on the operation to complete. + * It may throw ExecutionException if there was an error while executing the operation + * or TimeoutException in case the wait timeout was not long enough to allow the + * operation to complete. + * + * @param td description of the table + * @throws IOException if a remote or network exception occurs + * @return the result of the async modify. You can use Future.get(long, TimeUnit) to wait on the + * operation to complete + */ + Future modifyTableAsync(TableDescriptor td) + throws IOException; + + /** * Shuts down the HBase cluster * * @throws IOException if a remote or network exception occurs @@ -1178,10 +1279,21 @@ public interface Admin extends Abortable, Closeable { * @return HTD[] the read-only tableDescriptors * @throws IOException */ + @Deprecated HTableDescriptor[] listTableDescriptorsByNamespace(final String name) throws IOException; /** + * Get list of table descriptors by namespace + * + * @param name namespace name + * @return TD[] the tableDescriptors + * @throws IOException + */ + TableDescriptor[] listTableDescriptorsByNamespace(final byte[] name) + throws IOException; + + /** * Get list of table names by namespace * * @param name namespace name @@ -1211,16 +1323,28 @@ public interface Admin extends Abortable, Closeable { * @return HTD[] the read-only tableDescriptors * @throws IOException if a remote or network exception occurs */ + @Deprecated HTableDescriptor[] getTableDescriptorsByTableName(List tableNames) throws IOException; /** * Get tableDescriptors * + * @param tableNames List of table names + * @return TD[] the tableDescriptors + * @throws IOException if a remote or network exception occurs + */ + TableDescriptor[] listTableDescriptors(List tableNames) + throws IOException; + + /** + * Get tableDescriptors + * * @param names List of table names * @return HTD[] the read-only tableDescriptors * @throws IOException if a remote or network exception occurs */ + @Deprecated HTableDescriptor[] getTableDescriptors(List names) throws IOException; diff --git hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java index 1c6ea03b0c..53e92dea61 100644 --- hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java +++ hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java @@ -307,6 +307,97 @@ public class HBaseAdmin implements Admin { return new AbortProcedureFuture(this, procId, abortProcResponse); } + @Override + public TableDescriptor[] listTableDescriptors() throws IOException { + return listTableDescriptors((Pattern)null, false); + } + + @Override + public TableDescriptor[] listTableDescriptors(Pattern pattern) throws IOException { + return listTableDescriptors(pattern, false); + } + + @Override + public TableDescriptor[] listTableDescriptors(String regex) throws IOException { + return listTableDescriptors(Pattern.compile(regex), false); + } + + @Override + public TableDescriptor[] listTableDescriptors(Pattern pattern, boolean includeSysTables) throws IOException { + return executeCallable(new MasterCallable(getConnection(), + getRpcControllerFactory()) { + @Override + protected TableDescriptor[] rpcCall() throws Exception { + GetTableDescriptorsRequest req = + RequestConverter.buildGetTableDescriptorsRequest(pattern, includeSysTables); + return ProtobufUtil.getTableDescriptorArray(master.getTableDescriptors(getRpcController(), + req)); + } + }); + } + + @Override + public TableDescriptor[] listTableDescriptors(String regex, boolean includeSysTables) throws IOException { + return listTableDescriptors(Pattern.compile(regex), includeSysTables); + } + + @Override + public TableDescriptor listTableDescriptor(TableName tableName) throws TableNotFoundException, IOException { + return getTableDescriptor(tableName, getConnection(), rpcCallerFactory, rpcControllerFactory, + operationTimeout, rpcTimeout); + } + + @Override + public void modifyTable(TableDescriptor td) throws IOException { + get(modifyTableAsync(td), syncWaitTimeout, TimeUnit.MILLISECONDS); + } + + @Override + public Future modifyTableAsync(TableDescriptor td) throws IOException { + ModifyTableResponse response = executeCallable( + new MasterCallable(getConnection(), getRpcControllerFactory()) { + @Override + protected ModifyTableResponse rpcCall() throws Exception { + setPriority(td.getTableName()); + ModifyTableRequest request = RequestConverter.buildModifyTableRequest( + td.getTableName(), td, ng.getNonceGroup(), ng.newNonce()); + return master.modifyTable(getRpcController(), request); + } + }); + return new ModifyTableFuture(this, td.getTableName(), response); + } + + @Override + public TableDescriptor[] listTableDescriptorsByNamespace(byte[] name) throws IOException { + return executeCallable(new MasterCallable(getConnection(), + getRpcControllerFactory()) { + @Override + protected TableDescriptor[] rpcCall() throws Exception { + return master.listTableDescriptorsByNamespace(getRpcController(), + ListTableDescriptorsByNamespaceRequest.newBuilder() + .setNamespaceName(Bytes.toString(name)).build()) + .getTableSchemaList() + .stream() + .map(ProtobufUtil::convertToTableDesc) + .toArray(i -> new TableDescriptor[i]); + } + }); + } + + @Override + public TableDescriptor[] listTableDescriptors(List tableNames) throws IOException { + return executeCallable(new MasterCallable(getConnection(), + getRpcControllerFactory()) { + @Override + protected TableDescriptor[] rpcCall() throws Exception { + GetTableDescriptorsRequest req = + RequestConverter.buildGetTableDescriptorsRequest(tableNames); + return ProtobufUtil. + getTableDescriptorArray(master.getTableDescriptors(getRpcController(), req)); + } + }); + } + private static class AbortProcedureFuture extends ProcedureFuture { private boolean isAbortInProgress; @@ -419,11 +510,35 @@ public class HBaseAdmin implements Admin { @Override public HTableDescriptor getTableDescriptor(final TableName tableName) throws IOException { - return getTableDescriptor(tableName, getConnection(), rpcCallerFactory, rpcControllerFactory, + return getHTableDescriptor(tableName, getConnection(), rpcCallerFactory, rpcControllerFactory, operationTimeout, rpcTimeout); } - static HTableDescriptor getTableDescriptor(final TableName tableName, Connection connection, + static TableDescriptor getTableDescriptor(final TableName tableName, Connection connection, + RpcRetryingCallerFactory rpcCallerFactory, final RpcControllerFactory rpcControllerFactory, + int operationTimeout, int rpcTimeout) throws IOException { + if (tableName == null) return null; + TableDescriptor td = + executeCallable(new MasterCallable(connection, rpcControllerFactory) { + @Override + protected TableDescriptor rpcCall() throws Exception { + GetTableDescriptorsRequest req = + RequestConverter.buildGetTableDescriptorsRequest(tableName); + GetTableDescriptorsResponse htds = master.getTableDescriptors(getRpcController(), req); + if (!htds.getTableSchemaList().isEmpty()) { + return ProtobufUtil.convertToTableDesc(htds.getTableSchemaList().get(0)); + } + return null; + } + }, rpcCallerFactory, operationTimeout, rpcTimeout); + if (td != null) { + return td; + } + throw new TableNotFoundException(tableName.getNameAsString()); + } + + @Deprecated + static HTableDescriptor getHTableDescriptor(final TableName tableName, Connection connection, RpcRetryingCallerFactory rpcCallerFactory, final RpcControllerFactory rpcControllerFactory, int operationTimeout, int rpcTimeout) throws IOException { if (tableName == null) return null; @@ -455,13 +570,13 @@ public class HBaseAdmin implements Admin { } @Override - public void createTable(HTableDescriptor desc) + public void createTable(TableDescriptor desc) throws IOException { createTable(desc, null); } @Override - public void createTable(HTableDescriptor desc, byte [] startKey, + public void createTable(TableDescriptor desc, byte [] startKey, byte [] endKey, int numRegions) throws IOException { if(numRegions < 3) { @@ -481,13 +596,13 @@ public class HBaseAdmin implements Admin { } @Override - public void createTable(final HTableDescriptor desc, byte [][] splitKeys) + public void createTable(final TableDescriptor desc, byte [][] splitKeys) throws IOException { get(createTableAsync(desc, splitKeys), syncWaitTimeout, TimeUnit.MILLISECONDS); } @Override - public Future createTableAsync(final HTableDescriptor desc, final byte[][] splitKeys) + public Future createTableAsync(final TableDescriptor desc, final byte[][] splitKeys) throws IOException { if (desc.getTableName() == null) { throw new IllegalArgumentException("TableName cannot be null"); @@ -524,19 +639,19 @@ public class HBaseAdmin implements Admin { } private static class CreateTableFuture extends TableFuture { - private final HTableDescriptor desc; + private final TableDescriptor desc; private final byte[][] splitKeys; - public CreateTableFuture(final HBaseAdmin admin, final HTableDescriptor desc, + public CreateTableFuture(final HBaseAdmin admin, final TableDescriptor desc, final byte[][] splitKeys, final CreateTableResponse response) { super(admin, desc.getTableName(), (response != null && response.hasProcId()) ? response.getProcId() : null); this.splitKeys = splitKeys; - this.desc = new ImmutableHTableDescriptor(desc); + this.desc = desc; } @Override - protected HTableDescriptor getTableDescriptor() { + protected TableDescriptor getTableDescriptor() { return desc; } @@ -3546,7 +3661,7 @@ public class HBaseAdmin implements Admin { /** * @return the table descriptor */ - protected HTableDescriptor getTableDescriptor() throws IOException { + protected TableDescriptor getTableDescriptor() throws IOException { return getAdmin().getTableDescriptorByTableName(getTableName()); } @@ -3642,7 +3757,7 @@ public class HBaseAdmin implements Admin { protected void waitForAllRegionsOnline(final long deadlineTs, final byte[][] splitKeys) throws IOException, TimeoutException { - final HTableDescriptor desc = getTableDescriptor(); + final TableDescriptor desc = getTableDescriptor(); final AtomicInteger actualRegCount = new AtomicInteger(0); final MetaTableAccessor.Visitor visitor = new MetaTableAccessor.Visitor() { @Override diff --git hbase-client/src/main/java/org/apache/hadoop/hbase/client/HTable.java hbase-client/src/main/java/org/apache/hadoop/hbase/client/HTable.java index d207f6a098..46ce902c16 100644 --- hbase-client/src/main/java/org/apache/hadoop/hbase/client/HTable.java +++ hbase-client/src/main/java/org/apache/hadoop/hbase/client/HTable.java @@ -263,7 +263,17 @@ public class HTable implements Table { */ @Override public HTableDescriptor getTableDescriptor() throws IOException { - HTableDescriptor htd = HBaseAdmin.getTableDescriptor(tableName, connection, rpcCallerFactory, + HTableDescriptor htd = HBaseAdmin.getHTableDescriptor(tableName, connection, rpcCallerFactory, + rpcControllerFactory, operationTimeout, readRpcTimeout); + if (htd != null) { + return new ImmutableHTableDescriptor(htd); + } + return null; + } + + @Override + public TableDescriptor getDescriptor() throws IOException { + HTableDescriptor htd = HBaseAdmin.getHTableDescriptor(tableName, connection, rpcCallerFactory, rpcControllerFactory, operationTimeout, readRpcTimeout); if (htd != null) { return new ImmutableHTableDescriptor(htd); diff --git hbase-client/src/main/java/org/apache/hadoop/hbase/client/Table.java hbase-client/src/main/java/org/apache/hadoop/hbase/client/Table.java index 933329f734..f569eeaa03 100644 --- hbase-client/src/main/java/org/apache/hadoop/hbase/client/Table.java +++ hbase-client/src/main/java/org/apache/hadoop/hbase/client/Table.java @@ -66,9 +66,16 @@ public interface Table extends Closeable { * Gets the {@link org.apache.hadoop.hbase.HTableDescriptor table descriptor} for this table. * @throws java.io.IOException if a remote or network exception occurs. */ + @Deprecated HTableDescriptor getTableDescriptor() throws IOException; /** + * Gets the {@link org.apache.hadoop.hbase.client.TableDescriptor table descriptor} for this table. + * @throws java.io.IOException if a remote or network exception occurs. + */ + TableDescriptor getDescriptor() throws IOException; + + /** * Test for the existence of columns in the table, as specified by the Get. *

* diff --git hbase-client/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/RequestConverter.java hbase-client/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/RequestConverter.java index 67f7d0a5ad..727b991498 100644 --- hbase-client/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/RequestConverter.java +++ hbase-client/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/RequestConverter.java @@ -1263,7 +1263,7 @@ public final class RequestConverter { */ public static ModifyTableRequest buildModifyTableRequest( final TableName tableName, - final HTableDescriptor hTableDesc, + final TableDescriptor hTableDesc, final long nonceGroup, final long nonce) { ModifyTableRequest.Builder builder = ModifyTableRequest.newBuilder(); diff --git hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/client/RemoteHTable.java hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/client/RemoteHTable.java index 5012a5a941..63dfcaabfd 100644 --- hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/client/RemoteHTable.java +++ hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/client/RemoteHTable.java @@ -54,6 +54,7 @@ import org.apache.hadoop.hbase.client.Row; import org.apache.hadoop.hbase.client.RowMutations; import org.apache.hadoop.hbase.client.Scan; import org.apache.hadoop.hbase.client.Table; +import org.apache.hadoop.hbase.client.TableDescriptor; import org.apache.hadoop.hbase.client.coprocessor.Batch; import org.apache.hadoop.hbase.client.coprocessor.Batch.Callback; import org.apache.hadoop.hbase.client.metrics.ScanMetrics; @@ -508,6 +509,11 @@ public class RemoteHTable implements Table { // no-op } + @Override + public TableDescriptor getDescriptor() throws IOException { + return getTableDescriptor(); + } + class Scanner implements ResultScanner { String uri; diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/client/HTableWrapper.java hbase-server/src/main/java/org/apache/hadoop/hbase/client/HTableWrapper.java index 051a8f26e9..8824872416 100644 --- hbase-server/src/main/java/org/apache/hadoop/hbase/client/HTableWrapper.java +++ hbase-server/src/main/java/org/apache/hadoop/hbase/client/HTableWrapper.java @@ -220,6 +220,11 @@ public final class HTableWrapper implements Table { } @Override + public TableDescriptor getDescriptor() throws IOException { + return table.getDescriptor(); + } + + @Override public TableName getName() { return table.getName(); } diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java index b460d1ac9e..78742683ea 100644 --- hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java +++ hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java @@ -117,6 +117,7 @@ import org.apache.hadoop.hbase.client.RegionReplicaUtil; import org.apache.hadoop.hbase.client.Result; import org.apache.hadoop.hbase.client.RowMutations; import org.apache.hadoop.hbase.client.Scan; +import org.apache.hadoop.hbase.client.TableDescriptor; import org.apache.hadoop.hbase.conf.ConfigurationManager; import org.apache.hadoop.hbase.conf.PropagatingConfigurationObserver; import org.apache.hadoop.hbase.coprocessor.RegionObserver.MutationType; @@ -1846,6 +1847,11 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi return this.htableDescriptor; } + @Override + public TableDescriptor getTableDescriptor() { + return this.htableDescriptor; + } + /** @return WAL in use for this region */ public WAL getWAL() { return this.wal; diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/Region.java hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/Region.java index 63e18c3fe6..8df9d19eb5 100644 --- hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/Region.java +++ hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/Region.java @@ -41,6 +41,7 @@ import org.apache.hadoop.hbase.client.Put; import org.apache.hadoop.hbase.client.Result; import org.apache.hadoop.hbase.client.RowMutations; import org.apache.hadoop.hbase.client.Scan; +import org.apache.hadoop.hbase.client.TableDescriptor; import org.apache.hadoop.hbase.conf.ConfigurationObserver; import org.apache.hadoop.hbase.exceptions.FailedSanityCheckException; import org.apache.hadoop.hbase.filter.ByteArrayComparable; @@ -79,8 +80,12 @@ public interface Region extends ConfigurationObserver { HRegionInfo getRegionInfo(); /** @return table descriptor for this region */ + @Deprecated HTableDescriptor getTableDesc(); + /** @return table descriptor for this region */ + TableDescriptor getTableDescriptor(); + /** @return true if region is available (not closed and not closing) */ boolean isAvailable(); diff --git hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/RegionAsTable.java hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/RegionAsTable.java index 9b96ff2547..74eae8b409 100644 --- hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/RegionAsTable.java +++ hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/RegionAsTable.java @@ -40,6 +40,7 @@ import org.apache.hadoop.hbase.client.Row; import org.apache.hadoop.hbase.client.RowMutations; import org.apache.hadoop.hbase.client.Scan; import org.apache.hadoop.hbase.client.Table; +import org.apache.hadoop.hbase.client.TableDescriptor; import org.apache.hadoop.hbase.client.coprocessor.Batch.Call; import org.apache.hadoop.hbase.client.coprocessor.Batch.Callback; import org.apache.hadoop.hbase.client.metrics.ScanMetrics; @@ -87,6 +88,11 @@ public class RegionAsTable implements Table { } @Override + public TableDescriptor getDescriptor() throws IOException { + return this.region.getTableDescriptor(); + } + + @Override public boolean exists(Get get) throws IOException { if (!get.isCheckExistenceOnly()) throw new IllegalArgumentException(); return get(get) != null;