public class OffsetManager extends Object
Constructor and Description |
---|
OffsetManager(org.apache.kafka.common.TopicPartition tp,
long initialFetchOffset)
Creates a new OffsetManager.
|
Modifier and Type | Method and Description |
---|---|
void |
addToAckMsgs(KafkaSpoutMessageId msgId) |
void |
addToEmitMsgs(long offset) |
long |
commit(org.apache.kafka.clients.consumer.OffsetAndMetadata committedOffsetAndMeta)
Marks an offset as committed.
|
boolean |
contains(KafkaSpoutMessageId msgId) |
org.apache.kafka.clients.consumer.OffsetAndMetadata |
findNextCommitOffset(String commitMetadata)
An offset can only be committed when all emitted records with lower offset have been
acked.
|
long |
getCommittedOffset() |
long |
getLatestEmittedOffset() |
long |
getNthUncommittedOffsetAfterCommittedOffset(int index)
Gets the offset of the nth emitted message after the committed offset.
|
int |
getNumUncommittedOffsets() |
boolean |
hasCommitted()
Checks if this OffsetManager has committed to Kafka.
|
String |
toString() |
public OffsetManager(org.apache.kafka.common.TopicPartition tp, long initialFetchOffset)
tp
- The TopicPartitioninitialFetchOffset
- The initial fetch offset for the given TopicPartitionpublic void addToAckMsgs(KafkaSpoutMessageId msgId)
public void addToEmitMsgs(long offset)
public int getNumUncommittedOffsets()
public long getNthUncommittedOffsetAfterCommittedOffset(int index)
index
- The index of the message to get the offset forNoSuchElementException
- if the index is out of rangepublic org.apache.kafka.clients.consumer.OffsetAndMetadata findNextCommitOffset(String commitMetadata)
commitMetadata
- Metadata information to commit to Kafka. It is constant per KafkaSpout instance per topologypublic long commit(org.apache.kafka.clients.consumer.OffsetAndMetadata committedOffsetAndMeta)
findNextCommitOffset(String)
will return offsets greater than or equal to the
offset specified, if any.committedOffsetAndMeta
- The committed offset. All lower offsets are expected to have been committed.public boolean hasCommitted()
public boolean contains(KafkaSpoutMessageId msgId)
public long getLatestEmittedOffset()
public long getCommittedOffset()
Copyright © 2023 The Apache Software Foundation. All rights reserved.