You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by zh...@apache.org on 2019/05/23 14:31:26 UTC

[hbase] 27/27: HBASE-22351 Addendum limit the concurrency when creating table

This is an automated email from the ASF dual-hosted git repository.

zhangduo pushed a commit to branch HBASE-21512
in repository https://gitbox.apache.org/repos/asf/hbase.git

commit 5db9b8115e3658182eece94715d8d35927d7cb98
Author: zhangduo <zh...@apache.org>
AuthorDate: Thu May 23 22:22:25 2019 +0800

    HBASE-22351 Addendum limit the concurrency when creating table
---
 .../hbase/master/procedure/TestProcedurePriority.java      | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestProcedurePriority.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestProcedurePriority.java
index 36f31e0..3a01d16 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestProcedurePriority.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestProcedurePriority.java
@@ -22,13 +22,14 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Optional;
 import java.util.concurrent.Future;
+import java.util.concurrent.Semaphore;
 import java.util.concurrent.TimeUnit;
 import org.apache.hadoop.hbase.Cell;
 import org.apache.hadoop.hbase.HBaseClassTestRule;
 import org.apache.hadoop.hbase.HBaseTestingUtility;
-import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.Waiter.ExplainingPredicate;
+import org.apache.hadoop.hbase.client.AsyncAdmin;
 import org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder;
 import org.apache.hadoop.hbase.client.Durability;
 import org.apache.hadoop.hbase.client.Get;
@@ -108,16 +109,19 @@ public class TestProcedurePriority {
     UTIL.getConfiguration().setLong(ProcedureExecutor.WORKER_KEEP_ALIVE_TIME_CONF_KEY, 5000);
     UTIL.getConfiguration().setInt(MasterProcedureConstants.MASTER_PROCEDURE_THREADS, 4);
     UTIL.getConfiguration().set(CoprocessorHost.REGION_COPROCESSOR_CONF_KEY, MyCP.class.getName());
-    UTIL.getConfiguration().setInt(HConstants.REGION_SERVER_HANDLER_COUNT, 100);
     UTIL.startMiniCluster(3);
     CORE_POOL_SIZE =
       UTIL.getMiniHBaseCluster().getMaster().getMasterProcedureExecutor().getCorePoolSize();
     TABLE_COUNT = 50 * CORE_POOL_SIZE;
     List<Future<?>> futures = new ArrayList<>();
+    AsyncAdmin admin = UTIL.getAsyncConnection().getAdmin();
+    Semaphore concurrency = new Semaphore(10);
     for (int i = 0; i < TABLE_COUNT; i++) {
-      futures.add(UTIL.getAdmin().createTableAsync(
-        TableDescriptorBuilder.newBuilder(TableName.valueOf(TABLE_NAME_PREFIX + i))
-          .setColumnFamily(ColumnFamilyDescriptorBuilder.of(CF)).build()));
+      concurrency.acquire();
+      futures.add(admin
+        .createTable(TableDescriptorBuilder.newBuilder(TableName.valueOf(TABLE_NAME_PREFIX + i))
+          .setColumnFamily(ColumnFamilyDescriptorBuilder.of(CF)).build())
+        .whenComplete((r, e) -> concurrency.release()));
     }
     for (Future<?> future : futures) {
       future.get(3, TimeUnit.MINUTES);