use of org.apache.cassandra.service.reads.trackwarnings.WarningContext in project cassandra by apache.
the class ReadCallback method getWarningContext.
private WarningContext getWarningContext() {
WarningContext current;
do {
current = warningContext;
if (current != null)
return current;
current = new WarningContext();
} while (!warningsUpdater.compareAndSet(this, null, current));
return current;
}
use of org.apache.cassandra.service.reads.trackwarnings.WarningContext in project cassandra by apache.
the class ReadCallback method awaitResults.
public void awaitResults() throws ReadFailureException, ReadTimeoutException {
boolean signaled = await(command.getTimeout(MILLISECONDS), TimeUnit.MILLISECONDS);
/**
* Here we are checking isDataPresent in addition to the responses size because there is a possibility
* that an asynchronous speculative execution request could be returning after a local failure already
* signaled. Responses may have been set while the data reference is not yet.
* See {@link DigestResolver#preprocess(Message)}
* CASSANDRA-16097
*/
int received = resolver.responses.size();
boolean failed = failures > 0 && (blockFor > received || !resolver.isDataPresent());
WarningContext warnings = warningContext;
// save the snapshot so abort state is not changed between now and when mayAbort gets called
WarningsSnapshot snapshot = null;
if (warnings != null) {
snapshot = warnings.snapshot();
// this is likely to happen when a timeout happens or from a speculative response
if (!snapshot.isEmpty())
CoordinatorWarnings.update(command, snapshot);
}
if (signaled && !failed)
return;
if (isTracing()) {
String gotData = received > 0 ? (resolver.isDataPresent() ? " (including data)" : " (only digests)") : "";
Tracing.trace("{}; received {} of {} responses{}", failed ? "Failed" : "Timed out", received, blockFor, gotData);
} else if (logger.isDebugEnabled()) {
String gotData = received > 0 ? (resolver.isDataPresent() ? " (including data)" : " (only digests)") : "";
logger.debug("{}; received {} of {} responses{}", failed ? "Failed" : "Timed out", received, blockFor, gotData);
}
if (snapshot != null)
snapshot.maybeAbort(command, replicaPlan().consistencyLevel(), received, blockFor, resolver.isDataPresent(), failureReasonByEndpoint);
// Same as for writes, see AbstractWriteResponseHandler
throw failed ? new ReadFailureException(replicaPlan().consistencyLevel(), received, blockFor, resolver.isDataPresent(), failureReasonByEndpoint) : new ReadTimeoutException(replicaPlan().consistencyLevel(), received, blockFor, resolver.isDataPresent());
}
Aggregations