use of io.aeron.archive.Catalog in project Aeron by real-logic.
the class ArchiveTool method checksum.
static void checksum(final PrintStream out, final File archiveDir, final boolean allFiles, final Checksum checksum, final EpochClock epochClock) {
try (Catalog catalog = openCatalogReadWrite(archiveDir, epochClock, MIN_CAPACITY, checksum, null)) {
final ByteBuffer buffer = ByteBuffer.allocateDirect(align(Configuration.MAX_UDP_PAYLOAD_LENGTH, CACHE_LINE_LENGTH));
buffer.order(LITTLE_ENDIAN);
catalog.forEach((recordingDescriptorOffset, headerEncoder, headerDecoder, descriptorEncoder, descriptorDecoder) -> {
try {
catalog.updateChecksum(recordingDescriptorOffset);
checksum(buffer, out, archiveDir, allFiles, checksum, descriptorDecoder);
} catch (final Exception ex) {
out.println("(recordingId=" + descriptorDecoder.recordingId() + ") ERR: failed to compute checksums");
out.println(ex);
}
});
}
}
use of io.aeron.archive.Catalog in project Aeron by real-logic.
the class ArchiveTool method createVerifyEntryProcessor.
private static CatalogEntryProcessor createVerifyEntryProcessor(final PrintStream out, final File archiveDir, final Set<VerifyOption> options, final Catalog catalog, final Checksum checksum, final EpochClock epochClock, final MutableInteger errorCount, final ActionConfirmation<File> truncateOnPageStraddle) {
final ByteBuffer buffer = BufferUtil.allocateDirectAligned(FILE_IO_MAX_LENGTH_DEFAULT, CACHE_LINE_LENGTH);
buffer.order(LITTLE_ENDIAN);
final DataHeaderFlyweight headerFlyweight = new DataHeaderFlyweight(buffer);
return (recordingDescriptorOffset, headerEncoder, headerDecoder, descriptorEncoder, descriptorDecoder) -> verifyRecording(out, archiveDir, options, catalog, checksum, epochClock, errorCount, truncateOnPageStraddle, headerFlyweight, recordingDescriptorOffset, headerEncoder, headerDecoder, descriptorEncoder, descriptorDecoder);
}
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));
}
}
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;
}
}
Aggregations