org.apache.cassandra.service
Class ReadCallback<TMessage,TResolved>
java.lang.Object
org.apache.cassandra.service.ReadCallback<TMessage,TResolved>
- All Implemented Interfaces:
- IAsyncCallback<TMessage>, IMessageCallback
- Direct Known Subclasses:
- DatacenterReadCallback
public class ReadCallback<TMessage,TResolved>
- extends java.lang.Object
- implements IAsyncCallback<TMessage>
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
logger
protected static final org.slf4j.Logger logger
snitch
protected static final IEndpointSnitch snitch
localdc
protected static final java.lang.String localdc
resolver
public final IResponseResolver<TMessage,TResolved> resolver
condition
protected final SimpleCondition condition
blockfor
protected final int blockfor
consistencyLevel
protected final ConsistencyLevel consistencyLevel
received
protected final java.util.concurrent.atomic.AtomicInteger received
ReadCallback
public ReadCallback(IResponseResolver<TMessage,TResolved> resolver,
ConsistencyLevel consistencyLevel,
IReadCommand command,
java.util.List<java.net.InetAddress> endpoints)
- Constructor when response count has to be calculated and blocked for.
sortForConsistencyLevel
protected void sortForConsistencyLevel(java.util.List<java.net.InetAddress> endpoints)
- Endpoints is already restricted to live replicas, sorted by snitch preference. This is a hook for
DatacenterReadCallback to move local-DC replicas to the front of the list. We need this both
when doing read repair (because the first replica gets the data read) and otherwise (because
only the first 1..blockfor replicas will get digest reads).
get
public TResolved get()
throws ReadTimeoutException,
DigestMismatchException,
java.io.IOException
- Throws:
ReadTimeoutException
DigestMismatchException
java.io.IOException
response
public void response(MessageIn<TMessage> message)
- Specified by:
response
in interface IAsyncCallback<TMessage>
- Parameters:
message
- response received.
waitingFor
protected boolean waitingFor(MessageIn message)
- Returns:
- true if the message counts towards the blockfor threshold
response
public void response(TMessage result)
maybeResolveForRepair
protected void maybeResolveForRepair()
- Check digests in the background on the Repair stage if we've received replies
too all the requests we sent.
assureSufficientLiveNodes
public void assureSufficientLiveNodes()
throws UnavailableException
- Throws:
UnavailableException
isLatencyForSnitch
public boolean isLatencyForSnitch()
- Specified by:
isLatencyForSnitch
in interface IMessageCallback
- Returns:
- true if this callback is on the read path and its latency should be
given as input to the dynamic snitch.
Copyright © 2012 The Apache Software Foundation