Skip to content

Commit c0a09cc

Browse files
Karthik Palanisamysaintstack
authored andcommitted
HBASE-23152 Compaction_switch does not work by RegionServer name (#713)
Signed-off-by: Duo Zhang <zhangduo@apache.org> Signed-off-by: stack <stack@apache.org>
1 parent 5848e14 commit c0a09cc

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3165,6 +3165,8 @@ private CompletableFuture<List<ServerName>> getRegionServerList(List<String> ser
31653165
if (serverName == null) {
31663166
future.completeExceptionally(
31673167
new IllegalArgumentException(String.format("Null ServerName: %s", regionServerName)));
3168+
} else {
3169+
serverList.add(serverName);
31683170
}
31693171
}
31703172
future.complete(serverList);

hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncRegionAdminApi.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,26 @@ public void testCompactionSwitchStates() throws Exception {
335335
assertEquals("Last compaction state, expected=disabled actual=enabled",
336336
false, p.getValue());
337337
}
338+
ServerName serverName = TEST_UTIL.getHBaseCluster().getRegionServer(0)
339+
.getServerName();
340+
List<String> serverNameList = new ArrayList<String>();
341+
serverNameList.add(serverName.getServerName());
342+
CompletableFuture<Map<ServerName, Boolean>> listCompletableFuture3 =
343+
admin.compactionSwitch(false, serverNameList);
344+
Map<ServerName, Boolean> pairs3 = listCompletableFuture3.get();
345+
assertEquals(pairs3.entrySet().size(), 1);
346+
for (Map.Entry<ServerName, Boolean> p : pairs3.entrySet()) {
347+
assertEquals("Last compaction state, expected=enabled actual=disabled",
348+
true, p.getValue());
349+
}
350+
CompletableFuture<Map<ServerName, Boolean>> listCompletableFuture4 =
351+
admin.compactionSwitch(true, serverNameList);
352+
Map<ServerName, Boolean> pairs4 = listCompletableFuture4.get();
353+
assertEquals(pairs4.entrySet().size(), 1);
354+
for (Map.Entry<ServerName, Boolean> p : pairs4.entrySet()) {
355+
assertEquals("Last compaction state, expected=disabled actual=enabled",
356+
false, p.getValue());
357+
}
338358
}
339359

340360
@Test

hbase-shell/src/main/ruby/shell/commands/compaction_switch.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ def help
3333
To disable compactions on all region servers
3434
hbase> compaction_switch false
3535
To enable compactions on specific region servers
36-
hbase> compaction_switch true 'server2','server1'
36+
hbase> compaction_switch true, 'server2','server1'
3737
To disable compactions on specific region servers
38-
hbase> compaction_switch false 'server2','server1'
38+
hbase> compaction_switch false, 'server2','server1'
3939
NOTE: A server name is its host, port plus startcode. For example:
4040
host187.example.com,60020,1289493121758
4141
EOF

0 commit comments

Comments
 (0)