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

Java Aeron类代码示例

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

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



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

示例1: main

import io.aeron.Aeron; //导入依赖的package包/类
public static void main(final String... args) {
    final String aeronDirectoryName = args[0];
    final String channel = args[1];
    final int streamId = Integer.parseInt(args[2]);
    final long warmupCount = Long.parseLong(args[3]);
    final long measuredCount = Long.parseLong(args[4]);

    System.out.println("Started " + AeronSubscriber.class.getSimpleName() + ":");
    System.out.println("\twarmupCount       : " + warmupCount);
    System.out.println("\tmeasuredCount     : " + measuredCount);
    System.out.println("\tchannel           : " + channel);
    System.out.println("\tstreamId          : " + streamId);
    System.out.println();

    final Aeron aeron = aeron(aeronDirectoryName);
    final Subscription subscription = aeron.addSubscription(channel, streamId);
    try {
        run(subscription, warmupCount, measuredCount);
    } finally {
        subscription.close();
        aeron.close();
        System.out.println("Shutdown " + AeronSubscriber.class.getSimpleName() + "...");
    }
}
 
开发者ID:terzerm,项目名称:fx-highway,代码行数:25,代码来源:AeronSubscriber.java


示例2: setUp

import io.aeron.Aeron; //导入依赖的package包/类
@Before
public void setUp()
{
    when(completionPosition.hasCompleted()).thenReturn(true);
    when(completionPosition.positions()).thenReturn(completedPositions);

    deleteLogFileDir();

    mediaDriver = launchMediaDriver(TERM_LENGTH);
    aeron = Aeron.connect();

    final StreamIdentifier dataStream = new StreamIdentifier(CHANNEL, STREAM_ID);
    logDirectoryDescriptor = new LogDirectoryDescriptor(LOG_FILE_DIR);
    final ArchiveMetaData metaData = new ArchiveMetaData(logDirectoryDescriptor);
    archiveReader = new ArchiveReader(
        metaData, DEFAULT_LOGGER_CACHE_NUM_SETS, DEFAULT_LOGGER_CACHE_SET_SIZE, dataStream, NO_FILTER);
    filteredArchiveReader = new ArchiveReader(
        metaData, DEFAULT_LOGGER_CACHE_NUM_SETS, DEFAULT_LOGGER_CACHE_SET_SIZE, dataStream, RESERVED_VALUE);
    archiver = new Archiver(
        metaData, DEFAULT_LOGGER_CACHE_NUM_SETS, DEFAULT_LOGGER_CACHE_SET_SIZE, dataStream, DEFAULT_NAME_PREFIX,
        completionPosition);

    publication = aeron.addPublication(CHANNEL, STREAM_ID);
    archiver.subscription(aeron.addSubscription(CHANNEL, STREAM_ID));
}
 
开发者ID:real-logic,项目名称:artio,代码行数:26,代码来源:ArchiverTest.java


示例3: Archive

import io.aeron.Aeron; //导入依赖的package包/类
Archive(final Context ctx)
{
    this.ctx = ctx;
    ctx.conclude();

    final Aeron aeron = ctx.aeron();

    final ArchiveConductor conductor = ArchiveThreadingMode.DEDICATED == ctx.threadingMode() ?
        new DedicatedModeArchiveConductor(aeron, ctx) :
        new SharedModeArchiveConductor(aeron, ctx);

    if (ArchiveThreadingMode.INVOKER == ctx.threadingMode())
    {
        conductorInvoker = new AgentInvoker(ctx.errorHandler(), ctx.errorCounter(), conductor);
        conductorRunner = null;
    }
    else
    {
        conductorInvoker = null;
        conductorRunner = new AgentRunner(ctx.idleStrategy(), ctx.errorHandler(), ctx.errorCounter(), conductor);
    }
}
 
开发者ID:real-logic,项目名称:aeron,代码行数:23,代码来源:Archive.java


示例4: allocate

import io.aeron.Aeron; //导入依赖的package包/类
/**
 * Allocate a counter to represent the snapshot services should load on start.
 *
 * @param aeron            to allocate the counter.
 * @param tempBuffer       to use for building the key and label without allocation.
 * @param leadershipTermId at which the snapshot was taken.
 * @param termPosition     at which the snapshot was taken.
 * @param timestamp        the snapshot was taken.
 * @param replayTermCount  for the count of terms to be replayed during recovery after snapshot.
 * @return the {@link Counter} for the recovery state.
 */
public static Counter allocate(
    final Aeron aeron,
    final MutableDirectBuffer tempBuffer,
    final long leadershipTermId,
    final long termPosition,
    final long timestamp,
    final int replayTermCount)
{
    tempBuffer.putLong(LEADERSHIP_TERM_ID_OFFSET, leadershipTermId);
    tempBuffer.putLong(TERM_POSITION_OFFSET, termPosition);
    tempBuffer.putLong(TIMESTAMP_OFFSET, timestamp);
    tempBuffer.putInt(REPLAY_TERM_COUNT_OFFSET, replayTermCount);

    int labelOffset = 0;
    labelOffset += tempBuffer.putStringWithoutLengthAscii(KEY_LENGTH + labelOffset, NAME);
    labelOffset += tempBuffer.putLongAscii(KEY_LENGTH + labelOffset, leadershipTermId);
    labelOffset += tempBuffer.putStringWithoutLengthAscii(KEY_LENGTH + labelOffset, " termPosition=");
    labelOffset += tempBuffer.putLongAscii(KEY_LENGTH + labelOffset, termPosition);
    labelOffset += tempBuffer.putStringWithoutLengthAscii(KEY_LENGTH + labelOffset, " replayTermCount=");
    labelOffset += tempBuffer.putIntAscii(KEY_LENGTH + labelOffset, replayTermCount);

    return aeron.addCounter(
        RECOVERY_STATE_TYPE_ID, tempBuffer, 0, KEY_LENGTH, tempBuffer, KEY_LENGTH, labelOffset);
}
 
开发者ID:real-logic,项目名称:aeron,代码行数:36,代码来源:RecoveryState.java


示例5: EmbeddedRecordingThroughput

import io.aeron.Aeron; //导入依赖的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


示例6: main

import io.aeron.Aeron; //导入依赖的package包/类
public static void main(final String[] args)
{
    try (Aeron aeron = Aeron.connect())
    {
        final CountersReader countersReader = aeron.countersReader();
        final StatusIndicator statusIndicator = StatusUtil.controllableIdleStrategy(countersReader);

        if (null != statusIndicator)
        {
            final int status = Integer.parseInt(args[0]);

            statusIndicator.setOrdered(status);

            System.out.println("Set ControllableIdleStrategy status to " + status);
        }
        else
        {
            System.out.println("Could not find ControllableIdleStrategy status.");
        }
    }
}
 
开发者ID:real-logic,项目名称:aeron,代码行数:22,代码来源:SetControllableIdleStrategy.java


示例7: startPong

import io.aeron.Aeron; //导入依赖的package包/类
private static Thread startPong(final String embeddedDirName)
{
    return new Thread(() ->
    {
        System.out.println("Subscribing Ping at " + PING_CHANNEL + " on stream Id " + PING_STREAM_ID);
        System.out.println("Publishing Pong at " + PONG_CHANNEL + " on stream Id " + PONG_STREAM_ID);

        final Aeron.Context ctx = new Aeron.Context().aeronDirectoryName(embeddedDirName);

        try (Aeron aeron = Aeron.connect(ctx);
            Publication pongPublication = aeron.addPublication(PONG_CHANNEL, PONG_STREAM_ID);
            Subscription pingSubscription = aeron.addSubscription(PING_CHANNEL, PING_STREAM_ID))
        {
            final FragmentAssembler dataHandler = new FragmentAssembler(
                (buffer, offset, length, header) -> pingHandler(pongPublication, buffer, offset, length));

            while (RUNNING.get())
            {
                PING_HANDLER_IDLE_STRATEGY.idle(pingSubscription.poll(dataHandler, FRAME_COUNT_LIMIT));
            }

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


示例8: before

import io.aeron.Aeron; //导入依赖的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


示例9: AeronStream

import io.aeron.Aeron; //导入依赖的package包/类
AeronStream(final Aeron aeron, final String channel, final int streamId)
{
    this.aeron = Objects.requireNonNull(aeron);
    this.channel = Objects.requireNonNull(channel);
    this.streamId = streamId;

    this.key = channel + "::" + streamId;
}
 
开发者ID:canepat,项目名称:Helios,代码行数:9,代码来源:AeronStream.java


示例10: shouldThrowExceptionWhenChannelIsNull

import io.aeron.Aeron; //导入依赖的package包/类
@Test(expected = NullPointerException.class)
public void shouldThrowExceptionWhenChannelIsNull()
{
    final MediaDriver.Context driverContext = new MediaDriver.Context();
    driverContext.dirsDeleteOnStart(true);
    final MediaDriver driver = MediaDriver.launchEmbedded(driverContext);

    final Aeron.Context aeronContext = new Aeron.Context();
    aeronContext.aeronDirectoryName(driver.aeronDirectoryName());

    new AeronStream(Aeron.connect(aeronContext), null, 0);
}
 
开发者ID:canepat,项目名称:Helios,代码行数:13,代码来源:AeronStreamTest.java


示例11: EmbeddedAeron

import io.aeron.Aeron; //导入依赖的package包/类
public EmbeddedAeron(final String channel, final int streamId) {
    final MediaDriver.Context mctx = new MediaDriver.Context();
    mctx.threadingMode(ThreadingMode.DEDICATED);
    mediaDriver = MediaDriver.launchEmbedded(mctx);
    final Aeron.Context actx = new Aeron.Context();
    actx.aeronDirectoryName(mediaDriver.aeronDirectoryName());
    aeron = Aeron.connect(actx);
    subscription = aeron.addSubscription(channel, streamId);
    publication = aeron.addPublication(channel, streamId);
}
 
开发者ID:terzerm,项目名称:fx-highway,代码行数:11,代码来源:EmbeddedAeron.java


示例12: main

import io.aeron.Aeron; //导入依赖的package包/类
public static void main(final String... args) throws Exception {
    final String aeronDirectoryName = args[0];
    final String channel = args[1];
    final int streamId = Integer.parseInt(args[2]);
    final long messageCount = Long.parseLong(args[3]);
    final long messagesPerSecond = Long.parseLong(args[4]);
    final int marketDataDepth = Integer.parseInt(args[5]);

    System.out.println("Started " + AeronPublisher.class.getSimpleName() + ":");
    System.out.println("\tmessageCount      : " + messageCount);
    System.out.println("\tchannel           : " + channel);
    System.out.println("\tstreamId          : " + streamId);
    System.out.println("\tmessagesPerSecond : " + messagesPerSecond);
    System.out.println("\tmarketDataDepth   : " + marketDataDepth);
    System.out.println("\tmessageSize       : " + encode(new UnsafeBuffer(new byte[1024]), givenMarketDataSnapshot(new ImmutableMarketDataSnapshot.Builder(), marketDataDepth, marketDataDepth)) + " bytes");
    System.out.println();

    final Aeron aeron = aeron(aeronDirectoryName);
    final Publication publication = aeron.addPublication(channel, streamId);
    try {
        awaitConnection(publication, 5, TimeUnit.SECONDS);
        run(publication, messageCount, messagesPerSecond, marketDataDepth);
    } finally {
        publication.close();
        aeron.close();
        System.out.println("Shutdown " + AeronPublisher.class.getSimpleName() + "...");
    }
}
 
开发者ID:terzerm,项目名称:fx-highway,代码行数:29,代码来源:AeronPublisher.java


示例13: BenchServer

import io.aeron.Aeron; //导入依赖的package包/类
public BenchServer() {
  running = new AtomicBoolean(true);
  SigInt.register(() -> running.set(false));
  driver = EMBEDDED_MEDIA_DRIVER ? MediaDriver.launchEmbedded() : null;
  ctx = new Aeron.Context();
  if (EMBEDDED_MEDIA_DRIVER) {
    ctx.aeronDirectoryName(driver.aeronDirectoryName());
  }
  fragmentHandler = new FragmentAssembler(this::onMessage);
  aeron = Aeron.connect(ctx);
  publication = aeron.addPublication(REP_CHAN, REP_STREAM_ID);
  subscription = aeron.addSubscription(REQ_CHAN, REQ_STREAM_ID);
}
 
开发者ID:benalexau,项目名称:rpc-bench,代码行数:14,代码来源:BenchServer.java


示例14: BenchClient

import io.aeron.Aeron; //导入依赖的package包/类
public BenchClient() {
  driver = EMBEDDED_MEDIA_DRIVER ? MediaDriver.launchEmbedded() : null;
  ctx = new Aeron.Context().availableImageHandler(this::imageHandler);
  if (EMBEDDED_MEDIA_DRIVER) {
    ctx.aeronDirectoryName(driver.aeronDirectoryName());
  }
  fragmentHandler = new FragmentAssembler(this::onMessage);
  aeron = Aeron.connect(ctx);
  publication = aeron.addPublication(REQ_CHAN, REQ_STREAM_ID);
  subscription = aeron.addSubscription(REP_CHAN, REP_STREAM_ID);
}
 
开发者ID:benalexau,项目名称:rpc-bench,代码行数:12,代码来源:BenchClient.java


示例15: solo

import io.aeron.Aeron; //导入依赖的package包/类
public static SoloStreams solo(
    final Aeron aeron,
    final String aeronChannel,
    final boolean printAeronStreamIdentifiers)
{
    return new SoloStreams(aeron, aeronChannel, printAeronStreamIdentifiers);
}
 
开发者ID:real-logic,项目名称:artio,代码行数:8,代码来源:ClusterableStreams.java


示例16: SoloContext

import io.aeron.Aeron; //导入依赖的package包/类
SoloContext(
    final EngineConfiguration configuration,
    final ErrorHandler errorHandler,
    final ExclusivePublication replayPublication,
    final FixCounters fixCounters,
    final Aeron aeron)
{
    super(configuration, errorHandler, fixCounters, aeron);
    try
    {
        this.replayPublication = replayPublication;

        final String channel = configuration.libraryAeronChannel();
        this.inboundStreamId = new StreamIdentifier(channel, INBOUND_LIBRARY_STREAM);
        this.outboundStreamId = new StreamIdentifier(channel, OUTBOUND_LIBRARY_STREAM);

        node = newNode();
        newStreams(node);
        newArchival();
        newArchivingAgent();
    }
    catch (final Exception e)
    {
        completeDuringStartup();

        suppressingClose(this, e);

        throw e;
    }
}
 
开发者ID:real-logic,项目名称:artio,代码行数:31,代码来源:SoloContext.java


示例17: configure

import io.aeron.Aeron; //导入依赖的package包/类
public void configure(final Aeron.Context aeronContext)
{
    aeronContext.useConductorAgentInvoker(true);

    if (driverAgentInvoker != null)
    {
        aeronContext.driverAgentInvoker(driverAgentInvoker);
    }
}
 
开发者ID:real-logic,项目名称:artio,代码行数:10,代码来源:LowResourceEngineScheduler.java


示例18: node

import io.aeron.Aeron; //导入依赖的package包/类
private ClusterAgent node(
    final EngineConfiguration configuration,
    final FixCounters fixCounters,
    final Aeron aeron,
    final String clusterAeronChannel,
    final EngineDescriptorStore engineDescriptorStore)
{
    final int cacheNumSets = configuration.loggerCacheNumSets();
    final int cacheSetSize = configuration.loggerCacheSetSize();
    final String logFileDir = configuration.logFileDir();

    final Archiver archiver = new Archiver(
        newArchiveMetaData(logFileDir), cacheNumSets, cacheSetSize, dataStream, configuration.agentNamePrefix(),
        outboundClusterCompletionPosition());

    final ClusterConfiguration clusterConfiguration = new ClusterConfiguration()
        .nodeId(configuration.nodeId())
        .otherNodes(configuration.otherNodes())
        .timeoutIntervalInMs(configuration.clusterTimeoutIntervalInMs())
        .idleStrategy(configuration.framerIdleStrategy())
        .archiver(archiver)
        .archiveReaderSupplier(() -> archiveReader(dataStream))
        .failCounter(fixCounters.failedRaftPublications())
        .maxClaimAttempts(configuration.inboundMaxClaimAttempts())
        .copyTo(inboundPublication)
        .aeronChannel(clusterAeronChannel)
        .aeron(aeron)
        .nodeState(EngineDescriptorFactory.make(configuration.libraryAeronChannel()))
        .nodeStateHandler(engineDescriptorStore)
        .nodeHandler(configuration.roleHandler())
        .agentNamePrefix(configuration.agentNamePrefix())
        .printAeronStreamIdentifiers(configuration.printAeronStreamIdentifiers());

    return new ClusterAgent(clusterConfiguration, System.currentTimeMillis());
}
 
开发者ID:real-logic,项目名称:artio,代码行数:36,代码来源:ClusterContext.java


示例19: of

import io.aeron.Aeron; //导入依赖的package包/类
public static EngineContext of(
    final EngineConfiguration configuration,
    final ErrorHandler errorHandler,
    final ExclusivePublication replayPublication,
    final FixCounters fixCounters,
    final Aeron aeron,
    final EngineDescriptorStore engineDescriptorStore)
{
    if (configuration.isClustered())
    {
        if (!configuration.logInboundMessages() || !configuration.logOutboundMessages())
        {
            throw new IllegalArgumentException(
                "If you are enabling clustering, then you must enable both inbound and outbound logging");
        }

        return new ClusterContext(
            configuration,
            errorHandler,
            replayPublication,
            fixCounters,
            aeron,
            engineDescriptorStore);
    }
    else
    {
        return new SoloContext(
            configuration,
            errorHandler,
            replayPublication,
            fixCounters,
            aeron);
    }
}
 
开发者ID:real-logic,项目名称:artio,代码行数:35,代码来源:EngineContext.java


示例20: EngineContext

import io.aeron.Aeron; //导入依赖的package包/类
public EngineContext(
    final EngineConfiguration configuration,
    final ErrorHandler errorHandler,
    final FixCounters fixCounters,
    final Aeron aeron)
{
    this.configuration = configuration;
    this.errorHandler = errorHandler;
    this.fixCounters = fixCounters;
    this.aeron = aeron;
    this.nanoClock = configuration.nanoClock();

    try
    {
        sentSequenceNumberIndex = new SequenceNumberIndexWriter(
            configuration.sentSequenceNumberBuffer(),
            configuration.sentSequenceNumberIndex(),
            errorHandler,
            OUTBOUND_LIBRARY_STREAM);
        receivedSequenceNumberIndex = new SequenceNumberIndexWriter(
            configuration.receivedSequenceNumberBuffer(),
            configuration.receivedSequenceNumberIndex(),
            errorHandler,
            INBOUND_LIBRARY_STREAM);
    }
    catch (final Exception e)
    {
        suppressingClose(this, e);

        throw e;
    }
}
 
开发者ID:real-logic,项目名称:artio,代码行数:33,代码来源:EngineContext.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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