Search in sources :

Example 6 with StreamDescriptionSummary

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));
    }
}
Also used : StreamDescriptionSummary(com.amazonaws.services.kinesis.model.StreamDescriptionSummary) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) SdkClientException(com.amazonaws.SdkClientException) DescribeStreamSummaryResult(com.amazonaws.services.kinesis.model.DescribeStreamSummaryResult)

Example 7 with StreamDescriptionSummary

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);
    }
}
Also used : StreamDescriptionSummary(com.amazonaws.services.kinesis.model.StreamDescriptionSummary) Instant(org.joda.time.Instant) ShardFilter(com.amazonaws.services.kinesis.model.ShardFilter) Duration(org.joda.time.Duration)

Aggregations

StreamDescriptionSummary (com.amazonaws.services.kinesis.model.StreamDescriptionSummary)7 DescribeStreamSummaryRequest (com.amazonaws.services.kinesis.model.DescribeStreamSummaryRequest)5 DescribeStreamSummaryResult (com.amazonaws.services.kinesis.model.DescribeStreamSummaryResult)5 ShardFilter (com.amazonaws.services.kinesis.model.ShardFilter)5 Instant (org.joda.time.Instant)5 ListShardsRequest (com.amazonaws.services.kinesis.model.ListShardsRequest)4 ListShardsResult (com.amazonaws.services.kinesis.model.ListShardsResult)4 Shard (com.amazonaws.services.kinesis.model.Shard)4 Test (org.junit.Test)4 Datapoint (com.amazonaws.services.cloudwatch.model.Datapoint)3 SdkClientException (com.amazonaws.SdkClientException)1 LimitExceededException (com.amazonaws.services.kinesis.model.LimitExceededException)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Duration (org.joda.time.Duration)1