Search in sources :

Example 1 with ClearDeadServersResponse

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();
}
Also used : ClearDeadServersResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ClearDeadServersResponse) Address(org.apache.hadoop.hbase.net.Address) InetAddress(java.net.InetAddress) ServerCrashProcedure(org.apache.hadoop.hbase.master.procedure.ServerCrashProcedure) IOException(java.io.IOException) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) HBaseProtos(org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos) ServiceException(org.apache.hbase.thirdparty.com.google.protobuf.ServiceException) ServerName(org.apache.hadoop.hbase.ServerName) HashSet(java.util.HashSet)

Aggregations

IOException (java.io.IOException)1 InetAddress (java.net.InetAddress)1 HashSet (java.util.HashSet)1 DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)1 ServerName (org.apache.hadoop.hbase.ServerName)1 ServerCrashProcedure (org.apache.hadoop.hbase.master.procedure.ServerCrashProcedure)1 Address (org.apache.hadoop.hbase.net.Address)1 HBaseProtos (org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos)1 ClearDeadServersResponse (org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ClearDeadServersResponse)1 ServiceException (org.apache.hbase.thirdparty.com.google.protobuf.ServiceException)1