Search in sources :

Example 1 with CatalogHeaderEncoder

use of io.aeron.archive.codecs.CatalogHeaderEncoder in project Aeron by real-logic.

the class CatalogTest method setNextRecordingId.

private void setNextRecordingId(final long nextRecordingId) throws IOException {
    try (FileChannel channel = FileChannel.open(archiveDir.toPath().resolve(CATALOG_FILE_NAME), READ, WRITE)) {
        final MappedByteBuffer mappedByteBuffer = channel.map(READ_WRITE, 0, CatalogHeaderEncoder.BLOCK_LENGTH);
        mappedByteBuffer.order(CatalogHeaderEncoder.BYTE_ORDER);
        try {
            new CatalogHeaderEncoder().wrap(new UnsafeBuffer(mappedByteBuffer), 0).nextRecordingId(nextRecordingId);
        } finally {
            BufferUtil.free(mappedByteBuffer);
        }
    }
}
Also used : MappedByteBuffer(java.nio.MappedByteBuffer) CatalogHeaderEncoder(io.aeron.archive.codecs.CatalogHeaderEncoder) FileChannel(java.nio.channels.FileChannel) UnsafeBuffer(org.agrona.concurrent.UnsafeBuffer)

Example 2 with CatalogHeaderEncoder

use of io.aeron.archive.codecs.CatalogHeaderEncoder in project aeron by real-logic.

the class CatalogTest method setNextRecordingId.

private void setNextRecordingId(final long nextRecordingId) throws IOException {
    try (FileChannel channel = FileChannel.open(archiveDir.toPath().resolve(CATALOG_FILE_NAME), READ, WRITE)) {
        final MappedByteBuffer mappedByteBuffer = channel.map(READ_WRITE, 0, CatalogHeaderEncoder.BLOCK_LENGTH);
        mappedByteBuffer.order(CatalogHeaderEncoder.BYTE_ORDER);
        try {
            new CatalogHeaderEncoder().wrap(new UnsafeBuffer(mappedByteBuffer), 0).nextRecordingId(nextRecordingId);
        } finally {
            BufferUtil.free(mappedByteBuffer);
        }
    }
}
Also used : MappedByteBuffer(java.nio.MappedByteBuffer) CatalogHeaderEncoder(io.aeron.archive.codecs.CatalogHeaderEncoder) FileChannel(java.nio.channels.FileChannel) UnsafeBuffer(org.agrona.concurrent.UnsafeBuffer)

Aggregations

CatalogHeaderEncoder (io.aeron.archive.codecs.CatalogHeaderEncoder)2 MappedByteBuffer (java.nio.MappedByteBuffer)2 FileChannel (java.nio.channels.FileChannel)2 UnsafeBuffer (org.agrona.concurrent.UnsafeBuffer)2