use of java.nio.channels.FileChannel.MapMode.READ_ONLY in project aeron by real-logic.
the class SystemTests method verifyLossOccurredForStream.
static void verifyLossOccurredForStream(final String aeronDirectoryName, final int streamId) throws IOException {
final File lossReportFile = LossReportUtil.file(aeronDirectoryName);
assertTrue(lossReportFile.exists());
MappedByteBuffer mappedByteBuffer = null;
try (RandomAccessFile file = new RandomAccessFile(lossReportFile, "r");
FileChannel channel = file.getChannel()) {
mappedByteBuffer = channel.map(READ_ONLY, 0, channel.size());
final AtomicBuffer buffer = new UnsafeBuffer(mappedByteBuffer);
final LossReportReader.EntryConsumer lossEntryConsumer = mock(LossReportReader.EntryConsumer.class);
LossReportReader.read(buffer, lossEntryConsumer);
verify(lossEntryConsumer).accept(longThat((l) -> l > 0), longThat((l) -> l > 0), anyLong(), anyLong(), anyInt(), eq(streamId), any(), any());
} finally {
BufferUtil.free(mappedByteBuffer);
}
}
use of java.nio.channels.FileChannel.MapMode.READ_ONLY in project Aeron by real-logic.
the class SystemTests method verifyLossOccurredForStream.
static void verifyLossOccurredForStream(final String aeronDirectoryName, final int streamId) throws IOException {
final File lossReportFile = LossReportUtil.file(aeronDirectoryName);
assertTrue(lossReportFile.exists());
MappedByteBuffer mappedByteBuffer = null;
try (RandomAccessFile file = new RandomAccessFile(lossReportFile, "r");
FileChannel channel = file.getChannel()) {
mappedByteBuffer = channel.map(READ_ONLY, 0, channel.size());
final AtomicBuffer buffer = new UnsafeBuffer(mappedByteBuffer);
final LossReportReader.EntryConsumer lossEntryConsumer = mock(LossReportReader.EntryConsumer.class);
LossReportReader.read(buffer, lossEntryConsumer);
verify(lossEntryConsumer).accept(longThat((l) -> l > 0), longThat((l) -> l > 0), anyLong(), anyLong(), anyInt(), eq(streamId), any(), any());
} finally {
BufferUtil.free(mappedByteBuffer);
}
}
Aggregations