Class SplitTableRegionProcedure
java.lang.Object
org.apache.hadoop.hbase.procedure2.Procedure<TEnvironment>
org.apache.hadoop.hbase.procedure2.StateMachineProcedure<MasterProcedureEnv,TState>
org.apache.hadoop.hbase.master.procedure.AbstractStateMachineTableProcedure<TState>
org.apache.hadoop.hbase.master.procedure.AbstractStateMachineRegionProcedure<org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.SplitTableRegionState>
org.apache.hadoop.hbase.master.assignment.SplitTableRegionProcedure
- All Implemented Interfaces:
Comparable<Procedure<MasterProcedureEnv>>,TableProcedureInterface
@Private
public class SplitTableRegionProcedure
extends AbstractStateMachineRegionProcedure<org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.SplitTableRegionState>
The procedure to split a region in a table. Takes lock on the parent region. It holds the lock
for the life of the procedure.
Throws exception on construction if determines context hostile to spllt (cluster going down or master is shutting down or table is disabled).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classUtility class used to do the file splitting / reference writing in parallel instead of sequentially.Nested classes/interfaces inherited from class org.apache.hadoop.hbase.procedure2.StateMachineProcedure
StateMachineProcedure.FlowNested 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 byte[](package private) booleanprivate RegionInfoprivate RegionInfoprivate static final RegionState.State[]private static final org.slf4j.Loggerprivate RegionSplitPolicyFields inherited from class org.apache.hadoop.hbase.procedure2.StateMachineProcedure
stateCountFields 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
ConstructorsConstructorDescriptionSplitTableRegionProcedure(MasterProcedureEnv env, RegionInfo regionToSplit, byte[] splitRow) -
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 voidassertSplitResultFilesCount(org.apache.hadoop.fs.FileSystem fs, int expectedSplitResultFileCount, org.apache.hadoop.fs.Path dir) private voidprivate voidcheckSplittable(MasterProcedureEnv env, RegionInfo regionToSplit) Check whether the region is splittableprivate TransitRegionStateProcedure[]voidCreate daughter regionsprivate TransitRegionStateProcedure[]private voidprotected voiddeserializeStateData(ProcedureStateSerializer serializer) Called on store load to allow the user to decode the previously serialized state.protected StateMachineProcedure.FlowexecuteFromState(MasterProcedureEnv env, org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.SplitTableRegionState state) called to perform a single step of the specified 'state' of the procedureprivate static longCalculate daughter regionid to use.protected org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.SplitTableRegionStateReturn the initial state object that will be used for the first call to executeFromState().private RegionInfoprivate ServerNameprotected ProcedureMetricsOverride this method to provide procedure specific counters for submitted count, failed count and time histogram.private intprivate byte[]protected org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.SplitTableRegionStategetState(int stateId) Convert an ordinal (or state id) to an Enum (or more descriptive) state object.protected intgetStateId(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.SplitTableRegionState state) Convert the Enum (or more descriptive) state object to an ordinal (or state id).Given an operation type we can take decisions about what to do with pending operations.private booleanprotected booleanisRollbackSupported(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.SplitTableRegionState state) Used by the default implementation of abort() to know if the current state can be aborted and rollback can be triggered.private voidRollback close parent regionprivate voidAction after rollback a split table region action.private voidPost split region actionsbooleanPrepare to Split region.private voidAction before splitting region in a table.private voidPre split region actions after the Point-of-No-Return stepprivate voidPost split region actions before the Point-of-No-Return stepprotected voidThe user should override this method, and release lock if necessary.private voidprivate voidRollback prepare split regionprotected voidrollbackState(MasterProcedureEnv env, org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.SplitTableRegionState state) To rollbackSplitTableRegionProcedure, an AssignProcedure is asynchronously submitted for parent region to be split (rollback doesn't wait on the completion of the AssignProcedure) .protected voidserializeStateData(ProcedureStateSerializer serializer) The user-level code of the procedure may have some state to persist (e.g.private Pair<org.apache.hadoop.fs.Path,org.apache.hadoop.fs.Path> splitStoreFile(HRegionFileSystem regionFs, TableDescriptor htd, ColumnFamilyDescriptor hcd, HStoreFile sf) splitStoreFiles(MasterProcedureEnv env, HRegionFileSystem regionFs) Create Split directoryvoidExtend the toString() information with the procedure details e.g.private voidAdd daughter regions to METAprivate voidMethods inherited from class org.apache.hadoop.hbase.master.procedure.AbstractStateMachineRegionProcedure
getRegion, getTableName, holdLock, setFailure, setRegionMethods inherited from class org.apache.hadoop.hbase.master.procedure.AbstractStateMachineTableProcedure
checkOnline, checkTableModifiable, getUser, getWALRegionDir, isTableEnabled, isTableModificationInProgress, preflightChecks, releaseSyncLatch, setUser, waitInitializedMethods inherited from class org.apache.hadoop.hbase.procedure2.StateMachineProcedure
addChildProcedure, execute, failIfAborted, getCurrentState, getCurrentStateId, getCycles, isEofState, isRollbackSupported, isYieldAfterExecutionStep, isYieldBeforeExecuteFromState, rollback, setNextState, toStringStateMethods 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, 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, setTimeoutFailure, shouldWaitClientAck, skipPersistence, suspend, toString, toStringClass, toStringDetails, toStringSimpleSB, updateMetricsOnFinish, updateMetricsOnSubmit, updateTimestamp, wasExecuted
-
Field Details
-
LOG
-
daughterOneRI
-
daughterTwoRI
-
bestSplitRow
-
splitPolicy
-
checkTableModifyInProgress
boolean checkTableModifyInProgress -
EXPECTED_SPLIT_STATES
-
-
Constructor Details
-
SplitTableRegionProcedure
public SplitTableRegionProcedure() -
SplitTableRegionProcedure
public SplitTableRegionProcedure(MasterProcedureEnv env, RegionInfo regionToSplit, byte[] splitRow) throws IOException - Throws:
IOException
-
-
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 classAbstractStateMachineRegionProcedure<org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.SplitTableRegionState>- 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 classAbstractStateMachineRegionProcedure<org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.SplitTableRegionState>
-
getDaughterOneRI
-
getDaughterTwoRI
-
hasBestSplitRow
-
checkSplittable
Check whether the region is splittable- Parameters:
env- MasterProcedureEnvregionToSplit- parent Region to be split- Throws:
IOException
-
getDaughterRegionIdTimestamp
Calculate daughter regionid to use.- Parameters:
hri- ParentRegionInfo- Returns:
- Daughter region id (timestamp) to use.
-
removeNonDefaultReplicas
- Throws:
IOException
-
checkClosedRegions
- Throws:
IOException
-
executeFromState
protected StateMachineProcedure.Flow executeFromState(MasterProcedureEnv env, org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.SplitTableRegionState state) throws InterruptedException Description copied from class:StateMachineProcedurecalled to perform a single step of the specified 'state' of the procedure- Specified by:
executeFromStatein classStateMachineProcedure<MasterProcedureEnv,org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.SplitTableRegionState> state- state to execute- Returns:
- Flow.NO_MORE_STATE if the procedure is completed, Flow.HAS_MORE_STATE if there is another step.
- Throws:
InterruptedException
-
rollbackState
protected void rollbackState(MasterProcedureEnv env, org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.SplitTableRegionState state) throws IOException, InterruptedException To rollbackSplitTableRegionProcedure, an AssignProcedure is asynchronously submitted for parent region to be split (rollback doesn't wait on the completion of the AssignProcedure) . This can be improved by changing rollback() to support sub-procedures. See HBASE-19851 for details.- Specified by:
rollbackStatein classStateMachineProcedure<MasterProcedureEnv,org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.SplitTableRegionState> state- state to rollback- Throws:
IOException- temporary failure, the rollback will retry laterInterruptedException
-
isRollbackSupported
protected boolean isRollbackSupported(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.SplitTableRegionState state) Description copied from class:StateMachineProcedureUsed by the default implementation of abort() to know if the current state can be aborted and rollback can be triggered.- Overrides:
isRollbackSupportedin classStateMachineProcedure<MasterProcedureEnv,org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.SplitTableRegionState>
-
getState
protected org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.SplitTableRegionState getState(int stateId) Description copied from class:StateMachineProcedureConvert an ordinal (or state id) to an Enum (or more descriptive) state object.- Specified by:
getStatein classStateMachineProcedure<MasterProcedureEnv,org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.SplitTableRegionState> - 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.SplitTableRegionState state) Description copied from class:StateMachineProcedureConvert the Enum (or more descriptive) state object to an ordinal (or state id).- Specified by:
getStateIdin classStateMachineProcedure<MasterProcedureEnv,org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.SplitTableRegionState> - 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.SplitTableRegionState getInitialState()Description copied from class:StateMachineProcedureReturn the initial state object that will be used for the first call to executeFromState().- Specified by:
getInitialStatein classStateMachineProcedure<MasterProcedureEnv,org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.SplitTableRegionState> - Returns:
- the initial state enum object
-
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.- Overrides:
serializeStateDatain classAbstractStateMachineRegionProcedure<org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.SplitTableRegionState>- 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.- Overrides:
deserializeStateDatain classAbstractStateMachineRegionProcedure<org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.SplitTableRegionState>- Parameters:
serializer- contains the serialized state- Throws:
IOException
-
toStringClassDetails
Description copied from class:ProcedureExtend the toString() information with the procedure details e.g. className and parameters- Overrides:
toStringClassDetailsin classAbstractStateMachineRegionProcedure<org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.SplitTableRegionState>- Parameters:
sb- the string builder to use to append the proc specific information
-
getParentRegion
-
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- Specified by:
getTableOperationTypein classAbstractStateMachineRegionProcedure<org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.SplitTableRegionState>- Returns:
- the operation type that the procedure is executing.
-
getProcedureMetrics
Description copied from class:ProcedureOverride this method to provide procedure specific counters for submitted count, failed count and time histogram.- Overrides:
getProcedureMetricsin classProcedure<MasterProcedureEnv>- Parameters:
env- The environment passed to the procedure executor- Returns:
- Container object for procedure related metric
-
getSplitRow
-
prepareSplitRegion
Prepare to Split region.- Parameters:
env- MasterProcedureEnv- Throws:
IOException
-
rollbackPrepareSplit
Rollback prepare split region- Parameters:
env- MasterProcedureEnv
-
preSplitRegion
Action before splitting region in a table.- Parameters:
env- MasterProcedureEnv- Throws:
IOExceptionInterruptedException
-
postRollBackSplitRegion
Action after rollback a split table region action.- Parameters:
env- MasterProcedureEnv- Throws:
IOException
-
openParentRegion
Rollback close parent region- Throws:
IOException
-
createDaughterRegions
Create daughter regions- Throws:
IOException
-
deleteDaughterRegions
- Throws:
IOException
-
splitStoreFiles
private Pair<List<org.apache.hadoop.fs.Path>,List<org.apache.hadoop.fs.Path>> splitStoreFiles(MasterProcedureEnv env, HRegionFileSystem regionFs) throws IOException Create Split directory- Parameters:
env- MasterProcedureEnv- Throws:
IOException
-
assertSplitResultFilesCount
private void assertSplitResultFilesCount(org.apache.hadoop.fs.FileSystem fs, int expectedSplitResultFileCount, org.apache.hadoop.fs.Path dir) throws IOException - Throws:
IOException
-
splitStoreFile
private Pair<org.apache.hadoop.fs.Path,org.apache.hadoop.fs.Path> splitStoreFile(HRegionFileSystem regionFs, TableDescriptor htd, ColumnFamilyDescriptor hcd, HStoreFile sf) throws IOException - Throws:
IOException
-
preSplitRegionBeforeMETA
private void preSplitRegionBeforeMETA(MasterProcedureEnv env) throws IOException, InterruptedException Post split region actions before the Point-of-No-Return step- Parameters:
env- MasterProcedureEnv- Throws:
IOExceptionInterruptedException
-
updateMeta
Add daughter regions to META- Parameters:
env- MasterProcedureEnv- Throws:
IOException
-
preSplitRegionAfterMETA
private void preSplitRegionAfterMETA(MasterProcedureEnv env) throws IOException, InterruptedException Pre split region actions after the Point-of-No-Return step- Parameters:
env- MasterProcedureEnv- Throws:
IOExceptionInterruptedException
-
postSplitRegion
Post split region actions- Parameters:
env- MasterProcedureEnv- Throws:
IOException
-
getParentRegionServerName
-
createUnassignProcedures
private TransitRegionStateProcedure[] createUnassignProcedures(MasterProcedureEnv env) throws IOException - Throws:
IOException
-
createAssignProcedures
private TransitRegionStateProcedure[] createAssignProcedures(MasterProcedureEnv env) throws IOException - Throws:
IOException
-
getRegionReplication
- Throws:
IOException
-
writeMaxSequenceIdFile
- Throws:
IOException
-
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.
- Overrides:
abortin classStateMachineProcedure<MasterProcedureEnv,org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.SplitTableRegionState>
-