@InterfaceAudience.Private public abstract class RegionRemoteProcedureBase extends Procedure<MasterProcedureEnv> implements TableProcedureInterface, RemoteProcedureDispatcher.RemoteProcedure<MasterProcedureEnv,ServerName>
Procedure.LockState
TableProcedureInterface.TableOperationType
Modifier and Type | Field and Description |
---|---|
private static org.slf4j.Logger |
LOG |
protected RegionInfo |
region |
private RetryCounter |
retryCounter |
private long |
seqId |
private org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.RegionRemoteProcedureBaseState |
state |
protected ServerName |
targetServer |
private org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionStateTransition.TransitionCode |
transitionCode |
NO_PROC_ID, NO_TIMEOUT
Modifier | Constructor and Description |
---|---|
protected |
RegionRemoteProcedureBase() |
protected |
RegionRemoteProcedureBase(TransitRegionStateProcedure parent,
RegionInfo region,
ServerName targetServer) |
Modifier and Type | Method and Description |
---|---|
protected boolean |
abort(MasterProcedureEnv env)
The abort() call is asynchronous and each procedure must decide how to deal with it, if they
want to be abortable.
|
protected void |
afterReplay(MasterProcedureEnv env)
Called when the procedure is ready to be added to the queue after the loading/replay operation.
|
protected abstract void |
checkTransition(RegionStateNode regionNode,
org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionStateTransition.TransitionCode transitionCode,
long seqId) |
protected void |
deserializeStateData(ProcedureStateSerializer serializer)
Called on store load to allow the user to decode the previously serialized state.
|
protected Procedure<MasterProcedureEnv>[] |
execute(MasterProcedureEnv env)
The main code of the procedure.
|
private TransitRegionStateProcedure |
getParent(MasterProcedureEnv env) |
String |
getProcName() |
private RegionStateNode |
getRegionNode(MasterProcedureEnv env) |
TableName |
getTableName()
Returns the name of the table the procedure is operating on
|
protected abstract RemoteProcedureDispatcher.RemoteOperation |
newRemoteOperation() |
private void |
persistAndWake(MasterProcedureEnv env,
RegionStateNode regionNode) |
Optional<RemoteProcedureDispatcher.RemoteOperation> |
remoteCallBuild(MasterProcedureEnv env,
ServerName remote)
For building the remote operation.
|
void |
remoteCallFailed(MasterProcedureEnv env,
ServerName remote,
IOException exception)
Called when the executeProcedure call is failed.
|
void |
remoteOperationCompleted(MasterProcedureEnv env)
Called when RS tells the remote procedure is succeeded through the
reportProcedureDone method. |
void |
remoteOperationFailed(MasterProcedureEnv env,
RemoteProcedureException error)
Called when RS tells the remote procedure is failed through the
reportProcedureDone
method. |
(package private) void |
reportTransition(MasterProcedureEnv env,
RegionStateNode regionNode,
ServerName serverName,
org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionStateTransition.TransitionCode transitionCode,
long seqId) |
protected abstract void |
restoreSucceedState(AssignmentManager am,
RegionStateNode regionNode,
long seqId) |
protected void |
rollback(MasterProcedureEnv env)
The code to undo what was done by the execute() code.
|
protected void |
serializeStateData(ProcedureStateSerializer serializer)
The user-level code of the procedure may have some state to persist (e.g.
|
(package private) void |
serverCrashed(MasterProcedureEnv env,
RegionStateNode regionNode,
ServerName serverName) |
protected boolean |
setTimeoutFailure(MasterProcedureEnv env)
Called by the ProcedureExecutor when the timeout set by setTimeout() is expired.
|
(package private) void |
stateLoaded(AssignmentManager am,
RegionStateNode regionNode) |
boolean |
storeInDispatchedQueue()
Whether store this remote procedure in dispatched queue only OpenRegionProcedure and
CloseRegionProcedure return false since they are not fully controlled by dispatcher
|
protected void |
toStringClassDetails(StringBuilder builder)
Extend the toString() information with the procedure details e.g.
|
private void |
unattach(MasterProcedureEnv env) |
protected abstract void |
updateTransitionWithoutPersistingToMeta(MasterProcedureEnv env,
RegionStateNode regionNode,
org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionStateTransition.TransitionCode transitionCode,
long seqId) |
protected boolean |
waitInitialized(MasterProcedureEnv env)
The
Procedure.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 call
Procedure.acquireLock(Object) to actually handle the lock for this procedure. |
acquireLock, addStackIndex, 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, holdLock, incChildrenLatch, isBypass, isFailed, isFinished, isInitializing, isLockedWhenLoading, isRunnable, isSuccess, isWaiting, isYieldAfterExecutionStep, releaseLock, removeStackIndex, setAbortFailure, setChildrenLatch, setFailure, setFailure, setLastUpdate, setNonceKey, setOwner, setOwner, setParentProcId, setProcId, setResult, setRootProcId, setStackIndexes, setState, setSubmittedTime, setTimeout, shouldWaitClientAck, skipPersistence, toString, toStringClass, toStringDetails, toStringSimpleSB, toStringState, updateMetricsOnFinish, updateMetricsOnSubmit, updateTimestamp, wasExecuted
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getTableOperationType
private static final org.slf4j.Logger LOG
protected RegionInfo region
protected ServerName targetServer
private org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.RegionRemoteProcedureBaseState state
private org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionStateTransition.TransitionCode transitionCode
private long seqId
private RetryCounter retryCounter
protected RegionRemoteProcedureBase()
protected RegionRemoteProcedureBase(TransitRegionStateProcedure parent, RegionInfo region, ServerName targetServer)
public Optional<RemoteProcedureDispatcher.RemoteOperation> remoteCallBuild(MasterProcedureEnv env, ServerName remote)
RemoteProcedureDispatcher.RemoteProcedure
remoteCallBuild
in interface RemoteProcedureDispatcher.RemoteProcedure<MasterProcedureEnv,ServerName>
protected abstract RemoteProcedureDispatcher.RemoteOperation newRemoteOperation()
public void remoteOperationCompleted(MasterProcedureEnv env)
RemoteProcedureDispatcher.RemoteProcedure
reportProcedureDone
method.remoteOperationCompleted
in interface RemoteProcedureDispatcher.RemoteProcedure<MasterProcedureEnv,ServerName>
public void remoteOperationFailed(MasterProcedureEnv env, RemoteProcedureException error)
RemoteProcedureDispatcher.RemoteProcedure
reportProcedureDone
method.remoteOperationFailed
in interface RemoteProcedureDispatcher.RemoteProcedure<MasterProcedureEnv,ServerName>
private RegionStateNode getRegionNode(MasterProcedureEnv env)
public void remoteCallFailed(MasterProcedureEnv env, ServerName remote, IOException exception)
RemoteProcedureDispatcher.RemoteProcedure
remoteCallFailed
in interface RemoteProcedureDispatcher.RemoteProcedure<MasterProcedureEnv,ServerName>
public TableName getTableName()
TableProcedureInterface
getTableName
in interface TableProcedureInterface
protected boolean waitInitialized(MasterProcedureEnv env)
Procedure
Procedure.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 call
Procedure.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 if Procedure.holdLock(Object)
is true. But the
ProcedureExecutor
will 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.waitInitialized
in class Procedure<MasterProcedureEnv>
protected void rollback(MasterProcedureEnv env) throws IOException, InterruptedException
Procedure
rollback
in class Procedure<MasterProcedureEnv>
env
- the environment passed to the ProcedureExecutorIOException
- temporary failure, the rollback will retry laterInterruptedException
- the procedure will be added back to the queue and retried laterprotected boolean abort(MasterProcedureEnv env)
Procedure
NOTE: abort() is not like Thread.interrupt(). It is just a notification that allows the procedure implementor abort.
abort
in class Procedure<MasterProcedureEnv>
protected abstract void checkTransition(RegionStateNode regionNode, org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionStateTransition.TransitionCode transitionCode, long seqId) throws UnexpectedStateException
UnexpectedStateException
protected abstract void updateTransitionWithoutPersistingToMeta(MasterProcedureEnv env, RegionStateNode regionNode, org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionStateTransition.TransitionCode transitionCode, long seqId) throws IOException
IOException
private void persistAndWake(MasterProcedureEnv env, RegionStateNode regionNode)
void reportTransition(MasterProcedureEnv env, RegionStateNode regionNode, ServerName serverName, org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionStateTransition.TransitionCode transitionCode, long seqId) throws IOException
IOException
void serverCrashed(MasterProcedureEnv env, RegionStateNode regionNode, ServerName serverName)
protected abstract void restoreSucceedState(AssignmentManager am, RegionStateNode regionNode, long seqId) throws IOException
IOException
void stateLoaded(AssignmentManager am, RegionStateNode regionNode)
private TransitRegionStateProcedure getParent(MasterProcedureEnv env)
private void unattach(MasterProcedureEnv env)
protected Procedure<MasterProcedureEnv>[] execute(MasterProcedureEnv env) throws ProcedureYieldException, ProcedureSuspendedException, InterruptedException
Procedure
execute
in class Procedure<MasterProcedureEnv>
env
- the environment passed to the ProcedureExecutorProcedureYieldException
- 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.protected boolean setTimeoutFailure(MasterProcedureEnv env)
Procedure
WAITING_TIMEOUT
by calling setState
method, and throw a
ProcedureSuspendedException
to halt the execution of the procedure, and do not forget a
call Procedure.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.setTimeoutFailure
in class Procedure<MasterProcedureEnv>
public boolean storeInDispatchedQueue()
RemoteProcedureDispatcher.RemoteProcedure
storeInDispatchedQueue
in interface RemoteProcedureDispatcher.RemoteProcedure<MasterProcedureEnv,ServerName>
protected void serializeStateData(ProcedureStateSerializer serializer) throws IOException
Procedure
serializeStateData
in class Procedure<MasterProcedureEnv>
serializer
- stores the serializable stateIOException
protected void deserializeStateData(ProcedureStateSerializer serializer) throws IOException
Procedure
deserializeStateData
in class Procedure<MasterProcedureEnv>
serializer
- contains the serialized stateIOException
protected void afterReplay(MasterProcedureEnv env)
Procedure
afterReplay
in class Procedure<MasterProcedureEnv>
public String getProcName()
getProcName
in class Procedure<MasterProcedureEnv>
protected void toStringClassDetails(StringBuilder builder)
Procedure
toStringClassDetails
in class Procedure<MasterProcedureEnv>
builder
- the string builder to use to append the proc specific informationCopyright © 2007–2020 The Apache Software Foundation. All rights reserved.