use of org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ClearDeadServersResponse in project hbase by apache.
the class MasterRpcServices method clearDeadServers.
@Override
public ClearDeadServersResponse clearDeadServers(RpcController controller, ClearDeadServersRequest request) throws ServiceException {
LOG.debug(server.getClientIdAuditPrefix() + " clear dead region servers.");
ClearDeadServersResponse.Builder response = ClearDeadServersResponse.newBuilder();
try {
server.checkInitialized();
if (server.cpHost != null) {
server.cpHost.preClearDeadServers();
}
if (server.getServerManager().areDeadServersInProgress()) {
LOG.debug("Some dead server is still under processing, won't clear the dead server list");
response.addAllServerName(request.getServerNameList());
} else {
DeadServer deadServer = server.getServerManager().getDeadServers();
Set<Address> clearedServers = new HashSet<>();
for (HBaseProtos.ServerName pbServer : request.getServerNameList()) {
ServerName serverName = ProtobufUtil.toServerName(pbServer);
final boolean deadInProcess = server.getProcedures().stream().anyMatch(p -> (p instanceof ServerCrashProcedure) && ((ServerCrashProcedure) p).getServerName().equals(serverName));
if (deadInProcess) {
throw new ServiceException(String.format("Dead server '%s' is not 'dead' in fact...", serverName));
}
if (!deadServer.removeDeadServer(serverName)) {
response.addServerName(pbServer);
} else {
clearedServers.add(serverName.getAddress());
}
}
server.getRSGroupInfoManager().removeServers(clearedServers);
LOG.info("Remove decommissioned servers {} from RSGroup done", clearedServers);
}
if (server.cpHost != null) {
server.cpHost.postClearDeadServers(ProtobufUtil.toServerNameList(request.getServerNameList()), ProtobufUtil.toServerNameList(response.getServerNameList()));
}
} catch (IOException io) {
throw new ServiceException(io);
}
return response.build();
}
Aggregations