K
- record key typeV
- record value typepublic class OffsetTreePartitionImpl<K,V> extends AbstractPartition<K,V>
IPartition
implementation. This is one of the most crucial class
of the punch.consumer, earliestOffset, latestOffset, partitionNumber, topic
commitLatency, committedOffsetGauge, currentDelayGauge, currentTimestampGauge, earliestOffsetGauge, fetchSize, latestOffsetGauge, messagesCommitBacklogGauge, messagesFetchBacklogGauge, messagesPersistedBacklogGauge, messagesReplayableGauge, metricsContext, msgFetchRate, offsetAckRate, offsetFailRate
Modifier | Constructor and Description |
---|---|
protected |
OffsetTreePartitionImpl(org.thales.punch.libraries.metrics.api.IMetricContext metricContext,
String topic,
int partitionNumber,
org.apache.kafka.clients.consumer.KafkaConsumer<K,V> consumer,
long offsetToRead,
Long offsetWatchDogTimeout,
boolean smartFailureHandling)
constructor
|
Modifier and Type | Method and Description |
---|---|
void |
ack(long offset)
Optional operation.
|
void |
commit(long offset,
String metadata)
Commit an explicit offset for the given partition.
|
void |
commit(String metadata)
Commit the latest acknowledged offset for the given partition.
|
void |
fail(long offset)
Optional operation, fail an offset.
|
protected void |
onReceive(IRecordHandler<K,V> receiver,
org.apache.kafka.clients.consumer.ConsumerRecord<K,V> record)
Transfer the record to the receiver and keep track of
current offset.
|
void |
rewind(long offset)
Optional operation, rewind the offset to a past position.
|
String |
toString() |
attach, getAttachment, getPartitionNumber, getTopic, setEarliestOffset, setLatestOffset
close
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
close
protected OffsetTreePartitionImpl(org.thales.punch.libraries.metrics.api.IMetricContext metricContext, String topic, int partitionNumber, org.apache.kafka.clients.consumer.KafkaConsumer<K,V> consumer, long offsetToRead, Long offsetWatchDogTimeout, boolean smartFailureHandling)
topic
- the target topicpartitionNumber
- the partition number.consumer
- the associated KafkaConsumeroffsetToRead
- : the current offset at which the consumer is configured to fetch data for this partition.offsetWatchDogTimeout
- the watchdog committed offset timeout in ms.public void ack(long offset)
IPartition
offset
- the offsetpublic void fail(long offset)
IPartition
offset
- the failed offsetpublic void commit(String metadata)
IPartition
metadata
- an optional metadata, can be null. If not it will be saved along with the commitpublic void commit(long offset, String metadata)
IPartition
offset
- the offset to commit. Remember you should always commit +1 the latest processed message (this is the kafka way).metadata
- an optional metadata, can be null. If not it will be saved along with the commit. It should relate to the NEXT data to read and processprotected void onReceive(IRecordHandler<K,V> receiver, org.apache.kafka.clients.consumer.ConsumerRecord<K,V> record)
onReceive
in class AbstractPartition<K,V>
receiver
- record
- public void rewind(long offset)
IPartition
offset
- the offset valueCopyright © 2014–2023. All rights reserved.