Search in sources :

Example 1 with ConsistencyLevel

use of org.apache.cassandra.db.ConsistencyLevel 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);
}
Also used : ConsistencyLevel(org.apache.cassandra.db.ConsistencyLevel) ReadFailureException(org.apache.cassandra.exceptions.ReadFailureException) ErrorMessage(org.apache.cassandra.transport.messages.ErrorMessage) Test(org.junit.Test)

Example 2 with ConsistencyLevel

use of org.apache.cassandra.db.ConsistencyLevel 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);
}
Also used : ConsistencyLevel(org.apache.cassandra.db.ConsistencyLevel) WriteFailureException(org.apache.cassandra.exceptions.WriteFailureException) WriteType(org.apache.cassandra.db.WriteType) ErrorMessage(org.apache.cassandra.transport.messages.ErrorMessage) Test(org.junit.Test)

Aggregations

ConsistencyLevel (org.apache.cassandra.db.ConsistencyLevel)2 ErrorMessage (org.apache.cassandra.transport.messages.ErrorMessage)2 Test (org.junit.Test)2 WriteType (org.apache.cassandra.db.WriteType)1 ReadFailureException (org.apache.cassandra.exceptions.ReadFailureException)1 WriteFailureException (org.apache.cassandra.exceptions.WriteFailureException)1