Search in sources :

Example 1 with HBCKServerCrashProcedure

use of org.apache.hadoop.hbase.master.procedure.HBCKServerCrashProcedure in project hbase by apache.

the class AssignmentManager method submitServerCrash.

/**
 * Usually run by the Master in reaction to server crash during normal processing.
 * Can also be invoked via external RPC to effect repair; in the latter case,
 * the 'force' flag is set so we push through the SCP though context may indicate
 * already-running-SCP (An old SCP may have exited abnormally, or damaged cluster
 * may still have references in hbase:meta to 'Unknown Servers' -- servers that
 * are not online or in dead servers list, etc.)
 * @param force Set if the request came in externally over RPC (via hbck2). Force means
 *              run the SCP even if it seems as though there might be an outstanding
 *              SCP running.
 * @return pid of scheduled SCP or {@link Procedure#NO_PROC_ID} if none scheduled.
 */
public long submitServerCrash(ServerName serverName, boolean shouldSplitWal, boolean force) {
    // May be an 'Unknown Server' so handle case where serverNode is null.
    ServerStateNode serverNode = regionStates.getServerNode(serverName);
    // Remove the in-memory rsReports result
    synchronized (rsReports) {
        rsReports.remove(serverName);
    }
    // sure that, the region list fetched by SCP will not be changed any more.
    if (serverNode != null) {
        serverNode.writeLock().lock();
    }
    boolean carryingMeta;
    long pid;
    try {
        ProcedureExecutor<MasterProcedureEnv> procExec = this.master.getMasterProcedureExecutor();
        carryingMeta = isCarryingMeta(serverName);
        if (!force && serverNode != null && !serverNode.isInState(ServerState.ONLINE)) {
            LOG.info("Skip adding ServerCrashProcedure for {} (meta={}) -- running?", serverNode, carryingMeta);
            return Procedure.NO_PROC_ID;
        } else {
            MasterProcedureEnv mpe = procExec.getEnvironment();
            // If serverNode == null, then 'Unknown Server'. Schedule HBCKSCP instead.
            // HBCKSCP scours Master in-memory state AND hbase;meta for references to
            // serverName just-in-case. An SCP that is scheduled when the server is
            // 'Unknown' probably originated externally with HBCK2 fix-it tool.
            ServerState oldState = null;
            if (serverNode != null) {
                oldState = serverNode.getState();
                serverNode.setState(ServerState.CRASHED);
            }
            if (force) {
                pid = procExec.submitProcedure(new HBCKServerCrashProcedure(mpe, serverName, shouldSplitWal, carryingMeta));
            } else {
                pid = procExec.submitProcedure(new ServerCrashProcedure(mpe, serverName, shouldSplitWal, carryingMeta));
            }
            LOG.info("Scheduled ServerCrashProcedure pid={} for {} (carryingMeta={}){}.", pid, serverName, carryingMeta, serverNode == null ? "" : " " + serverNode.toString() + ", oldState=" + oldState);
        }
    } finally {
        if (serverNode != null) {
            serverNode.writeLock().unlock();
        }
    }
    return pid;
}
Also used : HBCKServerCrashProcedure(org.apache.hadoop.hbase.master.procedure.HBCKServerCrashProcedure) HBCKServerCrashProcedure(org.apache.hadoop.hbase.master.procedure.HBCKServerCrashProcedure) ServerCrashProcedure(org.apache.hadoop.hbase.master.procedure.ServerCrashProcedure) MasterProcedureEnv(org.apache.hadoop.hbase.master.procedure.MasterProcedureEnv)

Aggregations

HBCKServerCrashProcedure (org.apache.hadoop.hbase.master.procedure.HBCKServerCrashProcedure)1 MasterProcedureEnv (org.apache.hadoop.hbase.master.procedure.MasterProcedureEnv)1 ServerCrashProcedure (org.apache.hadoop.hbase.master.procedure.ServerCrashProcedure)1