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 Classes Modifier and Type Class Description static classPaxosPrepare.RequestHandlerstatic classPaxosPrepare.RequestSerializerstatic classPaxosPrepare.ResponseSerializer-
Nested classes/interfaces inherited from class org.apache.cassandra.service.FailureRecordingCallback
FailureRecordingCallback.AsMap, FailureRecordingCallback.FailureResponses
-
-
Field Summary
Fields Modifier and Type Field Description static PaxosPrepare.RequestHandlerrequestHandlerstatic PaxosPrepare.RequestSerializerrequestSerializerstatic PaxosPrepare.ResponseSerializerresponseSerializer
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description org.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(java.lang.Runnable runnable)-
Methods inherited from class org.apache.cassandra.service.paxos.PaxosRequestCallback
executeOnSelf, onResponse
-
Methods inherited from class org.apache.cassandra.service.FailureRecordingCallback
failureReasonsAsMap, onFailureWithMutex
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.cassandra.net.RequestCallback
trackLatencyForSnitch
-
Methods inherited from interface org.apache.cassandra.net.RequestCallbackWithFailure
invokeOnFailure
-
-
-
-
Field Detail
-
requestHandler
public static final PaxosPrepare.RequestHandler requestHandler
-
requestSerializer
public static final PaxosPrepare.RequestSerializer requestSerializer
-
responseSerializer
public static final PaxosPrepare.ResponseSerializer responseSerializer
-
-
Method Detail
-
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
public void onFailure(InetAddressAndPort from, RequestFailureReason reason)
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
public void onRefreshFailure(InetAddressAndPort from, RequestFailureReason reason)
-
onRefreshSuccess
public void onRefreshSuccess(Ballot isSupersededBy, InetAddressAndPort from)
-
setOnLinearizabilityViolation
public static void setOnLinearizabilityViolation(java.lang.Runnable runnable)
-
-