T
- The generic type of the future.public abstract class FutureTaskInvariantMon<T> extends FutureTaskMon<T> implements QuorumListener
Future
that allows you to cancel a computation if an invariant is
violated. This class is specifically designed to monitor quorum related
invariants for HA.
Once an invariant is established, listening for the relevant quorum events commences and a check is made to verify that the invariant holds on entry. This pattern ensures there is no possibility of a missed event.
This FutureTask
wrapper will return the value of the Callable
(or the specified result for the Runnable
) iff the task completes
successfully without the invariant being violated.
Constructor and Description |
---|
FutureTaskInvariantMon(Callable<T> callable,
Quorum<HAGlue,QuorumService<HAGlue>> quorum) |
FutureTaskInvariantMon(Runnable runnable,
T result,
Quorum<HAGlue,QuorumService<HAGlue>> quorum) |
Modifier and Type | Method and Description |
---|---|
void |
assertInPipeline(UUID serviceId)
Establish an invariant that the specified service is in the quorum
pipeline.
|
void |
assertJoined(UUID serviceId)
Establish an invariant that the specified service is joined with the met
quorum.
|
void |
assertMember(UUID serviceId)
Establish an invariant that the specified service is a member of the
quorum.
|
void |
assertNotJoined(UUID serviceId)
Establish an invariant that the specified service is a not joined with
the met quorum.
|
void |
assertQuorumFullyMet()
Establish an invariant that the quorum is fully met.
|
void |
assertQuorumMet()
Establish an invariant that the quorum is met and remains met on the same
token (the one specified to the constructor).
|
protected abstract void |
establishInvariants()
Concrete implementations use this callback hook to establish the
invariants to be monitored.
|
void |
notify(QuorumEvent e)
Any QuorumEvent must be checked to see if it matches an Invariant trigger
|
void |
run() |
cancel
done, get, get, isCancelled, isDone, runAndReset, set, setException
public FutureTaskInvariantMon(Callable<T> callable, Quorum<HAGlue,QuorumService<HAGlue>> quorum)
protected abstract void establishInvariants()
public void run()
Hooked to notice when the task has been started.
Hook to manage listener registration and establish invariants.
run
in interface Runnable
run
in interface RunnableFuture<T>
run
in class FutureTaskMon<T>
public void assertMember(UUID serviceId)
serviceId
- The service.public void assertJoined(UUID serviceId)
serviceId
- The service.public void assertNotJoined(UUID serviceId)
serviceId
- The service.public void assertInPipeline(UUID serviceId)
serviceId
- The service.public void assertQuorumMet()
public void assertQuorumFullyMet()
public void notify(QuorumEvent e)
notify
in interface QuorumListener
Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.