use of io.aeron.archive.client.ArchiveException in project aeron by real-logic.
the class ArchiveTest method shouldErrorOnLowSpace.
@Test
@InterruptAfter(10)
public void shouldErrorOnLowSpace() throws IOException {
final int streamId = 7;
final String channel = "aeron:ipc";
final long usableSpace = 100;
final long threshold = 101;
final FileStore fileStore = mock(FileStore.class);
when(fileStore.getUsableSpace()).thenReturn(usableSpace);
final MediaDriver.Context driverCtx = new MediaDriver.Context().dirDeleteOnStart(true).threadingMode(ThreadingMode.SHARED);
final Archive.Context archiveCtx = new Archive.Context().archiveFileStore(fileStore).lowStorageSpaceThreshold(threshold).deleteArchiveOnStart(true).threadingMode(SHARED);
try (ArchivingMediaDriver ignore = ArchivingMediaDriver.launch(driverCtx, archiveCtx);
AeronArchive archive = AeronArchive.connect()) {
try {
archive.startRecording(channel, streamId, LOCAL);
} catch (final ArchiveException ex) {
assertEquals(ArchiveException.STORAGE_SPACE, ex.errorCode());
return;
}
fail("Expected exception");
} finally {
archiveCtx.deleteDirectory();
driverCtx.deleteDirectory();
}
}
use of io.aeron.archive.client.ArchiveException in project aeron by real-logic.
the class CatalogTest method shouldThrowArchiveExceptionIfNextRecordingIdIsInvalidWriteableCatalog.
@Test
void shouldThrowArchiveExceptionIfNextRecordingIdIsInvalidWriteableCatalog() throws IOException {
setNextRecordingId(-1);
final ArchiveException exception = assertThrows(ArchiveException.class, () -> new Catalog(archiveDir, clock, MIN_CAPACITY, true, null, null));
assertEquals("ERROR - invalid nextRecordingId: expected value greater or equal to " + (recordingThreeId + 1) + ", was -1", exception.getMessage());
}
use of io.aeron.archive.client.ArchiveException in project aeron by real-logic.
the class ReplaySessionTest method shouldThrowArchiveExceptionIfCrcFails.
@Test
public void shouldThrowArchiveExceptionIfCrcFails() {
final long length = 4 * FRAME_LENGTH;
final long correlationId = 1L;
final Checksum checksum = crc32();
try (ReplaySession replaySession = replaySession(RECORDING_POSITION + 2 * FRAME_LENGTH, length, correlationId, mockReplayPub, mockControlSession, null, checksum)) {
when(mockReplayPub.isClosed()).thenReturn(false);
when(mockReplayPub.isConnected()).thenReturn(false);
replaySession.doWork();
assertEquals(ReplaySession.State.INIT, replaySession.state());
when(mockReplayPub.isConnected()).thenReturn(true);
final ArchiveException exception = assertThrows(ArchiveException.class, replaySession::doWork);
assertEquals(ArchiveException.GENERIC, exception.errorCode());
assertThat(exception.getMessage(), Matchers.startsWith("ERROR - CRC checksum mismatch at offset=0"));
verify(mockReplayPub, never()).tryClaim(anyInt(), any(BufferClaim.class));
}
}
use of io.aeron.archive.client.ArchiveException in project aeron by real-logic.
the class CatalogTest method growCatalogThrowsArchiveExceptionIfCatalogIsFull.
@Test
void growCatalogThrowsArchiveExceptionIfCatalogIsFull() {
try (Catalog catalog = new Catalog(archiveDir, null, 0, CAPACITY, clock, null, segmentFileBuffer)) {
final ArchiveException exception = assertThrows(ArchiveException.class, () -> catalog.growCatalog(CAPACITY, (int) (CAPACITY + 1)));
assertEquals("ERROR - catalog is full, max capacity reached: " + CAPACITY, exception.getMessage());
}
}
use of io.aeron.archive.client.ArchiveException in project aeron by real-logic.
the class ReplaySession method notHeaderAligned.
static boolean notHeaderAligned(final FileChannel channel, final UnsafeBuffer buffer, final int segmentOffset, final int termOffset, final int termId, final int streamId) throws IOException {
final ByteBuffer byteBuffer = buffer.byteBuffer();
byteBuffer.clear().limit(HEADER_LENGTH);
if (HEADER_LENGTH != channel.read(byteBuffer, segmentOffset)) {
throw new ArchiveException("failed to read fragment header");
}
return isInvalidHeader(buffer, streamId, termId, termOffset);
}
Aggregations