Class SnapshotRegionProcedure
java.lang.Object
org.apache.hadoop.hbase.procedure2.Procedure<MasterProcedureEnv>
org.apache.hadoop.hbase.master.procedure.SnapshotRegionProcedure
- All Implemented Interfaces:
Comparable<Procedure<MasterProcedureEnv>>,TableProcedureInterface,RemoteProcedureDispatcher.RemoteProcedure<MasterProcedureEnv,ServerName>
@Private
public class SnapshotRegionProcedure
extends Procedure<MasterProcedureEnv>
implements TableProcedureInterface, RemoteProcedureDispatcher.RemoteProcedure<MasterProcedureEnv,ServerName>
A remote procedure which is used to send region snapshot request to region server. The basic
logic of SnapshotRegionProcedure is similar like
ServerRemoteProcedure, only with a
little difference, when FailedRemoteDispatchException was thrown, SnapshotRegionProcedure
will sleep some time and continue retrying until success.-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.hadoop.hbase.procedure2.Procedure
Procedure.LockStateNested classes/interfaces inherited from interface org.apache.hadoop.hbase.master.procedure.TableProcedureInterface
TableProcedureInterface.TableOperationType -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprivate ProcedureEvent<?>private static final org.slf4j.Loggerprivate RegionInfoprivate RetryCounterprivate org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescriptionprivate booleanFields inherited from class org.apache.hadoop.hbase.procedure2.Procedure
NO_PROC_ID, NO_TIMEOUTFields inherited from interface org.apache.hadoop.hbase.master.procedure.TableProcedureInterface
DUMMY_NAMESPACE_TABLE_NAME -
Constructor Summary
ConstructorsConstructorDescriptionSnapshotRegionProcedure(org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription snapshot, RegionInfo region) -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanabort(MasterProcedureEnv env) The abort() call is asynchronous and each procedure must decide how to deal with it, if they want to be abortable.protected Procedure.LockStateThe user should override this method if they need a lock on an Entity.private voidcomplete(MasterProcedureEnv env, Throwable error) protected voiddeserializeStateData(ProcedureStateSerializer serializer) Called on store load to allow the user to decode the previously serialized state.protected Procedure<MasterProcedureEnv>[]The main code of the procedure.Returns the name of the table the procedure is operating onGiven an operation type we can take decisions about what to do with pending operations.protected booleanUsed to keep the procedure lock even when the procedure is yielding or suspended.(package private) booleanprotected voidThe user should override this method, and release lock if necessary.remoteCallBuild(MasterProcedureEnv env, ServerName serverName) For building the remote operation.voidremoteCallFailed(MasterProcedureEnv env, ServerName serverName, IOException e) Called when the executeProcedure call is failed.voidremoteOperationCompleted(MasterProcedureEnv env, byte[] remoteResultData) Called when RS tells the remote procedure is succeeded through thereportProcedureDonemethod.voidCalled when RS tells the remote procedure is failed through thereportProcedureDonemethod.protected voidThe code to undo what was done by the execute() code.protected voidserializeStateData(ProcedureStateSerializer serializer) The user-level code of the procedure may have some state to persist (e.g.protected booleanCalled by the ProcedureExecutor when the timeout set by setTimeout() is expired.private voidsetTimeoutForSuspend(MasterProcedureEnv env, String reason) protected voidtoStringClassDetails(StringBuilder builder) Extend the toString() information with the procedure details e.g.protected booleanTheProcedure.doAcquireLock(Object, ProcedureStore)will be split into two steps, first, it will call us to determine whether we need to wait for initialization, second, it will callProcedure.acquireLock(Object)to actually handle the lock for this procedure.Methods inherited from class org.apache.hadoop.hbase.procedure2.Procedure
addStackIndex, afterExec, afterReplay, beforeExec, beforeReplay, bypass, compareTo, completionCleanup, doExecute, doRollback, elapsedTime, getChildrenLatch, getException, getLastUpdate, getNonceKey, getOwner, getParentProcId, getProcedureMetrics, getProcId, getProcIdHashCode, getResult, getRootProcedureId, getRootProcId, getStackIndexes, getState, getSubmittedTime, getTimeout, getTimeoutTimestamp, hasChildren, hasException, hasLock, hasOwner, hasParent, hasTimeout, haveSameParent, incChildrenLatch, isBypass, isFailed, isFinished, isInitializing, isLockedWhenLoading, isRollbackSupported, isRunnable, isSuccess, isWaiting, isYieldAfterExecutionStep, removeStackIndex, setAbortFailure, setChildrenLatch, setExecuted, setFailure, setFailure, setLastUpdate, setNonceKey, setOwner, setOwner, setParentProcId, setProcId, setResult, setRootProcId, setStackIndexes, setState, setSubmittedTime, setTimeout, shouldWaitClientAck, skipPersistence, suspend, toString, toStringClass, toStringDetails, toStringSimpleSB, toStringState, updateMetricsOnFinish, updateMetricsOnSubmit, updateTimestamp, wasExecutedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.hadoop.hbase.procedure2.RemoteProcedureDispatcher.RemoteProcedure
storeInDispatchedQueue
-
Field Details
-
LOG
-
snapshot
private org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription snapshot -
event
-
region
-
dispatched
-
succ
-
retryCounter
-
-
Constructor Details
-
SnapshotRegionProcedure
public SnapshotRegionProcedure() -
SnapshotRegionProcedure
public SnapshotRegionProcedure(org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription snapshot, RegionInfo region)
-
-
Method Details
-
acquireLock
Description copied from class:ProcedureThe user should override this method if they need a lock on an Entity. A lock can be anything, and it is up to the implementor. The Procedure Framework will call this method just before it invokesProcedure.execute(Object). It callsProcedure.releaseLock(Object)after the call to execute. If you need to hold the lock for the life of the Procedure -- i.e. you do not want any other Procedure interfering while this Procedure is running, seeProcedure.holdLock(Object). Example: in our Master we can execute request in parallel for different tables. We can create t1 and create t2 and these creates can be executed at the same time. Anything else on t1/t2 is queued waiting that specific table create to happen. There are 3 LockState:- LOCK_ACQUIRED should be returned when the proc has the lock and the proc is ready to execute.
- LOCK_YIELD_WAIT should be returned when the proc has not the lock and the framework should take care of readding the procedure back to the runnable set for retry
- LOCK_EVENT_WAIT should be returned when the proc has not the lock and someone will take care of readding the procedure back to the runnable set when the lock is available.
- Overrides:
acquireLockin classProcedure<MasterProcedureEnv>- Returns:
- the lock state as described above.
-
releaseLock
Description copied from class:ProcedureThe user should override this method, and release lock if necessary.- Overrides:
releaseLockin classProcedure<MasterProcedureEnv>
-
holdLock
Description copied from class:ProcedureUsed to keep the procedure lock even when the procedure is yielding or suspended.- Overrides:
holdLockin classProcedure<MasterProcedureEnv>- Returns:
- true if the procedure should hold on the lock until completionCleanup()
-
remoteCallBuild
public Optional<RemoteProcedureDispatcher.RemoteOperation> remoteCallBuild(MasterProcedureEnv env, ServerName serverName) Description copied from interface:RemoteProcedureDispatcher.RemoteProcedureFor building the remote operation. May be empty if no need to send remote call. Usually, this means the RemoteProcedure has been finished already. This is possible, as we may have already sent the procedure to RS but then the rpc connection is broken so the executeProcedures call fails, but the RS does receive the procedure and execute it and then report back, before we retry again.- Specified by:
remoteCallBuildin interfaceRemoteProcedureDispatcher.RemoteProcedure<MasterProcedureEnv,ServerName>
-
remoteCallFailed
Description copied from interface:RemoteProcedureDispatcher.RemoteProcedureCalled when the executeProcedure call is failed.- Specified by:
remoteCallFailedin interfaceRemoteProcedureDispatcher.RemoteProcedure<MasterProcedureEnv,ServerName>
-
remoteOperationCompleted
Description copied from interface:RemoteProcedureDispatcher.RemoteProcedureCalled when RS tells the remote procedure is succeeded through thereportProcedureDonemethod.- Specified by:
remoteOperationCompletedin interfaceRemoteProcedureDispatcher.RemoteProcedure<MasterProcedureEnv,ServerName>
-
remoteOperationFailed
Description copied from interface:RemoteProcedureDispatcher.RemoteProcedureCalled when RS tells the remote procedure is failed through thereportProcedureDonemethod.- Specified by:
remoteOperationFailedin interfaceRemoteProcedureDispatcher.RemoteProcedure<MasterProcedureEnv,ServerName>
-
complete
-
getTableName
Description copied from interface:TableProcedureInterfaceReturns the name of the table the procedure is operating on- Specified by:
getTableNamein interfaceTableProcedureInterface
-
getTableOperationType
Description copied from interface:TableProcedureInterfaceGiven an operation type we can take decisions about what to do with pending operations. e.g. if we get a delete and we have some table operation pending (e.g. add column) we can abort those operations.- Specified by:
getTableOperationTypein interfaceTableProcedureInterface- Returns:
- the operation type that the procedure is executing.
-
execute
protected Procedure<MasterProcedureEnv>[] execute(MasterProcedureEnv env) throws ProcedureYieldException, ProcedureSuspendedException, InterruptedException Description copied from class:ProcedureThe main code of the procedure. It must be idempotent since execute() may be called multiple times in case of machine failure in the middle of the execution.- Specified by:
executein classProcedure<MasterProcedureEnv>- Parameters:
env- the environment passed to the ProcedureExecutor- Returns:
- a set of sub-procedures to run or ourselves if there is more work to do or null if the procedure is done.
- Throws:
ProcedureYieldException- the procedure will be added back to the queue and retried later.ProcedureSuspendedException- Signal to the executor that Procedure has suspended itself and has set itself up waiting for an external event to wake it back up again.InterruptedException- the procedure will be added back to the queue and retried later.
-
rollback
Description copied from class:ProcedureThe code to undo what was done by the execute() code. It is called when the procedure or one of the sub-procedures failed or an abort was requested. It should cleanup all the resources created by the execute() call. The implementation must be idempotent since rollback() may be called multiple time in case of machine failure in the middle of the execution.- Specified by:
rollbackin classProcedure<MasterProcedureEnv>- Parameters:
env- the environment passed to the ProcedureExecutor
-
setTimeoutForSuspend
-
setTimeoutFailure
Description copied from class:ProcedureCalled by the ProcedureExecutor when the timeout set by setTimeout() is expired. Another usage for this method is to implement retrying. A procedure can set the state toWAITING_TIMEOUTby callingsetStatemethod, and throw aProcedureSuspendedExceptionto halt the execution of the procedure, and do not forget a callProcedure.setTimeout(int)method to set the timeout. And you should also override this method to wake up the procedure, and also return false to tell the ProcedureExecutor that the timeout event has been handled.- Overrides:
setTimeoutFailurein classProcedure<MasterProcedureEnv>- Returns:
- true to let the framework handle the timeout as abort, false in case the procedure handled the timeout itself.
-
abort
Description copied from class:ProcedureThe abort() call is asynchronous and each procedure must decide how to deal with it, if they want to be abortable. The simplest implementation is to have an AtomicBoolean set in the abort() method and then the execute() will check if the abort flag is set or not. abort() may be called multiple times from the client, so the implementation must be idempotent.NOTE: abort() is not like Thread.interrupt(). It is just a notification that allows the procedure implementor abort.
- Specified by:
abortin classProcedure<MasterProcedureEnv>
-
serializeStateData
Description copied from class:ProcedureThe user-level code of the procedure may have some state to persist (e.g. input arguments or current position in the processing state) to be able to resume on failure.- Specified by:
serializeStateDatain classProcedure<MasterProcedureEnv>- Parameters:
serializer- stores the serializable state- Throws:
IOException
-
deserializeStateData
Description copied from class:ProcedureCalled on store load to allow the user to decode the previously serialized state.- Specified by:
deserializeStateDatain classProcedure<MasterProcedureEnv>- Parameters:
serializer- contains the serialized state- Throws:
IOException
-
getProcName
- Overrides:
getProcNamein classProcedure<MasterProcedureEnv>
-
toStringClassDetails
Description copied from class:ProcedureExtend the toString() information with the procedure details e.g. className and parameters- Overrides:
toStringClassDetailsin classProcedure<MasterProcedureEnv>- Parameters:
builder- the string builder to use to append the proc specific information
-
waitInitialized
Description copied from class:ProcedureTheProcedure.doAcquireLock(Object, ProcedureStore)will be split into two steps, first, it will call us to determine whether we need to wait for initialization, second, it will callProcedure.acquireLock(Object)to actually handle the lock for this procedure. This is because that when master restarts, we need to restore the lock state for all the procedures to not break the semantic ifProcedure.holdLock(Object)is true. But theProcedureExecutorwill be started before the master finish initialization(as it is part of the initialization!), so we need to split the code into two steps, and when restore, we just restore the lock part and ignore the waitInitialized part. Otherwise there will be dead lock.- Overrides:
waitInitializedin classProcedure<MasterProcedureEnv>- Returns:
- true means we need to wait until the environment has been initialized, otherwise true.
-
getRegion
-
inRetrying
boolean inRetrying()
-