Class Subprocedure
java.lang.Object
org.apache.hadoop.hbase.procedure.Subprocedure
- Direct Known Subclasses:
FlushSnapshotSubprocedure
,FlushTableSubprocedure
,LogRollBackupSubprocedure
,Subprocedure.SubprocedureImpl
Distributed procedure member's Subprocedure. A procedure is sarted on a ProcedureCoordinator
which communicates with ProcedureMembers who create and start its part of the Procedure. This sub
part is called a Subprocedure Users should subclass this and implement
acquireBarrier()
(get local barrier for this member), insideBarrier()
(execute while globally barriered
and release barrier) and cleanup(Exception)
(release state associated with
subprocedure.) When submitted to a ProcedureMember, the call method is executed in a separate
thread. Latches are use too block its progress and trigger continuations when barrier conditions
are met. Exception that makes it out of calls to acquireBarrier()
or
insideBarrier()
gets converted into ForeignException
, which will get propagated
to the ProcedureCoordinator
. There is a category of procedure (ex: online-snapshots), and
a user-specified instance-specific barrierName. (ex: snapshot121126).-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Empty Subprocedure for testing. -
Field Summary
Modifier and TypeFieldDescriptionprivate final String
private boolean
protected final TimeoutExceptionInjector
private final CountDownLatch
wait on before allowing the in barrier phase to proceedprivate static final org.slf4j.Logger
protected final ForeignExceptionDispatcher
monitor to check for errorsprivate final CountDownLatch
counted down when the Subprocedure has completedprotected final ProcedureMemberRpcs
protected final long
frequency to check for errors (ms) -
Constructor Summary
ConstructorDescriptionSubprocedure
(ProcedureMember member, String procName, ForeignExceptionDispatcher monitor, long wakeFrequency, long timeout) -
Method Summary
Modifier and TypeMethodDescriptionabstract void
The implementation of this method should gather and hold required resources (locks, disk space, etc) to satisfy the Procedures barrier condition.final Void
call()
Execute the SubprocedureacquireBarrier()
andinsideBarrier()
methods while keeping some state for other threads to access.void
Method to cancel the Subprocedure by injecting an exception from and external source.abstract void
Users should override this method.(package private) ForeignExceptionSnare
exposed for testing.getName()
abstract byte[]
The implementation of this method should act with the assumption that the barrier condition has been satisfied.(package private) boolean
void
Callback for the member rpcs to call when the global barrier has been reached.private void
void
Waits until the entire procedure has globally completed, or has been aborted.(package private) void
Wait for the reached global barrier notification.
-
Field Details
-
LOG
-
barrierName
-
inGlobalBarrier
wait on before allowing the in barrier phase to proceed -
releasedLocalBarrier
counted down when the Subprocedure has completed -
monitor
monitor to check for errors -
wakeFrequency
frequency to check for errors (ms) -
executionTimeoutTimer
-
rpcs
-
complete
-
-
Constructor Details
-
Subprocedure
public Subprocedure(ProcedureMember member, String procName, ForeignExceptionDispatcher monitor, long wakeFrequency, long timeout) - Parameters:
member
- reference to the member managing this subprocedureprocName
- name of the procedure this subprocedure is associated withmonitor
- notified if there is an error in the subprocedurewakeFrequency
- time in millis to wake to check if there is an error via the monitor (in milliseconds).timeout
- time in millis that will trigger a subprocedure abort if it has not completed
-
-
Method Details
-
getName
-
getMemberName
-
rethrowException
- Throws:
ForeignException
-
call
Execute the SubprocedureacquireBarrier()
andinsideBarrier()
methods while keeping some state for other threads to access. This would normally be executed by the ProcedureMember when a acquire message comes from the coordinator. Rpcs are used to spend message back to the coordinator after different phases are executed. Any exceptions caught during the execution (except for InterruptedException) get converted and propagated to coordinator viaProcedureMemberRpcs.sendMemberAborted(Subprocedure, ForeignException)
. -
isComplete
boolean isComplete() -
getErrorCheckable
exposed for testing. -
acquireBarrier
The implementation of this method should gather and hold required resources (locks, disk space, etc) to satisfy the Procedures barrier condition. For example, this would be where to make all the regions on a RS on the quiescent for an procedure that required all regions to be globally quiesed. Users should override this method. If a quiescent is not required, this is overkill but can still be used to execute a procedure on all members and to propagate any exceptions.- Throws:
ForeignException
-
insideBarrier
The implementation of this method should act with the assumption that the barrier condition has been satisfied. Continuing the previous example, a condition could be that all RS's globally have been quiesced, and procedures that require this precondition could be implemented here. The implementation should also collect the result of the subprocedure as data to be returned to the coordinator upon successful completion. Users should override this method.- Returns:
- the data the subprocedure wants to return to coordinator side.
- Throws:
ForeignException
-
cleanup
Users should override this method. This implementation of this method should rollback and cleanup any temporary or partially completed state that theacquireBarrier()
may have created. -
cancel
Method to cancel the Subprocedure by injecting an exception from and external source. -
receiveReachedGlobalBarrier
Callback for the member rpcs to call when the global barrier has been reached. This unblocks the main subprocedure exectuion thread so that the Subprocedure'sinsideBarrier()
method can be run. -
waitForReachedGlobalBarrier
Wait for the reached global barrier notification. Package visibility for testing- Throws:
ForeignException
InterruptedException
-
waitForLocallyCompleted
Waits until the entire procedure has globally completed, or has been aborted.- Throws:
ForeignException
InterruptedException
-