@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getRecords() == null) ? 0 : getRecords().hashCode()); hashCode = prime * hashCode + ((getNextShardIterator() == null) ? 0 : getNextShardIterator().hashCode()); hashCode = prime * hashCode + ((getMillisBehindLatest() == null) ? 0 : getMillisBehindLatest().hashCode()); return hashCode; }
public GetRecordsResult unmarshall(JsonUnmarshallerContext context) throws Exception { GetRecordsResult getRecordsResult = new GetRecordsResult(); if (context.testExpression("Records", targetDepth)) { context.nextToken(); getRecordsResult.setRecords(new ListUnmarshaller<Record>(RecordJsonUnmarshaller.getInstance()).unmarshall(context)); getRecordsResult.setNextShardIterator(context.getUnmarshaller(String.class).unmarshall(context)); getRecordsResult.setMillisBehindLatest(context.getUnmarshaller(Long.class).unmarshall(context));
GetRecordsResult getRecordsResult = kinesisConnection.fetchRecords(shardIterator); if (getRecordsResult != null) { List<Record> records = getRecordsResult.getRecords(); LOG.debug("Records size from fetchNewRecords is {}", records.size()); shardIteratorPerShard.put(shardId, getRecordsResult.getNextShardIterator()); if (records.size() == 0) { LOG.warn("No records returned from kinesis. Hence sleeping for 1 second");
@Override public ProcessRecordsInput getNextResult() { GetRecordsResult getRecordsResult = getRecordsRetrievalStrategy.getRecords(maxRecordsPerCall); return new ProcessRecordsInput() .withRecords(getRecordsResult.getRecords()) .withMillisBehindLatest(getRecordsResult.getMillisBehindLatest()); }
/** * <p> * The data records retrieved from the shard. * </p> * <p> * Returns a reference to this object so that method calls can be chained * together. * * @param records <p> * The data records retrieved from the shard. * </p> * @return A reference to this updated object so that method calls can be * chained together. */ public GetRecordsResult withRecords(Record... records) { if (getRecords() == null) { this.records = new java.util.ArrayList<Record>(records.length); } for (Record value : records) { this.records.add(value); } return this; }
@Override public GetRecordsResult getResult() { return new GetRecordsResult().withMillisBehindLatest(null).withRecords(Collections.emptyList()) .withNextShardIterator(null); }
.withShardIterator(shard1Iterator1) .withLimit(25))) .willReturn(new GetRecordsResult() .withNextShardIterator(null) .withRecords(new Record() .withPartitionKey("partition1") .withSequenceNumber("1")
@Test public void shouldReturnLimitedNumberOfRecords() throws Exception { final Integer limit = 100; doAnswer( (Answer<GetRecordsResult>) invocation -> { GetRecordsRequest request = (GetRecordsRequest) invocation.getArguments()[0]; List<Record> records = generateRecords(request.getLimit()); return new GetRecordsResult().withRecords(records).withMillisBehindLatest(1000L); }) .when(kinesis) .getRecords(any(GetRecordsRequest.class)); GetKinesisRecordsResult result = underTest.getRecords(SHARD_ITERATOR, STREAM, SHARD_1, limit); assertThat(result.getRecords().size()).isEqualTo(limit); }
GetRecordsResult getRecordsResult = kinesisConnection.fetchRecords(shardIterator); if (getRecordsResult != null) { List<Record> records = getRecordsResult.getRecords(); LOG.debug("Records size from fetchFailedRecords is {}", records.size()); shardIteratorPerFailedMessage.put(kinesisMessageId, getRecordsResult.getNextShardIterator()); if (records.size() == 0) { LOG.warn("No records returned from kinesis. Hence sleeping for 1 second");
lastSuccessfulCall = Instant.now(); ProcessRecordsInput processRecordsInput = new ProcessRecordsInput() .withRecords(getRecordsResult.getRecords()) .withMillisBehindLatest(getRecordsResult.getMillisBehindLatest()) .withCacheEntryTime(lastSuccessfulCall); getRecordsResultQueue.put(processRecordsInput);
return getResponse.getRecords(); } catch(AmazonClientException e)
@Override public GetRecordsResult getRecords(GetRecordsRequest getRecordsRequest) { List<String> shardIteratorParts = Splitter.on(':').splitToList(getRecordsRequest.getShardIterator()); int shardId = parseInt(shardIteratorParts.get(0)); int startingRecord = parseInt(shardIteratorParts.get(1)); List<Record> shardData = shardedData.get(shardId); int toIndex = min(startingRecord + numberOfRecordsPerGet, shardData.size()); int fromIndex = min(startingRecord, toIndex); return new GetRecordsResult() .withRecords(shardData.subList(fromIndex, toIndex)) .withNextShardIterator(String.format("%s:%s", shardId, toIndex)) .withMillisBehindLatest(0L); }
.withShardIterator(shard1Iterator2) .withLimit(25))) .willReturn(new GetRecordsResult() .withNextShardIterator(shard1Iterator3) .withRecords(new Record() .withPartitionKey("partition1") .withSequenceNumber("1") .withShardIterator(shard2Iterator1) .withLimit(25))) .willReturn(new GetRecordsResult() .withNextShardIterator(shard2Iterator1)); .willReturn(new GetRecordsResult() .withNextShardIterator(shard1Iterator3)); .withShardIterator(shard1Iterator4) .withLimit(25))) .willReturn(new GetRecordsResult() .withNextShardIterator(shard1Iterator3) .withRecords(new Record() .withPartitionKey("partition1") .withSequenceNumber("2")
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof GetRecordsResult == false) return false; GetRecordsResult other = (GetRecordsResult) obj; if (other.getRecords() == null ^ this.getRecords() == null) return false; if (other.getRecords() != null && other.getRecords().equals(this.getRecords()) == false) return false; if (other.getNextShardIterator() == null ^ this.getNextShardIterator() == null) return false; if (other.getNextShardIterator() != null && other.getNextShardIterator().equals(this.getNextShardIterator()) == false) return false; if (other.getMillisBehindLatest() == null ^ this.getMillisBehindLatest() == null) return false; if (other.getMillisBehindLatest() != null && other.getMillisBehindLatest().equals(this.getMillisBehindLatest()) == false) return false; return true; }
List<Record> records = recordsResult.getRecords(); shardIterator = recordsResult.getNextShardIterator();
return getResponse.getRecords(); } catch (AmazonClientException e) { throw new RuntimeException(e);
public GetRecordsResult unmarshall(JsonUnmarshallerContext context) throws Exception { GetRecordsResult getRecordsResult = new GetRecordsResult(); AwsJsonReader reader = context.getReader(); reader.beginObject(); while (reader.hasNext()) { String name = reader.nextName(); if (name.equals("Records")) { getRecordsResult.setRecords(new ListUnmarshaller<Record>(RecordJsonUnmarshaller .getInstance() ) .unmarshall(context)); } else if (name.equals("NextShardIterator")) { getRecordsResult.setNextShardIterator(StringJsonUnmarshaller.getInstance() .unmarshall(context)); } else if (name.equals("MillisBehindLatest")) { getRecordsResult.setMillisBehindLatest(LongJsonUnmarshaller.getInstance() .unmarshall(context)); } else { reader.skipValue(); } } reader.endObject(); return getRecordsResult; }
/** * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be * redacted from this string using a placeholder value. * * @return A string representation of this object. * * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getRecords() != null) sb.append("Records: ").append(getRecords()).append(","); if (getNextShardIterator() != null) sb.append("NextShardIterator: ").append(getNextShardIterator()).append(","); if (getMillisBehindLatest() != null) sb.append("MillisBehindLatest: ").append(getMillisBehindLatest()); sb.append("}"); return sb.toString(); }
for (Record kinesisRecord : recordsResult.getRecords()) { shardIterator = recordsResult.getNextShardIterator(); // will be null if the shard has been closed ); if (recordsResult != null) { shardIterator = recordsResult.getNextShardIterator(); // will be null if the shard has been closed rescheduleRunnable(fetchDelayMillis); } else {
public GetRecordsResult unmarshall(JsonUnmarshallerContext context) throws Exception { GetRecordsResult getRecordsResult = new GetRecordsResult(); if (context.testExpression("Records", targetDepth)) { context.nextToken(); getRecordsResult.setRecords(new ListUnmarshaller<Record>(RecordJsonUnmarshaller.getInstance()).unmarshall(context)); getRecordsResult.setNextShardIterator(context.getUnmarshaller(String.class).unmarshall(context)); getRecordsResult.setMillisBehindLatest(context.getUnmarshaller(Long.class).unmarshall(context));