Example usage for com.amazonaws.services.kinesis.model GetShardIteratorResult withShardIterator

List of usage examples for com.amazonaws.services.kinesis.model GetShardIteratorResult withShardIterator

Introduction

In this page you can find the example usage for com.amazonaws.services.kinesis.model GetShardIteratorResult withShardIterator.

Prototype


public GetShardIteratorResult withShardIterator(String shardIterator) 

Source Link

Document

The position in the shard from which to start reading data records sequentially.

Usage

From source file:com.facebook.presto.kinesis.util.MockKinesisClient.java

License:Apache License

@Override
public GetShardIteratorResult getShardIterator(GetShardIteratorRequest getShardIteratorRequest)
        throws AmazonServiceException, AmazonClientException {
    ShardIterator iter = ShardIterator.fromStreamAndShard(getShardIteratorRequest.getStreamName(),
            getShardIteratorRequest.getShardId());
    if (iter != null) {
        InternalStream theStream = this.getStream(iter.streamId);
        if (theStream != null) {
            String seqAsString = getShardIteratorRequest.getStartingSequenceNumber();
            if (seqAsString != null && !seqAsString.isEmpty()
                    && getShardIteratorRequest.getShardIteratorType().equals("AFTER_SEQUENCE_NUMBER")) {
                int sequence = Integer.parseInt(seqAsString);
                iter.recordIndex = sequence + 1;
            } else {
                iter.recordIndex = 100;//from   w ww. j a va 2s  .  c  o  m
            }

            GetShardIteratorResult result = new GetShardIteratorResult();
            return result.withShardIterator(iter.makeString());
        } else {
            throw new AmazonClientException("Unknown stream or bad shard iterator!");
        }
    } else {
        throw new AmazonClientException("Bad stream or shard iterator!");
    }
}