/** * Claim a fragment of the buffer with the given length. Use {@link ClaimedFragment#getBuffer()} * to write the message and finish the operation using {@link ClaimedFragment#commit()} or {@link * ClaimedFragment#abort()}. Note that the claim operation can fail if the publisher limit or the * buffer partition size is reached. * * @return the new publisher position if the fragment was claimed successfully. Otherwise, the * return value is negative. */ public long claim(ClaimedFragment claim, int length) { return claim(claim, length, 0); }
/** * Creates a new subscription with the given name. * * @throws IllegalStateException * <li>if the dispatcher runs in pipeline-mode, * <li>if a subscription with this name already exists */ public Subscription openSubscription(String subscriptionName) { return FutureUtil.join(openSubscriptionAsync(subscriptionName)); }
@Override public void stop(ServiceStopContext ctx) { ctx.async(dispatcher.closeAsync()); }
/** * Writes the given part of the message to the buffer. This can fail if the publisher limit or the * buffer partition size is reached. * * @return the new publisher position if the message was written successfully. Otherwise, the * return value is negative. */ public long offer(DirectBuffer msg, int start, int length) { return offer(msg, start, length, 0); }
/** * Close the given subscription. * * @throws IllegalStateException if the dispatcher runs in pipeline-mode. */ public void closeSubscription(Subscription subscriptionToClose) { FutureUtil.join(closeSubscriptionAsync(subscriptionToClose)); }
new Dispatcher( logBuffer, logAppender, actorScheduler.getMetricsManager()); dispatcher.updatePublisherLimit(); // make subscription initially writable without waiting for
/** * Writes the given part of the message to the buffer. This can fail if the publisher limit or the * buffer partition size is reached. * * @return the new publisher position if the message was written successfully. Otherwise, the * return value is negative. */ public long offer(DirectBuffer msg, int start, int length) { return offer(msg, start, length, 0); }
/** * Close the given subscription. * * @throws IllegalStateException if the dispatcher runs in pipeline-mode. */ public void closeSubscription(Subscription subscriptionToClose) { FutureUtil.join(closeSubscriptionAsync(subscriptionToClose)); }
new Dispatcher( logBuffer, logAppender, actorScheduler.getMetricsManager()); dispatcher.updatePublisherLimit(); // make subscription initially writable without waiting for
private long claimBatchForEvents() { final int batchLength = eventLength + (eventCount * HEADER_BLOCK_LENGTH); long claimedPosition = -1; do { claimedPosition = logWriteBuffer.claim(claimedBatch, eventCount, batchLength); } while (claimedPosition == RESULT_PADDING_AT_END_OF_PARTITION); return claimedPosition; }
/** * Creates a new subscription with the given name. * * @throws IllegalStateException * <li>if the dispatcher runs in pipeline-mode, * <li>if a subscription with this name already exists */ public Subscription openSubscription(String subscriptionName) { return FutureUtil.join(openSubscriptionAsync(subscriptionName)); }
@Override public void close() { FutureUtil.join(closeAsync()); }
protected int onMessage(DirectBuffer buffer, int offset, int length, int streamId) { if (receiveBuffer == null) { return CONSUME_FRAGMENT_RESULT; } final long offerPosition = receiveBuffer.offer(buffer, offset, length, streamId); if (offerPosition < 0) { return POSTPONE_FRAGMENT_RESULT; } else { return CONSUME_FRAGMENT_RESULT; } }
@Override public void stop(ServiceStopContext stopContext) { final Dispatcher logBuffer = logWritebufferInjector.getValue(); stopContext.async(logBuffer.closeSubscriptionAsync(subscriptionFuture.join())); }
private long claimBatchForEvents() { final int batchLength = eventLength + (eventCount * HEADER_BLOCK_LENGTH); long claimedPosition = -1; do { claimedPosition = logWriteBuffer.claim(claimedBatch, eventCount, batchLength); } while (claimedPosition == RESULT_PADDING_AT_END_OF_PARTITION); return claimedPosition; }
@Override public void start(ServiceStartContext startContext) { final Dispatcher logBuffer = logWritebufferInjector.getValue(); subscriptionFuture = logBuffer.openSubscriptionAsync(subscriptionName); startContext.async(subscriptionFuture); }
@Override public void stop(ServiceStopContext ctx) { ctx.async(dispatcher.closeAsync()); }
protected int onMessage(DirectBuffer buffer, int offset, int length, int streamId) { if (receiveBuffer == null) { return CONSUME_FRAGMENT_RESULT; } final long offerPosition = receiveBuffer.offer(buffer, offset, length, streamId); if (offerPosition < 0) { return POSTPONE_FRAGMENT_RESULT; } else { return CONSUME_FRAGMENT_RESULT; } }
@Override public void stop(ServiceStopContext stopContext) { final Dispatcher logBuffer = logWritebufferInjector.getValue(); stopContext.async(logBuffer.closeSubscriptionAsync(subscriptionFuture.join())); }
/** * Claim a fragment of the buffer with the given length. Use {@link ClaimedFragment#getBuffer()} * to write the message and finish the operation using {@link ClaimedFragment#commit()} or {@link * ClaimedFragment#abort()}. Note that the claim operation can fail if the publisher limit or the * buffer partition size is reached. * * @return the new publisher position if the fragment was claimed successfully. Otherwise, the * return value is negative. */ public long claim(ClaimedFragment claim, int length) { return claim(claim, length, 0); }