Package org.nuxeo.lib.stream.log
Interface LogTailer<M extends Externalizable>
-
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
ChronicleCompoundLogTailer
,ChronicleLogTailer
,KafkaLogTailer
public interface LogTailer<M extends Externalizable> extends AutoCloseable
Sequential reader for a partition or multiple partitions. A tailer is not thread safe and should not be shared by multiple threads.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Collection<LogPartition>
assignments()
Returns the list of Log name, partitions tuples currently assigned to this tailer.void
close()
boolean
closed()
Returnstrue
if the tailer has been closed.void
commit()
Commit current positions for all partitions (last message offset returned by read).LogOffset
commit(LogPartition partition)
Commit current position for the partition.Codec<M>
getCodec()
Returns the codec used to read the records.Name
group()
Returns the consumer group.LogOffset
offsetForTimestamp(LogPartition partition, long timestamp)
Look up the offset for the given partition by timestamp.LogRecord<M>
read(Duration timeout)
Read a message from assigned partitions within the timeout.void
reset()
Reset all committed positions for this group, next read will be done from beginning.void
reset(LogPartition partition)
Reset the committed position for this group on this partition, next read for this partition will be done from the beginning.void
seek(LogOffset offset)
Set the current position for a single partition.void
toEnd()
Set the current positions to the end of all partitions.void
toLastCommitted()
Set the current positions to previously committed positions.void
toStart()
Set the current positions to the beginning of all partitions.
-
-
-
Method Detail
-
group
Name group()
Returns the consumer group.
-
assignments
Collection<LogPartition> assignments()
Returns the list of Log name, partitions tuples currently assigned to this tailer. Assignments can change only if the tailer has been created usingLogManager.subscribe(org.nuxeo.lib.stream.log.Name, java.util.Collection<org.nuxeo.lib.stream.log.Name>, org.nuxeo.lib.stream.log.RebalanceListener, org.nuxeo.lib.stream.codec.Codec<M>)
.
-
read
LogRecord<M> read(Duration timeout) throws InterruptedException
Read a message from assigned partitions within the timeout.- Returns:
- null if there is no message in the queue after the timeout.
- Throws:
RebalanceException
- if a partition rebalancing happen during the read, this is possible only when usingLogManager.subscribe(org.nuxeo.lib.stream.log.Name, java.util.Collection<org.nuxeo.lib.stream.log.Name>, org.nuxeo.lib.stream.log.RebalanceListener, org.nuxeo.lib.stream.codec.Codec<M>)
.IllegalArgumentException
- if the message cannot be decoded as M type.InterruptedException
-
commit
void commit()
Commit current positions for all partitions (last message offset returned by read).
-
commit
LogOffset commit(LogPartition partition)
Commit current position for the partition.- Returns:
- the committed offset, can return null if there was no previous read done on this partition.
-
toEnd
void toEnd()
Set the current positions to the end of all partitions.
-
toStart
void toStart()
Set the current positions to the beginning of all partitions.
-
toLastCommitted
void toLastCommitted()
Set the current positions to previously committed positions.
-
seek
void seek(LogOffset offset)
Set the current position for a single partition. Do not change other partitions positions.- Since:
- 9.3
-
offsetForTimestamp
LogOffset offsetForTimestamp(LogPartition partition, long timestamp)
Look up the offset for the given partition by timestamp. The position is the earliest offset whose timestamp is greater than or equal to the given timestamp.The timestamp used depends on the implementation, for Kafka this is the LogAppendTime. Returns null if no record offset is found with an appropriate timestamp.
- Since:
- 10.1
-
reset
void reset()
Reset all committed positions for this group, next read will be done from beginning.- Since:
- 9.3
-
reset
void reset(LogPartition partition)
Reset the committed position for this group on this partition, next read for this partition will be done from the beginning.- Since:
- 9.3
-
close
void close()
- Specified by:
close
in interfaceAutoCloseable
-
closed
boolean closed()
Returnstrue
if the tailer has been closed.
-
-