@InterfaceAudience.Private public class SplitTableRegionProcedure extends AbstractStateMachineRegionProcedure<org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.SplitTableRegionState>
Throws exception on construction if determines context hostile to spllt (cluster going down or master is shutting down or table is disabled).
Modifier and Type | Class and Description |
---|---|
private class |
SplitTableRegionProcedure.StoreFileSplitter
Utility class used to do the file splitting / reference writing in parallel instead of
sequentially.
|
StateMachineProcedure.Flow
Procedure.LockState
TableProcedureInterface.TableOperationType
Modifier and Type | Field and Description |
---|---|
private byte[] |
bestSplitRow |
private RegionInfo |
daughterOneRI |
private RegionInfo |
daughterTwoRI |
private static RegionState.State[] |
EXPECTED_SPLIT_STATES |
private static org.slf4j.Logger |
LOG |
private RegionSplitPolicy |
splitPolicy |
stateCount
NO_PROC_ID, NO_TIMEOUT
Constructor and Description |
---|
SplitTableRegionProcedure() |
SplitTableRegionProcedure(MasterProcedureEnv env,
RegionInfo regionToSplit,
byte[] splitRow) |
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 void |
assertSplitResultFilesCount(org.apache.hadoop.fs.FileSystem fs,
int expectedSplitResultFileCount,
org.apache.hadoop.fs.Path dir) |
private void |
checkClosedRegions(MasterProcedureEnv env) |
private void |
checkSplittable(MasterProcedureEnv env,
RegionInfo regionToSplit)
Check whether the region is splittable
|
private TransitRegionStateProcedure[] |
createAssignProcedures(MasterProcedureEnv env) |
void |
createDaughterRegions(MasterProcedureEnv env)
Create daughter regions
|
private TransitRegionStateProcedure[] |
createUnassignProcedures(MasterProcedureEnv env) |
private void |
deleteDaughterRegions(MasterProcedureEnv env) |
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.SplitTableRegionState state)
called to perform a single step of the specified 'state' of the procedure
|
RegionInfo |
getDaughterOneRI() |
private static long |
getDaughterRegionIdTimestamp(RegionInfo hri)
Calculate daughter regionid to use.
|
RegionInfo |
getDaughterTwoRI() |
protected org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.SplitTableRegionState |
getInitialState()
Return the initial state object that will be used for the first call to executeFromState().
|
private RegionInfo |
getParentRegion() |
private ServerName |
getParentRegionServerName(MasterProcedureEnv env) |
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 byte[] |
getSplitRow() |
protected org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.SplitTableRegionState |
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.SplitTableRegionState state)
Convert the Enum (or more descriptive) state object to an ordinal (or state id).
|
TableProcedureInterface.TableOperationType |
getTableOperationType()
Given an operation type we can take decisions about what to do with pending operations.
|
private boolean |
hasBestSplitRow() |
protected boolean |
isRollbackSupported(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 void |
openParentRegion(MasterProcedureEnv env)
Rollback close parent region
|
private void |
postRollBackSplitRegion(MasterProcedureEnv env)
Action after rollback a split table region action.
|
private void |
postSplitRegion(MasterProcedureEnv env)
Post split region actions
|
boolean |
prepareSplitRegion(MasterProcedureEnv env)
Prepare to Split region.
|
private void |
preSplitRegion(MasterProcedureEnv env)
Action before splitting region in a table.
|
private void |
preSplitRegionAfterMETA(MasterProcedureEnv env)
Pre split region actions after the Point-of-No-Return step
|
private void |
preSplitRegionBeforeMETA(MasterProcedureEnv env)
Post split region actions before the Point-of-No-Return step
|
protected void |
releaseLock(MasterProcedureEnv env)
The user should override this method, and release lock if necessary.
|
private void |
removeNonDefaultReplicas(MasterProcedureEnv env) |
protected void |
rollbackState(MasterProcedureEnv env,
org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.SplitTableRegionState state)
To rollback
SplitTableRegionProcedure , an AssignProcedure is asynchronously submitted
for parent region to be split (rollback doesn't wait on the completion of the AssignProcedure)
. |
protected void |
serializeStateData(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,
byte[] family,
HStoreFile sf) |
private Pair<List<org.apache.hadoop.fs.Path>,List<org.apache.hadoop.fs.Path>> |
splitStoreFiles(MasterProcedureEnv env,
HRegionFileSystem regionFs)
Create Split directory
|
void |
toStringClassDetails(StringBuilder sb)
Extend the toString() information with the procedure details e.g.
|
private void |
updateMeta(MasterProcedureEnv env)
Add daughter regions to META
|
private void |
writeMaxSequenceIdFile(MasterProcedureEnv env) |
getRegion, getTableName, holdLock, setFailure, setRegion
checkOnline, checkTableModifiable, getUser, getWALRegionDir, isTableEnabled, 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 RegionInfo daughterOneRI
private RegionInfo daughterTwoRI
private byte[] bestSplitRow
private RegionSplitPolicy splitPolicy
private static final RegionState.State[] EXPECTED_SPLIT_STATES
public SplitTableRegionProcedure()
public SplitTableRegionProcedure(MasterProcedureEnv env, RegionInfo regionToSplit, byte[] splitRow) throws IOException
IOException
protected 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 AbstractStateMachineRegionProcedure<org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.SplitTableRegionState>
protected void releaseLock(MasterProcedureEnv env)
Procedure
releaseLock
in class AbstractStateMachineRegionProcedure<org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.SplitTableRegionState>
public RegionInfo getDaughterOneRI()
public RegionInfo getDaughterTwoRI()
private boolean hasBestSplitRow()
private void checkSplittable(MasterProcedureEnv env, RegionInfo regionToSplit) throws IOException
env
- MasterProcedureEnvregionToSplit
- parent Region to be splitIOException
private static long getDaughterRegionIdTimestamp(RegionInfo hri)
hri
- Parent RegionInfo
private void removeNonDefaultReplicas(MasterProcedureEnv env) throws IOException
IOException
private void checkClosedRegions(MasterProcedureEnv env) throws IOException
IOException
protected StateMachineProcedure.Flow executeFromState(MasterProcedureEnv env, org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.SplitTableRegionState state) throws InterruptedException
StateMachineProcedure
executeFromState
in class StateMachineProcedure<MasterProcedureEnv,org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.SplitTableRegionState>
state
- state to executeInterruptedException
protected void rollbackState(MasterProcedureEnv env, org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.SplitTableRegionState state) throws IOException, InterruptedException
SplitTableRegionProcedure
, 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.rollbackState
in class StateMachineProcedure<MasterProcedureEnv,org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.SplitTableRegionState>
state
- state to rollbackIOException
- temporary failure, the rollback will retry laterInterruptedException
protected boolean isRollbackSupported(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.SplitTableRegionState state)
StateMachineProcedure
isRollbackSupported
in class StateMachineProcedure<MasterProcedureEnv,org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.SplitTableRegionState>
protected org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.SplitTableRegionState getState(int stateId)
StateMachineProcedure
getState
in class StateMachineProcedure<MasterProcedureEnv,org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.SplitTableRegionState>
stateId
- the ordinal() of the state enum (or state id)protected int getStateId(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.SplitTableRegionState state)
StateMachineProcedure
getStateId
in class StateMachineProcedure<MasterProcedureEnv,org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.SplitTableRegionState>
state
- the state enum objectprotected org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.SplitTableRegionState getInitialState()
StateMachineProcedure
getInitialState
in class StateMachineProcedure<MasterProcedureEnv,org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.SplitTableRegionState>
protected void serializeStateData(ProcedureStateSerializer serializer) throws IOException
Procedure
serializeStateData
in class AbstractStateMachineRegionProcedure<org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.SplitTableRegionState>
serializer
- stores the serializable stateIOException
protected void deserializeStateData(ProcedureStateSerializer serializer) throws IOException
Procedure
deserializeStateData
in class AbstractStateMachineRegionProcedure<org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.SplitTableRegionState>
serializer
- contains the serialized stateIOException
public void toStringClassDetails(StringBuilder sb)
Procedure
toStringClassDetails
in class AbstractStateMachineRegionProcedure<org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.SplitTableRegionState>
sb
- the string builder to use to append the proc specific informationprivate RegionInfo getParentRegion()
public TableProcedureInterface.TableOperationType getTableOperationType()
TableProcedureInterface
getTableOperationType
in interface TableProcedureInterface
getTableOperationType
in class AbstractStateMachineRegionProcedure<org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.SplitTableRegionState>
protected ProcedureMetrics getProcedureMetrics(MasterProcedureEnv env)
Procedure
getProcedureMetrics
in class Procedure<MasterProcedureEnv>
env
- The environment passed to the procedure executorprivate byte[] getSplitRow()
public boolean prepareSplitRegion(MasterProcedureEnv env) throws IOException
env
- MasterProcedureEnvIOException
private void preSplitRegion(MasterProcedureEnv env) throws IOException, InterruptedException
env
- MasterProcedureEnvIOException
InterruptedException
private void postRollBackSplitRegion(MasterProcedureEnv env) throws IOException
env
- MasterProcedureEnvIOException
private void openParentRegion(MasterProcedureEnv env) throws IOException
IOException
public void createDaughterRegions(MasterProcedureEnv env) throws IOException
IOException
private void deleteDaughterRegions(MasterProcedureEnv env) throws IOException
IOException
private Pair<List<org.apache.hadoop.fs.Path>,List<org.apache.hadoop.fs.Path>> splitStoreFiles(MasterProcedureEnv env, HRegionFileSystem regionFs) throws IOException
env
- MasterProcedureEnvIOException
private void assertSplitResultFilesCount(org.apache.hadoop.fs.FileSystem fs, int expectedSplitResultFileCount, org.apache.hadoop.fs.Path dir) throws IOException
IOException
private Pair<org.apache.hadoop.fs.Path,org.apache.hadoop.fs.Path> splitStoreFile(HRegionFileSystem regionFs, byte[] family, HStoreFile sf) throws IOException
IOException
private void preSplitRegionBeforeMETA(MasterProcedureEnv env) throws IOException, InterruptedException
env
- MasterProcedureEnvIOException
InterruptedException
private void updateMeta(MasterProcedureEnv env) throws IOException
env
- MasterProcedureEnvIOException
private void preSplitRegionAfterMETA(MasterProcedureEnv env) throws IOException, InterruptedException
env
- MasterProcedureEnvIOException
InterruptedException
private void postSplitRegion(MasterProcedureEnv env) throws IOException
env
- MasterProcedureEnvIOException
private ServerName getParentRegionServerName(MasterProcedureEnv env)
private TransitRegionStateProcedure[] createUnassignProcedures(MasterProcedureEnv env) throws IOException
IOException
private TransitRegionStateProcedure[] createAssignProcedures(MasterProcedureEnv env) throws IOException
IOException
private int getRegionReplication(MasterProcedureEnv env) throws IOException
IOException
private void writeMaxSequenceIdFile(MasterProcedureEnv env) throws IOException
IOException
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.SplitTableRegionState>
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.