Example usage for com.amazonaws.services.kinesis.model GetRecordsResult setMillisBehindLatest

List of usage examples for com.amazonaws.services.kinesis.model GetRecordsResult setMillisBehindLatest

Introduction

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

Prototype


public void setMillisBehindLatest(Long millisBehindLatest) 

Source Link

Document

The number of milliseconds the GetRecords response is from the tip of the stream, indicating how far behind current time the consumer is.

Usage

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

License:Apache License

@Override
public GetRecordsResult getRecords(GetRecordsRequest getRecordsRequest)
        throws AmazonServiceException, AmazonClientException {
    ShardIterator iter = ShardIterator.fromString(getRecordsRequest.getShardIterator());
    if (iter == null) {
        throw new AmazonClientException("Bad shard iterator.");
    }// ww w  .j a  va  2 s. c  o  m

    // TODO: incorporate maximum batch size (getRecordsRequest.getLimit)
    GetRecordsResult result = null;
    InternalStream stream = this.getStream(iter.streamId);
    if (stream != null) {
        InternalShard shard = stream.getShards().get(iter.shardIndex);

        if (iter.recordIndex == 100) {
            result = new GetRecordsResult();
            ArrayList<Record> recs = shard.getRecords();
            result.setRecords(recs); // NOTE: getting all for now
            result.setNextShardIterator(getNextShardIterator(iter, recs).makeString());
            result.setMillisBehindLatest(100L);
        } else {
            result = new GetRecordsResult();
            ArrayList<Record> recs = shard.getRecordsFrom(iter);
            result.setRecords(recs); // may be empty
            result.setNextShardIterator(getNextShardIterator(iter, recs).makeString());
            result.setMillisBehindLatest(100L);
        }
    } else {
        throw new AmazonClientException("Unknown stream or bad shard iterator.");
    }

    return result;
}