Package org.nuxeo.lib.stream.log.mem
Class MemLogTailer<M extends Externalizable>
java.lang.Object
org.nuxeo.lib.stream.log.mem.MemLogTailer<M>
- All Implemented Interfaces:
AutoCloseable
,LogTailer<M>
Memory implementation of LogTailer.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionMemLogTailer
(MemLog log, LogPartition partition, Name group, Codec<M> codec) -
Method Summary
Modifier and TypeMethodDescriptionReturns the list of Log name, partitions tuples currently assigned to this tailer.protected void
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()
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.toString()
-
Field Details
-
POLL_INTERVAL_MS
protected static final long POLL_INTERVAL_MS- See Also:
-
-
Constructor Details
-
MemLogTailer
-
-
Method Details
-
checkInitialized
protected void checkInitialized() -
read
Description copied from interface:LogTailer
Read a message from assigned partitions within the timeout.- Specified by:
read
in interfaceLogTailer<M extends Externalizable>
- Returns:
- null if there is no message in the queue after the timeout.
- Throws:
InterruptedException
-
read
-
commit
Description copied from interface:LogTailer
Commit current position for the partition.- Specified by:
commit
in interfaceLogTailer<M extends Externalizable>
- Returns:
- the committed offset, can return null if there was no previous read done on this partition.
-
commit
public void commit()Description copied from interface:LogTailer
Commit current positions for all partitions (last message offset returned by read).- Specified by:
commit
in interfaceLogTailer<M extends Externalizable>
-
toEnd
public void toEnd()Description copied from interface:LogTailer
Set the current positions to the end of all partitions.- Specified by:
toEnd
in interfaceLogTailer<M extends Externalizable>
-
toStart
public void toStart()Description copied from interface:LogTailer
Set the current positions to the beginning of all partitions.- Specified by:
toStart
in interfaceLogTailer<M extends Externalizable>
-
toLastCommitted
public void toLastCommitted()Description copied from interface:LogTailer
Set the current positions to previously committed positions.- Specified by:
toLastCommitted
in interfaceLogTailer<M extends Externalizable>
-
seek
Description copied from interface:LogTailer
Set the current position for a single partition. Do not change other partitions positions.- Specified by:
seek
in interfaceLogTailer<M extends Externalizable>
-
reset
public void reset()Description copied from interface:LogTailer
Reset all committed positions for this group, next read will be done from beginning.- Specified by:
reset
in interfaceLogTailer<M extends Externalizable>
-
reset
Description copied from interface:LogTailer
Reset the committed position for this group on this partition, next read for this partition will be done from the beginning.- Specified by:
reset
in interfaceLogTailer<M extends Externalizable>
-
offsetForTimestamp
Description copied from interface:LogTailer
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.
- Specified by:
offsetForTimestamp
in interfaceLogTailer<M extends Externalizable>
-
assignments
Description copied from interface:LogTailer
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>)
.- Specified by:
assignments
in interfaceLogTailer<M extends Externalizable>
-
group
Description copied from interface:LogTailer
Returns the consumer group.- Specified by:
group
in interfaceLogTailer<M extends Externalizable>
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceLogTailer<M extends Externalizable>
-
closed
public boolean closed()Description copied from interface:LogTailer
Returnstrue
if the tailer has been closed.- Specified by:
closed
in interfaceLogTailer<M extends Externalizable>
-
getCodec
Description copied from interface:LogTailer
Returns the codec used to read the records. A null codec is the default legacy encoding.- Specified by:
getCodec
in interfaceLogTailer<M extends Externalizable>
-
toString
-