• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java MediaDriver类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中io.aeron.driver.MediaDriver的典型用法代码示例。如果您正苦于以下问题:Java MediaDriver类的具体用法?Java MediaDriver怎么用?Java MediaDriver使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MediaDriver类属于io.aeron.driver包,在下文中一共展示了MediaDriver类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: HeliosDriver

import io.aeron.driver.MediaDriver; //导入依赖的package包/类
public HeliosDriver(final HeliosContext context, final MediaDriver.Context driverContext)
{
    String mediaDriverConf = context.getMediaDriverConf();
    if (mediaDriverConf != null)
    {
        MediaDriver.loadPropertiesFile(mediaDriverConf);
    }
    else
    {
        driverContext.dirsDeleteOnStart(true);
    }

    driverContext.warnIfDirectoriesExist(false);

    final boolean embeddedMediaDriver = context.isMediaDriverEmbedded();
    mediaDriver = embeddedMediaDriver ? MediaDriver.launchEmbedded(driverContext) : null;
}
 
开发者ID:canepat,项目名称:Helios,代码行数:18,代码来源:HeliosDriver.java


示例2: main

import io.aeron.driver.MediaDriver; //导入依赖的package包/类
@SuppressWarnings("checkstyle:UncommentedMain")
public static void main(final String... args) {
  MediaDriver.loadPropertiesFiles(args);

  setProperty(DISABLE_BOUNDS_CHECKS_PROP_NAME, "true");
  setProperty("aeron.mtu.length", "16384");
  setProperty("aeron.socket.so_sndbuf", "2097152");
  setProperty("aeron.socket.so_rcvbuf", "2097152");
  setProperty("aeron.rcv.initial.window.length", "2097152");

  final MediaDriver.Context ctx = new MediaDriver.Context()
      .threadingMode(ThreadingMode.DEDICATED)
      .dirsDeleteOnStart(true)
      .termBufferSparseFile(false)
      .conductorIdleStrategy(new BusySpinIdleStrategy())
      .receiverIdleStrategy(new BusySpinIdleStrategy())
      .senderIdleStrategy(new BusySpinIdleStrategy());

  try (MediaDriver ignored = MediaDriver.launch(ctx)) {
    new SigIntBarrier().await();

  }
}
 
开发者ID:benalexau,项目名称:rpc-bench,代码行数:24,代码来源:LowLatencyMediaDriver.java


示例3: launch

import io.aeron.driver.MediaDriver; //导入依赖的package包/类
@Before
public void launch()
{
    final int libraryAeronPort = unusedPort();

    final MediaDriver.Context context = mediaDriverContext(TestFixtures.TERM_BUFFER_LENGTH, true);
    context.threadingMode(INVOKER);
    mediaDriver = launchMediaDriver(context);

    delete(ACCEPTOR_LOGS);
    acceptingEngine = FixEngine.launch(
        acceptingConfig(port, ACCEPTOR_ID, INITIATOR_ID)
            .scheduler(new LowResourceEngineScheduler(mediaDriver.sharedAgentInvoker())));

    initiatingEngine = launchInitiatingEngine(libraryAeronPort);

    initiatingLibrary = newInitiatingLibrary(libraryAeronPort, initiatingHandler);
    testSystem = new TestSystem(initiatingLibrary);
}
 
开发者ID:real-logic,项目名称:artio,代码行数:20,代码来源:MultipleAddressSystemTest.java


示例4: shouldRestartWithoutSessions

import io.aeron.driver.MediaDriver; //导入依赖的package包/类
@Test
public void shouldRestartWithoutSessions() throws Exception
{
    MediaDriver mediaDriver = null;
    try
    {
        mediaDriver = TestFixtures.launchMediaDriver();
        final int port = TestFixtures.unusedPort();
        try (FixEngine engine = SystemTestUtil.launchInitiatingEngine(port))
        {
        }

        try (FixEngine engine = SystemTestUtil.launchInitiatingEngineWithSameLogs(port))
        {
        }
    }
    finally
    {
        TestFixtures.cleanupMediaDriver(mediaDriver);
    }
}
 
开发者ID:real-logic,项目名称:artio,代码行数:22,代码来源:EngineRestartTest.java


示例5: shouldStartAndStopInstantly

import io.aeron.driver.MediaDriver; //导入依赖的package包/类
@Test(timeout = 10_000)
public void shouldStartAndStopInstantly()
{
    final MediaDriver.Context driverCtx = new MediaDriver.Context()
        .errorHandler(Throwable::printStackTrace);

    try (MediaDriver ignore = MediaDriver.launchEmbedded(driverCtx))
    {
        final Aeron.Context clientCtx = new Aeron.Context()
            .aeronDirectoryName(driverCtx.aeronDirectoryName());

        //noinspection EmptyTryBlock
        try (Aeron ignored = Aeron.connect(clientCtx))
        {
           // ignore
        }
    }
    finally
    {
        driverCtx.deleteAeronDirectory();
    }
}
 
开发者ID:real-logic,项目名称:aeron,代码行数:23,代码来源:StartStopSystemTest.java


示例6: setUp

import io.aeron.driver.MediaDriver; //导入依赖的package包/类
@Before
public void setUp()
{
    final MediaDriver.Context ctx = new MediaDriver.Context()
        .errorHandler(Throwable::printStackTrace)
        .threadingMode(ThreadingMode.SHARED);

    driver = MediaDriver.launch(ctx);
    pingClient = Aeron.connect();
    pongClient = Aeron.connect();

    pingPublication = pingClient.addPublication(PING_URI, PING_STREAM_ID);
    pingSubscription = pongClient.addSubscription(PING_URI, PING_STREAM_ID);

    pongPublication = pongClient.addPublication(PONG_URI, PONG_STREAM_ID);
    pongSubscription = pingClient.addSubscription(PONG_URI, PONG_STREAM_ID);
}
 
开发者ID:real-logic,项目名称:aeron,代码行数:18,代码来源:PongTest.java


示例7: launch

import io.aeron.driver.MediaDriver; //导入依赖的package包/类
private void launch(final String channelOne, final int streamOne, final String channelTwo, final int streamTwo)
{
    driverOne = MediaDriver.launchEmbedded(
        new MediaDriver.Context()
            .errorHandler(Throwable::printStackTrace)
            .termBufferSparseFile(true));

    driverTwo = MediaDriver.launchEmbedded(
        new MediaDriver.Context()
            .errorHandler(Throwable::printStackTrace)
            .termBufferSparseFile(true));

    publisherOne = Aeron.connect(new Aeron.Context().aeronDirectoryName(driverOne.aeronDirectoryName()));
    subscriberOne = Aeron.connect(new Aeron.Context().aeronDirectoryName(driverTwo.aeronDirectoryName()));
    publisherTwo = Aeron.connect(new Aeron.Context().aeronDirectoryName(driverOne.aeronDirectoryName()));
    subscriberTwo = Aeron.connect(new Aeron.Context().aeronDirectoryName(driverTwo.aeronDirectoryName()));

    publicationOne = publisherOne.addPublication(channelOne, streamOne);
    subscriptionOne = subscriberOne.addSubscription(channelOne, streamOne);
    publicationTwo = publisherTwo.addPublication(channelTwo, streamTwo);
    subscriptionTwo = subscriberTwo.addSubscription(channelTwo, streamTwo);
}
 
开发者ID:real-logic,项目名称:aeron,代码行数:23,代码来源:StopStartSecondSubscriberTest.java


示例8: launch

import io.aeron.driver.MediaDriver; //导入依赖的package包/类
private void launch()
{
    final String baseDirA = ROOT_DIR + "A";
    final String baseDirB = ROOT_DIR + "B";

    buffer.putInt(0, 1);

    final MediaDriver.Context driverAContext = new MediaDriver.Context()
        .errorHandler(Throwable::printStackTrace)
        .publicationTermBufferLength(TERM_BUFFER_LENGTH)
        .aeronDirectoryName(baseDirA)
        .threadingMode(ThreadingMode.SHARED);

    driverBContext.publicationTermBufferLength(TERM_BUFFER_LENGTH)
        .errorHandler(Throwable::printStackTrace)
        .aeronDirectoryName(baseDirB)
        .threadingMode(ThreadingMode.SHARED);

    driverA = MediaDriver.launch(driverAContext);
    driverB = MediaDriver.launch(driverBContext);
    clientA = Aeron.connect(new Aeron.Context().aeronDirectoryName(driverAContext.aeronDirectoryName()));
    clientB = Aeron.connect(new Aeron.Context().aeronDirectoryName(driverBContext.aeronDirectoryName()));
}
 
开发者ID:real-logic,项目名称:aeron,代码行数:24,代码来源:MultiDestinationCastTest.java


示例9: launch

import io.aeron.driver.MediaDriver; //导入依赖的package包/类
private void launch()
{
    labelBuffer.putStringWithoutLengthAscii(0, COUNTER_LABEL);

    driverContext =
        new MediaDriver.Context()
            .errorHandler(Throwable::printStackTrace)
            .threadingMode(ThreadingMode.SHARED);

    driver = MediaDriver.launch(driverContext);

    clientA = Aeron.connect(
        new Aeron.Context()
            .availableCounterHandler(availableCounterHandlerClientA)
            .unavailableCounterHandler(unavailableCounterHandlerClientA));

    clientB = Aeron.connect(
        new Aeron.Context()
            .availableCounterHandler(availableCounterHandlerClientB)
            .unavailableCounterHandler(unavailableCounterHandlerClientB));
}
 
开发者ID:real-logic,项目名称:aeron,代码行数:22,代码来源:CounterTest.java


示例10: shouldHaveCorrectTermBufferLength

import io.aeron.driver.MediaDriver; //导入依赖的package包/类
@Theory
@Test(timeout = 10000)
public void shouldHaveCorrectTermBufferLength(final String channel)
{
    final MediaDriver.Context ctx = new MediaDriver.Context()
        .errorHandler(Throwable::printStackTrace)
        .publicationTermBufferLength(TEST_TERM_LENGTH * 2)
        .ipcTermBufferLength(TEST_TERM_LENGTH * 2);

    try (MediaDriver ignore = MediaDriver.launch(ctx);
        Aeron aeron = Aeron.connect();
        Publication publication = aeron.addPublication(channel, STREAM_ID))
    {
        assertThat(publication.termBufferLength(), is(TEST_TERM_LENGTH));
    }
    finally
    {
        ctx.deleteAeronDirectory();
    }
}
 
开发者ID:real-logic,项目名称:aeron,代码行数:21,代码来源:TermBufferLengthTest.java


示例11: launch

import io.aeron.driver.MediaDriver; //导入依赖的package包/类
private void launch()
{
    final String baseDirA = ROOT_DIR + "A";
    final String baseDirB = ROOT_DIR + "B";

    buffer.putInt(0, 1);

    final MediaDriver.Context driverAContext = new MediaDriver.Context()
        .errorHandler(Throwable::printStackTrace)
        .publicationTermBufferLength(TERM_BUFFER_LENGTH)
        .aeronDirectoryName(baseDirA)
        .threadingMode(THREADING_MODE);

    final MediaDriver.Context driverBContext = new MediaDriver.Context()
        .errorHandler(Throwable::printStackTrace)
        .publicationTermBufferLength(TERM_BUFFER_LENGTH)
        .aeronDirectoryName(baseDirB)
        .threadingMode(THREADING_MODE);

    driverA = MediaDriver.launch(driverAContext);
    driverB = MediaDriver.launch(driverBContext);
    clientA = Aeron.connect(new Aeron.Context().aeronDirectoryName(driverAContext.aeronDirectoryName()));
    clientB = Aeron.connect(new Aeron.Context().aeronDirectoryName(driverBContext.aeronDirectoryName()));
}
 
开发者ID:real-logic,项目名称:aeron,代码行数:25,代码来源:MultiDriverTest.java


示例12: launch

import io.aeron.driver.MediaDriver; //导入依赖的package包/类
/**
 * Launch a new {@link ClusteredMediaDriver} with provided contexts.
 *
 * @param driverCtx          for configuring the {@link MediaDriver}.
 * @param archiveCtx         for configuring the {@link Archive}.
 * @param consensusModuleCtx for the configuration of the {@link ConsensusModule}.
 * @return a new {@link ClusteredMediaDriver} with the provided contexts.
 */
public static ClusteredMediaDriver launch(
    final MediaDriver.Context driverCtx,
    final Archive.Context archiveCtx,
    final ConsensusModule.Context consensusModuleCtx)
{
    final MediaDriver driver = MediaDriver.launch(driverCtx
        .spiesSimulateConnection(true));

    final Archive archive = Archive.launch(archiveCtx
        .mediaDriverAgentInvoker(driver.sharedAgentInvoker())
        .errorHandler(driverCtx.errorHandler())
        .errorCounter(driverCtx.systemCounters().get(SystemCounterDescriptor.ERRORS)));

    final ConsensusModule consensusModule = ConsensusModule.launch(consensusModuleCtx
        .errorHandler(driverCtx.errorHandler())
        .errorCounter(driverCtx.systemCounters().get(SystemCounterDescriptor.ERRORS)));

    return new ClusteredMediaDriver(driver, archive, consensusModule);
}
 
开发者ID:real-logic,项目名称:aeron,代码行数:28,代码来源:ClusteredMediaDriver.java


示例13: launchClusteredMediaDriver

import io.aeron.driver.MediaDriver; //导入依赖的package包/类
private void launchClusteredMediaDriver(final boolean initialLaunch)
{
    clusteredMediaDriver = ClusteredMediaDriver.launch(
        new MediaDriver.Context()
            .warnIfDirectoryExists(initialLaunch)
            .threadingMode(ThreadingMode.SHARED)
            .termBufferSparseFile(true)
            .errorHandler(Throwable::printStackTrace)
            .dirDeleteOnStart(true),
        new Archive.Context()
            .threadingMode(ArchiveThreadingMode.SHARED)
            .deleteArchiveOnStart(initialLaunch),
        new ConsensusModule.Context()
            .snapshotCounter(mockSnapshotCounter)
            .terminationHook(() -> isTerminated.set(true))
            .deleteDirOnStart(initialLaunch));
}
 
开发者ID:real-logic,项目名称:aeron,代码行数:18,代码来源:ClusterNodeRestartTest.java


示例14: EmbeddedReplayThroughput

import io.aeron.driver.MediaDriver; //导入依赖的package包/类
public EmbeddedReplayThroughput()
{
    final String archiveDirName = Archive.Configuration.archiveDirName();
    final File archiveDir =  ARCHIVE_DIR_DEFAULT.equals(archiveDirName) ?
        TestUtil.createTempDir() : new File(archiveDirName);

    archivingMediaDriver = ArchivingMediaDriver.launch(
        new MediaDriver.Context()
            .dirDeleteOnStart(true),
        new Archive.Context()
            .archiveDir(archiveDir));

    aeron = Aeron.connect();

    aeronArchive = AeronArchive.connect(
        new AeronArchive.Context()
            .aeron(aeron));
}
 
开发者ID:real-logic,项目名称:aeron,代码行数:19,代码来源:EmbeddedReplayThroughput.java


示例15: EmbeddedRecordingThroughput

import io.aeron.driver.MediaDriver; //导入依赖的package包/类
public EmbeddedRecordingThroughput()
{
    final String archiveDirName = Archive.Configuration.archiveDirName();
    final File archiveDir =  ARCHIVE_DIR_DEFAULT.equals(archiveDirName) ?
        TestUtil.createTempDir() : new File(archiveDirName);

    archivingMediaDriver = ArchivingMediaDriver.launch(
        new MediaDriver.Context()
            .spiesSimulateConnection(true)
            .dirDeleteOnStart(true),
        new Archive.Context()
            .deleteArchiveOnStart(true)
            .archiveDir(archiveDir));

    aeron = Aeron.connect();

    aeronArchive = AeronArchive.connect(
        new AeronArchive.Context()
            .aeron(aeron));

    recordingEventsThread = new Thread(this::runRecordingEventPoller);
    recordingEventsThread.setName("recording-events-poller");
    recordingEventsThread.start();
}
 
开发者ID:real-logic,项目名称:aeron,代码行数:25,代码来源:EmbeddedRecordingThroughput.java


示例16: main

import io.aeron.driver.MediaDriver; //导入依赖的package包/类
public static void main(final String[] args) throws Exception
{
    loadPropertiesFiles(args);

    final MediaDriver.Context ctx = new MediaDriver.Context()
        .threadingMode(ThreadingMode.DEDICATED)
        .conductorIdleStrategy(new BackoffIdleStrategy(1, 1, 1, 1))
        .receiverIdleStrategy(new NoOpIdleStrategy())
        .senderIdleStrategy(new NoOpIdleStrategy());

    try (MediaDriver ignored = MediaDriver.launch(ctx))
    {
        final Thread pongThread = startPong(ignored.aeronDirectoryName());
        pongThread.start();

        runPing(ignored.aeronDirectoryName());
        RUNNING.set(false);
        pongThread.join();

        System.out.println("Shutdown Driver...");
    }
}
 
开发者ID:real-logic,项目名称:aeron,代码行数:23,代码来源:EmbeddedPingPong.java


示例17: main

import io.aeron.driver.MediaDriver; //导入依赖的package包/类
public static void main(final String[] args)
{
    loadPropertiesFiles(args);

    final MediaDriver.Context ctx = new MediaDriver.Context()
        .termBufferSparseFile(false)
        .threadingMode(ThreadingMode.DEDICATED)
        .conductorIdleStrategy(new BusySpinIdleStrategy())
        .receiverIdleStrategy(new BusySpinIdleStrategy())
        .senderIdleStrategy(new BusySpinIdleStrategy());

    try (MediaDriver ignored = MediaDriver.launch(ctx))
    {
        new ShutdownSignalBarrier().await();

        System.out.println("Shutdown Driver...");
    }
}
 
开发者ID:real-logic,项目名称:aeron,代码行数:19,代码来源:LowLatencyMediaDriver.java


示例18: newInstance

import io.aeron.driver.MediaDriver; //导入依赖的package包/类
public CongestionControl newInstance(
    final long registrationId,
    final UdpChannel udpChannel,
    final int streamId,
    final int sessionId,
    final int termLength,
    final int senderMtuLength,
    final NanoClock clock,
    final MediaDriver.Context context,
    final CountersManager countersManager)
{
    return new CubicCongestionControl(
        registrationId,
        udpChannel,
        streamId,
        sessionId,
        termLength,
        senderMtuLength,
        clock,
        context,
        countersManager);
}
 
开发者ID:real-logic,项目名称:aeron,代码行数:23,代码来源:CubicCongestionControlSupplier.java


示例19: before

import io.aeron.driver.MediaDriver; //导入依赖的package包/类
@BeforeClass
public static void before() throws Exception {
    mediaDriver = MediaDriver.launchEmbedded(AeronUtil.getMediaDriverContext(parameterLength));
    System.setProperty("play.server.dir", "/tmp");
    aeron = Aeron.connect(getContext());
    parameterServerNode = new ParameterServerNode(mediaDriver, statusPort);
    parameterServerNode.runMain(new String[] {"-m", "true", "-s", "1," + String.valueOf(parameterLength), "-p",
                    String.valueOf(masterStatusPort), "-h", "localhost", "-id", "11", "-md",
                    mediaDriver.aeronDirectoryName(), "-sp", String.valueOf(statusPort), "-sh", "localhost", "-u",
                    String.valueOf(Runtime.getRuntime().availableProcessors())});

    while (!parameterServerNode.subscriberLaunched()) {
        Thread.sleep(10000);
    }

}
 
开发者ID:deeplearning4j,项目名称:nd4j,代码行数:17,代码来源:ParameterServerNodeTest.java


示例20: getMediaDriverContext

import io.aeron.driver.MediaDriver; //导入依赖的package包/类
/**
 * Get a media driver context
 * for sending ndarrays
 * based on a given length
 * where length is the length (number of elements)
 * in the ndarrays hat are being sent
 * @param length the length to based the ipc length
 * @return the media driver context based on the given length
 */
public static MediaDriver.Context getMediaDriverContext(int length) {
    //length of array * sizeof(float)
    int ipcLength = length * 16;
    //padding for NDArrayMessage
    ipcLength += 64;
    //must be a power of 2
    ipcLength *= 2;
    //ipc length must be positive power of 2
    while (!BitUtil.isPowerOfTwo(ipcLength))
        ipcLength += 2;
    // System.setProperty("aeron.term.buffer.size",String.valueOf(ipcLength));
    final MediaDriver.Context ctx =
                    new MediaDriver.Context().threadingMode(ThreadingMode.SHARED).dirsDeleteOnStart(true)
                                    /*  .ipcTermBufferLength(ipcLength)
                                      .publicationTermBufferLength(ipcLength)
                                      .maxTermBufferLength(ipcLength)*/
                                    .conductorIdleStrategy(new BusySpinIdleStrategy())
                                    .receiverIdleStrategy(new BusySpinIdleStrategy())
                                    .senderIdleStrategy(new BusySpinIdleStrategy());
    return ctx;
}
 
开发者ID:deeplearning4j,项目名称:nd4j,代码行数:31,代码来源:AeronUtil.java



注:本文中的io.aeron.driver.MediaDriver类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Element类代码示例发布时间:2022-05-23
下一篇:
Java FlyoutPaletteComposite类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap