use of io.aeron.archive.client.ArchiveException in project Aeron by real-logic.
the class RecordingWriter method onFileRollOver.
private void onFileRollOver() {
CloseHelper.close(recordingFileChannel);
segmentOffset = 0;
segmentBasePosition += segmentLength;
final File file = new File(archiveDir, Archive.segmentFileName(recordingId, segmentBasePosition));
if (file.exists()) {
throw new ArchiveException("segment file already exists: " + file);
}
openRecordingSegmentFile(file);
}
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;
}
use of io.aeron.archive.client.ArchiveException in project Aeron by real-logic.
the class Catalog method refreshAndFixDescriptor.
private void refreshAndFixDescriptor(final RecordingDescriptorHeaderDecoder headerDecoder, final RecordingDescriptorEncoder encoder, final RecordingDescriptorDecoder decoder, final Checksum checksum, final UnsafeBuffer buffer) {
final long recordingId = decoder.recordingId();
if (VALID == headerDecoder.state() && NULL_POSITION == decoder.stopPosition()) {
final String[] segmentFiles = listSegmentFiles(archiveDir, recordingId);
final String maxSegmentFile = findSegmentFileWithHighestPosition(segmentFiles);
encoder.stopPosition(computeStopPosition(archiveDir, maxSegmentFile, decoder.startPosition(), decoder.termBufferLength(), decoder.segmentFileLength(), checksum, buffer, (segmentFile) -> {
throw new ArchiveException("Found potentially incomplete last fragment straddling page boundary in file: " + segmentFile.getAbsolutePath() + "\nRun `ArchiveTool verify` for corrective action!");
}));
encoder.stopTimestamp(epochClock.time());
}
}
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 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());
}
Aggregations