library/src/main/java/com/kdgregory/aws/utils/kinesis/KinesisUtil.java
/**
     *  A wrapper around <code>DescribeStream</code> that retrieves all shard
     *  descriptions and retries if throttled. Returns null if the stream does
     *  not exist, the calling thread was interrupted, or we could not retrieve
     *  all shards within the timeout (this method does not return partial
     *  results).
     *
     *  @param  client          The AWS client used to make requests.
     *  @param  streamName      Identifies the stream to describe.
     *  @param  timeout         The total number of milliseconds to attempt retries due
     *                          to throttling.
     */
A wrapper around DescribeStream that retrieves all shard
descriptions and retries if throttled. Returns null if the stream does
not exist, the calling thread was interrupted, or we could not retrieve
all shards within the timeout (this method does not return partial
results).

@param  client          The AWS client used to make requests.
@param  streamName      Identifies the stream to describe.
@param  timeout         The total number of milliseconds to attempt retries due
to throttling.
A wrapper around DescribeStream that retrieves all shard descriptions and retries if throttled . Returns null if the stream does not exist the calling thread was interrupted or we could not retrieve all shards within the timeout ( this method does not return partial results ) . @param client The AWS client used to make requests . @param streamName Identifies the stream to describe . @param timeout The total number of milliseconds to attempt retries due to throttling .
public static List<Shard> describeShards(AmazonKinesis client, String streamName, long timeout)
    {
        List<Shard> result = new ArrayList<Shard>();
        long timeoutAt = System.currentTimeMillis() + timeout;
        String lastShardId = null;
        do
        {
            long currentTimeout = timeoutAt - System.currentTimeMillis();
            DescribeStreamRequest request = new DescribeStreamRequest().withStreamName(streamName);
            if (lastShardId != null) request.setExclusiveStartShardId(lastShardId);
            StreamDescription description = describeStream(client, request, currentTimeout);
            if (description == null) return null;
            List<Shard> shards = description.getShards();
            result.addAll(shards);
            lastShardId = description.getHasMoreShards()
                        ? shards.get(shards.size() - 1).getShardId()
                        : null;
        } while (lastShardId != null);
        return result;
    }
public static List < Shard > describeShards ( AmazonKinesis client , String streamName , long timeout ) { List < Shard > result = new ArrayList < Shard > ( ) ; long timeoutAt = System . currentTimeMillis ( ) + timeout ; String lastShardId = null ; do { long currentTimeout = timeoutAt - System . currentTimeMillis ( ) ; DescribeStreamRequest request = new DescribeStreamRequest ( ) . withStreamName ( streamName ) ; if ( lastShardId != null ) request . setExclusiveStartShardId ( lastShardId ) ; StreamDescription description = describeStream ( client , request , currentTimeout ) ; if ( description == null ) return null ; List < Shard > shards = description . getShards ( ) ; result . addAll ( shards ) ; lastShardId = description . getHasMoreShards ( ) ? shards . get ( shards . size ( ) - 1 ) . getShardId ( ) : null ; } while ( lastShardId != null ) ; return result ; }
A wrapper around <code>DescribeStream</code> that retrieves all shard
  descriptions and retries if throttled.
A wrapper around <code > DescribeStream< / code > that retrieves all shard descriptions and retries if throttled .