use of com.amazonaws.services.kinesis.model.ListShardsRequest in project hazelcast by hazelcast.
the class KinesisTestHelper method listOpenShards.
private List<Shard> listOpenShards() {
List<Shard> shards = new ArrayList<>();
String nextToken = null;
do {
// only the currently open shards
ShardFilterType filterType = ShardFilterType.AT_LATEST;
ListShardsRequest request = RangeMonitor.listAllShardsRequest(stream, nextToken, filterType);
ListShardsResult response = kinesis.listShards(request);
shards.addAll(response.getShards());
nextToken = response.getNextToken();
} while (nextToken != null);
return shards;
}
use of com.amazonaws.services.kinesis.model.ListShardsRequest in project flink by apache.
the class KinesisProxyTest method testGetShardWithNoNewShards.
@Test
public void testGetShardWithNoNewShards() throws Exception {
// given
String fakeStreamName = "fake-stream";
AmazonKinesis mockClient = mock(AmazonKinesis.class);
KinesisProxy kinesisProxy = getProxy(mockClient);
Mockito.when(mockClient.listShards(new ListShardsRequest().withStreamName(fakeStreamName).withExclusiveStartShardId(KinesisShardIdGenerator.generateFromShardOrder(1)))).thenReturn(new ListShardsResult().withShards(Collections.emptyList()));
HashMap<String, String> streamHashMap = new HashMap<>();
streamHashMap.put(fakeStreamName, KinesisShardIdGenerator.generateFromShardOrder(1));
// when
GetShardListResult shardListResult = kinesisProxy.getShardList(streamHashMap);
// then
Assert.assertFalse(shardListResult.hasRetrievedShards());
}
use of com.amazonaws.services.kinesis.model.ListShardsRequest in project druid by druid-io.
the class KinesisRecordSupplierTest method testSupplierSetup.
@Test
public void testSupplierSetup() {
final Capture<ListShardsRequest> capturedRequest0 = Capture.newInstance();
final Capture<ListShardsRequest> capturedRequest1 = Capture.newInstance();
EasyMock.expect(kinesis.listShards(EasyMock.capture(capturedRequest0))).andReturn(listShardsResult0).once();
EasyMock.expect(listShardsResult0.getShards()).andReturn(ImmutableList.of(shard0)).once();
String nextToken = "nextToken";
EasyMock.expect(listShardsResult0.getNextToken()).andReturn(nextToken).once();
EasyMock.expect(shard0.getShardId()).andReturn(SHARD_ID0).once();
EasyMock.expect(kinesis.listShards(EasyMock.capture(capturedRequest1))).andReturn(listShardsResult1).once();
EasyMock.expect(listShardsResult1.getShards()).andReturn(ImmutableList.of(shard1)).once();
EasyMock.expect(listShardsResult1.getNextToken()).andReturn(null).once();
EasyMock.expect(shard1.getShardId()).andReturn(SHARD_ID1).once();
replayAll();
Set<StreamPartition<String>> partitions = ImmutableSet.of(StreamPartition.of(STREAM, SHARD_ID0), StreamPartition.of(STREAM, SHARD_ID1));
recordSupplier = new KinesisRecordSupplier(kinesis, recordsPerFetch, 0, 2, false, 100, 5000, 5000, 60000, 5, true);
Assert.assertTrue(recordSupplier.getAssignment().isEmpty());
recordSupplier.assign(partitions);
Assert.assertEquals(partitions, recordSupplier.getAssignment());
Assert.assertEquals(ImmutableSet.of(SHARD_ID1, SHARD_ID0), recordSupplier.getPartitionIds(STREAM));
// calling poll would start background fetch if seek was called, but will instead be skipped and the results
// empty
Assert.assertEquals(Collections.emptyList(), recordSupplier.poll(100));
verifyAll();
final ListShardsRequest expectedRequest0 = new ListShardsRequest();
expectedRequest0.setStreamName(STREAM);
Assert.assertEquals(expectedRequest0, capturedRequest0.getValue());
final ListShardsRequest expectedRequest1 = new ListShardsRequest();
expectedRequest1.setNextToken(nextToken);
Assert.assertEquals(expectedRequest1, capturedRequest1.getValue());
}
Aggregations