use of software.amazon.awssdk.services.kinesis.model.ListShardsResponse in project beam by apache.
the class SimplifiedKinesisClient method listShards.
private List<Shard> listShards(final String streamName, final ShardFilter shardFilter) throws TransientKinesisException {
return wrapExceptions(() -> {
ImmutableList.Builder<Shard> shardsBuilder = ImmutableList.builder();
String currentNextToken = null;
do {
ListShardsRequest.Builder reqBuilder = ListShardsRequest.builder().maxResults(LIST_SHARDS_MAX_RESULTS).shardFilter(shardFilter);
if (currentNextToken != null) {
reqBuilder.nextToken(currentNextToken);
} else {
reqBuilder.streamName(streamName);
}
ListShardsResponse response = kinesis.listShards(reqBuilder.build());
shardsBuilder.addAll(response.shards());
currentNextToken = response.nextToken();
} while (currentNextToken != null);
return shardsBuilder.build();
});
}
use of software.amazon.awssdk.services.kinesis.model.ListShardsResponse in project aws-doc-sdk-examples by awsdocs.
the class ListShards method listKinShards.
// snippet-start:[kinesis.java2.ListShards.main]
public static void listKinShards(KinesisClient kinesisClient, String name) {
try {
ListShardsRequest request = ListShardsRequest.builder().streamName(name).build();
ListShardsResponse response = kinesisClient.listShards(request);
System.out.println(request.streamName() + " has " + response.shards());
} catch (KinesisException e) {
System.err.println(e.getMessage());
System.exit(1);
}
System.out.println("Done");
}
Aggregations