Package org.nuxeo.lib.stream.log
Interface LogTailer<M extends Externalizable>
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
KafkaLogTailer
,MemCompoundLogTailer
,MemLogTailer
Sequential reader for a partition or multiple partitions. A tailer is not thread safe and should not be shared by
multiple threads.
-
Method Summary
Modifier and TypeMethodDescriptionReturns 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).commit
(LogPartition partition) Commit current position for the partition.getCodec()
Returns the codec used to read the records.group()
Returns the consumer group.offsetForTimestamp
(LogPartition partition, long timestamp) Look up the offset for the given partition by timestamp.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
Set the current position for a single partition.void
toEnd()
Set the current positions to the end of all partitions.void
Set the current positions to previously committed positions.void
toStart()
Set the current positions to the beginning of all partitions.
-
Method Details
-
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
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
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
Set the current position for a single partition. Do not change other partitions positions.- Since:
- 9.3
-
offsetForTimestamp
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
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. -
getCodec
Returns the codec used to read the records. A null codec is the default legacy encoding.- Since:
- 10.2
-