From c0a09ccbbd0f0ee25c962744718b4b13adc26eb4 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 a006d166b678..dff8e64c041f 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 @@ -3165,6 +3165,8 @@ private CompletableFuture> getRegionServerList(List ser 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 28e60d2f9576..aeff96e8964b 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 void testCompactionSwitchStates() throws Exception { 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 94db700bc87e..6a58bbe5d563 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 @@ def help 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