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>
This commit is contained in:
Karthik Palanisamy 2019-10-12 09:08:20 -07:00 committed by stack
parent 595bcda9c3
commit bebf251179
3 changed files with 24 additions and 2 deletions

View File

@ -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);

View File

@ -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<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

View File

@ -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