@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();
  }
@return LOCKED, if procedure is found and it has the lock; else UNLOCKED.
@throws ServiceException if given proc id is found but it is not a LockProcedure.
hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java