use of org.apache.cassandra.exceptions.ReadFailureException in project cassandra by apache.
the class ReadCallback method awaitResults.
public void awaitResults() throws ReadFailureException, ReadTimeoutException {
boolean signaled = await(command.getTimeout(), TimeUnit.MILLISECONDS);
boolean failed = blockfor + failures > endpoints.size();
if (signaled && !failed)
return;
if (Tracing.isTracing()) {
String gotData = received > 0 ? (resolver.isDataPresent() ? " (including data)" : " (only digests)") : "";
Tracing.trace("{}; received {} of {} responses{}", new Object[] { (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{}", new Object[] { (failed ? "Failed" : "Timed out"), received, blockfor, gotData });
}
// Same as for writes, see AbstractWriteResponseHandler
throw failed ? new ReadFailureException(consistencyLevel, received, blockfor, resolver.isDataPresent(), failureReasonByEndpoint) : new ReadTimeoutException(consistencyLevel, received, blockfor, resolver.isDataPresent());
}
use of org.apache.cassandra.exceptions.ReadFailureException in project cassandra by apache.
the class ErrorMessageTest method testV5ReadFailureSerDeser.
@Test
public void testV5ReadFailureSerDeser() {
int receivedBlockFor = 3;
ConsistencyLevel consistencyLevel = ConsistencyLevel.ALL;
boolean dataPresent = false;
ReadFailureException rfe = new ReadFailureException(consistencyLevel, receivedBlockFor, receivedBlockFor, dataPresent, failureReasonMap1);
ErrorMessage deserialized = serializeAndGetDeserializedErrorMessage(ErrorMessage.fromException(rfe), ProtocolVersion.V5);
ReadFailureException deserializedRfe = (ReadFailureException) deserialized.error;
assertEquals(failureReasonMap1, deserializedRfe.failureReasonByEndpoint);
assertEquals(receivedBlockFor, deserializedRfe.received);
assertEquals(receivedBlockFor, deserializedRfe.blockFor);
assertEquals(consistencyLevel, deserializedRfe.consistency);
assertEquals(dataPresent, deserializedRfe.dataPresent);
}
use of org.apache.cassandra.exceptions.ReadFailureException in project cassandra by apache.
the class ErrorMessageTest method testRequestFailureExceptionMakesCopy.
/**
* Make sure that the map passed in to create a Read/WriteFailureException is copied
* so later modifications to the map passed in don't affect the map in the exception.
*
* This is to prevent potential issues in serialization if the map created in
* ReadCallback/AbstractWriteResponseHandler is modified due to a delayed failure
* response after the exception is created.
*/
@Test
public void testRequestFailureExceptionMakesCopy() throws UnknownHostException {
Map<InetAddress, RequestFailureReason> modifiableFailureReasons = new HashMap<>(failureReasonMap1);
ReadFailureException rfe = new ReadFailureException(ConsistencyLevel.ALL, 3, 3, false, modifiableFailureReasons);
WriteFailureException wfe = new WriteFailureException(ConsistencyLevel.ALL, 3, 3, WriteType.SIMPLE, modifiableFailureReasons);
modifiableFailureReasons.put(InetAddress.getByName("127.0.0.4"), RequestFailureReason.UNKNOWN);
assertEquals(failureReasonMap1, rfe.failureReasonByEndpoint);
assertEquals(failureReasonMap1, wfe.failureReasonByEndpoint);
}
Aggregations