Search in sources :

Example 1 with YieldingIdleStrategy

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();
}
Also used : YieldingIdleStrategy(org.agrona.concurrent.YieldingIdleStrategy) AeronArchive(io.aeron.archive.client.AeronArchive) TestMediaDriver(io.aeron.test.driver.TestMediaDriver) MediaDriver(io.aeron.driver.MediaDriver) File(java.io.File)

Aggregations

AeronArchive (io.aeron.archive.client.AeronArchive)1 MediaDriver (io.aeron.driver.MediaDriver)1 TestMediaDriver (io.aeron.test.driver.TestMediaDriver)1 File (java.io.File)1 YieldingIdleStrategy (org.agrona.concurrent.YieldingIdleStrategy)1