You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by "npawar (via GitHub)" <gi...@apache.org> on 2023/05/09 19:15:32 UTC

[GitHub] [pinot] npawar commented on a diff in pull request #9713: Extract headers for Kinesis Connector

npawar commented on code in PR #9713:
URL: https://github.com/apache/pinot/pull/9713#discussion_r1189024860


##########
pinot-plugins/pinot-stream-ingestion/pinot-kinesis/src/main/java/org/apache/pinot/plugin/stream/kinesis/KinesisMetadataExtractor.java:
##########
@@ -0,0 +1,44 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.plugin.stream.kinesis;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.pinot.spi.stream.RowMetadata;
+import software.amazon.awssdk.services.kinesis.model.Record;
+
+// TODO: Make this an interface/api in the stream spis st StreamMessageMetadata extract(T streamTypeRecord)
+
+public interface KinesisMetadataExtractor {
+  static KinesisMetadataExtractor build(boolean populateMetadata) {
+    return record -> {
+      long recordTimestamp = record.approximateArrivalTimestamp().toEpochMilli();
+      Map<String, String> metadataMap = new HashMap<>();
+      metadataMap.put(KinesisStreamMessageMetadata.APPRX_ARRIVAL_TIMESTAMP_KEY, String.valueOf(recordTimestamp));
+      if (!populateMetadata) {

Review Comment:
   the populateMetadata had me confused even during the Kafka impl time.. Please help me understand, why are we putting recordTimestamp as a top level param and also putting it in the metadata map? And why put it in the map even when the flag is false?



##########
pinot-plugins/pinot-stream-ingestion/pinot-kinesis/src/main/java/org/apache/pinot/plugin/stream/kinesis/KinesisStreamMetadataProvider.java:
##########
@@ -189,6 +192,24 @@ private boolean consumedEndOfShard(StreamPartitionMsgOffset startCheckpoint,
   }
 
   @Override
-  public void close() {
+  public Map<String, PartitionLagState> getCurrentPartitionLagState(
+      Map<String, ConsumerPartitionState> currentPartitionStateMap) {
+    Map<String, PartitionLagState> perPartitionLag = new HashMap<>();
+    for (Map.Entry<String, ConsumerPartitionState> entry: currentPartitionStateMap.entrySet()) {
+      ConsumerPartitionState partitionState = entry.getValue();
+      // Compute record-availability
+      String recordAvailabilityLag = "UNKNOWN";
+      RowMetadata lastProcessedMessageMetadata = partitionState.getLastProcessedRowMetadata();
+      if (lastProcessedMessageMetadata != null && partitionState.getLastProcessedTimeMs() > 0) {
+        long availabilityLag = partitionState.getLastProcessedTimeMs()
+            - lastProcessedMessageMetadata.getRecordIngestionTimeMs();
+        recordAvailabilityLag = String.valueOf(availabilityLag);
+      }
+      perPartitionLag.put(entry.getKey(), new KinesisConsumerPartitionLag(recordAvailabilityLag));

Review Comment:
   yea it won't be in the currentPartitionStateMap anymore once we've moved on to the children, so APIs should be fine. Do we also emit any metrics per partition about this? If yes, those will face issues of false alerts



-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org