use of io.atomix.storage.StorageException in project atomix by atomix.
the class MappableJournalSegmentWriter method map.
/**
* Maps the segment writer into memory, returning the mapped buffer.
*
* @return the buffer that was mapped into memory
*/
MappedByteBuffer map() {
if (writer instanceof MappedJournalSegmentWriter) {
return ((MappedJournalSegmentWriter<E>) writer).buffer();
}
try {
JournalWriter<E> writer = this.writer;
MappedByteBuffer buffer = channel.map(FileChannel.MapMode.READ_WRITE, 0, segment.descriptor().maxSegmentSize());
this.writer = new MappedJournalSegmentWriter<>(buffer, segment, maxEntrySize, index, namespace);
writer.close();
return buffer;
} catch (IOException e) {
throw new StorageException(e);
}
}
Aggregations