From bebf251179daaea898545c86f6e87fa0492b6709 Mon Sep 17 00:00:00 2001 From: Karthik Palanisamy Date: Sat, 12 Oct 2019 09:08:20 -0700 Subject: [PATCH] HBASE-23152 Compaction_switch does not work by RegionServer name (#713) Signed-off-by: Duo Zhang Signed-off-by: stack --- .../hbase/client/RawAsyncHBaseAdmin.java | 2 ++ .../hbase/client/TestAsyncRegionAdminApi.java | 20 +++++++++++++++++++ .../ruby/shell/commands/compaction_switch.rb | 4 ++-- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RawAsyncHBaseAdmin.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RawAsyncHBaseAdmin.java index b1f978696a4..dff2ccd2aa2 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RawAsyncHBaseAdmin.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RawAsyncHBaseAdmin.java @@ -3176,6 +3176,8 @@ class RawAsyncHBaseAdmin implements AsyncAdmin { if (serverName == null) { future.completeExceptionally( new IllegalArgumentException(String.format("Null ServerName: %s", regionServerName))); + } else { + serverList.add(serverName); } } future.complete(serverList); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncRegionAdminApi.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncRegionAdminApi.java index 28e60d2f957..aeff96e8964 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncRegionAdminApi.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncRegionAdminApi.java @@ -335,6 +335,26 @@ public class TestAsyncRegionAdminApi extends TestAsyncAdminBase { assertEquals("Last compaction state, expected=disabled actual=enabled", false, p.getValue()); } + ServerName serverName = TEST_UTIL.getHBaseCluster().getRegionServer(0) + .getServerName(); + List serverNameList = new ArrayList(); + serverNameList.add(serverName.getServerName()); + CompletableFuture> listCompletableFuture3 = + admin.compactionSwitch(false, serverNameList); + Map pairs3 = listCompletableFuture3.get(); + assertEquals(pairs3.entrySet().size(), 1); + for (Map.Entry p : pairs3.entrySet()) { + assertEquals("Last compaction state, expected=enabled actual=disabled", + true, p.getValue()); + } + CompletableFuture> listCompletableFuture4 = + admin.compactionSwitch(true, serverNameList); + Map pairs4 = listCompletableFuture4.get(); + assertEquals(pairs4.entrySet().size(), 1); + for (Map.Entry p : pairs4.entrySet()) { + assertEquals("Last compaction state, expected=disabled actual=enabled", + false, p.getValue()); + } } @Test diff --git a/hbase-shell/src/main/ruby/shell/commands/compaction_switch.rb b/hbase-shell/src/main/ruby/shell/commands/compaction_switch.rb index 94db700bc87..6a58bbe5d56 100644 --- a/hbase-shell/src/main/ruby/shell/commands/compaction_switch.rb +++ b/hbase-shell/src/main/ruby/shell/commands/compaction_switch.rb @@ -33,9 +33,9 @@ module Shell To disable compactions on all region servers hbase> compaction_switch false To enable compactions on specific region servers - hbase> compaction_switch true 'server2','server1' + hbase> compaction_switch true, 'server2','server1' To disable compactions on specific region servers - hbase> compaction_switch false 'server2','server1' + hbase> compaction_switch false, 'server2','server1' NOTE: A server name is its host, port plus startcode. For example: host187.example.com,60020,1289493121758 EOF