protected abstract class AbstractQuorum.QuorumWatcherBase extends Object implements QuorumWatcher<S,C>
QuorumWatcher
implementations.
The protected methods on this base class are designed to be invoked by
the QuorumWatcher
when it observes a change in the distributed
quorum state. Those methods know how to update the internal state of the
AbstractQuorum
based on state changes observed by a concrete
QuorumWatcher
implementations and will generate the appropriate
messages for the QuorumClient
or QuorumMember
and also
generate the appropriate QuorumEvent
s.
When a state change triggers certain events on the behalf of the
associated QuorumMember
the QuorumWatcher
will issue the
necessary requests to the QuorumActor
. For example, when the #of
joined services rises to (k+1)/2
, the QuorumWatcher
for the first service in the vote order will issue the requests to the
QuorumActor
which are necessary to execute the leader election
protocol.
Modifier and Type | Field and Description |
---|---|
protected String |
logicalServiceId
The identifier of the logical service whose quorum state is being
watched.
|
Modifier | Constructor and Description |
---|---|
protected |
AbstractQuorum.QuorumWatcherBase(String logicalServiceId) |
Modifier and Type | Method and Description |
---|---|
protected void |
castVote(UUID serviceId,
long lastCommitTime)
Method is invoked by the
QuorumWatcher when a service is
votes in an attempt to join a quorum and updates the internal state
of the quorum to reflect that state change. |
protected void |
clearToken()
Method is invoked by the
QuorumWatcher when the current
quorum token is invalidated. |
protected void |
doAction(Runnable r)
Run some action(s) on the behalf of the watcher outside of the thread
in which the watcher handles the state change (this is done to avoid
recursion through the watcher-action loop while holding the lock).
|
protected void |
memberAdd(UUID serviceId)
Method is invoked by the
QuorumWatcher when a member service
is added to the quorum and updates the internal state of the quorum
to reflect that state change. |
protected void |
memberRemove(UUID serviceId)
Method is invoked by the
QuorumWatcher when a member service
is removed from the quorum and updates the internal state of the
quorum to reflect that state change. |
protected void |
pipelineAdd(UUID serviceId)
Method is invoked by the
QuorumWatcher when a service is
added to the write pipeline and updates the internal state of the
quorum to reflect that state change. |
protected void |
pipelineRemove(UUID serviceId)
Method is invoked by the
QuorumWatcher when a service is
removed from the write pipeline and updates the internal state of the
quorum to reflect that state change. |
protected void |
serviceJoin(UUID serviceId)
Method is invoked by the
QuorumWatcher when a service joins
the quorum and updates the internal state of the quorum to reflect
that state change. |
protected void |
serviceLeave(UUID serviceId)
Method is invoked by the
QuorumWatcher when a joined service
leaves the quorum and updates the internal state of the quorum to
reflect that state change. |
protected void |
setToken(long newToken)
Method is invoked by the
QuorumWatcher when the leader
updates the (lastValidToken,token) pair atomically. |
protected void |
start()
Method is invoked by
AbstractQuorum.start(QuorumClient) and
provides the QuorumWatcher with an opportunity to setup
discovery (such as zookeeper watchers) and read the initial state of
the distributed quorum, causing it to be reflected on the
AbstractQuorum internal state. |
protected void |
terminate()
Method is invoked by
AbstractQuorum.terminate() and provides
the QuorumWatcher with an opportunity to terminate
asynchronous processing and tear down any resources it may be using. |
protected void |
withdrawVote(UUID serviceId)
Method is invoked by the
QuorumWatcher when a service has
withdrawn its vote for some lastCommitTime. |
protected final String logicalServiceId
protected AbstractQuorum.QuorumWatcherBase(String logicalServiceId)
protected void start()
AbstractQuorum.start(QuorumClient)
and
provides the QuorumWatcher
with an opportunity to setup
discovery (such as zookeeper watchers) and read the initial state of
the distributed quorum, causing it to be reflected on the
AbstractQuorum
internal state.protected void terminate()
AbstractQuorum.terminate()
and provides
the QuorumWatcher
with an opportunity to terminate
asynchronous processing and tear down any resources it may be using.protected void doAction(Runnable r)
r
- The action(s).protected void memberAdd(UUID serviceId)
QuorumWatcher
when a member service
is added to the quorum and updates the internal state of the quorum
to reflect that state change.serviceId
- The service UUID
.protected void memberRemove(UUID serviceId)
QuorumWatcher
when a member service
is removed from the quorum and updates the internal state of the
quorum to reflect that state change.serviceId
- The service UUID
.protected void pipelineAdd(UUID serviceId)
QuorumWatcher
when a service is
added to the write pipeline and updates the internal state of the
quorum to reflect that state change.serviceId
- The service UUID
.protected void pipelineRemove(UUID serviceId)
QuorumWatcher
when a service is
removed from the write pipeline and updates the internal state of the
quorum to reflect that state change.serviceId
- The service UUID
.protected void castVote(UUID serviceId, long lastCommitTime)
QuorumWatcher
when a service is
votes in an attempt to join a quorum and updates the internal state
of the quorum to reflect that state change. Each service has a single
vote to cast. If the service casts a different vote, then its old
vote must first be withdrawn. Once (k+1)/2 services vote for the same
lastCommitTime, the client will be notified with a
quorumMeet() event. Once a quorum meets on a lastCommitTime, cast
votes should be left in place (or withdrawn?). A new vote will be
required if the quorum breaks. Services seeking to join a met quorum
must first synchronize with the quorum.serviceId
- The service UUID
.lastCommitTime
- The lastCommitTime timestamp for which that service casts
its vote.IllegalArgumentException
- if the serviceId is null
.IllegalArgumentException
- if the lastCommitTime is negative.protected void withdrawVote(UUID serviceId)
QuorumWatcher
when a service has
withdrawn its vote for some lastCommitTime.
Note: If no votes remain for a given lastCommitTime, then the lastCommitTime is withdrawn from the internal pool of lastCommiTimes being considered. This ensures that we do not leak memory in that pool.
serviceId
- The service UUID
.protected void setToken(long newToken)
QuorumWatcher
when the leader
updates the (lastValidToken,token) pair atomically.newToken
- The new token.protected void clearToken()
QuorumWatcher
when the current
quorum token is invalidated.protected void serviceJoin(UUID serviceId)
QuorumWatcher
when a service joins
the quorum and updates the internal state of the quorum to reflect
that state change.serviceId
- The service UUID
.protected void serviceLeave(UUID serviceId)
QuorumWatcher
when a joined service
leaves the quorum and updates the internal state of the quorum to
reflect that state change.serviceId
- The service UUID
.Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.