List of usage examples for com.amazonaws.services.kinesis.model GetRecordsResult setRecords
public void setRecords(java.util.Collection<Record> records)
The data records retrieved from the shard.
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."); }/*from w ww . j a v a 2 s .com*/ // 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; }