Class PaxosPrepare
java.lang.Object
org.apache.cassandra.service.FailureRecordingCallback<T>
org.apache.cassandra.service.paxos.PaxosRequestCallback<org.apache.cassandra.service.paxos.PaxosPrepare.Response>
org.apache.cassandra.service.paxos.PaxosPrepare
- All Implemented Interfaces:
RequestCallback<org.apache.cassandra.service.paxos.PaxosPrepare.Response>,RequestCallbackWithFailure<org.apache.cassandra.service.paxos.PaxosPrepare.Response>,Paxos.Async<org.apache.cassandra.service.paxos.PaxosPrepare.Status>
public class PaxosPrepare
extends PaxosRequestCallback<org.apache.cassandra.service.paxos.PaxosPrepare.Response>
implements Paxos.Async<org.apache.cassandra.service.paxos.PaxosPrepare.Status>
Perform one paxos "prepare" attempt, with various optimisations.
The prepare step entails asking for a quorum of nodes to promise to accept our later proposal. It can
yield one of five logical answers:
1) Success - we have received a quorum of promises, and we know that a quorum of nodes
witnessed the prior round's commit (if any)
2) Timeout - we have not received enough responses at all before our deadline passed
3) Failure - we have received too many explicit failures to succeed
4) Superseded - we have been informed of a later ballot that has been promised
5) FoundInProgress - we have been informed of an earlier promise that has been accepted
Success hinges on two distinct criteria being met, as the quorum of promises may not guarantee a quorum of
witnesses of the prior round's commit. We track this separately by recording those nodes that have witnessed
the prior round's commit. On receiving a quorum of promises, we submit the prior round's commit to any promisers
that had not witnessed it, while continuing to wait for responses to our original request: as soon as we hear of
a quorum that have witnessed it, either by our refresh request or by responses to the original request, we yield Success.
Success is also accompanied by a quorum of read responses, avoiding another round-trip to obtain this result.
This operation may be started either with a solo Prepare command, or with a prefixed Commit command.
If we are completing an in-progress round we previously discovered, we save another round-trip by committing and
preparing simultaneously.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classstatic classNested classes/interfaces inherited from class org.apache.cassandra.service.FailureRecordingCallback
FailureRecordingCallback.AsMap, FailureRecordingCallback.FailureResponses -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final PaxosPrepare.RequestHandlerstatic final PaxosPrepare.RequestSerializerstatic final PaxosPrepare.ResponseSerializer -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.cassandra.service.paxos.PaxosPrepare.StatusawaitUntil(long deadline) voidonFailure(InetAddressAndPort from, RequestFailureReason reason) Called when there is an exception on the remote node or timeout happensvoidonRefreshFailure(InetAddressAndPort from, RequestFailureReason reason) voidonRefreshSuccess(Ballot isSupersededBy, InetAddressAndPort from) voidonResponse(org.apache.cassandra.service.paxos.PaxosPrepare.Response response, InetAddressAndPort from) static voidsetOnLinearizabilityViolation(Runnable runnable) Methods inherited from class org.apache.cassandra.service.paxos.PaxosRequestCallback
executeOnSelf, onResponseMethods inherited from class org.apache.cassandra.service.FailureRecordingCallback
failureReasonsAsMap, onFailureWithMutexMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.cassandra.net.RequestCallback
trackLatencyForSnitchMethods inherited from interface org.apache.cassandra.net.RequestCallbackWithFailure
invokeOnFailure
-
Field Details
-
requestHandler
-
requestSerializer
-
responseSerializer
-
-
Method Details
-
awaitUntil
public org.apache.cassandra.service.paxos.PaxosPrepare.Status awaitUntil(long deadline) - Specified by:
awaitUntilin interfacePaxos.Async<org.apache.cassandra.service.paxos.PaxosPrepare.Status>
-
onResponse
public void onResponse(org.apache.cassandra.service.paxos.PaxosPrepare.Response response, InetAddressAndPort from) - Specified by:
onResponsein classPaxosRequestCallback<org.apache.cassandra.service.paxos.PaxosPrepare.Response>
-
onFailure
Description copied from interface:RequestCallbackWithFailureCalled when there is an exception on the remote node or timeout happens- Specified by:
onFailurein interfaceRequestCallback<org.apache.cassandra.service.paxos.PaxosPrepare.Response>- Specified by:
onFailurein interfaceRequestCallbackWithFailure<org.apache.cassandra.service.paxos.PaxosPrepare.Response>- Overrides:
onFailurein classFailureRecordingCallback<org.apache.cassandra.service.paxos.PaxosPrepare.Response>
-
onRefreshFailure
-
onRefreshSuccess
-
setOnLinearizabilityViolation
-