Search in sources :

Example 11 with ClusterException

use of io.aeron.cluster.client.ClusterException in project aeron by real-logic.

the class ConsensusModuleContextTest method unknownTimerServiceSupplier.

@Test
void unknownTimerServiceSupplier() {
    final String supplierName = "unknown timer service supplier";
    System.setProperty(TIMER_SERVICE_SUPPLIER_PROP_NAME, supplierName);
    try {
        final ClusterException exception = assertThrows(ClusterException.class, context::conclude);
        assertEquals("ERROR - invalid TimerServiceSupplier: " + supplierName, exception.getMessage());
    } finally {
        System.clearProperty(TIMER_SERVICE_SUPPLIER_PROP_NAME);
    }
}
Also used : ClusterException(io.aeron.cluster.client.ClusterException) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 12 with ClusterException

use of io.aeron.cluster.client.ClusterException in project aeron by real-logic.

the class RecordingLogTest method shouldNotAllowInvalidateOfSnapshotWithoutParentTerm.

@Test
void shouldNotAllowInvalidateOfSnapshotWithoutParentTerm() {
    try (RecordingLog recordingLog = new RecordingLog(tempDir, true)) {
        recordingLog.appendSnapshot(-10, 1L, 0, 777L, 0, 0);
        recordingLog.appendSnapshot(-11, 1L, 0, 777L, 0, SERVICE_ID);
        final ClusterException ex = assertThrows(ClusterException.class, recordingLog::invalidateLatestSnapshot);
        assertEquals("ERROR - no matching term for snapshot: leadershipTermId=1", ex.getMessage());
    }
}
Also used : ClusterException(io.aeron.cluster.client.ClusterException) Test(org.junit.jupiter.api.Test)

Example 13 with ClusterException

use of io.aeron.cluster.client.ClusterException in project aeron by real-logic.

the class RecordingLogTest method appendTermShouldRejectNullValueAsRecordingId.

@Test
void appendTermShouldRejectNullValueAsRecordingId() {
    try (RecordingLog recordingLog = new RecordingLog(tempDir, true)) {
        final ClusterException exception = assertThrows(ClusterException.class, () -> recordingLog.appendTerm(NULL_VALUE, 0, 0, 0));
        assertEquals("ERROR - invalid recordingId=-1", exception.getMessage());
        assertEquals(0, recordingLog.entries().size());
    }
}
Also used : ClusterException(io.aeron.cluster.client.ClusterException) Test(org.junit.jupiter.api.Test)

Example 14 with ClusterException

use of io.aeron.cluster.client.ClusterException in project aeron by real-logic.

the class RecordingLogTest method appendTermShouldNotAcceptDifferentRecordingIds.

@Test
void appendTermShouldNotAcceptDifferentRecordingIds() {
    try (RecordingLog recordingLog = new RecordingLog(tempDir, true)) {
        recordingLog.appendTerm(42, 0, 0, 0);
        final ClusterException exception = assertThrows(ClusterException.class, () -> recordingLog.appendTerm(21, 1, 0, 0));
        assertEquals("ERROR - invalid TERM recordingId=21, expected recordingId=42", exception.getMessage());
        assertEquals(1, recordingLog.entries().size());
    }
    try (RecordingLog recordingLog = new RecordingLog(tempDir, true)) {
        final ClusterException exception = assertThrows(ClusterException.class, () -> recordingLog.appendTerm(-5, -5, -5, -5));
        assertEquals("ERROR - invalid TERM recordingId=-5, expected recordingId=42", exception.getMessage());
        assertEquals(1, recordingLog.entries().size());
    }
}
Also used : ClusterException(io.aeron.cluster.client.ClusterException) Test(org.junit.jupiter.api.Test)

Example 15 with ClusterException

use of io.aeron.cluster.client.ClusterException in project aeron by real-logic.

the class RecordingLogTest method appendSnapshotShouldRejectNullValueAsRecordingId.

@Test
void appendSnapshotShouldRejectNullValueAsRecordingId() {
    try (RecordingLog recordingLog = new RecordingLog(tempDir, true)) {
        final ClusterException exception = assertThrows(ClusterException.class, () -> recordingLog.appendSnapshot(NULL_VALUE, 0, 0, 0, 0, 0));
        assertEquals("ERROR - invalid recordingId=-1", exception.getMessage());
        assertEquals(0, recordingLog.entries().size());
    }
}
Also used : ClusterException(io.aeron.cluster.client.ClusterException) Test(org.junit.jupiter.api.Test)

Aggregations

ClusterException (io.aeron.cluster.client.ClusterException)34 Test (org.junit.jupiter.api.Test)12 AgentTerminationException (org.agrona.concurrent.AgentTerminationException)6 CountersReader (org.agrona.concurrent.status.CountersReader)4 AeronException (io.aeron.exceptions.AeronException)2 IOException (java.io.IOException)2 UncheckedIOException (java.io.UncheckedIOException)2 ByteBuffer (java.nio.ByteBuffer)2 MappedByteBuffer (java.nio.MappedByteBuffer)2 FileChannel (java.nio.channels.FileChannel)2 Path (java.nio.file.Path)2 TimeUnit (java.util.concurrent.TimeUnit)2 UnsafeBuffer (org.agrona.concurrent.UnsafeBuffer)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2