@Override public Iterator<DirectBuffer> iterator() { iterator.reset(); return iterator; }
/** * 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); }
protected void openDefaultSubscriptions() { final int subscriptionSize = defaultSubscriptionNames == null ? 0 : defaultSubscriptionNames.length; for (int i = 0; i < subscriptionSize; i++) { doOpenSubscription(defaultSubscriptionNames[i], dataConsumed); } }
/** * 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); }
@Override public int poll(int maxCount) { return subscription.poll(fragmentHandler, maxCount); } }
public long getCurrentAppenderPosition() { return writeBufferSubscription.getPosition(); } }
public long getPublisherLimit() { if (isClosed) { return -1L; } else { return publisherLimit.get(); } }
@Override public void removeConsumer(ActorCondition listener) { subscription.removeConsumer(listener); } }
@Override public boolean hasAvailable() { return subscription.hasAvailable(); }
/** Finish reading and consume the fragments (i.e. update the subscription position). */ public void markCompleted() { updatePosition(); }
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; }
/** * 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); }
@Override public int poll(int maxCount) { return subscription.poll(fragmentHandler, maxCount); } }
public long getPublisherLimit() { if (isClosed) { return -1L; } else { return publisherLimit.get(); } }
@Override public Iterator<DirectBuffer> iterator() { iterator.reset(); return iterator; }
protected void openDefaultSubscriptions() { final int subscriptionSize = defaultSubscriptionNames == null ? 0 : defaultSubscriptionNames.length; for (int i = 0; i < subscriptionSize; i++) { doOpenSubscription(defaultSubscriptionNames[i], dataConsumed); } }
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; }
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; } }
public long getPublisherPosition() { if (isClosed) { return -1L; } else { return publisherPosition.get(); } }
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; } }