public class KafkaLogAppender<M extends Externalizable> extends Object implements CloseableLogAppender<M>
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
closed |
protected Codec<M> |
codec |
protected Properties |
consumerProps |
protected Codec<M> |
encodingCodec |
protected String |
name |
protected KafkaNamespace |
ns |
protected org.apache.kafka.clients.producer.KafkaProducer<String,org.apache.kafka.common.utils.Bytes> |
producer |
protected Properties |
producerProps |
protected int |
size |
protected ConcurrentLinkedQueue<KafkaLogTailer<M>> |
tailers |
protected String |
topic |
| Modifier and Type | Method and Description |
|---|---|
LogOffset |
append(int partition,
M message)
Append a message into a partition, returns
LogOffset position of the message. |
LogOffset |
append(int partition,
String key,
M message) |
LogOffset |
append(String key,
M message)
Same as
LogAppender.append(int, Externalizable), the queue is chosen using a hash of . |
void |
close() |
boolean |
closed()
Returns
true if the appender has been closed by the manager. |
Codec<M> |
getCodec()
Returns the codec used to write record.
|
String |
getTopic() |
protected boolean |
isProcessed(String group,
org.apache.kafka.common.TopicPartition topicPartition,
long offset) |
String |
name()
Returns the Log's name.
|
static <M extends Externalizable> |
open(Codec<M> codec,
KafkaNamespace ns,
String name,
Properties producerProperties,
Properties consumerProperties) |
int |
size()
Returns the number of partitions in the Log.
|
String |
toString() |
boolean |
waitFor(LogOffset offset,
String group,
Duration timeout)
Wait for consumer to process a message up to the offset.
|
protected final Properties consumerProps
protected final Properties producerProps
protected final int size
protected final ConcurrentLinkedQueue<KafkaLogTailer<M extends Externalizable>> tailers
protected final KafkaNamespace ns
protected final Codec<M extends Externalizable> codec
protected final Codec<M extends Externalizable> encodingCodec
protected org.apache.kafka.clients.producer.KafkaProducer<String,org.apache.kafka.common.utils.Bytes> producer
protected boolean closed
public static <M extends Externalizable> KafkaLogAppender<M> open(Codec<M> codec, KafkaNamespace ns, String name, Properties producerProperties, Properties consumerProperties)
public String name()
LogAppendername in interface LogAppender<M extends Externalizable>public int size()
LogAppendersize in interface LogAppender<M extends Externalizable>public LogOffset append(String key, M message)
LogAppenderLogAppender.append(int, Externalizable), the queue is chosen using a hash of .append in interface LogAppender<M extends Externalizable>public LogOffset append(int partition, M message)
LogAppenderLogOffset position of the message. This method is thread safe,
a queue can be shared by multiple producers.append in interface LogAppender<M extends Externalizable>partition - index lower than LogAppender.size()public boolean waitFor(LogOffset offset, String group, Duration timeout) throws InterruptedException
LogAppendertrue if the message has been consumed, false in case
of timeout.waitFor in interface LogAppender<M extends Externalizable>InterruptedExceptionpublic boolean closed()
LogAppendertrue if the appender has been closed by the manager.closed in interface LogAppender<M extends Externalizable>public Codec<M> getCodec()
LogAppendergetCodec in interface LogAppender<M extends Externalizable>protected boolean isProcessed(String group, org.apache.kafka.common.TopicPartition topicPartition, long offset)
public void close()
close in interface AutoCloseableclose in interface CloseableLogAppender<M extends Externalizable>Copyright © 2018 Nuxeo. All rights reserved.