public class QuorumCommitImpl<S extends HACommitGlue> extends QuorumStateChangeListenerBase implements QuorumCommit<S>, QuorumStateChangeListener, ServiceLookup<HACommitGlue>
QuorumCommit
implementation.Constructor and Description |
---|
QuorumCommitImpl(QuorumMember<S> member) |
Modifier and Type | Method and Description |
---|---|
void |
abort2Phase(long token)
Used by the leader to send a message to each service joined with the
quorum telling it to discard its write set, reloading all state from the
last root block.
|
CommitResponse |
commit2Phase(CommitRequest commitRequest)
Used by the leader to send a message to each joined service in the quorum
telling it to commit using the root block from the corresponding
prepare message. |
HACommitGlue |
getService(UUID serviceId)
Return the remote interface used to perform HA operations on a member of
quorum.
|
PrepareResponse |
prepare2Phase(PrepareRequest req)
Used by the leader to send a message to each joined service in the quorum
instructing it to flush all writes to the backing channel, and
acknowledge "yes" if ready to commit.
|
consensus, lostConsensus, memberAdd, memberRemove, pipelineAdd, pipelineChange, pipelineElectedLeader, pipelineRemove, pipelineUpstreamChange, quorumBreak, quorumMeet, serviceJoin, serviceLeave
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
consensus, lostConsensus, memberAdd, memberRemove, pipelineAdd, pipelineChange, pipelineElectedLeader, pipelineRemove, pipelineUpstreamChange, quorumBreak, quorumMeet, serviceJoin, serviceLeave
public QuorumCommitImpl(QuorumMember<S> member)
public HACommitGlue getService(UUID serviceId)
ServiceLookup
getService
in interface ServiceLookup<HACommitGlue>
serviceId
- The UUID
associated with the service.public PrepareResponse prepare2Phase(PrepareRequest req) throws InterruptedException, IOException
commit
message.
This implementation runs the operation on the leader in the caller's thread to avoid deadlock. The other services run the operation asynchronously on their side while the leader awaits their future's using get().
Note: The IHA2PhasePrepareMessage
is sent to all services in
write pipeline. This ensures that services that are not yet joined with
the met quorum will still observe the root blocks. This is necessary in
order for them to catch up with the met quorum. The 2-phase commit
protocol is "aware" that not all messages are being sent to services
whose votes count. Only services that are actually in the met quorum get
a vote.
Note: This method is responsible for the atomic decision regarding
whether a service will be considered to be "joined" with the met quorum
for the 2-phase commit. A service that is synchronizing will either have
already voted the appropriate lastCommitTime and entered the met quorum
or it will not. That decision point is captured atomically when we obtain
a snapshot of the joined services from the quorum state. The decision is
propagated through the IHA2PhasePrepareMessage
and that
information is retained by the service together with the new root block
from the prepare message. This metadata is used to decide how the service
will handle the prepare, commit, and abort messages.
prepare2Phase
in interface QuorumCommit<S extends HACommitGlue>
InterruptedException
IOException
public CommitResponse commit2Phase(CommitRequest commitRequest) throws IOException, InterruptedException
QuorumCommit
prepare
message. The commit MAY
NOT go forward unless both the current quorum token and the
lastCommitTime on this message agree with the quorum token and
lastCommitTime in the root block from the last "prepare" message.commit2Phase
in interface QuorumCommit<S extends HACommitGlue>
IOException
InterruptedException
public void abort2Phase(long token) throws IOException, InterruptedException
abort2Phase
in interface QuorumCommit<S extends HACommitGlue>
token
- The quorum token.IOException
InterruptedException
Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.