This is an automated email from the ASF dual-hosted git repository.
zhangduo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/master by this push:
new 11547b7 HBASE-22178 Introduce a createTableAsync with TableDescriptor
method in Admin
11547b7 is described below
commit 11547b79f3e7fec26a7e18d00a991cc80a7c03ff
Author: zhangduo <[email protected]>
AuthorDate: Sat Apr 6 22:15:41 2019 +0800
HBASE-22178 Introduce a createTableAsync with TableDescriptor method in
Admin
---
.../java/org/apache/hadoop/hbase/client/Admin.java | 42 ++++++++++++++--------
.../org/apache/hadoop/hbase/client/HBaseAdmin.java | 10 +++---
.../hadoop/hbase/thrift2/client/ThriftAdmin.java | 5 +++
3 files changed, 38 insertions(+), 19 deletions(-)
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 0f59c23..bf52af9 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
@@ -196,7 +196,9 @@ 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(TableDescriptor desc) throws IOException;
+ default void createTable(TableDescriptor desc) throws IOException {
+ get(createTableAsync(desc), getSyncWaitTimeout(), TimeUnit.MILLISECONDS);
+ }
/**
* Creates a new table with the specified number of regions. The start key
specified will become
@@ -213,7 +215,6 @@ public interface Admin extends Abortable, Closeable {
* @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;
@@ -237,22 +238,35 @@ public interface Admin extends Abortable, Closeable {
}
/**
- * 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.
- *
+ * 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.
+ * <p/>
+ * 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
+ * @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<Void> createTableAsync(TableDescriptor desc) throws IOException;
+
+ /**
+ * 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.
+ * <p/>
+ * 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.
+ * @return the result of the async creation. You can use Future.get(long,
TimeUnit) to wait on the
+ * operation to complete.
*/
- Future<Void> createTableAsync(TableDescriptor desc, byte[][] splitKeys)
- throws IOException;
+ Future<Void> createTableAsync(TableDescriptor desc, byte[][] splitKeys)
throws IOException;
/**
* Deletes a table. Synchronous operation.
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 b364bbc..fd1cbc7 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
@@ -514,11 +514,6 @@ public class HBaseAdmin implements Admin {
}
@Override
- public void createTable(TableDescriptor desc) throws IOException {
- createTable(desc, null);
- }
-
- @Override
public void createTable(TableDescriptor desc, byte[] startKey, byte[]
endKey, int numRegions)
throws IOException {
if (numRegions < 3) {
@@ -3866,4 +3861,9 @@ public class HBaseAdmin implements Admin {
public Future<Void> splitRegionAsync(byte[] regionName) throws IOException {
return splitRegionAsync(regionName, null);
}
+
+ @Override
+ public Future<Void> createTableAsync(TableDescriptor desc) throws
IOException {
+ return createTableAsync(desc, null);
+ }
}
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 848e625..7ff1979 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
@@ -1032,6 +1032,11 @@ public class ThriftAdmin implements Admin {
}
@Override
+ public Future<Void> createTableAsync(TableDescriptor desc) {
+ throw new NotImplementedException("createTableAsync not supported in
ThriftAdmin");
+ }
+
+ @Override
public Future<Void> createTableAsync(TableDescriptor desc, byte[][]
splitKeys) {
throw new NotImplementedException("createTableAsync not supported in
ThriftAdmin");
}