use of com.amazonaws.services.dynamodbv2.model.ListStreamsRequest in project camel by apache.
the class ShardIteratorHandler method getShardIterator.
String getShardIterator(String resumeFromSequenceNumber) {
ShardIteratorType iteratorType = getEndpoint().getIteratorType();
String sequenceNumber = getEndpoint().getSequenceNumber();
if (resumeFromSequenceNumber != null) {
// Reset things as we're in an error condition.
currentShard = null;
currentShardIterator = null;
iteratorType = ShardIteratorType.AFTER_SEQUENCE_NUMBER;
sequenceNumber = resumeFromSequenceNumber;
}
// either return a cached one or get a new one via a GetShardIterator request.
if (currentShardIterator == null) {
ListStreamsResult streamsListResult = getClient().listStreams(new ListStreamsRequest().withTableName(getEndpoint().getTableName()));
// XXX assumes there is only one stream
final String streamArn = streamsListResult.getStreams().get(0).getStreamArn();
DescribeStreamResult streamDescriptionResult = getClient().describeStream(new DescribeStreamRequest().withStreamArn(streamArn));
shardList.addAll(streamDescriptionResult.getStreamDescription().getShards());
LOG.trace("Current shard is: {} (in {})", currentShard, shardList);
if (currentShard == null) {
currentShard = resolveNewShard(iteratorType, resumeFromSequenceNumber);
} else {
currentShard = shardList.nextAfter(currentShard);
}
shardList.removeOlderThan(currentShard);
LOG.trace("Next shard is: {} (in {})", currentShard, shardList);
GetShardIteratorResult result = getClient().getShardIterator(buildGetShardIteratorRequest(streamArn, iteratorType, sequenceNumber));
currentShardIterator = result.getShardIterator();
}
LOG.trace("Shard Iterator is: {}", currentShardIterator);
return currentShardIterator;
}
Aggregations