use of org.apache.cassandra.service.StorageProxy.LocalReadRunnable in project cassandra by apache.
the class AbstractReadExecutor method makeRequests.
private void makeRequests(ReadCommand readCommand, Iterable<InetAddress> endpoints) {
boolean hasLocalEndpoint = false;
for (InetAddress endpoint : endpoints) {
if (StorageProxy.canDoLocalRequest(endpoint)) {
hasLocalEndpoint = true;
continue;
}
if (traceState != null)
traceState.trace("reading {} from {}", readCommand.isDigestQuery() ? "digest" : "data", endpoint);
logger.trace("reading {} from {}", readCommand.isDigestQuery() ? "digest" : "data", endpoint);
MessageOut<ReadCommand> message = readCommand.createMessage();
MessagingService.instance().sendRRWithFailure(message, endpoint, handler);
}
// We delay the local (potentially blocking) read till the end to avoid stalling remote requests.
if (hasLocalEndpoint) {
logger.trace("reading {} locally", readCommand.isDigestQuery() ? "digest" : "data");
StageManager.getStage(Stage.READ).maybeExecuteImmediately(new LocalReadRunnable(command, handler));
}
}
use of org.apache.cassandra.service.StorageProxy.LocalReadRunnable in project cassandra by apache.
the class AbstractReadExecutor method makeRequests.
private void makeRequests(ReadCommand readCommand, Iterable<Replica> replicas) {
boolean hasLocalEndpoint = false;
Message<ReadCommand> message = null;
for (Replica replica : replicas) {
assert replica.isFull() || readCommand.acceptsTransient();
InetAddressAndPort endpoint = replica.endpoint();
if (replica.isSelf()) {
hasLocalEndpoint = true;
continue;
}
if (traceState != null)
traceState.trace("reading {} from {}", readCommand.isDigestQuery() ? "digest" : "data", endpoint);
if (null == message)
message = readCommand.createMessage(false);
MessagingService.instance().sendWithCallback(message, endpoint, handler);
}
// We delay the local (potentially blocking) read till the end to avoid stalling remote requests.
if (hasLocalEndpoint) {
logger.trace("reading {} locally", readCommand.isDigestQuery() ? "digest" : "data");
Stage.READ.maybeExecuteImmediately(new LocalReadRunnable(readCommand, handler));
}
}
Aggregations