HBASE-20927 RSGroupAdminEndpoint doesn't handle clearing dead servers if they are not processed yet.

Signed-off-by: tedyu <yuzhihong@gmail.com>
This commit is contained in:
Sergey Soldatov 2018-07-25 23:32:36 -07:00 committed by tedyu
parent 8b8de1f8a7
commit 973b4ddcfa
2 changed files with 31 additions and 1 deletions

View File

@ -539,7 +539,9 @@ public class RSGroupAdminEndpoint implements MasterCoprocessor, MasterObserver {
filter(server -> !notClearedServers.contains(server)).
map(ServerName::getAddress).
collect(Collectors.toSet());
groupAdminServer.removeServers(clearedServer);
if(!clearedServer.isEmpty()) {
groupAdminServer.removeServers(clearedServer);
}
}
public void checkPermission(String request) throws IOException {

View File

@ -1121,4 +1121,32 @@ public abstract class TestRSGroupsBase {
}
});
}
@Test
public void testClearNotProcessedDeadServer() throws Exception {
LOG.info("testClearNotProcessedDeadServer");
NUM_DEAD_SERVERS = cluster.getClusterMetrics().getDeadServerNames().size();
RSGroupInfo appInfo = addGroup("deadServerGroup", 1);
ServerName targetServer =
ServerName.parseServerName(appInfo.getServers().iterator().next().toString());
AdminProtos.AdminService.BlockingInterface targetRS =
((ClusterConnection) admin.getConnection()).getAdmin(targetServer);
try {
targetServer = ProtobufUtil.toServerName(targetRS.getServerInfo(null,
AdminProtos.GetServerInfoRequest.newBuilder().build()).getServerInfo().getServerName());
//stopping may cause an exception
//due to the connection loss
targetRS.stopServer(null,
AdminProtos.StopServerRequest.newBuilder().setReason("Die").build());
NUM_DEAD_SERVERS ++;
} catch(Exception e) {
}
TEST_UTIL.waitFor(WAIT_TIMEOUT, new Waiter.Predicate<Exception>() {
@Override
public boolean evaluate() throws Exception {
return cluster.getClusterMetrics().getDeadServerNames().size() == NUM_DEAD_SERVERS;
}
});
List<ServerName> notClearedServers = admin.clearDeadServers(Lists.newArrayList(targetServer));
assertEquals(1, notClearedServers.size());
}
}