use of org.apache.cassandra.exceptions.WriteFailureException 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);
}
use of org.apache.cassandra.exceptions.WriteFailureException in project cassandra by apache.
the class ErrorMessageTest method testV5WriteFailureSerDeser.
@Test
public void testV5WriteFailureSerDeser() {
int receivedBlockFor = 3;
ConsistencyLevel consistencyLevel = ConsistencyLevel.ALL;
WriteType writeType = WriteType.SIMPLE;
WriteFailureException wfe = new WriteFailureException(consistencyLevel, receivedBlockFor, receivedBlockFor, writeType, failureReasonMap2);
ErrorMessage deserialized = serializeAndGetDeserializedErrorMessage(ErrorMessage.fromException(wfe), ProtocolVersion.V5);
WriteFailureException deserializedWfe = (WriteFailureException) deserialized.error;
assertEquals(failureReasonMap2, deserializedWfe.failureReasonByEndpoint);
assertEquals(receivedBlockFor, deserializedWfe.received);
assertEquals(receivedBlockFor, deserializedWfe.blockFor);
assertEquals(consistencyLevel, deserializedWfe.consistency);
assertEquals(writeType, deserializedWfe.writeType);
}
Aggregations