gianm commented on a change in pull request #8644: Fix Kinesis resharding issues
URL: https://github.com/apache/incubator-druid/pull/8644#discussion_r332853621
 
 

 ##########
 File path: 
extensions-core/kinesis-indexing-service/src/main/java/org/apache/druid/indexing/kinesis/supervisor/KinesisSupervisor.java
 ##########
 @@ -314,4 +360,79 @@ protected boolean 
useExclusiveStartSequenceNumberForNonFirstSequence()
   {
     return true;
   }
+
+  @Override
+  protected Map<String, OrderedSequenceNumber<String>> 
filterExpiredPartitionsFromStartingOffsets(
+      Map<String, OrderedSequenceNumber<String>> startingOffsets
+  )
+  {
+    Map<String, OrderedSequenceNumber<String>> filteredOffsets = new 
HashMap<>();
+    for (Map.Entry<String, OrderedSequenceNumber<String>> entry : 
startingOffsets.entrySet()) {
+      if 
(!entry.getValue().get().equals(KinesisSequenceNumber.END_OF_SHARD_MARKER)) {
+        filteredOffsets.put(entry.getKey(), entry.getValue());
+      } else {
+        log.debug("Excluding shard[%s] because it has reached EOS.", 
entry.getKey());
+      }
+    }
+    return filteredOffsets;
+  }
+
+  @Override
+  protected boolean supportsPartitionExpiration()
+  {
+    return true;
+  }
+
+  @Override
+  protected KinesisDataSourceMetadata 
createDataSourceMetadataWithoutExpiredPartitions(
+      SeekableStreamDataSourceMetadata<String, String> currentMetadata,
+      Set<String> expiredPartitionIds
+  )
+  {
+    log.info("Cleaning up dead shards: " + expiredPartitionIds);
+
+    final KinesisDataSourceMetadata dataSourceMetadata = 
(KinesisDataSourceMetadata) currentMetadata;
+
+    SeekableStreamSequenceNumbers<String, String> old = 
dataSourceMetadata.getSeekableStreamSequenceNumbers();
+
+    Map<String, String> oldPartitionSequenceNumberMap = 
old.getPartitionSequenceNumberMap();
+    Map<String, String> newPartitionSequenceNumberMap = new HashMap<>();
+    for (Map.Entry<String, String> entry : 
oldPartitionSequenceNumberMap.entrySet()) {
+      if (!expiredPartitionIds.contains(entry.getKey())) {
+        newPartitionSequenceNumberMap.put(entry.getKey(), entry.getValue());
+      }
+    }
+
+    Set<String> oldExclusiveStartPartitions = null;
+    Set<String> newExclusiveStartPartitions = null;
+    if (old instanceof SeekableStreamStartSequenceNumbers) {
 
 Review comment:
   Adding an isStart (in a separate patch) sounds like a nice idea. It looks 
like a couple other spots do similar instanceof checks.

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


With regards,
Apache Git Services

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

Reply via email to