public abstract class Subprocedure extends Object implements Callable<Void>
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 ProcedureMemeber, 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).Modifier and Type | Class and Description |
---|---|
static class |
Subprocedure.SubprocedureImpl
Empty Subprocedure for testing.
|
Modifier and Type | Field and Description |
---|---|
private String |
barrierName |
private boolean |
complete |
protected TimeoutExceptionInjector |
executionTimeoutTimer |
private CountDownLatch |
inGlobalBarrier
wait on before allowing the in barrier phase to proceed
|
private static org.apache.commons.logging.Log |
LOG |
protected ForeignExceptionDispatcher |
monitor
monitor to check for errors
|
private CountDownLatch |
releasedLocalBarrier
counted down when the Subprocedure has completed
|
protected ProcedureMemberRpcs |
rpcs |
protected long |
wakeFrequency
frequency to check for errors (ms)
|
Constructor and Description |
---|
Subprocedure(ProcedureMember member,
String procName,
ForeignExceptionDispatcher monitor,
long wakeFrequency,
long timeout) |
Modifier and Type | Method and Description |
---|---|
abstract void |
acquireBarrier()
The implementation of this method should gather and hold required resources (locks, disk
space, etc) to satisfy the Procedures barrier condition.
|
Void |
call()
Execute the Subprocedure
acquireBarrier() and insideBarrier() methods
while keeping some state for other threads to access. |
void |
cancel(String msg,
Throwable cause)
Method to cancel the Subprocedure by injecting an exception from and external source.
|
abstract void |
cleanup(Exception e)
Users should override this method.
|
(package private) ForeignExceptionSnare |
getErrorCheckable()
exposed for testing.
|
String |
getMemberName() |
String |
getName() |
abstract byte[] |
insideBarrier()
The implementation of this method should act with the assumption that the barrier condition
has been satisfied.
|
(package private) boolean |
isComplete() |
void |
receiveReachedGlobalBarrier()
Callback for the member rpcs to call when the global barrier has been reached.
|
private void |
rethrowException() |
void |
waitForLocallyCompleted()
Waits until the entire procedure has globally completed, or has been aborted.
|
(package private) void |
waitForReachedGlobalBarrier()
Wait for the reached global barrier notification.
|
private static final org.apache.commons.logging.Log LOG
private final String barrierName
private final CountDownLatch inGlobalBarrier
private final CountDownLatch releasedLocalBarrier
protected final ForeignExceptionDispatcher monitor
protected final long wakeFrequency
protected final TimeoutExceptionInjector executionTimeoutTimer
protected final ProcedureMemberRpcs rpcs
private volatile boolean complete
public Subprocedure(ProcedureMember member, String procName, ForeignExceptionDispatcher monitor, long wakeFrequency, long timeout)
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 completedpublic String getName()
public String getMemberName()
private void rethrowException() throws ForeignException
ForeignException
public final Void call()
acquireBarrier()
and insideBarrier()
methods
while keeping some state for other threads to access.
This would normally be executed by the ProcedureMemeber 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 via ProcedureMemberRpcs.sendMemberAborted(
Subprocedure, ForeignException)
.boolean isComplete()
ForeignExceptionSnare getErrorCheckable()
public abstract void acquireBarrier() throws ForeignException
ForeignException
public abstract byte[] insideBarrier() throws ForeignException
ForeignException
public abstract void cleanup(Exception e)
acquireBarrier()
may have
created.e
- public void cancel(String msg, Throwable cause)
cause
- public void receiveReachedGlobalBarrier()
insideBarrier()
method can be run.void waitForReachedGlobalBarrier() throws ForeignException, InterruptedException
ForeignException
InterruptedException
public void waitForLocallyCompleted() throws ForeignException, InterruptedException
ForeignException
InterruptedException
Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.