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 Michael Stack
parent 5848e149f4
commit c0a09ccbbd
3 changed files with 24 additions and 2 deletions

View File

@ -3165,6 +3165,8 @@ class RawAsyncHBaseAdmin implements AsyncAdmin {
if (serverName == null) { if (serverName == null) {
future.completeExceptionally( future.completeExceptionally(
new IllegalArgumentException(String.format("Null ServerName: %s", regionServerName))); new IllegalArgumentException(String.format("Null ServerName: %s", regionServerName)));
} else {
serverList.add(serverName);
} }
} }
future.complete(serverList); future.complete(serverList);

View File

@ -335,6 +335,26 @@ public class TestAsyncRegionAdminApi extends TestAsyncAdminBase {
assertEquals("Last compaction state, expected=disabled actual=enabled", assertEquals("Last compaction state, expected=disabled actual=enabled",
false, p.getValue()); 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 @Test

View File

@ -33,9 +33,9 @@ module Shell
To disable compactions on all region servers To disable compactions on all region servers
hbase> compaction_switch false hbase> compaction_switch false
To enable compactions on specific region servers 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 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: NOTE: A server name is its host, port plus startcode. For example:
host187.example.com,60020,1289493121758 host187.example.com,60020,1289493121758
EOF EOF