当前位置: 首页>>代码示例>>Java>>正文


Java Aeron类代码示例

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


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


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