library/src/main/java/com/kdgregory/aws/utils/kinesis/KinesisUtil.java
/**
     *  Repeatedly calls {@link #describeStream} (with a pause between calls) until
     *  the stream's status is the desired value, the calling thrad is interrupted,
     *  or the timeout expires. Returns the last retrieved status value (which may
     *  be null even if the actual status is not, due to timeout or interruption).
     *
     *  @param  client          The AWS client used to make requests.
     *  @param  streamName      Identifies the stream to describe.
     *  @param  desiredStatus   The desired stream status.
     *  @param  timeout         The total number of milliseconds to attempt retries due
     *                          to throttling.
     */
Repeatedly calls  #describeStream (with a pause between calls) until
the stream's status is the desired value, the calling thrad is interrupted,
or the timeout expires. Returns the last retrieved status value (which may
be null even if the actual status is not, due to timeout or interruption).

@param  client          The AWS client used to make requests.
@param  streamName      Identifies the stream to describe.
@param  desiredStatus   The desired stream status.
@param  timeout         The total number of milliseconds to attempt retries due
to throttling.
Repeatedly calls #describeStream ( with a pause between calls ) until the stream ' s status is the desired value the calling thrad is interrupted or the timeout expires . Returns the last retrieved status value ( which may be null even if the actual status is not due to timeout or interruption ) . @param client The AWS client used to make requests . @param streamName Identifies the stream to describe . @param desiredStatus The desired stream status . @param timeout The total number of milliseconds to attempt retries due to throttling .
public static StreamStatus waitForStatus(AmazonKinesis client, String streamName, StreamStatus desiredStatus, long timeout)
    {
        StreamStatus lastStatus = null;
        long timeoutAt = System.currentTimeMillis() + timeout;
        while (System.currentTimeMillis() < timeoutAt)
        {
            long remainingTimeout = timeoutAt - System.currentTimeMillis();
            StreamDescription description = describeStream(client, streamName, remainingTimeout);
            lastStatus = getStatus(description);
            if (lastStatus == desiredStatus)
            {
                return lastStatus;
            }
            CommonUtils.sleepQuietly(100);
        }
        logger.debug("waitForStatus timeout: " + streamName);
        return lastStatus;
    }
public static StreamStatus waitForStatus ( AmazonKinesis client , String streamName , StreamStatus desiredStatus , long timeout ) { StreamStatus lastStatus = null ; long timeoutAt = System . currentTimeMillis ( ) + timeout ; while ( System . currentTimeMillis ( ) < timeoutAt ) { long remainingTimeout = timeoutAt - System . currentTimeMillis ( ) ; StreamDescription description = describeStream ( client , streamName , remainingTimeout ) ; lastStatus = getStatus ( description ) ; if ( lastStatus == desiredStatus ) { return lastStatus ; } CommonUtils . sleepQuietly ( 100 ) ; } logger . debug ( "waitForStatus timeout: " + streamName ) ; return lastStatus ; }
Repeatedly calls {@link #describeStream} (with a pause between calls) until
  the stream's status is the desired value, the calling thrad is interrupted,
  or the timeout expires.
Repeatedly calls { @link #describeStream } ( with a pause between calls ) until the stream ' s status is the desired value the calling thrad is interrupted or the timeout expires .
// arbitrary sleep to minimize throttling