public abstract class ConsumerLease extends Object implements Closeable, org.apache.kafka.clients.consumer.ConsumerRebalanceListener
| Modifier and Type | Class and Description |
|---|---|
private static class |
ConsumerLease.BundleInformation |
private static class |
ConsumerLease.BundleTracker |
| Modifier and Type | Field and Description |
|---|---|
private String |
bootstrapServers |
private Map<ConsumerLease.BundleInformation,ConsumerLease.BundleTracker> |
bundleMap |
private byte[] |
demarcatorBytes |
private Charset |
headerCharacterSet |
private Pattern |
headerNamePattern |
private org.apache.kafka.clients.consumer.Consumer<byte[],byte[]> |
kafkaConsumer |
private String |
keyEncoding |
private boolean |
lastPollEmpty |
private long |
leaseStartNanos |
private ComponentLog |
logger |
private long |
maxWaitMillis |
private boolean |
poisoned |
private RecordReaderFactory |
readerFactory |
private String |
securityProtocol |
private int |
totalMessages |
private Map<org.apache.kafka.common.TopicPartition,org.apache.kafka.clients.consumer.OffsetAndMetadata> |
uncommittedOffsetsMap |
private RecordSetWriterFactory |
writerFactory |
| Constructor and Description |
|---|
ConsumerLease(long maxWaitMillis,
org.apache.kafka.clients.consumer.Consumer<byte[],byte[]> kafkaConsumer,
byte[] demarcatorBytes,
String keyEncoding,
String securityProtocol,
String bootstrapServers,
RecordReaderFactory readerFactory,
RecordSetWriterFactory writerFactory,
ComponentLog logger,
Charset headerCharacterSet,
Pattern headerNamePattern) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Abstract method that is intended to be extended by the pool that created
this ConsumerLease object.
|
private void |
closeWriter(RecordSetWriter writer) |
(package private) boolean |
commit()
Notifies Kafka to commit the offsets for the specified topic/partition
pairs to the specified offsets w/the given metadata.
|
(package private) boolean |
continuePolling()
Indicates whether we should continue polling for data.
|
private static String |
encodeKafkaKey(byte[] key,
String encoding) |
private Map<String,String> |
getAttributes(org.apache.kafka.clients.consumer.ConsumerRecord<?,?> consumerRecord) |
private Collection<FlowFile> |
getBundles() |
abstract ProcessSession |
getProcessSession() |
private void |
handleParseFailure(org.apache.kafka.clients.consumer.ConsumerRecord<byte[],byte[]> consumerRecord,
ProcessSession session,
Exception cause) |
private void |
handleParseFailure(org.apache.kafka.clients.consumer.ConsumerRecord<byte[],byte[]> consumerRecord,
ProcessSession session,
Exception cause,
String message) |
(package private) boolean |
isPoisoned() |
void |
onPartitionsAssigned(Collection<org.apache.kafka.common.TopicPartition> partitions)
This will be called by Kafka when the rebalance has completed.
|
void |
onPartitionsRevoked(Collection<org.apache.kafka.common.TopicPartition> partitions)
Kafka will call this method whenever it is about to rebalance the
consumers for the given partitions.
|
private void |
poison()
Indicates that the underlying session and consumer should be immediately
considered invalid.
|
(package private) void |
poll()
Executes a poll on the underlying Kafka Consumer and creates any new
flowfiles necessary or appends to existing ones if in demarcation mode.
|
private void |
populateAttributes(ConsumerLease.BundleTracker tracker) |
private boolean |
processBundle(ConsumerLease.BundleTracker bundle) |
private void |
processRecords(org.apache.kafka.clients.consumer.ConsumerRecords<byte[],byte[]> records) |
private void |
resetInternalState()
clears out internal state elements excluding session and consumer as
those are managed by the pool itself
|
private void |
rollback(org.apache.kafka.common.TopicPartition topicPartition) |
void |
wakeup()
Trigger the consumer's
wakeup() method. |
private void |
writeData(ProcessSession session,
org.apache.kafka.clients.consumer.ConsumerRecord<byte[],byte[]> record,
org.apache.kafka.common.TopicPartition topicPartition) |
private void |
writeDemarcatedData(ProcessSession session,
List<org.apache.kafka.clients.consumer.ConsumerRecord<byte[],byte[]>> records,
org.apache.kafka.common.TopicPartition topicPartition) |
private void |
writeRecordData(ProcessSession session,
List<org.apache.kafka.clients.consumer.ConsumerRecord<byte[],byte[]>> records,
org.apache.kafka.common.TopicPartition topicPartition) |
abstract void |
yield() |
private final long maxWaitMillis
private final org.apache.kafka.clients.consumer.Consumer<byte[],byte[]> kafkaConsumer
private final ComponentLog logger
private final byte[] demarcatorBytes
private final String keyEncoding
private final String securityProtocol
private final String bootstrapServers
private final RecordSetWriterFactory writerFactory
private final RecordReaderFactory readerFactory
private final Charset headerCharacterSet
private final Pattern headerNamePattern
private boolean poisoned
private final Map<ConsumerLease.BundleInformation,ConsumerLease.BundleTracker> bundleMap
private final Map<org.apache.kafka.common.TopicPartition,org.apache.kafka.clients.consumer.OffsetAndMetadata> uncommittedOffsetsMap
private long leaseStartNanos
private boolean lastPollEmpty
private int totalMessages
ConsumerLease(long maxWaitMillis,
org.apache.kafka.clients.consumer.Consumer<byte[],byte[]> kafkaConsumer,
byte[] demarcatorBytes,
String keyEncoding,
String securityProtocol,
String bootstrapServers,
RecordReaderFactory readerFactory,
RecordSetWriterFactory writerFactory,
ComponentLog logger,
Charset headerCharacterSet,
Pattern headerNamePattern)
private void resetInternalState()
public void onPartitionsRevoked(Collection<org.apache.kafka.common.TopicPartition> partitions)
onPartitionsRevoked in interface org.apache.kafka.clients.consumer.ConsumerRebalanceListenerpartitions - partitions being reassignedpublic void onPartitionsAssigned(Collection<org.apache.kafka.common.TopicPartition> partitions)
onPartitionsAssigned in interface org.apache.kafka.clients.consumer.ConsumerRebalanceListenerpartitions - topic partition set being reassignedvoid poll()
boolean commit()
boolean continuePolling()
private void poison()
boolean isPoisoned()
public void wakeup()
wakeup() method.public void close()
close in interface Closeableclose in interface AutoCloseablepublic abstract ProcessSession getProcessSession()
public abstract void yield()
private void processRecords(org.apache.kafka.clients.consumer.ConsumerRecords<byte[],byte[]> records)
private Collection<FlowFile> getBundles() throws IOException
IOExceptionprivate boolean processBundle(ConsumerLease.BundleTracker bundle) throws IOException
IOExceptionprivate void writeData(ProcessSession session, org.apache.kafka.clients.consumer.ConsumerRecord<byte[],byte[]> record, org.apache.kafka.common.TopicPartition topicPartition)
private void writeDemarcatedData(ProcessSession session, List<org.apache.kafka.clients.consumer.ConsumerRecord<byte[],byte[]>> records, org.apache.kafka.common.TopicPartition topicPartition)
private void handleParseFailure(org.apache.kafka.clients.consumer.ConsumerRecord<byte[],byte[]> consumerRecord,
ProcessSession session,
Exception cause)
private void handleParseFailure(org.apache.kafka.clients.consumer.ConsumerRecord<byte[],byte[]> consumerRecord,
ProcessSession session,
Exception cause,
String message)
private Map<String,String> getAttributes(org.apache.kafka.clients.consumer.ConsumerRecord<?,?> consumerRecord)
private void writeRecordData(ProcessSession session, List<org.apache.kafka.clients.consumer.ConsumerRecord<byte[],byte[]>> records, org.apache.kafka.common.TopicPartition topicPartition)
private void closeWriter(RecordSetWriter writer)
private void rollback(org.apache.kafka.common.TopicPartition topicPartition)
private void populateAttributes(ConsumerLease.BundleTracker tracker)
Copyright © 2022 Apache NiFi Project. All rights reserved.