AmatyaAvadhanula commented on a change in pull request #12235:
URL: https://github.com/apache/druid/pull/12235#discussion_r807612810
##########
File path:
extensions-core/kinesis-indexing-service/src/main/java/org/apache/druid/indexing/kinesis/KinesisRecordSupplier.java
##########
@@ -667,28 +666,31 @@ public String
getEarliestSequenceNumber(StreamPartition<String> partition)
* This makes the method resilient to LimitExceeded exceptions (compared to
100 shards, 10 TPS of describeStream)
*
* @param stream name of stream
- *
- * @return Set of Shard ids
+ * @return Immutable set of shards
*/
+ public Set<Shard> getShards(String stream)
+ {
+ ImmutableSet.Builder<Shard> shards = ImmutableSet.builder();
+ ListShardsRequest request = new ListShardsRequest().withStreamName(stream);
+ while (true) {
+ ListShardsResult result = kinesis.listShards(request);
+ shards.addAll(result.getShards());
+ String nextToken = result.getNextToken();
+ if (nextToken == null) {
+ return shards.build();
+ }
+ request = new ListShardsRequest().withNextToken(nextToken);
+ }
+ }
+
@Override
public Set<String> getPartitionIds(String stream)
{
return wrapExceptions(() -> {
- final Set<String> retVal = new TreeSet<>();
- ListShardsRequest request = new
ListShardsRequest().withStreamName(stream);
- while (true) {
- ListShardsResult result = kinesis.listShards(request);
- retVal.addAll(result.getShards()
- .stream()
- .map(Shard::getShardId)
- .collect(Collectors.toList())
- );
- String nextToken = result.getNextToken();
- if (nextToken == null) {
- return retVal;
- }
- request = new ListShardsRequest().withNextToken(nextToken);
- }
+ return ImmutableSet.copyOf(getShards(stream).stream()
+ .map(shard ->
shard.getShardId())
+ .collect(Collectors.toList())
Review comment:
done
--
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]