@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getFailedRecordCount() == null) ? 0 : getFailedRecordCount().hashCode()); hashCode = prime * hashCode + ((getRecords() == null) ? 0 : getRecords().hashCode()); hashCode = prime * hashCode + ((getEncryptionType() == null) ? 0 : getEncryptionType().hashCode()); return hashCode; }
/** * 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 (getFailedRecordCount() != null) sb.append("FailedRecordCount: ").append(getFailedRecordCount()).append(","); if (getRecords() != null) sb.append("Records: ").append(getRecords()).append(","); if (getEncryptionType() != null) sb.append("EncryptionType: ").append(getEncryptionType()); sb.append("}"); return sb.toString(); }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof PutRecordsResult == false) return false; PutRecordsResult other = (PutRecordsResult) obj; if (other.getFailedRecordCount() == null ^ this.getFailedRecordCount() == null) return false; if (other.getFailedRecordCount() != null && other.getFailedRecordCount().equals(this.getFailedRecordCount()) == false) return false; if (other.getRecords() == null ^ this.getRecords() == null) return false; if (other.getRecords() != null && other.getRecords().equals(this.getRecords()) == false) return false; if (other.getEncryptionType() == null ^ this.getEncryptionType() == null) return false; if (other.getEncryptionType() != null && other.getEncryptionType().equals(this.getEncryptionType()) == false) return false; return true; }
PutRecordsResult results = client.putRecords(putRecordRequest); List<PutRecordsResultEntry> responseEntries = results.getRecords(); for (int i = 0; i < responseEntries.size(); i++ ) { PutRecordsResultEntry entry = responseEntries.get(i);
if (getRecords() == null) { this.records = new java.util.ArrayList<PutRecordsResultEntry>(records.length);
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getFailedRecordCount() == null) ? 0 : getFailedRecordCount().hashCode()); hashCode = prime * hashCode + ((getRecords() == null) ? 0 : getRecords().hashCode()); hashCode = prime * hashCode + ((getEncryptionType() == null) ? 0 : getEncryptionType().hashCode()); return hashCode; }
/** * Returns a string representation of this object; useful for testing and * debugging. * * @return A string representation of this object. * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getFailedRecordCount() != null) sb.append("FailedRecordCount: " + getFailedRecordCount() + ","); if (getRecords() != null) sb.append("Records: " + getRecords() + ","); if (getEncryptionType() != null) sb.append("EncryptionType: " + getEncryptionType()); sb.append("}"); return sb.toString(); }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof PutRecordsResult == false) return false; PutRecordsResult other = (PutRecordsResult) obj; if (other.getFailedRecordCount() == null ^ this.getFailedRecordCount() == null) return false; if (other.getFailedRecordCount() != null && other.getFailedRecordCount().equals(this.getFailedRecordCount()) == false) return false; if (other.getRecords() == null ^ this.getRecords() == null) return false; if (other.getRecords() != null && other.getRecords().equals(this.getRecords()) == false) return false; if (other.getEncryptionType() == null ^ this.getEncryptionType() == null) return false; if (other.getEncryptionType() != null && other.getEncryptionType().equals(this.getEncryptionType()) == false) return false; return true; } }
@Override public List<byte[]> sendBatch(String streamName, List<byte[]> data) { if (data == null || data.isEmpty()) { return Collections.emptyList(); } final PutRecordsRequest request = new PutRecordsRequest(); request.setStreamName(streamName); final List<PutRecordsRequestEntry> records = new ArrayList<PutRecordsRequestEntry>(data.size()); for (final byte[] d : data) { final String partKey = StringUtils.isBlank(this.partitionKey) ? UUID.randomUUID().toString() : this.partitionKey; final PutRecordsRequestEntry r = new PutRecordsRequestEntry(); r.setData(ByteBuffer.wrap(d)); r.setPartitionKey(partKey); records.add(r); } request.setRecords(records); request.getRequestClientOptions().appendUserAgent(userAgent); final PutRecordsResult result = client.putRecords(request); final int size = result.getRecords().size(); final List<byte[]> failures = new ArrayList<byte[]>(result.getFailedRecordCount()); for (int i = 0; i < size; i++) { if (result.getRecords().get(i).getErrorCode() != null) { // always retry failed record failures.add(data.get(i)); } } return failures; }
final List<PutRecordsResultEntry> results = res.getRecords(); List<PutRecordsRequestEntry> retries = IntStream .range(0, results.size())
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getFailedRecordCount() == null) ? 0 : getFailedRecordCount().hashCode()); hashCode = prime * hashCode + ((getRecords() == null) ? 0 : getRecords().hashCode()); hashCode = prime * hashCode + ((getEncryptionType() == null) ? 0 : getEncryptionType().hashCode()); return hashCode; }
/** * 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 (getFailedRecordCount() != null) sb.append("FailedRecordCount: ").append(getFailedRecordCount()).append(","); if (getRecords() != null) sb.append("Records: ").append(getRecords()).append(","); if (getEncryptionType() != null) sb.append("EncryptionType: ").append(getEncryptionType()); sb.append("}"); return sb.toString(); }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof PutRecordsResult == false) return false; PutRecordsResult other = (PutRecordsResult) obj; if (other.getFailedRecordCount() == null ^ this.getFailedRecordCount() == null) return false; if (other.getFailedRecordCount() != null && other.getFailedRecordCount().equals(this.getFailedRecordCount()) == false) return false; if (other.getRecords() == null ^ this.getRecords() == null) return false; if (other.getRecords() != null && other.getRecords().equals(this.getRecords()) == false) return false; if (other.getEncryptionType() == null ^ this.getEncryptionType() == null) return false; if (other.getEncryptionType() != null && other.getEncryptionType().equals(this.getEncryptionType()) == false) return false; return true; }
if (putRecordsResult.getFailedRecordCount() > 0) { List<PutRecordsRequestEntry> entriesForRetry = new ArrayList<>(); for (int i = 0; i < putRecordsResult.getRecords().size(); i++) { PutRecordsResultEntry resultEntry = putRecordsResult.getRecords().get(i); PutRecordsRequestEntry requestEntry = putRecordsRequest.getRecords().get(i); if (resultEntry.getErrorCode() != null) {
public Observable<PutRecordsResultEntry> play(LocalDateTime start, @Nullable LocalDateTime end) { return playableObjects(start, end) .onBackpressureBuffer() .observeOn(Schedulers.io()) .flatMap(this::objectToPayloads) .map(ByteBuffer::wrap) .lift(new OperatorBufferKinesisBatch(MAX_KINESIS_BATCH_SIZE, MAX_KINESIS_BATCH_WEIGHT)) .onBackpressureBuffer() .map(byteBuffers -> byteBuffers.stream() .map(buffer -> new PutRecordsRequestEntry() .withData(buffer) .withPartitionKey(UUID.randomUUID().toString())) .collect(toList())) .map(entries -> new PutRecordsRequest() .withStreamName(vcrConfiguration.targetStream) .withRecords(entries)) .observeOn(Schedulers.io()) .flatMap(putRecordsRequest -> Observable.create((Observable.OnSubscribe<List<PutRecordsResult>>) os -> { os.onStart(); kinesisWriter.submit(() -> { os.onNext(putWithRetry(putRecordsRequest).orElse(Collections.<PutRecordsResult>emptyList())); os.onCompleted(); }); })) .flatMap(Observable::from) .flatMap(putRecordsResult -> Observable.from(putRecordsResult.getRecords())) .doOnNext(result -> LOGGER.debug("Wrote record. Seq {}, shard {}", result.getSequenceNumber(), result.getShardId())); }
PutRecordsResult results = client.putRecords(putRecordRequest); List<PutRecordsResultEntry> responseEntries = results.getRecords(); for (int i = 0; i < responseEntries.size(); i++ ) { PutRecordsResultEntry entry = responseEntries.get(i);
int index = 0; long totalBytesSent = 0; for (final PutRecordsResultEntry responseEntry : result.getRecords()) { final PutRecordsRequestEntry record = requestRecords.get(index); if (responseEntry.getErrorCode() == null) {
List<PutRecordsResultEntry> recordsResponse = putRecordsResult.getRecords(); for (int i = 0; i < recordsResponse.size(); i++) { if (recordsResponse.get(i).getErrorCode() != null) {
public void storeBatchInline(List<Event> events, int offset, int limit) { PutRecordsRequestEntry[] records = new PutRecordsRequestEntry[limit]; for (int i = 0; i < limit; i++) { Event event = events.get(offset + i); PutRecordsRequestEntry putRecordsRequestEntry = new PutRecordsRequestEntry() .withData(getBuffer(event)) .withPartitionKey(event.project() + "|" + event.collection()); records[i] = putRecordsRequestEntry; } try { PutRecordsResult putRecordsResult = kinesis.putRecords(new PutRecordsRequest() .withRecords(records) .withStreamName(config.getEventStoreStreamName())); if (putRecordsResult.getFailedRecordCount() > 0) { for (PutRecordsResultEntry resultEntry : putRecordsResult.getRecords()) { resultEntry.getErrorMessage(); } } } catch (ResourceNotFoundException e) { try { createAndWaitForStreamToBecomeAvailable(kinesis, config.getEventStoreStreamName(), 1); } catch (Exception e1) { throw new RuntimeException("Couldn't send event to Amazon Kinesis", e); } } }
List<PutRecordsRequestEntry> failedRecords = new ArrayList<>(); int i = 0; for (PutRecordsResultEntry row : result.getRecords()) { if (row.getErrorCode() != null) { failedRecords.add(allRecords.get(i));