zhangyue19921010 commented on a change in pull request #11006:
URL: https://github.com/apache/druid/pull/11006#discussion_r595782296



##########
File path: 
extensions-core/kinesis-indexing-service/src/main/java/org/apache/druid/indexing/kinesis/KinesisRecordSupplier.java
##########
@@ -863,21 +863,36 @@ private Long getPartitionTimeLag(StreamPartition<String> 
partition, String offse
         iteratorType = ShardIteratorType.AT_SEQUENCE_NUMBER.toString();
         offsetToUse = offset;
       }
-      String shardIterator = kinesis.getShardIterator(
-          partition.getStream(),
-          partition.getPartitionId(),
-          iteratorType,
-          offsetToUse
-      ).getShardIterator();
 
-      GetRecordsResult recordsResult = kinesis.getRecords(
-          new GetRecordsRequest().withShardIterator(shardIterator).withLimit(1)
-      );
+      GetRecordsResult recordsResult = 
getRecords(ShardIteratorType.AFTER_SEQUENCE_NUMBER.toString(), offsetToUse, 
partition);
+
+      // If no more new data after offsetToUse, it means there is no lag for 
now.
+      // So report lag points as 0L.
+      if (recordsResult.getRecords().size() == 0) {
+        return 0L;
+      } else {
+        recordsResult = getRecords(iteratorType, offsetToUse, partition);
+      }
 
       return recordsResult.getMillisBehindLatest();
     });
   }
 
+  private GetRecordsResult getRecords(String iteratorType, String offsetToUse, 
StreamPartition<String> partition)

Review comment:
       Changed. Thanks for your review.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to