Package org.apache.cassandra.service
Class AbstractWriteResponseHandler<T>
java.lang.Object
org.apache.cassandra.service.AbstractWriteResponseHandler<T>
- All Implemented Interfaces:
RequestCallback<T>
- Direct Known Subclasses:
BatchlogResponseHandler,DatacenterSyncWriteResponseHandler,WriteResponseHandler
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Runnableprotected static final org.slf4j.Loggerprotected final ReplicaPlan.ForWriteprotected final WriteType -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractWriteResponseHandler(ReplicaPlan.ForWrite replicaPlan, Runnable callback, WriteType writeType, Supplier<Mutation> hintOnFailure, Dispatcher.RequestTime requestTime) -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract intackCount()protected intblockFor()protected intTODO: this method is brittle for its purpose of deciding when we should fail a query; this needs to be aware of which nodes are live/downfinal longfinal voidexpired()voidget()booleanReturns true if the callback handles failure reporting - in which case the remove host will be asked to report failures to us in the event of a problem processing the request.protected final voidprotected final voidThis logs the response but doesn't do any further processing related to this write response handler on whether the CL was achieved.voidmaybeTryAdditionalReplicas(IMutation mutation, StorageProxy.WritePerformer writePerformer, String localDC) Cheap Quorum backup.voidonFailure(InetAddressAndPort from, RequestFailureReason failureReason) Called when there is an exception on the remote node or timeout happensabstract voidonResponse(Message<T> msg) null message means "response from local write"voidSet a delegate ideal CL write response handler.protected voidsignal()protected booleanwaitingFor(InetAddressAndPort from) Methods 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
trackLatencyForSnitch
-
Field Details
-
logger
protected static final org.slf4j.Logger logger -
replicaPlan
-
callback
-
writeType
-
-
Constructor Details
-
AbstractWriteResponseHandler
protected AbstractWriteResponseHandler(ReplicaPlan.ForWrite replicaPlan, Runnable callback, WriteType writeType, Supplier<Mutation> hintOnFailure, Dispatcher.RequestTime requestTime) - Parameters:
callback- A callback to be called when the write is successful.hintOnFailure-requestTime-
-
-
Method Details
-
get
-
currentTimeoutNanos
public final long currentTimeoutNanos() -
setIdealCLResponseHandler
Set a delegate ideal CL write response handler. Note that this could be the same as this if the ideal CL and requested CL are the same. -
logResponseToIdealCLDelegate
This logs the response but doesn't do any further processing related to this write response handler on whether the CL was achieved. Only call this after the subclass has completed all it's processing since the subclass instance may be queried to find out if the CL was achieved. -
logFailureOrTimeoutToIdealCLDelegate
protected final void logFailureOrTimeoutToIdealCLDelegate() -
expired
public final void expired() -
blockFor
protected int blockFor()- Returns:
- the minimum number of endpoints that must respond.
-
candidateReplicaCount
protected int candidateReplicaCount()TODO: this method is brittle for its purpose of deciding when we should fail a query; this needs to be aware of which nodes are live/down- Returns:
- the total number of endpoints the request can send to.
-
consistencyLevel
-
waitingFor
- Returns:
- true if the message counts towards the blockFor() threshold
-
ackCount
protected abstract int ackCount()- Returns:
- number of responses received
-
getRequestTime
-
onResponse
null message means "response from local write"- Specified by:
onResponsein interfaceRequestCallback<T>- Parameters:
msg- response received.
-
signal
protected void signal() -
onFailure
Description copied from interface:RequestCallbackCalled when there is an exception on the remote node or timeout happens- Specified by:
onFailurein interfaceRequestCallback<T>
-
invokeOnFailure
public boolean invokeOnFailure()Description copied from interface:RequestCallbackReturns true if the callback handles failure reporting - in which case the remove host will be asked to report failures to us in the event of a problem processing the request. TODO: this is an error prone method, and we should be handling failures everywhere so we should probably just start doing that, and remove this method- Specified by:
invokeOnFailurein interfaceRequestCallback<T>- Returns:
- true if the callback should be invoked on failure
-
maybeTryAdditionalReplicas
public void maybeTryAdditionalReplicas(IMutation mutation, StorageProxy.WritePerformer writePerformer, String localDC) Cheap Quorum backup. If we failed to reach quorum with our initial (full) nodes, reach out to other nodes.
-