use of io.aeron.archive.Catalog in project aeron by real-logic.
the class CatalogTest method stopPositionShouldUpdateChecksum.
@Test
void stopPositionShouldUpdateChecksum() {
final Checksum checksum = crc32();
try (Catalog catalog = new Catalog(archiveDir, null, 0, CAPACITY, clock, checksum, segmentFileBuffer)) {
assertChecksum(catalog, recordingTwoId, 0);
catalog.stopPosition(recordingTwoId, 7777);
assertChecksum(catalog, recordingTwoId, -1985007076);
}
}
use of io.aeron.archive.Catalog in project aeron by real-logic.
the class CatalogTest method before.
@BeforeEach
void before() {
try (Catalog catalog = new Catalog(archiveDir, null, 0, CAPACITY, clock, null, segmentFileBuffer)) {
recordingOneId = catalog.addNewRecording(0L, 0L, 0, SEGMENT_LENGTH, TERM_LENGTH, MTU_LENGTH, 6, 1, "channelG", "channelG?tag=f", "sourceA");
recordingTwoId = catalog.addNewRecording(0L, 0L, 0, SEGMENT_LENGTH, TERM_LENGTH, MTU_LENGTH, 7, 2, "channelH", "channelH?tag=f", "sourceV");
recordingThreeId = catalog.addNewRecording(0L, 0L, 0, SEGMENT_LENGTH, TERM_LENGTH, MTU_LENGTH, 8, 3, "channelThatIsVeryLongAndShouldNotBeTruncated", "channelThatIsVeryLongAndShouldNotBeTruncated?tag=f", "source can also be a very very very long String and it will not be truncated even " + "if gets very very long");
}
}
use of io.aeron.archive.Catalog in project aeron by real-logic.
the class ArchiveTool method migrate.
/**
* Migrate previous archive {@link org.agrona.MarkFile}, {@link Catalog}, and recordings from previous version
* to the latest version.
*
* @param out output stream to print results and errors to.
* @param archiveDir that contains MarkFile, Catalog and recordings.
*/
public static void migrate(final PrintStream out, final File archiveDir) {
final EpochClock epochClock = INSTANCE;
try {
final int markFileVersion;
final IntConsumer noVersionCheck = (version) -> {
};
try (ArchiveMarkFile markFile = openMarkFileReadWrite(archiveDir, epochClock);
Catalog catalog = openCatalogReadWrite(archiveDir, epochClock, MIN_CAPACITY, null, noVersionCheck)) {
markFileVersion = markFile.decoder().version();
out.println("MarkFile version=" + fullVersionString(markFileVersion));
out.println("Catalog version=" + fullVersionString(catalog.version()));
out.println("Latest version=" + fullVersionString(ArchiveMarkFile.SEMANTIC_VERSION));
}
final List<ArchiveMigrationStep> steps = ArchiveMigrationPlanner.createPlan(markFileVersion);
for (final ArchiveMigrationStep step : steps) {
try (ArchiveMarkFile markFile = openMarkFileReadWrite(archiveDir, epochClock);
Catalog catalog = openCatalogReadWrite(archiveDir, epochClock, MIN_CAPACITY, null, noVersionCheck)) {
out.println("Migration step " + step.toString());
step.migrate(out, markFile, catalog, archiveDir);
}
}
} catch (final Exception ex) {
ex.printStackTrace(out);
}
}
use of io.aeron.archive.Catalog in project aeron by real-logic.
the class ArchiveTool method verify.
static boolean verify(final PrintStream out, final File archiveDir, final Set<VerifyOption> options, final Checksum checksum, final EpochClock epochClock, final ActionConfirmation<File> truncateOnPageStraddle) {
try (Catalog catalog = openCatalogReadWrite(archiveDir, epochClock, MIN_CAPACITY, checksum, null)) {
final MutableInteger errorCount = new MutableInteger();
catalog.forEach(createVerifyEntryProcessor(out, archiveDir, options, catalog, checksum, epochClock, errorCount, truncateOnPageStraddle));
return errorCount.get() == 0;
}
}
use of io.aeron.archive.Catalog in project aeron by real-logic.
the class ArchiveTool method describe.
/**
* Describe the metadata for entries in the {@link Catalog}.
*
* @param out to which the entries will be printed.
* @param archiveDir containing the {@link Catalog}.
*/
public static void describe(final PrintStream out, final File archiveDir) {
try (Catalog catalog = openCatalogReadOnly(archiveDir, INSTANCE);
ArchiveMarkFile markFile = openMarkFile(archiveDir, out::println)) {
printMarkInformation(markFile, out);
out.println("Catalog capacity in bytes: " + catalog.capacity());
catalog.forEach((recordingDescriptorOffset, he, hd, e, d) -> out.println(d));
}
}
Aggregations