@InterfaceAudience.Private public final class LockProcedure extends Procedure<MasterProcedureEnv> implements TableProcedureInterface
Procedure.LockState
TableProcedureInterface.TableOperationType
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_LOCAL_MASTER_LOCKS_TIMEOUT_MS |
static int |
DEFAULT_REMOTE_LOCKS_TIMEOUT_MS |
static String |
LOCAL_MASTER_LOCKS_TIMEOUT_MS_CONF |
static String |
REMOTE_LOCKS_TIMEOUT_MS_CONF |
NO_PROC_ID, NO_TIMEOUT
Constructor and Description |
---|
LockProcedure() |
LockProcedure(org.apache.hadoop.conf.Configuration conf,
RegionInfo[] regionInfos,
LockType type,
String description,
CountDownLatch lockAcquireLatch)
Constructor for region lock(s).
|
LockProcedure(org.apache.hadoop.conf.Configuration conf,
String namespace,
LockType type,
String description,
CountDownLatch lockAcquireLatch)
Constructor for namespace lock.
|
LockProcedure(org.apache.hadoop.conf.Configuration conf,
TableName tableName,
LockType type,
String description,
CountDownLatch lockAcquireLatch)
Constructor for table lock.
|
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.
|
protected void |
beforeReplay(MasterProcedureEnv env)
On recovery, re-execute from start to acquire the locks.
|
protected void |
deserializeStateData(ProcedureStateSerializer serializer)
Called on store load to allow the user to decode the previously serialized
state.
|
protected Procedure<MasterProcedureEnv>[] |
execute(MasterProcedureEnv env)
The main code of the procedure.
|
String |
getDescription() |
TableName |
getTableName() |
TableProcedureInterface.TableOperationType |
getTableOperationType()
Given an operation type we can take decisions about what to do with pending operations.
|
LockType |
getType() |
boolean |
holdLock(MasterProcedureEnv env)
Used to keep the procedure lock even when the procedure is yielding or suspended.
|
boolean |
isLocked() |
protected void |
releaseLock(MasterProcedureEnv env)
The user should override this method, and release lock if necessary.
|
protected void |
rollback(MasterProcedureEnv env)
The code to undo what was done by the execute() code.
|
protected void |
serializeStateData(ProcedureStateSerializer serializer)
The user-level code of the procedure may have some state to
persist (e.g.
|
protected boolean |
setTimeoutFailure(MasterProcedureEnv env)
Re run the procedure after every timeout to write new WAL entries so we don't hold back old
WALs.
|
protected void |
toStringClassDetails(StringBuilder builder)
Extend the toString() information with the procedure details
e.g.
|
void |
unlock(MasterProcedureEnv env) |
void |
updateHeartBeat()
Updates timeout deadline for the lock.
|
addStackIndex, afterReplay, bypass, compareTo, completionCleanup, 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, incChildrenLatch, isBypass, isFailed, isFinished, isInitializing, isLockedWhenLoading, isRunnable, isSuccess, isWaiting, isYieldAfterExecutionStep, removeStackIndex, setAbortFailure, setChildrenLatch, setFailure, setFailure, setLastUpdate, setNonceKey, setOwner, setOwner, setParentProcId, setProcId, setResult, setRootProcId, setStackIndexes, setState, setSubmittedTime, setTimeout, shouldWaitClientAck, skipPersistence, toString, toStringClass, toStringDetails, toStringSimpleSB, toStringState, updateMetricsOnFinish, updateMetricsOnSubmit, updateTimestamp, waitInitialized, wasExecuted
public static final int DEFAULT_REMOTE_LOCKS_TIMEOUT_MS
public static final String REMOTE_LOCKS_TIMEOUT_MS_CONF
public static final int DEFAULT_LOCAL_MASTER_LOCKS_TIMEOUT_MS
public static final String LOCAL_MASTER_LOCKS_TIMEOUT_MS_CONF
public LockProcedure()
public LockProcedure(org.apache.hadoop.conf.Configuration conf, String namespace, LockType type, String description, CountDownLatch lockAcquireLatch) throws IllegalArgumentException
lockAcquireLatch
- if not null, the latch is decreased when lock is acquired.IllegalArgumentException
public LockProcedure(org.apache.hadoop.conf.Configuration conf, TableName tableName, LockType type, String description, CountDownLatch lockAcquireLatch) throws IllegalArgumentException
lockAcquireLatch
- if not null, the latch is decreased when lock is acquired.IllegalArgumentException
public LockProcedure(org.apache.hadoop.conf.Configuration conf, RegionInfo[] regionInfos, LockType type, String description, CountDownLatch lockAcquireLatch) throws IllegalArgumentException
lockAcquireLatch
- if not null, the latch is decreased when lock is acquired.
Useful for locks acquired locally from master process.IllegalArgumentException
- if all regions are not from same table.public TableName getTableName()
getTableName
in interface TableProcedureInterface
public TableProcedureInterface.TableOperationType getTableOperationType()
TableProcedureInterface
getTableOperationType
in interface TableProcedureInterface
public void updateHeartBeat()
protected boolean setTimeoutFailure(MasterProcedureEnv env)
setTimeoutFailure
in class Procedure<MasterProcedureEnv>
public void unlock(MasterProcedureEnv env)
protected Procedure<MasterProcedureEnv>[] execute(MasterProcedureEnv env) throws ProcedureSuspendedException
Procedure
execute
in class Procedure<MasterProcedureEnv>
env
- the environment passed to the ProcedureExecutorProcedureSuspendedException
- Signal to the executor that Procedure has suspended itself and
has set itself up waiting for an external event to wake it back up again.protected void rollback(MasterProcedureEnv env)
Procedure
rollback
in class Procedure<MasterProcedureEnv>
env
- the environment passed to the ProcedureExecutorprotected 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 Procedure<MasterProcedureEnv>
protected void serializeStateData(ProcedureStateSerializer serializer) throws IOException
Procedure
serializeStateData
in class Procedure<MasterProcedureEnv>
serializer
- stores the serializable stateIOException
protected void deserializeStateData(ProcedureStateSerializer serializer) throws IOException
Procedure
deserializeStateData
in class Procedure<MasterProcedureEnv>
serializer
- contains the serialized stateIOException
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 Procedure<MasterProcedureEnv>
protected void releaseLock(MasterProcedureEnv env)
Procedure
releaseLock
in class Procedure<MasterProcedureEnv>
protected void beforeReplay(MasterProcedureEnv env)
beforeReplay
in class Procedure<MasterProcedureEnv>
protected void toStringClassDetails(StringBuilder builder)
Procedure
toStringClassDetails
in class Procedure<MasterProcedureEnv>
builder
- the string builder to use to append the proc specific informationpublic LockType getType()
public String getDescription()
public boolean isLocked()
public boolean holdLock(MasterProcedureEnv env)
Procedure
holdLock
in class Procedure<MasterProcedureEnv>
Copyright © 2007–2019 Cloudera. All rights reserved.