Search in sources :

Example 1 with SegmentedRingByteBuffer

use of org.apache.ignite.internal.processors.cache.persistence.wal.SegmentedRingByteBuffer in project ignite by apache.

the class FileHandleManagerImpl method nextHandle.

/**
 * {@inheritDoc}
 */
@Override
public FileWriteHandle nextHandle(SegmentIO fileIO, RecordSerializer serializer) throws IOException {
    SegmentedRingByteBuffer rbuf;
    if (mmap) {
        MappedByteBuffer buf = fileIO.map((int) maxWalSegmentSize);
        rbuf = new SegmentedRingByteBuffer(buf, metrics);
    } else
        rbuf = currentHandle().buf.reset();
    try {
        return new FileWriteHandleImpl(cctx, fileIO, rbuf, serializer, metrics, walWriter, 0, mode, mmap, false, fsyncDelay, maxWalSegmentSize);
    } catch (ClosedByInterruptException e) {
        if (rbuf != null)
            rbuf.free();
    }
    return null;
}
Also used : ClosedByInterruptException(java.nio.channels.ClosedByInterruptException) MappedByteBuffer(java.nio.MappedByteBuffer) SegmentedRingByteBuffer(org.apache.ignite.internal.processors.cache.persistence.wal.SegmentedRingByteBuffer)

Example 2 with SegmentedRingByteBuffer

use of org.apache.ignite.internal.processors.cache.persistence.wal.SegmentedRingByteBuffer in project ignite by apache.

the class FileHandleManagerImpl method initHandle.

/**
 * {@inheritDoc}
 */
@Override
public FileWriteHandle initHandle(SegmentIO fileIO, long position, RecordSerializer serializer) throws IOException {
    SegmentedRingByteBuffer rbuf;
    if (mmap) {
        MappedByteBuffer buf = fileIO.map((int) maxWalSegmentSize);
        rbuf = new SegmentedRingByteBuffer(buf, metrics);
    } else
        rbuf = new SegmentedRingByteBuffer(walBufferSize, maxWalSegmentSize, DIRECT, metrics);
    rbuf.init(position);
    return new FileWriteHandleImpl(cctx, fileIO, rbuf, serializer, metrics, walWriter, position, mode, mmap, true, fsyncDelay, maxWalSegmentSize);
}
Also used : MappedByteBuffer(java.nio.MappedByteBuffer) SegmentedRingByteBuffer(org.apache.ignite.internal.processors.cache.persistence.wal.SegmentedRingByteBuffer)

Aggregations

MappedByteBuffer (java.nio.MappedByteBuffer)2 SegmentedRingByteBuffer (org.apache.ignite.internal.processors.cache.persistence.wal.SegmentedRingByteBuffer)2 ClosedByInterruptException (java.nio.channels.ClosedByInterruptException)1