@InterfaceAudience.Private public class MergeTableRegionsProcedure extends AbstractStateMachineTableProcedure<org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.MergeTableRegionsState>
StateMachineProcedure.Flow
Procedure.LockState
TableProcedureInterface.TableOperationType
Modifier and Type | Field and Description |
---|---|
private boolean |
force |
private static org.slf4j.Logger |
LOG |
private RegionInfo |
mergedRegion
The resulting merged region.
|
private ServerName |
regionLocation |
private RegionInfo[] |
regionsToMerge
Two or more regions to merge, the 'merge parents'.
|
stateCount
NO_PROC_ID, NO_TIMEOUT
Constructor and Description |
---|
MergeTableRegionsProcedure() |
MergeTableRegionsProcedure(MasterProcedureEnv env,
RegionInfo[] regionsToMerge,
boolean force) |
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 Procedure.LockState |
acquireLock(MasterProcedureEnv env)
The user should override this method if they need a lock on an Entity.
|
private static void |
checkRegionsToMerge(MasterProcedureEnv env,
RegionInfo[] regions,
boolean force) |
private void |
cleanupMergedRegion(MasterProcedureEnv env)
Clean up a merged region on rollback after failure.
|
private AssignProcedure[] |
createAssignProcedures(MasterProcedureEnv env,
int regionReplication) |
private void |
createMergedRegion(MasterProcedureEnv env)
Create merged region.
|
private static RegionInfo |
createMergedRegionInfo(RegionInfo[] regionsToMerge)
Create merged region info by looking at passed in
regionsToMerge
to figure what extremes for start and end keys to use; merged region needs
to have an extent sufficient to cover all regions-to-merge. |
private UnassignProcedure[] |
createUnassignProcedures(MasterProcedureEnv env,
int regionReplication) |
protected void |
deserializeStateData(ProcedureStateSerializer serializer)
Called on store load to allow the user to decode the previously serialized
state.
|
protected StateMachineProcedure.Flow |
executeFromState(MasterProcedureEnv env,
org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.MergeTableRegionsState state)
called to perform a single step of the specified 'state' of the procedure
|
protected org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.MergeTableRegionsState |
getInitialState()
Return the initial state object that will be used for the first call to executeFromState().
|
(package private) RegionInfo |
getMergedRegion() |
protected ProcedureMetrics |
getProcedureMetrics(MasterProcedureEnv env)
Override this method to provide procedure specific counters for submitted count, failed
count and time histogram.
|
private int |
getRegionReplication(MasterProcedureEnv env) |
private ServerName |
getServerName(MasterProcedureEnv env)
The procedure could be restarted from a different machine.
|
protected org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.MergeTableRegionsState |
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.MergeTableRegionsState state)
Convert the Enum (or more descriptive) state object to an ordinal (or state id).
|
TableName |
getTableName() |
TableProcedureInterface.TableOperationType |
getTableOperationType()
Given an operation type we can take decisions about what to do with pending operations.
|
private List<RegionInfo> |
hasRecoveredEdits(MasterProcedureEnv env)
Return list of regions that have recovered.edits...
|
protected boolean |
holdLock(MasterProcedureEnv env)
Used to keep the procedure lock even when the procedure is yielding or suspended.
|
private boolean |
isMergeable(MasterProcedureEnv env,
RegionState rs) |
protected boolean |
isRollbackSupported(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.MergeTableRegionsState state)
Used by the default implementation of abort() to know if the current state can be aborted
and rollback can be triggered.
|
private void |
mergeStoreFiles(MasterProcedureEnv env,
HRegionFileSystem regionFs,
org.apache.hadoop.fs.Path mergeDir)
Create reference file(s) to parent region hfiles in the
mergeDir |
private void |
postCompletedMergeRegions(MasterProcedureEnv env)
Post merge region action
|
private void |
postMergeRegionsCommit(MasterProcedureEnv env)
Post merge region action
|
private void |
postRollBackMergeRegions(MasterProcedureEnv env)
Action after rollback a merge table regions action.
|
private void |
preMergeRegions(MasterProcedureEnv env)
Pre merge region action
|
private void |
preMergeRegionsCommit(MasterProcedureEnv env)
Post merge region action
|
private boolean |
prepareMergeRegion(MasterProcedureEnv env)
Prepare merge and do some check
|
protected void |
releaseLock(MasterProcedureEnv env)
The user should override this method, and release lock if necessary.
|
private void |
rollbackCloseRegionsForMerge(MasterProcedureEnv env)
Rollback close regions
|
protected void |
rollbackState(MasterProcedureEnv env,
org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.MergeTableRegionsState state)
To rollback
MergeTableRegionsProcedure , two AssignProcedures are asynchronously
submitted for each region to be merged (rollback doesn't wait on the completion of the
AssignProcedures) . |
protected void |
serializeStateData(ProcedureStateSerializer serializer)
The user-level code of the procedure may have some state to
persist (e.g.
|
void |
setRegionStateToMerging(MasterProcedureEnv env)
Set the region states to MERGING state
|
void |
toStringClassDetails(StringBuilder sb)
Extend the toString() information with the procedure details
e.g.
|
private void |
updateMetaForMergedRegions(MasterProcedureEnv env)
Add merged region to META and delete original regions.
|
private void |
writeMaxSequenceIdFile(MasterProcedureEnv env) |
checkOnline, checkTableModifiable, getRegionDir, getUser, getWALRegionDir, preflightChecks, releaseSyncLatch, setUser, waitInitialized
addChildProcedure, execute, failIfAborted, getCurrentState, getCurrentStateId, getCycles, isEofState, isYieldAfterExecutionStep, isYieldBeforeExecuteFromState, rollback, setNextState, toStringState
addStackIndex, afterReplay, 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, setFailure, setFailure, setLastUpdate, setNonceKey, setOwner, setOwner, setParentProcId, setProcId, setResult, setRootProcId, setStackIndexes, setState, setSubmittedTime, setTimeout, setTimeoutFailure, shouldWaitClientAck, skipPersistence, toString, toStringClass, toStringDetails, toStringSimpleSB, updateMetricsOnFinish, updateMetricsOnSubmit, updateTimestamp, wasExecuted
private static final org.slf4j.Logger LOG
private ServerName regionLocation
private RegionInfo[] regionsToMerge
private RegionInfo mergedRegion
private boolean force
public MergeTableRegionsProcedure()
public MergeTableRegionsProcedure(MasterProcedureEnv env, RegionInfo[] regionsToMerge, boolean force) throws IOException
IOException
private static void checkRegionsToMerge(MasterProcedureEnv env, RegionInfo[] regions, boolean force) throws MergeRegionException
MergeRegionException
- If unable to merge regions for whatever reasons.private static RegionInfo createMergedRegionInfo(RegionInfo[] regionsToMerge)
regionsToMerge
to figure what extremes for start and end keys to use; merged region needs
to have an extent sufficient to cover all regions-to-merge.protected StateMachineProcedure.Flow executeFromState(MasterProcedureEnv env, org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.MergeTableRegionsState state)
StateMachineProcedure
executeFromState
in class StateMachineProcedure<MasterProcedureEnv,org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.MergeTableRegionsState>
state
- state to executeprotected void rollbackState(MasterProcedureEnv env, org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.MergeTableRegionsState state) throws IOException
MergeTableRegionsProcedure
, two AssignProcedures are asynchronously
submitted for each region to be merged (rollback doesn't wait on the completion of the
AssignProcedures) . This can be improved by changing rollback() to support sub-procedures.
See HBASE-19851 for details.rollbackState
in class StateMachineProcedure<MasterProcedureEnv,org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.MergeTableRegionsState>
state
- state to rollbackIOException
- temporary failure, the rollback will retry laterprotected boolean isRollbackSupported(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.MergeTableRegionsState state)
StateMachineProcedure
isRollbackSupported
in class StateMachineProcedure<MasterProcedureEnv,org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.MergeTableRegionsState>
protected org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.MergeTableRegionsState getState(int stateId)
StateMachineProcedure
getState
in class StateMachineProcedure<MasterProcedureEnv,org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.MergeTableRegionsState>
stateId
- the ordinal() of the state enum (or state id)protected int getStateId(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.MergeTableRegionsState state)
StateMachineProcedure
getStateId
in class StateMachineProcedure<MasterProcedureEnv,org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.MergeTableRegionsState>
state
- the state enum objectprotected org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.MergeTableRegionsState getInitialState()
StateMachineProcedure
getInitialState
in class StateMachineProcedure<MasterProcedureEnv,org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.MergeTableRegionsState>
protected void serializeStateData(ProcedureStateSerializer serializer) throws IOException
Procedure
serializeStateData
in class StateMachineProcedure<MasterProcedureEnv,org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.MergeTableRegionsState>
serializer
- stores the serializable stateIOException
protected void deserializeStateData(ProcedureStateSerializer serializer) throws IOException
Procedure
deserializeStateData
in class StateMachineProcedure<MasterProcedureEnv,org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.MergeTableRegionsState>
serializer
- contains the serialized stateIOException
public void toStringClassDetails(StringBuilder sb)
Procedure
toStringClassDetails
in class AbstractStateMachineTableProcedure<org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.MergeTableRegionsState>
sb
- the string builder to use to append the proc specific informationprotected Procedure.LockState acquireLock(MasterProcedureEnv env)
Procedure
Procedure.execute(Object)
. It calls Procedure.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, see Procedure.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:
acquireLock
in class AbstractStateMachineTableProcedure<org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.MergeTableRegionsState>
protected void releaseLock(MasterProcedureEnv env)
Procedure
releaseLock
in class AbstractStateMachineTableProcedure<org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.MergeTableRegionsState>
protected boolean holdLock(MasterProcedureEnv env)
Procedure
holdLock
in class Procedure<MasterProcedureEnv>
public TableName getTableName()
getTableName
in interface TableProcedureInterface
getTableName
in class AbstractStateMachineTableProcedure<org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.MergeTableRegionsState>
public TableProcedureInterface.TableOperationType getTableOperationType()
TableProcedureInterface
getTableOperationType
in interface TableProcedureInterface
getTableOperationType
in class AbstractStateMachineTableProcedure<org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.MergeTableRegionsState>
protected ProcedureMetrics getProcedureMetrics(MasterProcedureEnv env)
Procedure
getProcedureMetrics
in class Procedure<MasterProcedureEnv>
env
- The environment passed to the procedure executorprivate List<RegionInfo> hasRecoveredEdits(MasterProcedureEnv env) throws IOException
env
- the master envIOException
- IOExceptionprivate boolean prepareMergeRegion(MasterProcedureEnv env) throws IOException
env
- MasterProcedureEnvIOException
private boolean isMergeable(MasterProcedureEnv env, RegionState rs) throws IOException
IOException
private void preMergeRegions(MasterProcedureEnv env) throws IOException
env
- MasterProcedureEnvIOException
private void postRollBackMergeRegions(MasterProcedureEnv env) throws IOException
IOException
public void setRegionStateToMerging(MasterProcedureEnv env)
env
- MasterProcedureEnvprivate void createMergedRegion(MasterProcedureEnv env) throws IOException
IOException
private void mergeStoreFiles(MasterProcedureEnv env, HRegionFileSystem regionFs, org.apache.hadoop.fs.Path mergeDir) throws IOException
mergeDir
regionFs
- merge parent region file systemmergeDir
- the temp directory in which we are accumulating references.IOException
private void cleanupMergedRegion(MasterProcedureEnv env) throws IOException
IOException
private void rollbackCloseRegionsForMerge(MasterProcedureEnv env) throws IOException
env
- MasterProcedureEnvIOException
private UnassignProcedure[] createUnassignProcedures(MasterProcedureEnv env, int regionReplication)
private AssignProcedure[] createAssignProcedures(MasterProcedureEnv env, int regionReplication)
private int getRegionReplication(MasterProcedureEnv env) throws IOException
IOException
private void preMergeRegionsCommit(MasterProcedureEnv env) throws IOException
env
- MasterProcedureEnvIOException
private void updateMetaForMergedRegions(MasterProcedureEnv env) throws IOException
IOException
private void postMergeRegionsCommit(MasterProcedureEnv env) throws IOException
env
- MasterProcedureEnvIOException
private void postCompletedMergeRegions(MasterProcedureEnv env) throws IOException
env
- MasterProcedureEnvIOException
private ServerName getServerName(MasterProcedureEnv env)
env
- MasterProcedureEnvprivate void writeMaxSequenceIdFile(MasterProcedureEnv env) throws IOException
IOException
RegionInfo getMergedRegion()
protected 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 StateMachineProcedure<MasterProcedureEnv,org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.MergeTableRegionsState>
Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.