Class ModifyTableProcedure
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<org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.ModifyTableState>
org.apache.hadoop.hbase.master.procedure.ModifyTableProcedure
- All Implemented Interfaces:
Comparable<Procedure<MasterProcedureEnv>>
,TableProcedureInterface
@Private
public class ModifyTableProcedure
extends AbstractStateMachineTableProcedure<org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.ModifyTableState>
-
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.TableProcedureInterface
TableProcedureInterface.TableOperationType
-
Field Summary
Modifier and TypeFieldDescriptionprivate boolean
private static final org.slf4j.Logger
private TableDescriptor
private boolean
private boolean
private static final List<byte[]>
List of column families that cannot be deleted from the hbase:meta table.private TableDescriptor
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
Fields inherited from interface org.apache.hadoop.hbase.master.procedure.TableProcedureInterface
DUMMY_NAMESPACE_TABLE_NAME
-
Constructor Summary
ConstructorDescriptionModifyTableProcedure
(MasterProcedureEnv env, TableDescriptor htd, ProcedurePrepareLatch latch) ModifyTableProcedure
(MasterProcedureEnv env, TableDescriptor newTableDescriptor, ProcedurePrepareLatch latch, TableDescriptor oldTableDescriptor, boolean shouldCheckDescriptor, boolean reopenRegions) -
Method Summary
Modifier and TypeMethodDescriptionprivate void
private void
protected void
Called when the procedure is marked as completed (success or rollback).private void
deleteFromFs
(MasterProcedureEnv env, TableDescriptor oldTableDescriptor, TableDescriptor newTableDescriptor) Removes from hdfs the families that are not longer present in the new table descriptor.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.ModifyTableState state) called to perform a single step of the specified 'state' of the procedureprotected org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.ModifyTableState
Return the initial state object that will be used for the first call to executeFromState().private List<RegionInfo>
Fetches all Regions for a table.protected org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.ModifyTableState
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.ModifyTableState state) Convert the Enum (or more descriptive) state object to an ordinal (or state id).Returns the name of the table the procedure is operating onGiven an operation type we can take decisions about what to do with pending operations.private void
initialize
(TableDescriptor unmodifiedTableDescriptor, boolean shouldCheckDescriptor) private static boolean
isDeleteColumnFamily
(TableDescriptor originalDescriptor, TableDescriptor newDescriptor) Find out whether all column families in unmodifiedTableDescriptor also exists in the modifiedTableDescriptor.protected boolean
isRollbackSupported
(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.ModifyTableState state) Used by the default implementation of abort() to know if the current state can be aborted and rollback can be triggered.private boolean
isTablePropertyModified
(TableDescriptor oldDescriptor, TableDescriptor newDescriptor, String key) Comparing the value associated with a given key across two TableDescriptor instances' properties.private void
postModify
(MasterProcedureEnv env, org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.ModifyTableState state) Action after modifying table.protected void
preflightChecks
(MasterProcedureEnv env, Boolean enabled) Check that cluster is up and master is running.private void
preModify
(MasterProcedureEnv env, org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.ModifyTableState state) Action before modifying table.private void
Check conditions before any real action of modifying a table.private void
remove replica columns if necessary.protected void
rollbackState
(MasterProcedureEnv env, org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.ModifyTableState state) called to perform the rollback of the specified stateprivate void
runCoprocessorAction
(MasterProcedureEnv env, org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.ModifyTableState state) Coprocessor Action.protected void
serializeStateData
(ProcedureStateSerializer serializer) The user-level code of the procedure may have some state to persist (e.g.private void
Update descriptorMethods inherited from class org.apache.hadoop.hbase.master.procedure.AbstractStateMachineTableProcedure
acquireLock, checkOnline, checkTableModifiable, getUser, getWALRegionDir, isTableEnabled, releaseLock, releaseSyncLatch, setUser, toStringClassDetails, waitInitialized
Methods inherited from class org.apache.hadoop.hbase.procedure2.StateMachineProcedure
abort, addChildProcedure, execute, failIfAborted, getCurrentState, getCurrentStateId, getCycles, isEofState, isRollbackSupported, isYieldAfterExecutionStep, isYieldBeforeExecuteFromState, rollback, setNextState, toStringState
Methods inherited from class org.apache.hadoop.hbase.procedure2.Procedure
addStackIndex, afterReplay, beforeReplay, bypass, compareTo, 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, holdLock, 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
-
unmodifiedTableDescriptor
-
modifiedTableDescriptor
-
deleteColumnFamilyInModify
-
shouldCheckDescriptor
-
reopenRegions
-
UNDELETABLE_META_COLUMNFAMILIES
List of column families that cannot be deleted from the hbase:meta table. They are critical to cluster operation. This is a bit of an odd place to keep this list but then this is the tooling that does add/remove. Keeping it local!
-
-
Constructor Details
-
ModifyTableProcedure
public ModifyTableProcedure() -
ModifyTableProcedure
- Throws:
HBaseIOException
-
ModifyTableProcedure
public ModifyTableProcedure(MasterProcedureEnv env, TableDescriptor htd, ProcedurePrepareLatch latch) throws HBaseIOException - Throws:
HBaseIOException
-
ModifyTableProcedure
public ModifyTableProcedure(MasterProcedureEnv env, TableDescriptor newTableDescriptor, ProcedurePrepareLatch latch, TableDescriptor oldTableDescriptor, boolean shouldCheckDescriptor, boolean reopenRegions) throws HBaseIOException - Throws:
HBaseIOException
-
-
Method Details
-
preflightChecks
Description copied from class:AbstractStateMachineTableProcedure
Check that cluster is up and master is running. Check table is modifiable. Ifenabled
, check table is enabled else check it is disabled. Call in Procedure constructor so can pass any exception to caller.- Overrides:
preflightChecks
in classAbstractStateMachineTableProcedure<org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.ModifyTableState>
enabled
- If true, check table is enabled and throw exception if not. If false, do the inverse. If null, do no table checks.- Throws:
HBaseIOException
-
isTablePropertyModified
private boolean isTablePropertyModified(TableDescriptor oldDescriptor, TableDescriptor newDescriptor, String key) Comparing the value associated with a given key across two TableDescriptor instances' properties.- Returns:
- True if the table property
key
is the same in both.
-
initialize
-
executeFromState
protected StateMachineProcedure.Flow executeFromState(MasterProcedureEnv env, org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.ModifyTableState state) throws InterruptedException 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.ModifyTableState> 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.ModifyTableState state) throws IOException 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.ModifyTableState> state
- state to rollback- Throws:
IOException
- temporary failure, the rollback will retry later
-
isRollbackSupported
protected boolean isRollbackSupported(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.ModifyTableState state) Description copied from class:StateMachineProcedure
Used by the default implementation of abort() to know if the current state can be aborted and rollback can be triggered.- Overrides:
isRollbackSupported
in classStateMachineProcedure<MasterProcedureEnv,
org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.ModifyTableState>
-
completionCleanup
Description copied from class:Procedure
Called when the procedure is marked as completed (success or rollback). The procedure implementor may use this method to cleanup in-memory states. This operation will not be retried on failure. If a procedure took a lock, it will have been released when this method runs.- Overrides:
completionCleanup
in classProcedure<MasterProcedureEnv>
-
getState
protected org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.ModifyTableState 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.ModifyTableState> - 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.ModifyTableState 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.ModifyTableState> - 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.ModifyTableState 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.ModifyTableState> - Returns:
- the initial state enum object
-
serializeStateData
Description copied from class:Procedure
The 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:
serializeStateData
in classStateMachineProcedure<MasterProcedureEnv,
org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.ModifyTableState> - Parameters:
serializer
- stores the serializable state- Throws:
IOException
-
deserializeStateData
Description copied from class:Procedure
Called on store load to allow the user to decode the previously serialized state.- Overrides:
deserializeStateData
in classStateMachineProcedure<MasterProcedureEnv,
org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.ModifyTableState> - Parameters:
serializer
- contains the serialized state- Throws:
IOException
-
getTableName
Description copied from interface:TableProcedureInterface
Returns the name of the table the procedure is operating on- Specified by:
getTableName
in interfaceTableProcedureInterface
- Specified by:
getTableName
in classAbstractStateMachineTableProcedure<org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.ModifyTableState>
-
getTableOperationType
Description copied from interface:TableProcedureInterface
Given 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:
getTableOperationType
in interfaceTableProcedureInterface
- Specified by:
getTableOperationType
in classAbstractStateMachineTableProcedure<org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.ModifyTableState>
- Returns:
- the operation type that the procedure is executing.
-
prepareModify
Check conditions before any real action of modifying a table.- Throws:
IOException
-
isDeleteColumnFamily
private static boolean isDeleteColumnFamily(TableDescriptor originalDescriptor, TableDescriptor newDescriptor) Find out whether all column families in unmodifiedTableDescriptor also exists in the modifiedTableDescriptor.- Returns:
- True if we are deleting a column family.
-
preModify
private void preModify(MasterProcedureEnv env, org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.ModifyTableState state) throws IOException, InterruptedException Action before modifying table.- Parameters:
env
- MasterProcedureEnvstate
- the procedure state- Throws:
IOException
InterruptedException
-
updateTableDescriptor
Update descriptor- Parameters:
env
- MasterProcedureEnv- Throws:
IOException
-
deleteFromFs
private void deleteFromFs(MasterProcedureEnv env, TableDescriptor oldTableDescriptor, TableDescriptor newTableDescriptor) throws IOException Removes from hdfs the families that are not longer present in the new table descriptor.- Parameters:
env
- MasterProcedureEnv- Throws:
IOException
-
removeReplicaColumnsIfNeeded
remove replica columns if necessary.- Throws:
IOException
-
assignNewReplicasIfNeeded
- Throws:
IOException
-
closeExcessReplicasIfNeeded
-
postModify
private void postModify(MasterProcedureEnv env, org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.ModifyTableState state) throws IOException, InterruptedException Action after modifying table.- Parameters:
env
- MasterProcedureEnvstate
- the procedure state- Throws:
IOException
InterruptedException
-
runCoprocessorAction
private void runCoprocessorAction(MasterProcedureEnv env, org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.ModifyTableState state) throws IOException, InterruptedException Coprocessor Action.- Parameters:
env
- MasterProcedureEnvstate
- the procedure state- Throws:
IOException
InterruptedException
-
getRegionInfoList
Fetches all Regions for a table. Cache the result of this method if you need to use it multiple times. Be aware that it may change over in between calls to this procedure.- Throws:
IOException
-