use of net.openhft.chronicle.queue.impl.single.SingleChronicleQueue.SUFFIX in project Chronicle-Queue by OpenHFT.
the class SingleChronicleQueueTest method mappedSegmentsShouldBeUnmappedAsCycleRolls.
@Test
public void mappedSegmentsShouldBeUnmappedAsCycleRolls() throws Exception {
final Random random = new Random(0xDEADBEEF);
final File queueFolder = DirectoryUtils.tempDir("mappedSegmentsShouldBeUnmappedAsCycleRolls");
final AtomicLong clock = new AtomicLong(System.currentTimeMillis());
try (final SingleChronicleQueue queue = SingleChronicleQueueBuilder.binary(queueFolder).timeProvider(clock::get).testBlockSize().rollCycle(RollCycles.HOURLY).build()) {
final ExcerptAppender appender = queue.acquireAppender();
for (int i = 0; i < 20_000; i++) {
final int batchSize = random.nextInt(10);
appender.writeDocument(batchSize, ValueOut::int64);
final byte payload = (byte) random.nextInt();
for (int j = 0; j < batchSize; j++) {
appender.writeDocument(payload, ValueOut::int8);
}
if (random.nextDouble() > 0.995) {
clock.addAndGet(TimeUnit.MINUTES.toMillis(37L));
// this give the reference processor a chance to run
LockSupport.parkNanos(TimeUnit.MILLISECONDS.toNanos(15L));
}
}
if (OS.isLinux())
assertTrue("Too many mapped files: " + getMappedQueueFileCount(), getMappedQueueFileCount() < 40);
assertTrue(Files.list(queueFolder.toPath()).filter(p -> p.toString().endsWith(SUFFIX)).count() > 10L);
}
}
Aggregations