本文整理汇总了Java中io.aeron.Subscription类的典型用法代码示例。如果您正苦于以下问题:Java Subscription类的具体用法?Java Subscription怎么用?Java Subscription使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Subscription类属于io.aeron包,在下文中一共展示了Subscription类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: main
import io.aeron.Subscription; //导入依赖的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: ClusterSubscription
import io.aeron.Subscription; //导入依赖的package包/类
ClusterSubscription(
final Subscription dataSubscription,
final int clusterStreamId,
final Subscription controlSubscription,
final ArchiveReader archiveReader)
{
this.controlSubscription = controlSubscription;
this.archiveReader = archiveReader;
// We use clusterStreamId as a reserved value filter
if (clusterStreamId == NO_FILTER)
{
throw new IllegalArgumentException("ClusterStreamId must not be 0");
}
this.dataSubscription = dataSubscription;
messageFilter = new MessageFilter(clusterStreamId);
clusterHeader = new ClusterHeader(clusterStreamId);
}
开发者ID:real-logic,项目名称:artio,代码行数:19,代码来源:ClusterSubscription.java
示例3: initialiseRoles
import io.aeron.Subscription; //导入依赖的package包/类
void initialiseRoles(final Leader leader, final Candidate candidate, final Follower follower)
{
final RaftPublication acknowledgementPublication = raftPublication(
configuration.acknowledgementStream(), "acknowledgementPublication");
final StreamIdentifier controlStream = configuration.controlStream();
final RaftPublication controlPublication = raftPublication(controlStream, "controlStream");
final Subscription controlSubscription = controlSubscription();
leader
.controlPublication(controlPublication)
.controlSubscription(controlSubscription);
candidate
.controlPublication(controlPublication)
.controlSubscription(controlSubscription);
follower
.controlPublication(controlPublication)
.acknowledgementPublication(acknowledgementPublication)
.controlSubscription(controlSubscription);
}
开发者ID:real-logic,项目名称:artio,代码行数:22,代码来源:RaftTransport.java
示例4: replayImage
import io.aeron.Subscription; //导入依赖的package包/类
private Image replayImage(final String name, final int replaySessionId)
{
final Subscription subscription = aeron.addSubscription(
IPC_CHANNEL, OUTBOUND_REPLAY_STREAM);
StreamInformation.print(name, subscription, configuration);
// Await replay publication
while (true)
{
final Image image = subscription.imageBySessionId(replaySessionId);
if (image != null)
{
return image;
}
invokeAeronConductor();
Thread.yield();
}
}
开发者ID:real-logic,项目名称:artio,代码行数:21,代码来源:FixEngine.java
示例5: awaitResponse
import io.aeron.Subscription; //导入依赖的package包/类
static void awaitResponse(final Subscription controlResponse, final long expectedCorrelationId)
{
final ControlResponseAdapter controlResponseAdapter = new ControlResponseAdapter(
new FailControlResponseListener()
{
public void onResponse(
final long controlSessionId,
final long correlationId,
final long relevantId,
final ControlResponseCode code,
final String errorMessage)
{
if (correlationId != expectedCorrelationId)
{
throw new IllegalStateException(
"expected=" + expectedCorrelationId + " actual=" + correlationId);
}
}
},
controlResponse,
1
);
await(() -> controlResponseAdapter.poll() != 0);
}
开发者ID:real-logic,项目名称:aeron,代码行数:26,代码来源:TestUtil.java
示例6: mockImage
import io.aeron.Subscription; //导入依赖的package包/类
private Image mockImage(
final int sessionId,
final int initialTermId,
final String sourceIdentity,
final int termBufferLength,
final Subscription subscription)
{
final Image image = mock(Image.class);
when(image.sessionId()).thenReturn(sessionId);
when(image.initialTermId()).thenReturn(initialTermId);
when(image.sourceIdentity()).thenReturn(sourceIdentity);
when(image.termBufferLength()).thenReturn(termBufferLength);
when(image.subscription()).thenReturn(subscription);
when(image.mtuLength()).thenReturn(MTU_LENGTH);
when(image.joinPosition()).thenReturn(START_POSITION);
return image;
}
开发者ID:real-logic,项目名称:aeron,代码行数:20,代码来源:RecordingSessionTest.java
示例7: runRecordingEventPoller
import io.aeron.Subscription; //导入依赖的package包/类
private void runRecordingEventPoller()
{
try (Subscription subscription = aeron.addSubscription(
AeronArchive.Configuration.recordingEventsChannel(),
AeronArchive.Configuration.recordingEventsStreamId()))
{
final IdleStrategy idleStrategy = new BackoffIdleStrategy(10, 100, 1, 1);
final RecordingEventsAdapter recordingEventsAdapter = new RecordingEventsAdapter(
this, subscription, FRAGMENT_COUNT_LIMIT);
while (isRunning)
{
idleStrategy.idle(recordingEventsAdapter.poll());
}
}
}
开发者ID:real-logic,项目名称:aeron,代码行数:17,代码来源:EmbeddedRecordingThroughput.java
示例8: startPong
import io.aeron.Subscription; //导入依赖的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
示例9: run
import io.aeron.Subscription; //导入依赖的package包/类
private static void run(final Subscription subscription, final long warmupCount, final long measuredCount) {
final NanoClock clock = new SystemNanoClock();
final Histogram histogram = new Histogram(1, 1000000000, 3);
final MutableMarketDataSnapshot snapshot = new MutableMarketDataSnapshot();
final UnsafeBuffer unsafeBuffer = new UnsafeBuffer(0, 0);
final AtomicLong t0 = new AtomicLong();
final AtomicLong t1 = new AtomicLong();
final AtomicLong t2 = new AtomicLong();
final long n = warmupCount + measuredCount;
final AtomicLong count = new AtomicLong();
final FragmentHandler fh = (buf, offset, len, header) -> {
if (count.get() == 0) t0.set(clock.nanoTime());
else if (count.get() == warmupCount-1) t1.set(clock.nanoTime());
else if (count.get() == n-1) t2.set(clock.nanoTime());
unsafeBuffer.wrap(buf, offset, len);
final MarketDataSnapshot decoded = SerializerHelper.decode(unsafeBuffer, snapshot.builder());
final long time = clock.nanoTime();
if (count.incrementAndGet() <= n) {
histogram.recordValue(time - decoded.getEventTimestamp());
}
if (count.get() == warmupCount) {
histogram.reset();
}
};
while (count.get() < n) {
subscription.poll(fh, 256);
}
final long c = count.get();
System.out.println((t2.get() - t0.get())/1000.0 + " us total receiving time (" + (t2.get() - t0.get())/(1000f*c) + " us/message, " + c/((t2.get()-t0.get())/1000000000f) + " messages/second)");
System.out.println();
HistogramPrinter.printHistogram(histogram);
}
开发者ID:terzerm,项目名称:fx-highway,代码行数:33,代码来源:AeronSubscriber.java
示例10: commandReceiver
import io.aeron.Subscription; //导入依赖的package包/类
public static AeronReceiver<Command> commandReceiver(final DirectFactory directFactory,
final Subscription subscription) {
return new AeronReceiver<>(subscription, new AeronHandler<Command>() {
@Override
protected Command message(DirectBuffer buffer, int offset, int length) {
return directFactory.command();
}
});
}
开发者ID:terzerm,项目名称:hover-raft,代码行数:10,代码来源:AeronReceiver.java
示例11: messageReceiver
import io.aeron.Subscription; //导入依赖的package包/类
public static AeronReceiver<Message> messageReceiver(final DirectFactory directFactory,
final Subscription subscription) {
return new AeronReceiver<>(subscription, new AeronHandler<Message>() {
@Override
protected Message message(DirectBuffer buffer, int offset, int length) {
final MessageType messageType = MessageType.readFrom(buffer, offset);
return messageType.create(directFactory);
}
});
}
开发者ID:terzerm,项目名称:hover-raft,代码行数:11,代码来源:AeronReceiver.java
示例12: injectLeaderSubscriptions
import io.aeron.Subscription; //导入依赖的package包/类
void injectLeaderSubscriptions(final Leader leader)
{
final StreamIdentifier data = configuration.dataStream();
final StreamIdentifier acknowledgement = configuration.acknowledgementStream();
final Subscription leaderAcknowledgementSubscription = subscription(
acknowledgement.channel(), acknowledgement.streamId(), "leaderAcknowledgementSubscription");
final Subscription leaderDataSubscription = subscription(
data.spyChannel(), data.streamId(), "leaderDataSubscription");
leader
.acknowledgementSubscription(leaderAcknowledgementSubscription)
// The leader uses a spy subscription in order to avoid reading its own data
.dataSubscription(leaderDataSubscription);
}
开发者ID:real-logic,项目名称:artio,代码行数:16,代码来源:RaftTransport.java
示例13: archiverSubscription
import io.aeron.Subscription; //导入依赖的package包/类
private void archiverSubscription(final Archiver archiver, final StreamIdentifier streamId)
{
final Subscription subscription = aeron.addSubscription(streamId.channel(), streamId.streamId());
StreamInformation.print("Archiver", subscription, configuration);
archiver.subscription(subscription);
}
开发者ID:real-logic,项目名称:artio,代码行数:8,代码来源:SoloContext.java
示例14: ClusterPositionSender
import io.aeron.Subscription; //导入依赖的package包/类
ClusterPositionSender(
final Subscription outboundLibrarySubscription,
final ClusterableSubscription outboundClusterSubscription,
final GatewayPublication inboundLibraryPublication,
final String agentNamePrefix)
{
this.outboundLibrarySubscription = outboundLibrarySubscription;
this.outboundClusterSubscription = outboundClusterSubscription;
this.inboundLibraryPublication = inboundLibraryPublication;
this.agentNamePrefix = agentNamePrefix;
}
开发者ID:real-logic,项目名称:artio,代码行数:12,代码来源:ClusterPositionSender.java
示例15: outboundLibrarySubscription
import io.aeron.Subscription; //导入依赖的package包/类
public Subscription outboundLibrarySubscription(
final String name, final UnavailableImageHandler unavailableImageHandler)
{
final Subscription subscription = aeron.addSubscription(
configuration.libraryAeronChannel(), OUTBOUND_LIBRARY_STREAM, null, unavailableImageHandler);
StreamInformation.print(name, subscription, configuration);
return subscription;
}
开发者ID:real-logic,项目名称:artio,代码行数:9,代码来源:EngineContext.java
示例16: print
import io.aeron.Subscription; //导入依赖的package包/类
public static void print(
final String name, final Subscription subscription, final boolean printAeronStreamIdentifiers)
{
if (printAeronStreamIdentifiers)
{
System.out.printf(
"%-40s - registrationId=%d,streamId=%d%n",
name,
subscription.registrationId(),
subscription.streamId());
}
}
开发者ID:real-logic,项目名称:artio,代码行数:13,代码来源:StreamInformation.java
示例17: follower
import io.aeron.Subscription; //导入依赖的package包/类
protected Follower follower(
final short id,
final ClusterAgent clusterNode,
final TermState termState)
{
final ArchiveMetaData metaData = archiveMetaData(id);
final Subscription subscription = dataSubscription();
final StreamIdentifier streamId = new StreamIdentifier(subscription);
final Archiver archiver = new Archiver(
metaData,
DEFAULT_LOGGER_CACHE_NUM_SETS,
DEFAULT_LOGGER_CACHE_SET_SIZE,
streamId,
DEFAULT_NAME_PREFIX,
mock(CompletionPosition.class))
.subscription(subscription);
return new Follower(
id,
clusterNode,
0,
TIMEOUT,
termState,
new RaftArchiver(termState.leaderSessionId(), archiver),
NODE_STATE_BUFFER,
nodeStateHandler)
.controlSubscription(controlSubscription())
.acknowledgementPublication(raftPublication(ClusterConfiguration.DEFAULT_ACKNOWLEDGEMENT_STREAM_ID))
.controlPublication(raftPublication(ClusterConfiguration.DEFAULT_CONTROL_STREAM_ID))
.follow(0);
}
开发者ID:real-logic,项目名称:artio,代码行数:32,代码来源:AbstractReplicationTest.java
示例18: ControlResponseAdapter
import io.aeron.Subscription; //导入依赖的package包/类
/**
* Create an adapter for a given subscription to an archive for control response messages.
*
* @param listener to which responses are dispatched.
* @param subscription to poll for new events.
* @param fragmentLimit to apply for each polling operation.
*/
public ControlResponseAdapter(
final ControlResponseListener listener,
final Subscription subscription,
final int fragmentLimit)
{
this.fragmentLimit = fragmentLimit;
this.listener = listener;
this.subscription = subscription;
}
开发者ID:real-logic,项目名称:aeron,代码行数:17,代码来源:ControlResponseAdapter.java
示例19: RecordingDescriptorPoller
import io.aeron.Subscription; //导入依赖的package包/类
/**
* Create a poller for a given subscription to an archive for control response messages.
*
* @param subscription to poll for new events.
* @param fragmentLimit to apply for each polling operation.
* @param controlSessionId to filter the responses.
*/
public RecordingDescriptorPoller(
final Subscription subscription, final int fragmentLimit, final long controlSessionId)
{
this.subscription = subscription;
this.fragmentLimit = fragmentLimit;
this.controlSessionId = controlSessionId;
}
开发者ID:real-logic,项目名称:aeron,代码行数:15,代码来源:RecordingDescriptorPoller.java
示例20: RecordingEventsAdapter
import io.aeron.Subscription; //导入依赖的package包/类
/**
* Create a poller for a given subscription to an archive for recording events.
*
* @param listener to which events are dispatched.
* @param subscription to poll for new events.
* @param fragmentLimit to apply for each polling operation.
*/
public RecordingEventsAdapter(
final RecordingEventsListener listener,
final Subscription subscription,
final int fragmentLimit)
{
this.fragmentLimit = fragmentLimit;
this.listener = listener;
this.subscription = subscription;
}
开发者ID:real-logic,项目名称:aeron,代码行数:17,代码来源:RecordingEventsAdapter.java
注:本文中的io.aeron.Subscription类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论