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.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 booleanprivate static final org.slf4j.Loggerprivate TableDescriptorprivate booleanprivate booleanprivate static final List<byte[]>List of column families that cannot be deleted from the hbase:meta table.private TableDescriptorFields inherited from class org.apache.hadoop.hbase.procedure2.StateMachineProcedure
stateCountFields inherited from class org.apache.hadoop.hbase.procedure2.Procedure
NO_PROC_ID, NO_TIMEOUT -
Constructor Summary
ConstructorsConstructorDescriptionModifyTableProcedure(MasterProcedureEnv env, TableDescriptor htd, ProcedurePrepareLatch latch) ModifyTableProcedure(MasterProcedureEnv env, TableDescriptor newTableDescriptor, ProcedurePrepareLatch latch, TableDescriptor oldTableDescriptor, boolean shouldCheckDescriptor, boolean reopenRegions) -
Method Summary
Modifier and TypeMethodDescriptionprivate voidprivate voidprotected voidCalled when the procedure is marked as completed (success or rollback).private voiddeleteFromFs(MasterProcedureEnv env, TableDescriptor oldTableDescriptor, TableDescriptor newTableDescriptor) Removes from hdfs the families that are not longer present in the new table descriptor.protected 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.ModifyTableState state) called to perform a single step of the specified 'state' of the procedureprotected org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.ModifyTableStateReturn 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.ModifyTableStategetState(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.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 voidinitialize(TableDescriptor unmodifiedTableDescriptor, boolean shouldCheckDescriptor) private static booleanisDeleteColumnFamily(TableDescriptor originalDescriptor, TableDescriptor newDescriptor) Find out whether all column families in unmodifiedTableDescriptor also exists in the modifiedTableDescriptor.protected booleanisRollbackSupported(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 booleanisTablePropertyModified(TableDescriptor oldDescriptor, TableDescriptor newDescriptor, String key) Comparing the value associated with a given key across two TableDescriptor instances' properties.private voidpostModify(MasterProcedureEnv env, org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.ModifyTableState state) Action after modifying table.protected voidpreflightChecks(MasterProcedureEnv env, Boolean enabled) Check that cluster is up and master is running.private voidpreModify(MasterProcedureEnv env, org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.ModifyTableState state) Action before modifying table.private voidCheck conditions before any real action of modifying a table.private voidremove replica columns if necessary.protected voidrollbackState(MasterProcedureEnv env, org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.ModifyTableState state) called to perform the rollback of the specified stateprivate voidrunCoprocessorAction(MasterProcedureEnv env, org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.ModifyTableState state) Coprocessor Action.protected voidserializeStateData(ProcedureStateSerializer serializer) The user-level code of the procedure may have some state to persist (e.g.private voidUpdate descriptorMethods inherited from class org.apache.hadoop.hbase.master.procedure.AbstractStateMachineTableProcedure
acquireLock, checkOnline, checkTableModifiable, getUser, getWALRegionDir, isTableEnabled, releaseLock, releaseSyncLatch, setUser, toStringClassDetails, waitInitializedMethods inherited from class org.apache.hadoop.hbase.procedure2.StateMachineProcedure
abort, addChildProcedure, execute, failIfAborted, getCurrentState, getCurrentStateId, getCycles, isEofState, isRollbackSupported, isYieldAfterExecutionStep, isYieldBeforeExecuteFromState, rollback, setNextState, toStringStateMethods 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:AbstractStateMachineTableProcedureCheck 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:
preflightChecksin 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
keyis 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: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.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:StateMachineProcedurecalled to perform the rollback of the specified state- Specified by:
rollbackStatein 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: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.ModifyTableState>
-
completionCleanup
Description copied from class:ProcedureCalled 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:
completionCleanupin classProcedure<MasterProcedureEnv>
-
getState
protected org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.ModifyTableState 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.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: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.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: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.ModifyTableState> - 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 classStateMachineProcedure<MasterProcedureEnv,org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.ModifyTableState> - 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 classStateMachineProcedure<MasterProcedureEnv,org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.ModifyTableState> - Parameters:
serializer- contains the serialized state- Throws:
IOException
-
getTableName
Description copied from interface:TableProcedureInterfaceReturns the name of the table the procedure is operating on- Specified by:
getTableNamein interfaceTableProcedureInterface- Specified by:
getTableNamein classAbstractStateMachineTableProcedure<org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.ModifyTableState>
-
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 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.- Parameters:
env- MasterProcedureEnv- 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:
IOExceptionInterruptedException
-
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:
IOExceptionInterruptedException
-
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:
IOExceptionInterruptedException
-
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
-