Class ReadCallback<E extends Endpoints<E>,P extends ReplicaPlan.ForRead<E,P>>
- java.lang.Object
-
- org.apache.cassandra.service.reads.ReadCallback<E,P>
-
- All Implemented Interfaces:
RequestCallback<ReadResponse>
public class ReadCallback<E extends Endpoints<E>,P extends ReplicaPlan.ForRead<E,P>> extends java.lang.Object implements RequestCallback<ReadResponse>
-
-
Field Summary
Fields Modifier and Type Field Description protected static org.slf4j.LoggerloggerResponseResolver<E,P>resolver
-
Constructor Summary
Constructors Constructor Description ReadCallback(ResponseResolver<E,P> resolver, ReadCommand command, ReplicaPlan.Shared<E,P> replicaPlan, Dispatcher.RequestTime requestTime)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanawait(long commandTimeout, java.util.concurrent.TimeUnit unit)voidawaitResults()booleanawaitUntil(long deadline)In case of speculation, we want to time out the request immediately if we have _also_ hit a deadline.intblockFor()booleaninvokeOnFailure()Returns 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.voidonFailure(InetAddressAndPort from, RequestFailureReason failureReason)Called when there is an exception on the remote node or timeout happensvoidonResponse(Message<ReadResponse> message)protected PreplicaPlan()voidresponse(ReadResponse result)booleantrackLatencyForSnitch()
-
-
-
Field Detail
-
logger
protected static final org.slf4j.Logger logger
-
resolver
public final ResponseResolver<E extends Endpoints<E>,P extends ReplicaPlan.ForRead<E,P>> resolver
-
-
Constructor Detail
-
ReadCallback
public ReadCallback(ResponseResolver<E,P> resolver, ReadCommand command, ReplicaPlan.Shared<E,P> replicaPlan, Dispatcher.RequestTime requestTime)
-
-
Method Detail
-
replicaPlan
protected P replicaPlan()
-
await
public boolean await(long commandTimeout, java.util.concurrent.TimeUnit unit)
-
awaitUntil
public boolean awaitUntil(long deadline)
In case of speculation, we want to time out the request immediately if we have _also_ hit a deadline. For example, we have a read timeout of 10s, 99% latency of 5 seconds, and time base is QUEUE: * Request has spent 3 seconds in the queue. Here, we will wait for 2 seconds and try to speculate * Request has spent 10 seconds in the queue. Here, we will wait for 0 seconds and try to speculate If the time base is REQUEST: * Request has spent 10 seconds in the queue. Here, we will only wait 2 seconds and then try to speculate We should _not_ speculate in all these cases, since by that time we are already past request deadline.
-
awaitResults
public void awaitResults() throws ReadFailureException, ReadTimeoutException
-
blockFor
public int blockFor()
-
onResponse
public void onResponse(Message<ReadResponse> message)
- Specified by:
onResponsein interfaceRequestCallback<E extends Endpoints<E>>- Parameters:
message- response received.
-
response
public void response(ReadResponse result)
-
trackLatencyForSnitch
public boolean trackLatencyForSnitch()
- Specified by:
trackLatencyForSnitchin interfaceRequestCallback<E extends Endpoints<E>>- Returns:
- true if this callback is on the read path and its latency should be given as input to the dynamic snitch.
-
onFailure
public void onFailure(InetAddressAndPort from, RequestFailureReason failureReason)
Description copied from interface:RequestCallbackCalled when there is an exception on the remote node or timeout happens- Specified by:
onFailurein interfaceRequestCallback<E extends Endpoints<E>>
-
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<E extends Endpoints<E>>- Returns:
- true if the callback should be invoked on failure
-
-