我看不到在哪里执行方法Aeron低延迟库

问题描述 投票:1回答:1

早上好,

我试图理解低延迟库aeron,我有一个类Publication的实例:

Publication publication=new Publication(CHANNEL, STREAM_ID);

位置:

CHANNEL=System.getProperty("aeron.sample.channel", "aeron:udp?endpoint=224.0.1.1:40456");

STREAM_ID=Integer.getInteger("aeron.sample.streamId", 10);

创建实例后,发送消息的作用是:

String a="What I want to send"; //Text that I want to send
bytes[] aBytes=a.getBytes(); // Convert the string to an array of bytes
UnsafeBuffer BUFFER = new UnsafeBuffer(BufferUtil.allocateDirectAligned(256, 64)); //Create an UnsafeBuffer (https://github.com/real-logic/agrona/blob/master/agrona/src/main/java/org/agrona/concurrent/UnsafeBuffer.java)
BUFFER.putBytes(0, aBytes); //Put the Bytes of the array of bytes that contains the text intro tje BUFFER
final long result = publication.offer(BUFFER, 0, messageBytes.length); //This is the last line of the code to send the message, so I guess that this line is used to send the message to the mediaDriver.

我想了解代码的最后一行是如何工作的,方法offer()位于以下文件中:https://github.com/real-logic/aeron/blob/master/aeron-client/src/main/java/io/aeron/Publication.java

在第373行,有以下方法:

 public final long offer(final DirectBuffer buffer, final int offset, final int length)
 {
     return offer(buffer, offset, length, null);
 }

这返回一个函数,如果我在Publication.java文件中搜索此函数,则只会发现以下内容:

public abstract long offer(DirectBuffer buffer, int offset, int length, ReservedValueSupplier reservedValueSupplier);

这是一种抽象方法,我不知道在哪里可以找到它的定义。

如果有人可以帮助我,我将不胜感激,以了解该库的工作原理。

java low-latency aeron
1个回答
1
投票

我敢打赌,您已经找到了所有答案,但以防将来的搜索者使用:

[发布类有2种实现:

我可以推荐观看Martin关于Aeron工作原理的视频https://www.youtube.com/watch?v=tM4YskS94b0

© www.soinside.com 2019 - 2024. All rights reserved.