use of org.agrona.concurrent.YieldingIdleStrategy in project Aeron by real-logic.
the class ArchiveTest method before.
private void before(final ThreadingMode threadingMode, final ArchiveThreadingMode archiveThreadingMode) {
if (threadingMode == ThreadingMode.INVOKER) {
TestMediaDriver.notSupportedOnCMediaDriver("C driver does not integrate with Java Invoker");
}
IoUtil.delete(new File(CommonContext.getAeronDirectoryName()), false);
rnd.setSeed(seed);
requestedInitialTermId = rnd.nextInt(1234);
// 1M to 8M
final int termLength = 1 << (16 + rnd.nextInt(10));
// 1024 to 8096
final int mtu = 1 << (10 + rnd.nextInt(3));
final int requestedStartTermOffset = BitUtil.align(rnd.nextInt(termLength), FrameDescriptor.FRAME_ALIGNMENT);
final int requestedStartTermId = requestedInitialTermId + rnd.nextInt(1000);
final int segmentFileLength = termLength << rnd.nextInt(4);
final MediaDriver.Context driverCtx = new MediaDriver.Context().termBufferSparseFile(true).threadingMode(threadingMode).sharedIdleStrategy(YieldingIdleStrategy.INSTANCE).spiesSimulateConnection(true).dirDeleteOnStart(true);
final Archive.Context archiveContext = new Archive.Context().catalogCapacity(ArchiveSystemTests.CATALOG_CAPACITY).fileSyncLevel(SYNC_LEVEL).deleteArchiveOnStart(true).archiveDir(new File(SystemUtil.tmpDirName(), "archive-test")).segmentFileLength(segmentFileLength).threadingMode(archiveThreadingMode).idleStrategySupplier(YieldingIdleStrategy::new);
try {
driver = TestMediaDriver.launch(driverCtx, systemTestWatcher);
if (threadingMode == ThreadingMode.INVOKER) {
archiveContext.mediaDriverAgentInvoker(driver.sharedAgentInvoker());
}
archive = Archive.launch(archiveContext);
} finally {
systemTestWatcher.dataCollector().add(driverCtx.aeronDirectory());
systemTestWatcher.dataCollector().add(archiveContext.archiveDir());
}
client = Aeron.connect();
requestedStartPosition = ((requestedStartTermId - requestedInitialTermId) * (long) termLength) + requestedStartTermOffset;
publishUri = new ChannelUriStringBuilder().media("udp").endpoint("localhost:24325").termLength(termLength).mtu(mtu).initialTermId(requestedInitialTermId).termId(requestedStartTermId).termOffset(requestedStartTermOffset).build();
}
Aggregations