library/src/main/java/com/kdgregory/aws/utils/kinesis/KinesisUtil.java
/**
     *  Retrieves a single shard iterator, retrying until a caller-specified timeout.
     *  This function provides arguments for multiple iterator types; pass null for
     *  those arguments that don't apply to your call.
     *
     *  @param  client          The AWS client used to make requests.
     *  @param  streamName      The name of the stream.
     *  @param  shardId         The shard identifier.
     *  @param  iteratorType    The type of iterator to retrieve.
     *  @param  sequenceNumber  The relevant sequence number, for iterator types
     *                          that need one. Ignored for iterator types that don't.
     *  @param  timestamp       A starting timestamp, for the AT_TIMESTAMP iterator
     *                          type only. Ignored for all other iterator types.
     *  @param  timeout         The number of milliseconds to attempt retries due
     *                          to throttling.
     *
     *  @return The shard iterator, null if unable to do so within timeout.
     *
     *  @throws All non-throttling exceptions from underlying call.
     *
     */
Retrieves a single shard iterator, retrying until a caller-specified timeout.
This function provides arguments for multiple iterator types; pass null for
those arguments that don't apply to your call.

@param  client          The AWS client used to make requests.
@param  streamName      The name of the stream.
@param  shardId         The shard identifier.
@param  iteratorType    The type of iterator to retrieve.
@param  sequenceNumber  The relevant sequence number, for iterator types
that need one. Ignored for iterator types that don't.
@param  timestamp       A starting timestamp, for the AT_TIMESTAMP iterator
type only. Ignored for all other iterator types.
@param  timeout         The number of milliseconds to attempt retries due
to throttling.

@return The shard iterator, null if unable to do so within timeout.

@throws All non-throttling exceptions from underlying call.
Retrieves a single shard iterator retrying until a caller - specified timeout . This function provides arguments for multiple iterator types ; pass null for those arguments that don ' t apply to your call . @param client The AWS client used to make requests . @param streamName The name of the stream . @param shardId The shard identifier . @param iteratorType The type of iterator to retrieve . @param sequenceNumber The relevant sequence number for iterator types that need one . Ignored for iterator types that don ' t . @param timestamp A starting timestamp for the AT_TIMESTAMP iterator type only . Ignored for all other iterator types . @param timeout The number of milliseconds to attempt retries due to throttling . @return The shard iterator null if unable to do so within timeout . @throws All non - throttling exceptions from underlying call .
public static String retrieveShardIterator(
        AmazonKinesis client, String streamName, String shardId,
        ShardIteratorType iteratorType, String sequenceNumber, Date timestamp,
        long timeout)
    {
        GetShardIteratorRequest request = new GetShardIteratorRequest()
                      .withStreamName(streamName)
                      .withShardId(shardId)
                      .withShardIteratorType(iteratorType);
        switch (iteratorType)
        {
            case AT_SEQUENCE_NUMBER:
            case AFTER_SEQUENCE_NUMBER:
                request.setStartingSequenceNumber(sequenceNumber);
                break;
            case AT_TIMESTAMP:
                request.setTimestamp(timestamp);
                break;
            default:
        }
        long timeoutAt = System.currentTimeMillis() + timeout;
        long currentSleepTime = 100;
        while (System.currentTimeMillis() < timeoutAt)
        {
            try
            {
                GetShardIteratorResult response = client.getShardIterator(request);
                return response.getShardIterator();
            }
            catch (ProvisionedThroughputExceededException ex)
            {
                CommonUtils.sleepQuietly(currentSleepTime);
                currentSleepTime *= 2;
            }
        }
        logger.warn("retrieveShardIterator timeout: " + streamName + " shard " + shardId);
        return null;
    }
public static String retrieveShardIterator ( AmazonKinesis client , String streamName , String shardId , ShardIteratorType iteratorType , String sequenceNumber , Date timestamp , long timeout ) { GetShardIteratorRequest request = new GetShardIteratorRequest ( ) . withStreamName ( streamName ) . withShardId ( shardId ) . withShardIteratorType ( iteratorType ) ; switch ( iteratorType ) { case AT_SEQUENCE_NUMBER : case AFTER_SEQUENCE_NUMBER : request . setStartingSequenceNumber ( sequenceNumber ) ; break ; case AT_TIMESTAMP : request . setTimestamp ( timestamp ) ; break ; default : } long timeoutAt = System . currentTimeMillis ( ) + timeout ; long currentSleepTime = 100 ; while ( System . currentTimeMillis ( ) < timeoutAt ) { try { GetShardIteratorResult response = client . getShardIterator ( request ) ; return response . getShardIterator ( ) ; } catch ( ProvisionedThroughputExceededException ex ) { CommonUtils . sleepQuietly ( currentSleepTime ) ; currentSleepTime *= 2 ; } } logger . warn ( "retrieveShardIterator timeout: " + streamName + " shard " + shardId ) ; return null ; }
Retrieves a single shard iterator, retrying until a caller-specified timeout.
Retrieves a single shard iterator retrying until a caller - specified timeout .
// nothing special