kfaraz commented on code in PR #17735:
URL: https://github.com/apache/druid/pull/17735#discussion_r1959155803
##########
extensions-core/kafka-indexing-service/src/main/java/org/apache/druid/indexing/kafka/supervisor/KafkaSupervisor.java:
##########
@@ -280,8 +281,43 @@ protected Map<KafkaTopicPartition, Long>
getPartitionRecordLag()
@Override
protected Map<KafkaTopicPartition, Long> getPartitionTimeLag()
{
- // time lag not currently support with kafka
- return null;
+ return latestSequenceFromStream == null ? null :
getTimeLagPerPartitionInLatestSequences(getHighestCurrentOffsets());
+ }
+
+ protected Map<KafkaTopicPartition, Long>
getTimeLagPerPartitionInLatestSequences(Map<KafkaTopicPartition, Long>
currentOffsets)
+ {
+ getRecordSupplierLock().lock();
+ Map<KafkaTopicPartition, Long> timeAtCurrOffsets = new HashMap<>();
+ try {
+ for (Map.Entry<KafkaTopicPartition, Long> entry :
currentOffsets.entrySet()) {
+ timeAtCurrOffsets.put(entry.getKey(), entry.getValue() == null ? 0L :
recordSupplier.getTimeAtOffset(
+ new StreamPartition<>(getIoConfig().getStream(),
entry.getKey()),
+ KafkaSequenceNumber.of(entry.getValue()),
+ getIoConfig().getPollTimeout()
+ ));
Review Comment:
Please format this a little better to make it more readable.
##########
extensions-core/kafka-indexing-service/src/main/java/org/apache/druid/indexing/kafka/supervisor/KafkaSupervisor.java:
##########
@@ -280,8 +281,43 @@ protected Map<KafkaTopicPartition, Long>
getPartitionRecordLag()
@Override
protected Map<KafkaTopicPartition, Long> getPartitionTimeLag()
{
- // time lag not currently support with kafka
- return null;
+ return latestSequenceFromStream == null ? null :
getTimeLagPerPartitionInLatestSequences(getHighestCurrentOffsets());
+ }
+
+ protected Map<KafkaTopicPartition, Long>
getTimeLagPerPartitionInLatestSequences(Map<KafkaTopicPartition, Long>
currentOffsets)
Review Comment:
Please add a javadoc. Can this method be private instead?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]