Skip to content

Commit

Permalink
HBASE-23152 Compaction_switch does not work by RegionServer name (#713)
Browse files Browse the repository at this point in the history
 Signed-off-by: Duo Zhang <[email protected]>
 Signed-off-by: stack <[email protected]>
  • Loading branch information
Karthik Palanisamy authored and saintstack committed Oct 12, 2019
1 parent 5848e14 commit c0a09cc
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3165,6 +3165,8 @@ private CompletableFuture<List<ServerName>> getRegionServerList(List<String> ser
if (serverName == null) {
future.completeExceptionally(
new IllegalArgumentException(String.format("Null ServerName: %s", regionServerName)));
} else {
serverList.add(serverName);
}
}
future.complete(serverList);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> serverNameList = new ArrayList<String>();
serverNameList.add(serverName.getServerName());
CompletableFuture<Map<ServerName, Boolean>> listCompletableFuture3 =
admin.compactionSwitch(false, serverNameList);
Map<ServerName, Boolean> pairs3 = listCompletableFuture3.get();
assertEquals(pairs3.entrySet().size(), 1);
for (Map.Entry<ServerName, Boolean> p : pairs3.entrySet()) {
assertEquals("Last compaction state, expected=enabled actual=disabled",
true, p.getValue());
}
CompletableFuture<Map<ServerName, Boolean>> listCompletableFuture4 =
admin.compactionSwitch(true, serverNameList);
Map<ServerName, Boolean> pairs4 = listCompletableFuture4.get();
assertEquals(pairs4.entrySet().size(), 1);
for (Map.Entry<ServerName, Boolean> p : pairs4.entrySet()) {
assertEquals("Last compaction state, expected=disabled actual=enabled",
false, p.getValue());
}
}

@Test
Expand Down
4 changes: 2 additions & 2 deletions hbase-shell/src/main/ruby/shell/commands/compaction_switch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c0a09cc

Please sign in to comment.