Skip to content

Commit 11547b7

Browse files
committed
HBASE-22178 Introduce a createTableAsync with TableDescriptor method in Admin
1 parent b3f62a7 commit 11547b7

File tree

3 files changed

+38
-19
lines changed

3 files changed

+38
-19
lines changed

hbase-client/src/main/java/org/apache/hadoop/hbase/client/Admin.java

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,9 @@ TableDescriptor getDescriptor(TableName tableName)
196196
* threads, the table may have been created between test-for-existence and attempt-at-creation).
197197
* @throws IOException if a remote or network exception occurs
198198
*/
199-
void createTable(TableDescriptor desc) throws IOException;
199+
default void createTable(TableDescriptor desc) throws IOException {
200+
get(createTableAsync(desc), getSyncWaitTimeout(), TimeUnit.MILLISECONDS);
201+
}
200202

201203
/**
202204
* Creates a new table with the specified number of regions. The start key specified will become
@@ -213,7 +215,6 @@ TableDescriptor getDescriptor(TableName tableName)
213215
* @throws org.apache.hadoop.hbase.MasterNotRunningException if master is not running
214216
* @throws org.apache.hadoop.hbase.TableExistsException if table already exists (If concurrent
215217
* threads, the table may have been created between test-for-existence and attempt-at-creation).
216-
* @throws IOException
217218
*/
218219
void createTable(TableDescriptor desc, byte[] startKey, byte[] endKey, int numRegions)
219220
throws IOException;
@@ -237,22 +238,35 @@ default void createTable(TableDescriptor desc, byte[][] splitKeys) throws IOExce
237238
}
238239

239240
/**
240-
* Creates a new table but does not block and wait for it to come online.
241-
* You can use Future.get(long, TimeUnit) to wait on the operation to complete.
242-
* It may throw ExecutionException if there was an error while executing the operation
243-
* or TimeoutException in case the wait timeout was not long enough to allow the
244-
* operation to complete.
245-
* Throws IllegalArgumentException Bad table name, if the split keys
246-
* are repeated and if the split key has empty byte array.
247-
*
241+
* Creates a new table but does not block and wait for it to come online. You can use
242+
* Future.get(long, TimeUnit) to wait on the operation to complete. It may throw
243+
* ExecutionException if there was an error while executing the operation or TimeoutException in
244+
* case the wait timeout was not long enough to allow the operation to complete.
245+
* <p/>
246+
* Throws IllegalArgumentException Bad table name, if the split keys are repeated and if the split
247+
* key has empty byte array.
248+
* @param desc table descriptor for table
249+
* @throws IOException if a remote or network exception occurs
250+
* @return the result of the async creation. You can use Future.get(long, TimeUnit) to wait on the
251+
* operation to complete.
252+
*/
253+
Future<Void> createTableAsync(TableDescriptor desc) throws IOException;
254+
255+
/**
256+
* Creates a new table but does not block and wait for it to come online. You can use
257+
* Future.get(long, TimeUnit) to wait on the operation to complete. It may throw
258+
* ExecutionException if there was an error while executing the operation or TimeoutException in
259+
* case the wait timeout was not long enough to allow the operation to complete.
260+
* <p/>
261+
* Throws IllegalArgumentException Bad table name, if the split keys are repeated and if the split
262+
* key has empty byte array.
248263
* @param desc table descriptor for table
249264
* @param splitKeys keys to check if the table has been created with all split keys
250265
* @throws IOException if a remote or network exception occurs
251-
* @return the result of the async creation. You can use Future.get(long, TimeUnit)
252-
* to wait on the operation to complete.
266+
* @return the result of the async creation. You can use Future.get(long, TimeUnit) to wait on the
267+
* operation to complete.
253268
*/
254-
Future<Void> createTableAsync(TableDescriptor desc, byte[][] splitKeys)
255-
throws IOException;
269+
Future<Void> createTableAsync(TableDescriptor desc, byte[][] splitKeys) throws IOException;
256270

257271
/**
258272
* Deletes a table. Synchronous operation.

hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -513,11 +513,6 @@ private long getPauseTime(int tries) {
513513
return this.pause * HConstants.RETRY_BACKOFF[triesCount];
514514
}
515515

516-
@Override
517-
public void createTable(TableDescriptor desc) throws IOException {
518-
createTable(desc, null);
519-
}
520-
521516
@Override
522517
public void createTable(TableDescriptor desc, byte[] startKey, byte[] endKey, int numRegions)
523518
throws IOException {
@@ -3866,4 +3861,9 @@ public void close() {
38663861
public Future<Void> splitRegionAsync(byte[] regionName) throws IOException {
38673862
return splitRegionAsync(regionName, null);
38683863
}
3864+
3865+
@Override
3866+
public Future<Void> createTableAsync(TableDescriptor desc) throws IOException {
3867+
return createTableAsync(desc, null);
3868+
}
38693869
}

hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/client/ThriftAdmin.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,6 +1031,11 @@ public void cloneTableSchema(TableName tableName, TableName newTableName,
10311031

10321032
}
10331033

1034+
@Override
1035+
public Future<Void> createTableAsync(TableDescriptor desc) {
1036+
throw new NotImplementedException("createTableAsync not supported in ThriftAdmin");
1037+
}
1038+
10341039
@Override
10351040
public Future<Void> createTableAsync(TableDescriptor desc, byte[][] splitKeys) {
10361041
throw new NotImplementedException("createTableAsync not supported in ThriftAdmin");

0 commit comments

Comments
 (0)