Class ModifyPeerProcedure
java.lang.Object
org.apache.hadoop.hbase.procedure2.Procedure<TEnvironment>
org.apache.hadoop.hbase.procedure2.StateMachineProcedure<MasterProcedureEnv,TState>
org.apache.hadoop.hbase.master.replication.AbstractPeerProcedure<org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.PeerModificationState>
org.apache.hadoop.hbase.master.replication.ModifyPeerProcedure
- All Implemented Interfaces:
Comparable<Procedure<MasterProcedureEnv>>
,PeerProcedureInterface
- Direct Known Subclasses:
AddPeerProcedure
,DisablePeerProcedure
,EnablePeerProcedure
,RemovePeerProcedure
,UpdatePeerConfigProcedure
@Private
public abstract class ModifyPeerProcedure
extends AbstractPeerProcedure<org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.PeerModificationState>
The base class for all replication peer related procedure except sync replication state
transition.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.hadoop.hbase.procedure2.StateMachineProcedure
StateMachineProcedure.Flow
Nested classes/interfaces inherited from class org.apache.hadoop.hbase.procedure2.Procedure
Procedure.LockState
Nested classes/interfaces inherited from interface org.apache.hadoop.hbase.master.procedure.PeerProcedureInterface
PeerProcedureInterface.PeerOperationType
-
Field Summary
Modifier and TypeFieldDescriptionprivate static final org.slf4j.Logger
private RetryCounter
protected static final int
protected static final int
Fields inherited from class org.apache.hadoop.hbase.master.replication.AbstractPeerProcedure
latch, peerId
Fields inherited from class org.apache.hadoop.hbase.procedure2.StateMachineProcedure
stateCount
Fields inherited from class org.apache.hadoop.hbase.procedure2.Procedure
NO_PROC_ID, NO_TIMEOUT
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprivate void
addToMap
(Map<String, Long> lastSeqIds, String encodedRegionName, long barrier, ReplicationQueueStorage queueStorage) protected void
protected boolean
The implementation class should override this method if the procedure may enter the serial related states.protected StateMachineProcedure.Flow
executeFromState
(MasterProcedureEnv env, org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.PeerModificationState state) called to perform a single step of the specified 'state' of the procedureprotected org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.PeerModificationState
Return the initial state object that will be used for the first call to executeFromState().protected ReplicationPeerConfig
protected ReplicationPeerConfig
protected org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.PeerModificationState
getState
(int stateId) Convert an ordinal (or state id) to an Enum (or more descriptive) state object.protected int
getStateId
(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.PeerModificationState state) Convert the Enum (or more descriptive) state object to an ordinal (or state id).private boolean
needReopen
(TableStateManager tsm, TableName tn) private boolean
protected org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.PeerModificationState
Implementation class can override this method.protected abstract void
Called before we finish the procedure.protected abstract void
Called before we start the actual processing.private void
private void
protected void
protected void
rollbackState
(MasterProcedureEnv env, org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.PeerModificationState state) called to perform the rollback of the specified stateprotected final void
setLastPushedSequenceId
(MasterProcedureEnv env, ReplicationPeerConfig peerConfig) protected final void
setLastPushedSequenceIdForTable
(MasterProcedureEnv env, TableName tableName, Map<String, Long> lastSeqIds) protected boolean
Called by the ProcedureExecutor when the timeout set by setTimeout() is expired.private ProcedureSuspendedException
suspend
(org.apache.hadoop.conf.Configuration conf, LongConsumer backoffConsumer) protected void
protected abstract void
Methods inherited from class org.apache.hadoop.hbase.master.replication.AbstractPeerProcedure
acquireLock, checkPeerModificationEnabled, deserializeStateData, getLatch, getPeerId, holdLock, releaseLock, serializeStateData, waitInitialized
Methods inherited from class org.apache.hadoop.hbase.procedure2.StateMachineProcedure
abort, addChildProcedure, execute, failIfAborted, getCurrentState, getCurrentStateId, getCycles, isEofState, isRollbackSupported, isRollbackSupported, isYieldAfterExecutionStep, isYieldBeforeExecuteFromState, rollback, setNextState, toStringState
Methods inherited from class org.apache.hadoop.hbase.procedure2.Procedure
addStackIndex, afterReplay, beforeReplay, bypass, compareTo, completionCleanup, doExecute, doRollback, elapsedTime, getChildrenLatch, getException, getLastUpdate, getNonceKey, getOwner, getParentProcId, getProcedureMetrics, getProcId, getProcIdHashCode, getProcName, getResult, getRootProcedureId, getRootProcId, getStackIndexes, getState, getSubmittedTime, getTimeout, getTimeoutTimestamp, hasChildren, hasException, hasLock, hasOwner, hasParent, hasTimeout, haveSameParent, incChildrenLatch, isBypass, isFailed, isFinished, isInitializing, isLockedWhenLoading, isRunnable, isSuccess, isWaiting, removeStackIndex, setAbortFailure, setChildrenLatch, setExecuted, setFailure, setFailure, setLastUpdate, setNonceKey, setOwner, setOwner, setParentProcId, setProcId, setResult, setRootProcId, setStackIndexes, setState, setSubmittedTime, setTimeout, shouldWaitClientAck, skipPersistence, suspend, toString, toStringClass, toStringClassDetails, toStringDetails, toStringSimpleSB, updateMetricsOnFinish, updateMetricsOnSubmit, updateTimestamp, wasExecuted
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.hadoop.hbase.master.procedure.PeerProcedureInterface
getPeerOperationType
-
Field Details
-
LOG
-
UPDATE_LAST_SEQ_ID_BATCH_SIZE
- See Also:
-
SLEEP_INTERVAL_MS
- See Also:
-
retryCounter
-
-
Constructor Details
-
ModifyPeerProcedure
protected ModifyPeerProcedure() -
ModifyPeerProcedure
-
-
Method Details
-
prePeerModification
protected abstract void prePeerModification(MasterProcedureEnv env) throws IOException, ReplicationException Called before we start the actual processing. The implementation should call the pre CP hook, and also the pre-check for the peer modification.If an IOException is thrown then we will give up and mark the procedure as failed directly. If all checks passes then the procedure can not be rolled back any more.
- Throws:
IOException
ReplicationException
-
updatePeerStorage
- Throws:
ReplicationException
-
postPeerModification
protected abstract void postPeerModification(MasterProcedureEnv env) throws IOException, ReplicationException Called before we finish the procedure. The implementation can do some logging work, and also call the coprocessor hook if any.Notice that, since we have already done the actual work, throwing
IOException
here will not fail this procedure, we will just ignore it and finish the procedure as suceeded. IfReplicationException
is thrown we will retry since this usually means we fails to update the peer storage.- Throws:
IOException
ReplicationException
-
releaseLatch
-
nextStateAfterRefresh
protected org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.PeerModificationState nextStateAfterRefresh()Implementation class can override this method. By default we will jump to POST_PEER_MODIFICATION and finish the procedure. -
enablePeerBeforeFinish
The implementation class should override this method if the procedure may enter the serial related states. -
refreshPeer
-
getOldPeerConfig
-
getNewPeerConfig
-
updateLastPushedSequenceIdForSerialPeer
protected void updateLastPushedSequenceIdForSerialPeer(MasterProcedureEnv env) throws IOException, ReplicationException - Throws:
IOException
ReplicationException
-
needReopen
- Throws:
IOException
-
reopenRegions
- Throws:
IOException
-
enablePeer
- Throws:
ReplicationException
-
addToMap
private void addToMap(Map<String, Long> lastSeqIds, String encodedRegionName, long barrier, ReplicationQueueStorage queueStorage) throws ReplicationException- Throws:
ReplicationException
-
setLastPushedSequenceId
protected final void setLastPushedSequenceId(MasterProcedureEnv env, ReplicationPeerConfig peerConfig) throws IOException, ReplicationException - Throws:
IOException
ReplicationException
-
needSetLastPushedSequenceId
- Throws:
IOException
-
setLastPushedSequenceIdForTable
protected final void setLastPushedSequenceIdForTable(MasterProcedureEnv env, TableName tableName, Map<String, Long> lastSeqIds) throws IOException, ReplicationException- Throws:
IOException
ReplicationException
-
setTimeoutFailure
Description copied from class:Procedure
Called 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_TIMEOUT
by callingsetState
method, and throw aProcedureSuspendedException
to 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:
setTimeoutFailure
in classProcedure<MasterProcedureEnv>
- Returns:
- true to let the framework handle the timeout as abort, false in case the procedure handled the timeout itself.
-
suspend
private ProcedureSuspendedException suspend(org.apache.hadoop.conf.Configuration conf, LongConsumer backoffConsumer) throws ProcedureSuspendedException - Throws:
ProcedureSuspendedException
-
executeFromState
protected StateMachineProcedure.Flow executeFromState(MasterProcedureEnv env, org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.PeerModificationState state) throws ProcedureSuspendedException Description copied from class:StateMachineProcedure
called to perform a single step of the specified 'state' of the procedure- Specified by:
executeFromState
in classStateMachineProcedure<MasterProcedureEnv,
org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.PeerModificationState> state
- state to execute- Returns:
- Flow.NO_MORE_STATE if the procedure is completed, Flow.HAS_MORE_STATE if there is another step.
- Throws:
ProcedureSuspendedException
-
rollbackState
protected void rollbackState(MasterProcedureEnv env, org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.PeerModificationState state) throws IOException, InterruptedException Description copied from class:StateMachineProcedure
called to perform the rollback of the specified state- Specified by:
rollbackState
in classStateMachineProcedure<MasterProcedureEnv,
org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.PeerModificationState> state
- state to rollback- Throws:
IOException
- temporary failure, the rollback will retry laterInterruptedException
-
getState
protected org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.PeerModificationState getState(int stateId) Description copied from class:StateMachineProcedure
Convert an ordinal (or state id) to an Enum (or more descriptive) state object.- Specified by:
getState
in classStateMachineProcedure<MasterProcedureEnv,
org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.PeerModificationState> - Parameters:
stateId
- the ordinal() of the state enum (or state id)- Returns:
- the state enum object
-
getStateId
protected int getStateId(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.PeerModificationState state) Description copied from class:StateMachineProcedure
Convert the Enum (or more descriptive) state object to an ordinal (or state id).- Specified by:
getStateId
in classStateMachineProcedure<MasterProcedureEnv,
org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.PeerModificationState> - Parameters:
state
- the state enum object- Returns:
- stateId the ordinal() of the state enum (or state id)
-
getInitialState
protected org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.PeerModificationState getInitialState()Description copied from class:StateMachineProcedure
Return the initial state object that will be used for the first call to executeFromState().- Specified by:
getInitialState
in classStateMachineProcedure<MasterProcedureEnv,
org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.PeerModificationState> - Returns:
- the initial state enum object
-