use of io.aeron.archive.client.ArchiveException in project aeron by real-logic.
the class CatalogTest method shouldThrowArchiveExceptionIfNextRecordingIdIsSmallerThanTheActualLastRecordInTheCatalog.
@Test
void shouldThrowArchiveExceptionIfNextRecordingIdIsSmallerThanTheActualLastRecordInTheCatalog() throws IOException {
setNextRecordingId(recordingTwoId);
final ArchiveException exception = assertThrows(ArchiveException.class, () -> new Catalog(archiveDir, null, 0, CAPACITY, clock, null, segmentFileBuffer));
assertEquals("ERROR - invalid nextRecordingId: expected value greater or equal to " + (recordingThreeId + 1) + ", was " + recordingTwoId, exception.getMessage());
}
use of io.aeron.archive.client.ArchiveException in project aeron by real-logic.
the class CatalogTest method growCatalogThrowsArchiveExceptionIfRecordingIsTooBig.
@Test
void growCatalogThrowsArchiveExceptionIfRecordingIsTooBig() {
try (Catalog catalog = new Catalog(archiveDir, null, 0, CAPACITY, clock, null, segmentFileBuffer)) {
final ArchiveException exception = assertThrows(ArchiveException.class, () -> catalog.growCatalog(CAPACITY * 2, Integer.MAX_VALUE));
assertEquals("ERROR - recording is too big: total recording length is " + Integer.MAX_VALUE + " bytes, available space is " + (CAPACITY * 2 - 800) + " bytes", exception.getMessage());
}
}
use of io.aeron.archive.client.ArchiveException in project aeron by real-logic.
the class RecordingWriterTest method onBlockThrowsArchiveExceptionIfCurrentThreadWasInterrupted.
@Test
void onBlockThrowsArchiveExceptionIfCurrentThreadWasInterrupted() throws IOException {
final Image image = mockImage(0L);
final RecordingWriter recordingWriter = new RecordingWriter(1, 0, SEGMENT_LENGTH, image, new Context().archiveDir(archiveDir));
recordingWriter.init();
assertFalse(Thread.interrupted());
try {
Thread.currentThread().interrupt();
final ArchiveException exception = assertThrows(ArchiveException.class, () -> recordingWriter.onBlock(new UnsafeBuffer(allocate(32)), 0, 10, 5, 8));
assertEquals(GENERIC, exception.errorCode());
assertEquals("ERROR - file closed by interrupt, recording aborted", exception.getMessage());
} finally {
assertTrue(Thread.interrupted());
}
}
use of io.aeron.archive.client.ArchiveException in project aeron by real-logic.
the class Catalog method buildIndex.
private void buildIndex(final boolean writable) {
int offset = firstRecordingDescriptorOffset;
long recordingId = -1;
while (offset < capacity) {
final int frameLength = wrapDescriptorAtOffset(catalogBuffer, offset);
if (frameLength < 0) {
break;
}
recordingId = recordingId(catalogBuffer);
if (isValidDescriptor(catalogBuffer)) {
catalogIndex.add(recordingId, offset);
}
offset += frameLength;
}
nextRecordingDescriptorOffset = offset;
if (0 == nextRecordingId) {
nextRecordingId = recordingId + 1;
} else if (writable && nextRecordingId < recordingId + 1) {
throw new ArchiveException("invalid nextRecordingId: expected value greater or equal to " + (recordingId + 1) + ", was " + nextRecordingId);
}
}
use of io.aeron.archive.client.ArchiveException in project aeron by real-logic.
the class RecordingWriter method checkErrorType.
private void checkErrorType(final IOException ex, final int writeLength) {
final String msg = ex.getMessage();
boolean isLowStorageSpace = false;
IOException suppressed = null;
try {
isLowStorageSpace = (!Strings.isEmpty(msg) && msg.contains("No space left on device")) || ctx.archiveFileStore().getUsableSpace() < writeLength;
} catch (final IOException ex2) {
suppressed = ex2;
}
final int errorCode = isLowStorageSpace ? ArchiveException.STORAGE_SPACE : ArchiveException.GENERIC;
final ArchiveException error = new ArchiveException("java.io.IOException - " + msg, ex, errorCode);
if (null != suppressed) {
error.addSuppressed(suppressed);
}
throw error;
}
Aggregations