public class KafkaLogTailer<M extends Externalizable> extends Object implements LogTailer<M>, org.apache.kafka.clients.consumer.ConsumerRebalanceListener
Modifier and Type | Field and Description |
---|---|
protected boolean |
closed |
protected Codec<M> |
codec |
protected org.apache.kafka.clients.consumer.KafkaConsumer<String,org.apache.kafka.common.utils.Bytes> |
consumer |
protected static AtomicInteger |
CONSUMER_CLIENT_ID_SEQUENCE |
protected boolean |
consumerMoved |
protected Codec<M> |
decodeCodec |
protected String |
group |
protected String |
id |
protected boolean |
isRebalanced |
protected Map<org.apache.kafka.common.TopicPartition,Long> |
lastCommittedOffsets |
protected Map<org.apache.kafka.common.TopicPartition,Long> |
lastOffsets |
protected RebalanceListener |
listener |
protected Collection<String> |
names |
protected KafkaNamespace |
ns |
protected Collection<LogPartition> |
partitions |
protected Queue<org.apache.kafka.clients.consumer.ConsumerRecord<String,org.apache.kafka.common.utils.Bytes>> |
records |
protected Collection<org.apache.kafka.common.TopicPartition> |
topicPartitions |
Modifier | Constructor and Description |
---|---|
protected |
KafkaLogTailer(Codec<M> codec,
KafkaNamespace ns,
String group,
Properties consumerProps) |
Modifier and Type | Method and Description |
---|---|
Collection<LogPartition> |
assignments()
Returns the list of Log name, partitions tuples currently assigned to this tailer.
|
protected static String |
buildId(String group,
Collection<LogPartition> partitions) |
protected static String |
buildSubscribeId(String group,
Collection<String> names) |
void |
close() |
boolean |
closed()
Returns
true 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.
|
static <M extends Externalizable> |
createAndAssign(Codec<M> codec,
KafkaNamespace ns,
Collection<LogPartition> partitions,
String group,
Properties consumerProps) |
static <M extends Externalizable> |
createAndSubscribe(Codec<M> codec,
KafkaNamespace ns,
Collection<String> names,
String group,
Properties consumerProps,
RebalanceListener listener) |
protected void |
forceCommit()
Commits the consumer at its current position regardless of lastOffsets or lastCommittedOffsets
|
Codec<M> |
getCodec()
Returns the codec used to read the records.
|
String |
group()
Returns the consumer group.
|
LogOffset |
offsetForTimestamp(LogPartition partition,
long timestamp)
Look up the offset for the given partition by timestamp.
|
void |
onPartitionsAssigned(Collection<org.apache.kafka.common.TopicPartition> newPartitions) |
void |
onPartitionsRevoked(Collection<org.apache.kafka.common.TopicPartition> partitions) |
protected int |
poll(Duration timeout) |
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.
|
protected long |
toLastCommitted(org.apache.kafka.common.TopicPartition topicPartition) |
void |
toStart()
Set the current positions to the beginning of all partitions.
|
String |
toString() |
protected final Map<org.apache.kafka.common.TopicPartition,Long> lastOffsets
protected final Map<org.apache.kafka.common.TopicPartition,Long> lastCommittedOffsets
protected final Queue<org.apache.kafka.clients.consumer.ConsumerRecord<String,org.apache.kafka.common.utils.Bytes>> records
protected final KafkaNamespace ns
protected final Codec<M extends Externalizable> codec
protected final Codec<M extends Externalizable> decodeCodec
protected org.apache.kafka.clients.consumer.KafkaConsumer<String,org.apache.kafka.common.utils.Bytes> consumer
protected Collection<org.apache.kafka.common.TopicPartition> topicPartitions
protected Collection<LogPartition> partitions
protected boolean closed
protected Collection<String> names
protected RebalanceListener listener
protected boolean isRebalanced
protected boolean consumerMoved
protected static final AtomicInteger CONSUMER_CLIENT_ID_SEQUENCE
protected KafkaLogTailer(Codec<M> codec, KafkaNamespace ns, String group, Properties consumerProps)
public static <M extends Externalizable> KafkaLogTailer<M> createAndAssign(Codec<M> codec, KafkaNamespace ns, Collection<LogPartition> partitions, String group, Properties consumerProps)
public static <M extends Externalizable> KafkaLogTailer<M> createAndSubscribe(Codec<M> codec, KafkaNamespace ns, Collection<String> names, String group, Properties consumerProps, RebalanceListener listener)
protected static String buildId(String group, Collection<LogPartition> partitions)
protected static String buildSubscribeId(String group, Collection<String> names)
public LogRecord<M> read(Duration timeout) throws InterruptedException
LogTailer
read
in interface LogTailer<M extends Externalizable>
InterruptedException
protected int poll(Duration timeout) throws InterruptedException
InterruptedException
public void toEnd()
LogTailer
toEnd
in interface LogTailer<M extends Externalizable>
public void toStart()
LogTailer
toStart
in interface LogTailer<M extends Externalizable>
public void toLastCommitted()
LogTailer
toLastCommitted
in interface LogTailer<M extends Externalizable>
protected long toLastCommitted(org.apache.kafka.common.TopicPartition topicPartition)
public void seek(LogOffset offset)
LogTailer
seek
in interface LogTailer<M extends Externalizable>
public void reset()
LogTailer
reset
in interface LogTailer<M extends Externalizable>
public void reset(LogPartition partition)
LogTailer
reset
in interface LogTailer<M extends Externalizable>
public LogOffset offsetForTimestamp(LogPartition partition, long timestamp)
LogTailer
offsetForTimestamp
in interface LogTailer<M extends Externalizable>
public void commit()
LogTailer
commit
in interface LogTailer<M extends Externalizable>
protected void forceCommit()
public LogOffset commit(LogPartition partition)
LogTailer
commit
in interface LogTailer<M extends Externalizable>
public Collection<LogPartition> assignments()
LogTailer
LogManager.subscribe(java.lang.String, java.util.Collection<java.lang.String>, org.nuxeo.lib.stream.log.RebalanceListener, org.nuxeo.lib.stream.codec.Codec<M>)
.assignments
in interface LogTailer<M extends Externalizable>
public String group()
LogTailer
group
in interface LogTailer<M extends Externalizable>
public boolean closed()
LogTailer
true
if the tailer has been closed.closed
in interface LogTailer<M extends Externalizable>
public Codec<M> getCodec()
LogTailer
getCodec
in interface LogTailer<M extends Externalizable>
public void close()
close
in interface AutoCloseable
close
in interface LogTailer<M extends Externalizable>
public void onPartitionsRevoked(Collection<org.apache.kafka.common.TopicPartition> partitions)
onPartitionsRevoked
in interface org.apache.kafka.clients.consumer.ConsumerRebalanceListener
public void onPartitionsAssigned(Collection<org.apache.kafka.common.TopicPartition> newPartitions)
onPartitionsAssigned
in interface org.apache.kafka.clients.consumer.ConsumerRebalanceListener
Copyright © 2018 Nuxeo. All rights reserved.