GetRecordsResult fetchRecords (String shardIterator) { GetRecordsRequest getRecordsRequest = new GetRecordsRequest(); getRecordsRequest.setShardIterator(shardIterator); getRecordsRequest.setLimit(kinesisConnectionInfo.getRecordsLimit()); GetRecordsResult getRecordsResult = kinesisClient.getRecords(getRecordsRequest); return getRecordsResult; }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getShardIterator() == null) ? 0 : getShardIterator().hashCode()); hashCode = prime * hashCode + ((getLimit() == null) ? 0 : getLimit().hashCode()); return hashCode; }
recordsResult = kinesis.getRecords(new GetRecordsRequest().withShardIterator(shardIterator).withLimit(1000));
@Override public GetRecordsResult get(String shardIterator, int maxRecords) throws ResourceNotFoundException, InvalidArgumentException, ExpiredIteratorException { final GetRecordsRequest getRecordsRequest = new GetRecordsRequest(); getRecordsRequest.setRequestCredentials(credentialsProvider.getCredentials()); getRecordsRequest.setShardIterator(shardIterator); getRecordsRequest.setLimit(maxRecords); final GetRecordsResult response = client.getRecords(getRecordsRequest); return response; }
/** * <p> * The position in the shard from which you want to start sequentially reading data records. A shard iterator * specifies this position using the sequence number of a data record in the shard. * </p> * * @param shardIterator * The position in the shard from which you want to start sequentially reading data records. A shard iterator * specifies this position using the sequence number of a data record in the shard. * @return Returns a reference to this object so that method calls can be chained together. */ public GetRecordsRequest withShardIterator(String shardIterator) { setShardIterator(shardIterator); return this; }
GetRecordsRequest recordsRequest = new GetRecordsRequest() .withShardIterator(shardIteratorId);
/** * <p> * The maximum number of records to return. Specify a value of up to 10,000. If you specify a value that is greater * than 10,000, <a>GetRecords</a> throws <code>InvalidArgumentException</code>. * </p> * * @param limit * The maximum number of records to return. Specify a value of up to 10,000. If you specify a value that is * greater than 10,000, <a>GetRecords</a> throws <code>InvalidArgumentException</code>. * @return Returns a reference to this object so that method calls can be chained together. */ public GetRecordsRequest withLimit(Integer limit) { setLimit(limit); return this; }
/** * @param getRecordsRequest Container for the necessary parameters to execute the GetRecords service method on DynamoDB Streams. * @return The response from the GetRecords service method, adapted for use with the AmazonKinesis model. */ @Override public GetRecordsResult getRecords(GetRecordsRequest getRecordsRequest) { if (getRecordsRequest.getLimit() != null && getRecordsRequest.getLimit() > GET_RECORDS_LIMIT) { getRecordsRequest.setLimit(GET_RECORDS_LIMIT); } GetRecordsRequestAdapter requestAdapter = new GetRecordsRequestAdapter(getRecordsRequest); requestCache.addEntry(getRecordsRequest, requestAdapter); try { com.amazonaws.services.dynamodbv2.model.GetRecordsResult result = internalClient.getRecords(requestAdapter); return new GetRecordsResultAdapter(result, generateRecordBytes); } catch (AmazonServiceException e) { throw AmazonServiceExceptionTransformer.transformDynamoDBStreamsToKinesisGetRecords(e, skipRecordsBehavior); } }
/** * @return The maximum number of records to return. */ @Override public Integer getLimit() { return internalRequest.getLimit(); }
/** * @return The position in the shard from which you want to start sequentially * reading data records. */ @Override public String getShardIterator() { return internalRequest.getShardIterator(); }
@Override public GetRecordsResult get(String shardIterator, int maxRecords) throws ResourceNotFoundException, InvalidArgumentException, ExpiredIteratorException { final GetRecordsRequest getRecordsRequest = new GetRecordsRequest(); getRecordsRequest.setRequestCredentials(credentialsProvider.getCredentials()); getRecordsRequest.setShardIterator(shardIterator); getRecordsRequest.setLimit(maxRecords); final GetRecordsResult response = client.getRecords(getRecordsRequest); return response; }
/** * @param shardIterator The position in the shard from which you want to start sequentially * reading data records. * @return A reference to this updated object so that method calls can be chained together. */ @Override public GetRecordsRequest withShardIterator(String shardIterator) { internalRequest.setShardIterator(shardIterator); return this; }
/** * @param limit The maximum number of records to return. */ @Override public void setLimit(Integer limit) { internalRequest.setLimit(limit); }
/** * @param getRecordsRequest Container for the necessary parameters to execute the GetRecords service method on DynamoDB Streams. * @return The response from the GetRecords service method, adapted for use with the AmazonKinesis model. */ @Override public GetRecordsResult getRecords(GetRecordsRequest getRecordsRequest) { if (getRecordsRequest.getLimit() != null && getRecordsRequest.getLimit() > GET_RECORDS_LIMIT) { getRecordsRequest.setLimit(GET_RECORDS_LIMIT); } GetRecordsRequestAdapter requestAdapter = new GetRecordsRequestAdapter(getRecordsRequest); requestCache.addEntry(getRecordsRequest, requestAdapter); try { com.amazonaws.services.dynamodbv2.model.GetRecordsResult result = internalClient.getRecords(requestAdapter); return new GetRecordsResultAdapter(result, generateRecordBytes); } catch (AmazonServiceException e) { throw AmazonServiceExceptionTransformer.transformDynamoDBStreamsToKinesisGetRecords(e, skipRecordsBehavior); } }
/** * @return The maximum number of records to return. */ @Override public Integer getLimit() { return internalRequest.getLimit(); }
/** * @return The position in the shard from which you want to start sequentially * reading data records. */ @Override public String getShardIterator() { return internalRequest.getShardIterator(); }
@Override public Records getNext(int maxNumberOfRecords) throws AmazonClientException, ResourceNotFoundException, InvalidArgumentException { if (shardIterator == null) { LOG.debug(this + " Null shardIterator for " + shardId + ". This can happen if shard is closed."); return Records.empty(true); } final ImmutableList.Builder<Record> records = new ImmutableList.Builder<>(); try { final GetRecordsRequest request = new GetRecordsRequest(); request.setShardIterator(shardIterator); request.setLimit(maxNumberOfRecords); final GetRecordsResult result = safeGetRecords(request); for (Record rec : result.getRecords()) { records.add(rec); positionInShard = ShardPosition.afterSequenceNumber(rec.getSequenceNumber()); } if (LOG.isDebugEnabled()) { LOG.debug(this + " fetched " + result.getRecords().size() + " records from Kinesis (requested " + maxNumberOfRecords + ")."); } shardIterator = result.getNextShardIterator(); } catch (AmazonClientException e) { // We'll treat this equivalent to fetching 0 records - the spout drives the retry as part of nextTuple() // We don't sleep here - we can continue processing ack/fail on the spout thread. LOG.error(this + "Caught exception when fetching records for " + shardId, e); } return new Records(records.build(), shardIterator == null); }
/** * {@inheritDoc} */ @Override public GetRecordsResult get(String shardIterator, int maxRecords) throws ResourceNotFoundException, InvalidArgumentException, ExpiredIteratorException { final GetRecordsRequest getRecordsRequest = new GetRecordsRequest(); getRecordsRequest.setRequestCredentials(credentialsProvider.getCredentials()); getRecordsRequest.setShardIterator(shardIterator); getRecordsRequest.setLimit(maxRecords); final GetRecordsResult response = client.getRecords(getRecordsRequest); return response; }
recordsResult = kinesis.getRecords(new GetRecordsRequest().withShardIterator( shardIterator).withLimit(recordsPerFetch));
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof GetRecordsRequest == false) return false; GetRecordsRequest other = (GetRecordsRequest) obj; if (other.getShardIterator() == null ^ this.getShardIterator() == null) return false; if (other.getShardIterator() != null && other.getShardIterator().equals(this.getShardIterator()) == false) return false; if (other.getLimit() == null ^ this.getLimit() == null) return false; if (other.getLimit() != null && other.getLimit().equals(this.getLimit()) == false) return false; return true; }