Example usage for com.amazonaws.services.kinesis.model StreamDescription setShards

List of usage examples for com.amazonaws.services.kinesis.model StreamDescription setShards

Introduction

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

Prototype


public void setShards(java.util.Collection<Shard> shards) 

Source Link

Document

The shards that comprise the stream.

Usage

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

License:Apache License

@Override
public DescribeStreamResult describeStream(DescribeStreamRequest describeStreamRequest)
        throws AmazonServiceException, AmazonClientException {
    InternalStream theStream = this.getStream(describeStreamRequest.getStreamName());
    if (theStream != null) {
        StreamDescription desc = new StreamDescription();
        desc = desc.withStreamName(theStream.getStreamName()).withStreamStatus(theStream.getStreamStatus())
                .withStreamARN(theStream.getStreamARN());

        if (describeStreamRequest.getExclusiveStartShardId() == null
                || describeStreamRequest.getExclusiveStartShardId().isEmpty()) {
            desc.setShards(this.getShards(theStream));
            desc.setHasMoreShards(false);
        } else {/*from  w  w  w .  j a  v  a  2s.com*/
            // Filter from given shard Id, or may not have any more
            String startId = describeStreamRequest.getExclusiveStartShardId();
            desc.setShards(this.getShards(theStream, startId));
            desc.setHasMoreShards(false);
        }

        DescribeStreamResult result = new DescribeStreamResult();
        result = result.withStreamDescription(desc);
        return result;
    } else {
        throw new AmazonClientException("This stream does not exist!");
    }
}