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 org.apache.kafka.clients.consumer.KafkaConsumer<String,org.apache.kafka.common.utils.Bytes> |
consumer |
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 Collection<LogPartition> |
partitions |
protected String |
prefix |
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(String prefix,
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(String prefix,
Collection<LogPartition> partitions,
String group,
Properties consumerProps) |
static <M extends Externalizable> |
createAndSubscribe(String prefix,
Collection<String> names,
String group,
Properties consumerProps,
RebalanceListener listener) |
protected String |
getNameForTopic(String topic) |
String |
group()
Returns the consumer group.
|
protected M |
messageOf(org.apache.kafka.common.utils.Bytes value) |
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 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 KafkaLogTailer(String prefix, String group, Properties consumerProps)
public static <M extends Externalizable> KafkaLogTailer<M> createAndAssign(String prefix, Collection<LogPartition> partitions, String group, Properties consumerProps)
public static <M extends Externalizable> KafkaLogTailer<M> createAndSubscribe(String prefix, 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 String getNameForTopic(String topic)
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 void commit()
LogTailer
commit
in interface LogTailer<M extends Externalizable>
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)
.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 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.