Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 6C8F1200CEF for ; Mon, 4 Sep 2017 11:09:11 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 67D501637BA; Mon, 4 Sep 2017 09:09:11 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 383B916378B for ; Mon, 4 Sep 2017 11:09:10 +0200 (CEST) Received: (qmail 30781 invoked by uid 500); 4 Sep 2017 09:09:09 -0000 Mailing-List: contact commits-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hbase.apache.org Delivered-To: mailing list commits@hbase.apache.org Received: (qmail 30771 invoked by uid 99); 4 Sep 2017 09:09:09 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 04 Sep 2017 09:09:09 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id D267DF32A6; Mon, 4 Sep 2017 09:09:07 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: chia7712@apache.org To: commits@hbase.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: hbase git commit: HBASE-18736 Cleanup the HTD/HCD for Admin Date: Mon, 4 Sep 2017 09:09:07 +0000 (UTC) archived-at: Mon, 04 Sep 2017 09:09:11 -0000 Repository: hbase Updated Branches: refs/heads/branch-2 a1efda29e -> 0e0154483 HBASE-18736 Cleanup the HTD/HCD for Admin Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/0e015448 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/0e015448 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/0e015448 Branch: refs/heads/branch-2 Commit: 0e0154483872a9d85dc2e75aab8274f065ea8931 Parents: a1efda2 Author: Chia-Ping Tsai Authored: Sat Sep 2 00:06:02 2017 +0800 Committer: Chia-Ping Tsai Committed: Mon Sep 4 17:02:28 2017 +0800 ---------------------------------------------------------------------- .../archetypes/exemplars/client/HelloHBase.java | 12 ++- .../org/apache/hadoop/hbase/client/Admin.java | 107 +++---------------- .../apache/hadoop/hbase/client/HBaseAdmin.java | 46 ++------ .../org/apache/hadoop/hbase/client/HTable.java | 6 +- .../hadoop/hbase/snapshot/SnapshotInfo.java | 2 +- 5 files changed, 27 insertions(+), 146 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/0e015448/hbase-archetypes/hbase-client-project/src/main/java/org/apache/hbase/archetypes/exemplars/client/HelloHBase.java ---------------------------------------------------------------------- diff --git a/hbase-archetypes/hbase-client-project/src/main/java/org/apache/hbase/archetypes/exemplars/client/HelloHBase.java b/hbase-archetypes/hbase-client-project/src/main/java/org/apache/hbase/archetypes/exemplars/client/HelloHBase.java index e327541..ee2f034 100644 --- a/hbase-archetypes/hbase-client-project/src/main/java/org/apache/hbase/archetypes/exemplars/client/HelloHBase.java +++ b/hbase-archetypes/hbase-client-project/src/main/java/org/apache/hbase/archetypes/exemplars/client/HelloHBase.java @@ -21,12 +21,11 @@ package org.apache.hbase.archetypes.exemplars.client; import java.io.IOException; import java.util.Map.Entry; import java.util.NavigableMap; -import org.apache.hadoop.hbase.HColumnDescriptor; -import org.apache.hadoop.hbase.HTableDescriptor; import org.apache.hadoop.hbase.NamespaceDescriptor; import org.apache.hadoop.hbase.NamespaceNotFoundException; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.client.Admin; +import org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder; import org.apache.hadoop.hbase.client.Connection; import org.apache.hadoop.hbase.client.ConnectionFactory; import org.apache.hadoop.hbase.client.Delete; @@ -34,6 +33,8 @@ import org.apache.hadoop.hbase.client.Get; import org.apache.hadoop.hbase.client.Put; import org.apache.hadoop.hbase.client.Result; import org.apache.hadoop.hbase.client.Table; +import org.apache.hadoop.hbase.client.TableDescriptor; +import org.apache.hadoop.hbase.client.TableDescriptorBuilder; import org.apache.hadoop.hbase.util.Bytes; /** @@ -110,9 +111,10 @@ public final class HelloHBase { System.out.println("Creating Table [" + MY_TABLE_NAME.getNameAsString() + "], with one Column Family [" + Bytes.toString(MY_COLUMN_FAMILY_NAME) + "]."); - - admin.createTable(new HTableDescriptor(MY_TABLE_NAME) - .addFamily(new HColumnDescriptor(MY_COLUMN_FAMILY_NAME))); + TableDescriptor desc = TableDescriptorBuilder.newBuilder(MY_TABLE_NAME) + .addColumnFamily(ColumnFamilyDescriptorBuilder.of(MY_COLUMN_FAMILY_NAME)) + .build(); + admin.createTable(desc); } } http://git-wip-us.apache.org/repos/asf/hbase/blob/0e015448/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Admin.java ---------------------------------------------------------------------- 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 8de9f89..b19c107 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 @@ -32,7 +32,6 @@ import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.Abortable; import org.apache.hadoop.hbase.ClusterStatus; import org.apache.hadoop.hbase.ClusterStatus.Options; -import org.apache.hadoop.hbase.HColumnDescriptor; import org.apache.hadoop.hbase.HRegionInfo; import org.apache.hadoop.hbase.HTableDescriptor; import org.apache.hadoop.hbase.NamespaceDescriptor; @@ -291,23 +290,6 @@ public interface Admin extends Abortable, Closeable { * @throws org.apache.hadoop.hbase.TableExistsException if table already exists (If concurrent * threads, the table may have been created between test-for-existence and attempt-at-creation). * @throws IOException if a remote or network exception occurs - * @deprecated since 2.0 version and will be removed in 3.0 version. - * use {@link #createTable(TableDescriptor)} - */ - @Deprecated - default void createTable(HTableDescriptor desc) throws IOException { - createTable((TableDescriptor) desc); - } - - /** - * Creates a new table. Synchronous operation. - * - * @param desc table descriptor for table - * @throws IllegalArgumentException if the table name is reserved - * @throws org.apache.hadoop.hbase.MasterNotRunningException if master is not running - * @throws org.apache.hadoop.hbase.TableExistsException if table already exists (If concurrent - * 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(TableDescriptor desc) throws IOException; @@ -327,31 +309,6 @@ public interface Admin extends Abortable, Closeable { * @throws org.apache.hadoop.hbase.TableExistsException if table already exists (If concurrent * threads, the table may have been created between test-for-existence and attempt-at-creation). * @throws IOException - * @deprecated since 2.0 version and will be removed in 3.0 version. - * use {@link #createTable(TableDescriptor, byte[], byte[], int)} - */ - @Deprecated - default void createTable(HTableDescriptor desc, byte[] startKey, byte[] endKey, int numRegions) - throws IOException { - createTable((TableDescriptor) desc, startKey, endKey, numRegions); - } - - /** - * Creates a new table with the specified number of regions. The start key specified will become - * the end key of the first region of the table, and the end key specified will become the start - * key of the last region of the table (the first region has a null start key and the last region - * has a null end key). BigInteger math will be used to divide the key range specified into enough - * segments to make the required number of total regions. Synchronous operation. - * - * @param desc table descriptor for table - * @param startKey beginning of key range - * @param endKey end of key range - * @param numRegions the total number of regions to create - * @throws IllegalArgumentException if the table name is reserved - * @throws org.apache.hadoop.hbase.MasterNotRunningException if master is not running - * @throws org.apache.hadoop.hbase.TableExistsException if table already exists (If concurrent - * threads, the table may have been created between test-for-existence and attempt-at-creation). - * @throws IOException */ void createTable(TableDescriptor desc, byte[] startKey, byte[] endKey, int numRegions) throws IOException; @@ -369,27 +326,6 @@ public interface Admin extends Abortable, Closeable { * @throws org.apache.hadoop.hbase.TableExistsException if table already exists (If concurrent * threads, the table may have been created between test-for-existence and attempt-at-creation). * @throws IOException - * @deprecated since 2.0 version and will be removed in 3.0 version. - * use {@link #createTable(TableDescriptor, byte[][])} - */ - @Deprecated - default void createTable(final HTableDescriptor desc, byte[][] splitKeys) throws IOException { - createTable((TableDescriptor) desc, splitKeys); - } - - /** - * Creates a new table with an initial set of empty regions defined by the specified split keys. - * The total number of regions created will be the number of split keys plus one. Synchronous - * operation. Note : Avoid passing empty split key. - * - * @param desc table descriptor for table - * @param splitKeys array of split keys for the initial regions of the table - * @throws IllegalArgumentException if the table name is reserved, if the split keys are repeated - * and if the split key has empty byte array. - * @throws org.apache.hadoop.hbase.MasterNotRunningException if master is not running - * @throws org.apache.hadoop.hbase.TableExistsException if table already exists (If concurrent - * threads, the table may have been created between test-for-existence and attempt-at-creation). - * @throws IOException */ void createTable(final TableDescriptor desc, byte[][] splitKeys) throws IOException; @@ -407,29 +343,6 @@ public interface Admin extends Abortable, Closeable { * @throws IOException if a remote or network exception occurs * @return the result of the async creation. You can use Future.get(long, TimeUnit) * to wait on the operation to complete. - * @deprecated since 2.0 version and will be removed in 3.0 version. - * use {@link #createTableAsync(TableDescriptor, byte[][])} - */ - @Deprecated - default Future createTableAsync(final HTableDescriptor desc, final byte[][] splitKeys) - throws IOException { - return createTableAsync((TableDescriptor) desc, splitKeys); - } - - /** - * Creates a new table but does not block and wait for it to come online. - * 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. - * Throws IllegalArgumentException Bad table name, if the split keys - * are repeated and if the split key has empty byte array. - * - * @param desc table descriptor for table - * @param splitKeys keys to check if the table has been created with all split keys - * @throws IOException if a remote or network exception occurs - * @return the result of the async creation. You can use Future.get(long, TimeUnit) - * to wait on the operation to complete. */ Future createTableAsync(final TableDescriptor desc, final byte[][] splitKeys) throws IOException; @@ -718,8 +631,10 @@ public interface Admin extends Abortable, Closeable { * Use {@link #addColumnFamily(TableName, ColumnFamilyDescriptor)}. */ @Deprecated - void addColumn(final TableName tableName, final HColumnDescriptor columnFamily) - throws IOException; + default void addColumn(final TableName tableName, final ColumnFamilyDescriptor columnFamily) + throws IOException { + addColumnFamily(tableName, columnFamily); + } /** * Add a column family to an existing table. @@ -798,8 +713,10 @@ public interface Admin extends Abortable, Closeable { * Use {@link #modifyColumnFamily(TableName, ColumnFamilyDescriptor)}. */ @Deprecated - void modifyColumn(final TableName tableName, final HColumnDescriptor columnFamily) - throws IOException; + default void modifyColumn(final TableName tableName, final ColumnFamilyDescriptor columnFamily) + throws IOException { + modifyColumnFamily(tableName, columnFamily); + } /** * Modify an existing column family on a table. @@ -1231,13 +1148,13 @@ public interface Admin extends Abortable, Closeable { * Modify an existing table, more IRB friendly version. * * @param tableName name of table. - * @param htd modified description of the table + * @param td modified description of the table * @throws IOException if a remote or network exception occurs * @deprecated since 2.0 version and will be removed in 3.0 version. * use {@link #modifyTable(TableDescriptor)} */ @Deprecated - void modifyTable(final TableName tableName, final HTableDescriptor htd) + void modifyTable(final TableName tableName, final TableDescriptor td) throws IOException; /** @@ -1257,7 +1174,7 @@ public interface Admin extends Abortable, Closeable { * operation to complete. * * @param tableName name of table. - * @param htd modified description of the table + * @param td modified 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 @@ -1265,7 +1182,7 @@ public interface Admin extends Abortable, Closeable { * use {@link #modifyTableAsync(TableDescriptor)} */ @Deprecated - Future modifyTableAsync(final TableName tableName, final HTableDescriptor htd) + Future modifyTableAsync(final TableName tableName, final TableDescriptor td) throws IOException; /** http://git-wip-us.apache.org/repos/asf/hbase/blob/0e015448/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java ---------------------------------------------------------------------- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java index a2fa7e0..c699676 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java @@ -994,18 +994,6 @@ public class HBaseAdmin implements Admin { return getAlterStatus(TableName.valueOf(tableName)); } - /** - * {@inheritDoc} - * @deprecated Since 2.0. Will be removed in 3.0. Use - * {@link #addColumnFamily(TableName, ColumnFamilyDescriptor)} instead. - */ - @Override - @Deprecated - public void addColumn(final TableName tableName, final HColumnDescriptor columnFamily) - throws IOException { - addColumnFamily(tableName, columnFamily); - } - @Override public void addColumnFamily(final TableName tableName, final ColumnFamilyDescriptor columnFamily) throws IOException { @@ -1092,18 +1080,6 @@ public class HBaseAdmin implements Admin { } } - /** - * {@inheritDoc} - * @deprecated As of 2.0. Will be removed in 3.0. Use - * {@link #modifyColumnFamily(TableName, ColumnFamilyDescriptor)} instead. - */ - @Override - @Deprecated - public void modifyColumn(final TableName tableName, final HColumnDescriptor columnFamily) - throws IOException { - modifyColumnFamily(tableName, columnFamily); - } - @Override public void modifyColumnFamily(final TableName tableName, final ColumnFamilyDescriptor columnFamily) throws IOException { @@ -1872,29 +1848,19 @@ public class HBaseAdmin implements Admin { } @Override - public void modifyTable(final TableName tableName, final HTableDescriptor htd) + public void modifyTable(final TableName tableName, final TableDescriptor td) throws IOException { - get(modifyTableAsync(tableName, htd), syncWaitTimeout, TimeUnit.MILLISECONDS); + get(modifyTableAsync(tableName, td), syncWaitTimeout, TimeUnit.MILLISECONDS); } @Override - public Future modifyTableAsync(final TableName tableName, final HTableDescriptor htd) + public Future modifyTableAsync(final TableName tableName, final TableDescriptor td) throws IOException { - if (!tableName.equals(htd.getTableName())) { + if (!tableName.equals(td.getTableName())) { throw new IllegalArgumentException("the specified table name '" + tableName + - "' doesn't match with the HTD one: " + htd.getTableName()); + "' doesn't match with the HTD one: " + td.getTableName()); } - ModifyTableResponse response = executeCallable( - new MasterCallable(getConnection(), getRpcControllerFactory()) { - @Override - protected ModifyTableResponse rpcCall() throws Exception { - setPriority(tableName); - ModifyTableRequest request = RequestConverter.buildModifyTableRequest( - tableName, htd, ng.getNonceGroup(), ng.newNonce()); - return master.modifyTable(getRpcController(), request); - } - }); - return new ModifyTableFuture(this, tableName, response); + return modifyTableAsync(td); } private static class ModifyTableFuture extends TableFuture { http://git-wip-us.apache.org/repos/asf/hbase/blob/0e015448/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HTable.java ---------------------------------------------------------------------- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HTable.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HTable.java index 43b05f4..b5c2f92 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HTable.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HTable.java @@ -243,12 +243,8 @@ public class HTable implements Table { @Override public TableDescriptor getDescriptor() throws IOException { - HTableDescriptor htd = HBaseAdmin.getHTableDescriptor(tableName, connection, rpcCallerFactory, + return HBaseAdmin.getTableDescriptor(tableName, connection, rpcCallerFactory, rpcControllerFactory, operationTimeout, readRpcTimeout); - if (htd != null) { - return new ImmutableHTableDescriptor(htd); - } - return null; } /** http://git-wip-us.apache.org/repos/asf/hbase/blob/0e015448/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/SnapshotInfo.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/SnapshotInfo.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/SnapshotInfo.java index d3f1cbc..dad6127 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/SnapshotInfo.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/SnapshotInfo.java @@ -438,7 +438,7 @@ public final class SnapshotInfo extends AbstractHBaseTool { } /** - * Dump the {@link org.apache.hadoop.hbase.HTableDescriptor} + * Dump the {@link org.apache.hadoop.hbase.client.TableDescriptor} */ private void printSchema() { System.out.println("Table Descriptor");