use of io.aeron.archive.codecs.RecordingState.INVALID in project Aeron by real-logic.
the class ArchiveToolTests method verifyChecksum.
@Test
void verifyChecksum() {
final Checksum checksum = crc32();
try (Catalog catalog = openCatalogReadWrite(archiveDir, epochClock, MIN_CAPACITY, checksum, null)) {
assertRecording(catalog, validRecording51, (recordingDescriptorOffset, headerEncoder, headerDecoder, descriptorEncoder, descriptorDecoder) -> catalog.updateChecksum(recordingDescriptorOffset));
assertRecording(catalog, validRecording6, (recordingDescriptorOffset, headerEncoder, headerDecoder, descriptorEncoder, descriptorDecoder) -> catalog.updateChecksum(recordingDescriptorOffset));
}
assertFalse(verify(out, archiveDir, of(APPLY_CHECKSUM), checksum, epochClock, (file) -> true));
try (Catalog catalog = openCatalogReadOnly(archiveDir, epochClock)) {
assertRecording(catalog, validRecording0, INVALID, 0, 0, NULL_POSITION, 15, NULL_TIMESTAMP, 0, 2, "ch2", "src2");
assertRecording(catalog, validRecording1, INVALID, 0, 1024, NULL_POSITION, 16, NULL_TIMESTAMP, 0, 2, "ch2", "src2");
assertRecording(catalog, validRecording2, INVALID, 0, TERM_LENGTH * 3 + 96, NULL_POSITION, 17, NULL_TIMESTAMP, 0, 2, "ch2", "src2");
assertRecording(catalog, validRecording3, INVALID, 0, 7 * TERM_LENGTH + 96, 7 * TERM_LENGTH + 128, 18, NULL_TIMESTAMP, 7, 13, "ch2", "src2");
assertRecording(catalog, validRecording4, INVALID, 0, 21 * TERM_LENGTH + (TERM_LENGTH - 64), 22 * TERM_LENGTH + 992, 19, 1, -25, 7, "ch2", "src2");
assertRecording(catalog, validRecording51, VALID, -940881948, 0, 64 + PAGE_SIZE, 20, 777, 0, 20, "ch2", "src2");
assertRecording(catalog, validRecording52, INVALID, 0, 0, NULL_POSITION, 21, NULL_TIMESTAMP, 0, 52, "ch2", "src2");
assertRecording(catalog, validRecording53, INVALID, 0, 0, NULL_POSITION, 22, NULL_TIMESTAMP, 0, 53, "ch2", "src2");
assertRecording(catalog, validRecording6, VALID, -175549265, 352, 960, 23, 100, 0, 6, "ch2", "src2");
}
Mockito.verify(out, times(24)).println(any(String.class));
}
use of io.aeron.archive.codecs.RecordingState.INVALID in project Aeron by real-logic.
the class ArchiveToolTests method compactDeletesRecordingsInStateInvalidAndDeletesTheCorrespondingSegmentFiles.
@Test
void compactDeletesRecordingsInStateInvalidAndDeletesTheCorrespondingSegmentFiles() {
// Mark recording as INVALID without invoking `invalidateRecording` operation
verifyRecording(out, archiveDir, validRecording3, allOf(VerifyOption.class), crc32(), epochClock, (file) -> false);
try (Catalog catalog = openCatalogReadWrite(archiveDir, epochClock, MIN_CAPACITY, null, null)) {
assertRecordingState(catalog, validRecording3, INVALID);
assertTrue(catalog.invalidateRecording(validRecording6));
assertRecordingState(catalog, validRecording6, INVALID);
}
final List<String> segmentFiles = new ArrayList<>();
addAll(segmentFiles, listSegmentFiles(archiveDir, validRecording3));
addAll(segmentFiles, listSegmentFiles(archiveDir, validRecording6));
assertTrue(segmentFiles.stream().allMatch(file -> new File(archiveDir, file).exists()), "Non-existing segment files");
compact(out, archiveDir, epochClock);
try (Catalog catalog = openCatalogReadOnly(archiveDir, epochClock)) {
assertNoRecording(catalog, validRecording3);
assertNoRecording(catalog, validRecording6);
assertEquals(22, catalog.entryCount());
assertRecording(catalog, validRecording0, VALID, 0, 0, NULL_POSITION, 15, NULL_TIMESTAMP, 0, 2, "ch2", "src2");
assertRecording(catalog, validRecording51, VALID, 0, 0, 64 + PAGE_SIZE, 20, 777, 0, 20, "ch2", "src2");
}
assertTrue(segmentFiles.stream().noneMatch(file -> new File(archiveDir, file).exists()), "Segment files not deleted");
Mockito.verify(out).println("Compaction result: deleted 2 records and reclaimed 384 bytes");
}
use of io.aeron.archive.codecs.RecordingState.INVALID in project Aeron by real-logic.
the class ArchiveToolTests method checksumRecordingLastSegmentFile.
@Test
void checksumRecordingLastSegmentFile() {
checksumRecording(out, archiveDir, validRecording3, false, crc32(), epochClock);
assertTrue(verifyRecording(out, archiveDir, validRecording3, of(APPLY_CHECKSUM), crc32(), epochClock, (file) -> false));
try (Catalog catalog = openCatalogReadOnly(archiveDir, epochClock)) {
assertRecording(catalog, validRecording3, VALID, 963969455, 7 * TERM_LENGTH + 96, 11 * TERM_LENGTH + 320, 18, 100, 7, 13, "ch2", "src2");
}
verifyRecording(out, archiveDir, validRecording3, allOf(VerifyOption.class), crc32(), epochClock, (file) -> false);
try (Catalog catalog = openCatalogReadOnly(archiveDir, epochClock)) {
assertRecording(catalog, validRecording3, INVALID, 963969455, 7 * TERM_LENGTH + 96, 11 * TERM_LENGTH + 320, 18, 100, 7, 13, "ch2", "src2");
}
}
use of io.aeron.archive.codecs.RecordingState.INVALID in project Aeron by real-logic.
the class ArchiveToolTests method verifyAllOptionsTruncateOnPageStraddle.
@Test
void verifyAllOptionsTruncateOnPageStraddle() {
final Checksum checksum = crc32();
try (Catalog catalog = openCatalogReadWrite(archiveDir, epochClock, MIN_CAPACITY, checksum, null)) {
catalog.forEach((recordingDescriptorOffset, headerEncoder, headerDecoder, descriptorEncoder, descriptorDecoder) -> catalog.updateChecksum(recordingDescriptorOffset));
}
assertFalse(verify(out, archiveDir, allOf(VerifyOption.class), checksum, epochClock, (file) -> true));
try (Catalog catalog = openCatalogReadOnly(archiveDir, epochClock)) {
assertRecording(catalog, invalidRecording0, INVALID, -119969720, NULL_POSITION, NULL_POSITION, 1, NULL_TIMESTAMP, 0, 1, "ch1", "src1");
assertRecording(catalog, invalidRecording1, INVALID, 768794941, FRAME_ALIGNMENT - 7, NULL_POSITION, 2, NULL_TIMESTAMP, 0, 1, "ch1", "src1");
assertRecording(catalog, invalidRecording2, INVALID, -1340428433, 1024, FRAME_ALIGNMENT * 2, 3, NULL_TIMESTAMP, 0, 1, "ch1", "src1");
assertRecording(catalog, invalidRecording3, INVALID, 1464972620, 0, FRAME_ALIGNMENT * 5 + 11, 4, NULL_TIMESTAMP, 0, 1, "ch1", "src1");
assertRecording(catalog, invalidRecording4, INVALID, 21473288, SEGMENT_LENGTH, NULL_POSITION, 5, NULL_TIMESTAMP, 0, 1, "ch1", "src1");
assertRecording(catalog, invalidRecording5, INVALID, -2119992405, 0, SEGMENT_LENGTH, 6, NULL_TIMESTAMP, 0, 1, "ch1", "src1");
assertRecording(catalog, invalidRecording6, INVALID, 2054096463, 0, NULL_POSITION, 7, NULL_TIMESTAMP, 0, 1, "ch1", "src1");
assertRecording(catalog, invalidRecording7, INVALID, -1050175867, 0, NULL_POSITION, 8, NULL_TIMESTAMP, 0, 1, "ch1", "src1");
assertRecording(catalog, invalidRecording8, INVALID, -504693275, 0, NULL_POSITION, 9, NULL_TIMESTAMP, 0, 1, "ch1", "src1");
assertRecording(catalog, invalidRecording9, INVALID, -2036430506, 0, NULL_POSITION, 10, NULL_TIMESTAMP, 0, 1, "ch1", "src1");
assertRecording(catalog, invalidRecording10, INVALID, -414736820, 128, NULL_POSITION, 11, NULL_TIMESTAMP, 0, 1, "ch1", "src1");
assertRecording(catalog, invalidRecording11, INVALID, 1983095657, 0, NULL_POSITION, 12, NULL_TIMESTAMP, 5, 1, "ch1", "src1");
assertRecording(catalog, invalidRecording12, INVALID, -1308504240, 0, NULL_POSITION, 13, NULL_TIMESTAMP, 9, 6, "ch1", "src1");
assertRecording(catalog, invalidRecording13, INVALID, -273182324, 0, NULL_POSITION, 14, NULL_TIMESTAMP, 0, 13, "ch1", "src1");
assertRecording(catalog, invalidRecording14, INVALID, 213018412, 128, NULL_POSITION, -14, 41, -14, 0, "ch1", "src1");
assertRecording(catalog, validRecording0, VALID, 356725588, 0, TERM_LENGTH + 64, 15, 100, 0, 2, "ch2", "src2");
assertRecording(catalog, validRecording1, VALID, -1571032591, 1024, 1024, 16, 200, 0, 2, "ch2", "src2");
assertRecording(catalog, validRecording2, VALID, 114203747, TERM_LENGTH * 3 + 96, TERM_LENGTH * 3 + 96, 17, 300, 0, 2, "ch2", "src2");
assertRecording(catalog, validRecording3, INVALID, 963969455, 7 * TERM_LENGTH + 96, 7 * TERM_LENGTH + 128, 18, NULL_TIMESTAMP, 7, 13, "ch2", "src2");
assertRecording(catalog, validRecording4, INVALID, 162247708, 21 * TERM_LENGTH + (TERM_LENGTH - 64), 22 * TERM_LENGTH + 992, 19, 1, -25, 7, "ch2", "src2");
assertRecording(catalog, validRecording51, VALID, -940881948, 0, 64 + PAGE_SIZE, 20, 777, 0, 20, "ch2", "src2");
assertRecording(catalog, validRecording52, INVALID, 1046083782, 0, NULL_POSITION, 21, NULL_TIMESTAMP, 0, 52, "ch2", "src2");
assertRecording(catalog, validRecording53, INVALID, 428178649, 0, NULL_POSITION, 22, NULL_TIMESTAMP, 0, 53, "ch2", "src2");
assertRecording(catalog, validRecording6, VALID, -175549265, 352, 960, 23, 400, 0, 6, "ch2", "src2");
}
Mockito.verify(out, times(24)).println(any(String.class));
}
use of io.aeron.archive.codecs.RecordingState.INVALID in project Aeron by real-logic.
the class ArchiveToolTests method checksumLastSegmentFile.
@Test
void checksumLastSegmentFile() {
checksum(out, archiveDir, false, crc32(), epochClock);
assertFalse(verify(out, archiveDir, allOf(VerifyOption.class), crc32(), epochClock, (file) -> false));
try (Catalog catalog = openCatalogReadOnly(archiveDir, epochClock)) {
assertRecording(catalog, validRecording0, VALID, 356725588, 0, TERM_LENGTH + 64, 15, 100, 0, 2, "ch2", "src2");
assertRecording(catalog, validRecording1, VALID, -1571032591, 1024, 1024, 16, 200, 0, 2, "ch2", "src2");
assertRecording(catalog, validRecording2, VALID, 114203747, TERM_LENGTH * 3 + 96, TERM_LENGTH * 3 + 96, 17, 300, 0, 2, "ch2", "src2");
assertRecording(catalog, validRecording3, INVALID, 963969455, 7 * TERM_LENGTH + 96, 7 * TERM_LENGTH + 128, 18, NULL_TIMESTAMP, 7, 13, "ch2", "src2");
assertRecording(catalog, validRecording4, INVALID, 162247708, 21 * TERM_LENGTH + (TERM_LENGTH - 64), 22 * TERM_LENGTH + 992, 19, 1, -25, 7, "ch2", "src2");
assertRecording(catalog, validRecording51, VALID, -940881948, 0, 64 + PAGE_SIZE, 20, 777, 0, 20, "ch2", "src2");
assertRecording(catalog, validRecording6, VALID, -175549265, 352, 960, 23, 600, 0, 6, "ch2", "src2");
}
}
Aggregations