use of com.amazonaws.services.kinesis.model.StreamDescriptionSummary in project hazelcast by hazelcast.
the class NoopShardCountMonitor method checkForStreamDescription.
private void checkForStreamDescription() {
if (!describeStreamResult.isDone()) {
return;
}
DescribeStreamSummaryResult result;
try {
result = KinesisUtil.readResult(describeStreamResult);
} catch (SdkClientException e) {
dealWithDescribeStreamFailure(e);
return;
} catch (Throwable t) {
throw rethrow(t);
} finally {
describeStreamResult = null;
}
describeStreamRetryTracker.reset();
StreamDescriptionSummary streamDescription = result.getStreamDescriptionSummary();
if (streamDescription == null) {
return;
}
Integer newShardCount = streamDescription.getOpenShardCount();
if (newShardCount == null) {
return;
}
int oldShardCount = shardCount.getAndSet(newShardCount);
if (oldShardCount != newShardCount) {
logger.info(String.format("Updated shard count for stream '%s': %d", streamName, newShardCount));
}
}
use of com.amazonaws.services.kinesis.model.StreamDescriptionSummary in project beam by apache.
the class SimplifiedKinesisClient method buildShardFilterForTimestamp.
private ShardFilter buildShardFilterForTimestamp(String streamName, Instant startingPointTimestamp) throws IOException, InterruptedException {
StreamDescriptionSummary streamDescription = describeStreamSummary(streamName);
Instant streamCreationTimestamp = new Instant(streamDescription.getStreamCreationTimestamp());
if (streamCreationTimestamp.isAfter(startingPointTimestamp)) {
return new ShardFilter().withType(ShardFilterType.AT_TRIM_HORIZON);
}
Duration retentionPeriod = Duration.standardHours(streamDescription.getRetentionPeriodHours());
Instant streamTrimHorizonTimestamp = currentInstantSupplier.get().minus(retentionPeriod).plus(SPACING_FOR_TIMESTAMP_LIST_SHARDS_REQUEST_TO_NOT_EXCEED_TRIM_HORIZON);
if (startingPointTimestamp.isAfter(streamTrimHorizonTimestamp)) {
return new ShardFilter().withType(ShardFilterType.AT_TIMESTAMP).withTimestamp(startingPointTimestamp.toDate());
} else {
return new ShardFilter().withType(ShardFilterType.AT_TRIM_HORIZON);
}
}
Aggregations