Package org.nuxeo.lib.stream.log.kafka
Class KafkaLogAppender<M extends Externalizable>
java.lang.Object
org.nuxeo.lib.stream.log.kafka.KafkaLogAppender<M>
- All Implemented Interfaces:
AutoCloseable
,CloseableLogAppender<M>
,LogAppender<M>
public class KafkaLogAppender<M extends Externalizable>
extends Object
implements CloseableLogAppender<M>
Apache Kafka implementation of Log.
- Since:
- 9.3
-
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
protected final Properties
protected final Name
protected org.apache.kafka.clients.producer.KafkaProducer<String,
org.apache.kafka.common.utils.Bytes> protected static final AtomicInteger
protected final Properties
protected final NameResolver
protected final int
protected final ConcurrentLinkedQueue<KafkaLogTailer<M>>
protected final String
-
Method Summary
Modifier and TypeMethodDescriptionAppend a message into a partition, returnsLogOffset
position of the message.Same asLogAppender.append(int, Externalizable)
, the queue is chosen using a hash of parameters "key".void
close()
boolean
closed()
Returnstrue
if the appender has been closed by the manager.getCodec()
Returns the codec used to write record.getTopic()
protected boolean
isProcessed
(Name group, org.apache.kafka.common.TopicPartition topicPartition, long offset) name()
Returns the Log's name.static <M extends Externalizable>
KafkaLogAppender<M>open
(Codec<M> codec, NameResolver resolver, Name name, Properties producerProperties, Properties consumerProperties) int
size()
Returns the number of partitions in the Log.toString()
boolean
Wait for consumer to process a message up to the offset.
-
Field Details
-
topic
-
consumerProps
-
producerProps
-
size
protected final int size -
tailers
-
name
-
codec
-
encodingCodec
-
resolver
-
producer
protected org.apache.kafka.clients.producer.KafkaProducer<String,org.apache.kafka.common.utils.Bytes> producer -
closed
protected boolean closed -
PRODUCER_CLIENT_ID_SEQUENCE
-
-
Method Details
-
open
public static <M extends Externalizable> KafkaLogAppender<M> open(Codec<M> codec, NameResolver resolver, Name name, Properties producerProperties, Properties consumerProperties) -
name
Description copied from interface:LogAppender
Returns the Log's name.- Specified by:
name
in interfaceLogAppender<M extends Externalizable>
-
getTopic
-
size
public int size()Description copied from interface:LogAppender
Returns the number of partitions in the Log.- Specified by:
size
in interfaceLogAppender<M extends Externalizable>
-
append
Description copied from interface:LogAppender
Same asLogAppender.append(int, Externalizable)
, the queue is chosen using a hash of parameters "key".- Specified by:
append
in interfaceLogAppender<M extends Externalizable>
-
append
Description copied from interface:LogAppender
Append a message into a partition, returnsLogOffset
position of the message. This method is thread safe, a queue can be shared by multiple producers.- Specified by:
append
in interfaceLogAppender<M extends Externalizable>
- Parameters:
partition
- index lower thanLogAppender.size()
-
append
-
waitFor
Description copied from interface:LogAppender
Wait for consumer to process a message up to the offset. The message is processed if a consumer of the group commits a greater or equals offset. Returntrue
if the message has been consumed,false
in case of timeout.- Specified by:
waitFor
in interfaceLogAppender<M extends Externalizable>
- Throws:
InterruptedException
-
closed
public boolean closed()Description copied from interface:LogAppender
Returnstrue
if the appender has been closed by the manager.- Specified by:
closed
in interfaceLogAppender<M extends Externalizable>
-
toString
-
getCodec
Description copied from interface:LogAppender
Returns the codec used to write record. A null codec is the default legacy encoding.- Specified by:
getCodec
in interfaceLogAppender<M extends Externalizable>
-
isProcessed
protected boolean isProcessed(Name group, org.apache.kafka.common.TopicPartition topicPartition, long offset) -
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseableLogAppender<M extends Externalizable>
-