use of com.amazonaws.services.kinesis.model.DescribeStreamSummaryResult in project beam by apache.
the class SimplifiedKinesisClientTest method shouldListAllShardsForTimestampWithRetriedDescribeStreamSummaryCallAfterStreamCreationTimestamp.
@Test
public void shouldListAllShardsForTimestampWithRetriedDescribeStreamSummaryCallAfterStreamCreationTimestamp() throws TransientKinesisException {
Shard shard1 = new Shard().withShardId(SHARD_1);
Shard shard2 = new Shard().withShardId(SHARD_2);
Shard shard3 = new Shard().withShardId(SHARD_3);
int hoursDifference = 1;
int retentionPeriodHours = hoursDifference * 3;
Instant streamCreationTimestamp = CURRENT_TIMESTAMP.minus(Duration.standardHours(retentionPeriodHours));
Instant startingPointTimestamp = streamCreationTimestamp.plus(Duration.standardHours(hoursDifference));
when(currentInstantSupplier.get()).thenReturn(CURRENT_TIMESTAMP);
when(kinesis.describeStreamSummary(new DescribeStreamSummaryRequest().withStreamName(STREAM))).thenThrow(new LimitExceededException("Fake Exception: Limit exceeded")).thenReturn(new DescribeStreamSummaryResult().withStreamDescriptionSummary(new StreamDescriptionSummary().withRetentionPeriodHours(retentionPeriodHours).withStreamCreationTimestamp(streamCreationTimestamp.toDate())));
ShardFilter shardFilter = new ShardFilter().withType(ShardFilterType.AT_TIMESTAMP).withTimestamp(startingPointTimestamp.toDate());
when(kinesis.listShards(new ListShardsRequest().withStreamName(STREAM).withShardFilter(shardFilter).withMaxResults(1_000))).thenReturn(new ListShardsResult().withShards(shard1, shard2, shard3).withNextToken(null));
List<Shard> shards = underTest.listShardsAtPoint(STREAM, new StartingPoint(startingPointTimestamp));
assertThat(shards).containsOnly(shard1, shard2, shard3);
}
use of com.amazonaws.services.kinesis.model.DescribeStreamSummaryResult in project beam by apache.
the class SimplifiedKinesisClientTest method shouldListAllShardsForTimestampOutsideStreamRetentionAfterStreamCreationTimestamp.
@Test
public void shouldListAllShardsForTimestampOutsideStreamRetentionAfterStreamCreationTimestamp() throws Exception {
Shard shard1 = new Shard().withShardId(SHARD_1);
Shard shard2 = new Shard().withShardId(SHARD_2);
Shard shard3 = new Shard().withShardId(SHARD_3);
int retentionPeriodHours = 3;
int startingPointHours = 5;
int hoursSinceStreamCreation = 6;
Instant streamCreationTimestamp = CURRENT_TIMESTAMP.minus(Duration.standardHours(hoursSinceStreamCreation));
Instant startingPointTimestampAfterStreamRetentionTimestamp = CURRENT_TIMESTAMP.minus(Duration.standardHours(startingPointHours));
when(currentInstantSupplier.get()).thenReturn(CURRENT_TIMESTAMP);
DescribeStreamSummaryRequest describeStreamRequest = new DescribeStreamSummaryRequest().withStreamName(STREAM);
when(kinesis.describeStreamSummary(describeStreamRequest)).thenReturn(new DescribeStreamSummaryResult().withStreamDescriptionSummary(new StreamDescriptionSummary().withRetentionPeriodHours(retentionPeriodHours).withStreamCreationTimestamp(streamCreationTimestamp.toDate())));
ShardFilter shardFilter = new ShardFilter().withType(ShardFilterType.AT_TRIM_HORIZON);
when(kinesis.listShards(new ListShardsRequest().withStreamName(STREAM).withShardFilter(shardFilter).withMaxResults(1_000))).thenReturn(new ListShardsResult().withShards(shard1, shard2, shard3).withNextToken(null));
List<Shard> shards = underTest.listShardsAtPoint(STREAM, new StartingPoint(startingPointTimestampAfterStreamRetentionTimestamp));
assertThat(shards).containsOnly(shard1, shard2, shard3);
}
use of com.amazonaws.services.kinesis.model.DescribeStreamSummaryResult in project beam by apache.
the class SimplifiedKinesisClientTest method shouldListAllShardsForTimestampBeforeStreamCreationTimestamp.
@Test
public void shouldListAllShardsForTimestampBeforeStreamCreationTimestamp() throws Exception {
Shard shard1 = new Shard().withShardId(SHARD_1);
Shard shard2 = new Shard().withShardId(SHARD_2);
Shard shard3 = new Shard().withShardId(SHARD_3);
Instant startingPointTimestamp = Instant.parse("2000-01-01T15:00:00.000Z");
Instant streamCreationTimestamp = startingPointTimestamp.plus(Duration.standardHours(1));
DescribeStreamSummaryRequest describeStreamRequest = new DescribeStreamSummaryRequest().withStreamName(STREAM);
when(kinesis.describeStreamSummary(describeStreamRequest)).thenReturn(new DescribeStreamSummaryResult().withStreamDescriptionSummary(new StreamDescriptionSummary().withStreamCreationTimestamp(streamCreationTimestamp.toDate())));
ShardFilter shardFilter = new ShardFilter().withType(ShardFilterType.AT_TRIM_HORIZON);
when(kinesis.listShards(new ListShardsRequest().withStreamName(STREAM).withShardFilter(shardFilter).withMaxResults(1_000))).thenReturn(new ListShardsResult().withShards(shard1, shard2, shard3).withNextToken(null));
List<Shard> shards = underTest.listShardsAtPoint(STREAM, new StartingPoint(startingPointTimestamp));
assertThat(shards).containsOnly(shard1, shard2, shard3);
}
use of com.amazonaws.services.kinesis.model.DescribeStreamSummaryResult in project beam by apache.
the class SimplifiedKinesisClientTest method shouldListAllShardsForTimestampWithinStreamRetentionAfterStreamCreationTimestamp.
@Test
public void shouldListAllShardsForTimestampWithinStreamRetentionAfterStreamCreationTimestamp() throws Exception {
Shard shard1 = new Shard().withShardId(SHARD_1);
Shard shard2 = new Shard().withShardId(SHARD_2);
Shard shard3 = new Shard().withShardId(SHARD_3);
int hoursDifference = 1;
int retentionPeriodHours = hoursDifference * 3;
Instant streamCreationTimestamp = CURRENT_TIMESTAMP.minus(Duration.standardHours(retentionPeriodHours));
Instant startingPointTimestamp = streamCreationTimestamp.plus(Duration.standardHours(hoursDifference));
when(currentInstantSupplier.get()).thenReturn(CURRENT_TIMESTAMP);
when(kinesis.describeStreamSummary(new DescribeStreamSummaryRequest().withStreamName(STREAM))).thenReturn(new DescribeStreamSummaryResult().withStreamDescriptionSummary(new StreamDescriptionSummary().withRetentionPeriodHours(retentionPeriodHours).withStreamCreationTimestamp(streamCreationTimestamp.toDate())));
ShardFilter shardFilter = new ShardFilter().withType(ShardFilterType.AT_TIMESTAMP).withTimestamp(startingPointTimestamp.toDate());
when(kinesis.listShards(new ListShardsRequest().withStreamName(STREAM).withShardFilter(shardFilter).withMaxResults(1_000))).thenReturn(new ListShardsResult().withShards(shard1, shard2, shard3).withNextToken(null));
List<Shard> shards = underTest.listShardsAtPoint(STREAM, new StartingPoint(startingPointTimestamp));
assertThat(shards).containsOnly(shard1, shard2, shard3);
}
use of com.amazonaws.services.kinesis.model.DescribeStreamSummaryResult 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));
}
}
Aggregations