/** * <p> * An array of successfully and unsuccessfully processed record results, correlated with the request by natural * ordering. A record that is successfully added to a stream includes <code>SequenceNumber</code> and * <code>ShardId</code> in the result. A record that fails to be added to a stream includes <code>ErrorCode</code> * and <code>ErrorMessage</code> in the result. * </p> * * @param records * An array of successfully and unsuccessfully processed record results, correlated with the request by * natural ordering. A record that is successfully added to a stream includes <code>SequenceNumber</code> and * <code>ShardId</code> in the result. A record that fails to be added to a stream includes * <code>ErrorCode</code> and <code>ErrorMessage</code> in the result. * @return Returns a reference to this object so that method calls can be chained together. */ public PutRecordsResult withRecords(java.util.Collection<PutRecordsResultEntry> records) { setRecords(records); return this; }
/** * <p> * An array of successfully and unsuccessfully processed record results, correlated with the request by natural * ordering. A record that is successfully added to a stream includes <code>SequenceNumber</code> and * <code>ShardId</code> in the result. A record that fails to be added to a stream includes <code>ErrorCode</code> * and <code>ErrorMessage</code> in the result. * </p> * <p> * <b>NOTE:</b> This method appends the values to the existing list (if any). Use * {@link #setRecords(java.util.Collection)} or {@link #withRecords(java.util.Collection)} if you want to override * the existing values. * </p> * * @param records * An array of successfully and unsuccessfully processed record results, correlated with the request by * natural ordering. A record that is successfully added to a stream includes <code>SequenceNumber</code> and * <code>ShardId</code> in the result. A record that fails to be added to a stream includes * <code>ErrorCode</code> and <code>ErrorMessage</code> in the result. * @return Returns a reference to this object so that method calls can be chained together. */ public PutRecordsResult withRecords(PutRecordsResultEntry... records) { if (this.records == null) { setRecords(new com.amazonaws.internal.SdkInternalList<PutRecordsResultEntry>(records.length)); } for (PutRecordsResultEntry ele : records) { this.records.add(ele); } return this; }
putRecordsResult.setRecords(new ListUnmarshaller<PutRecordsResultEntry>(PutRecordsResultEntryJsonUnmarshaller.getInstance()) .unmarshall(context));
/** * <p> * An array of successfully and unsuccessfully processed record results, * correlated with the request by natural ordering. A record that is * successfully added to a stream includes <code>SequenceNumber</code> and * <code>ShardId</code> in the result. A record that fails to be added to a * stream includes <code>ErrorCode</code> and <code>ErrorMessage</code> in * the result. * </p> * <p> * Returns a reference to this object so that method calls can be chained * together. * * @param records <p> * An array of successfully and unsuccessfully processed record * results, correlated with the request by natural ordering. A * record that is successfully added to a stream includes * <code>SequenceNumber</code> and <code>ShardId</code> in the * result. A record that fails to be added to a stream includes * <code>ErrorCode</code> and <code>ErrorMessage</code> in the * result. * </p> * @return A reference to this updated object so that method calls can be * chained together. */ public PutRecordsResult withRecords(java.util.Collection<PutRecordsResultEntry> records) { setRecords(records); return this; }
public PutRecordsResult unmarshall(JsonUnmarshallerContext context) throws Exception { PutRecordsResult putRecordsResult = new PutRecordsResult(); AwsJsonReader reader = context.getReader(); reader.beginObject(); while (reader.hasNext()) { String name = reader.nextName(); if (name.equals("FailedRecordCount")) { putRecordsResult.setFailedRecordCount(IntegerJsonUnmarshaller.getInstance() .unmarshall(context)); } else if (name.equals("Records")) { putRecordsResult.setRecords(new ListUnmarshaller<PutRecordsResultEntry>( PutRecordsResultEntryJsonUnmarshaller.getInstance() ) .unmarshall(context)); } else if (name.equals("EncryptionType")) { putRecordsResult.setEncryptionType(StringJsonUnmarshaller.getInstance() .unmarshall(context)); } else { reader.skipValue(); } } reader.endObject(); return putRecordsResult; }
@Test(expected = AmazonClientException.class) public void testSendBatchException() { String streamName = "stream"; int count = 10; // create an ok result PutRecordsResult result = new PutRecordsResult(); List<PutRecordsResultEntry> entries = new ArrayList<PutRecordsResultEntry>(); result.setFailedRecordCount(0); for (int i = 0; i < count; i++) { PutRecordsResultEntry entry = new PutRecordsResultEntry(); entry.setSequenceNumber("record_id_" + i); entries.add(entry); } result.setRecords(entries); // create data List<byte[]> data = new ArrayList<byte[]>(); for (int i = 0; i < count; i++) { data.add(("record" + i).getBytes(StringUtils.UTF8)); } Mockito.when(client.putRecords(any(PutRecordsRequest.class))).thenThrow( new InvalidArgumentException("invalid argument")); sender.sendBatch(streamName, data); }
result.setRecords(entries);
entries.add(entry); result.setRecords(entries);
/** * <p> * An array of successfully and unsuccessfully processed record results, correlated with the request by natural * ordering. A record that is successfully added to a stream includes <code>SequenceNumber</code> and * <code>ShardId</code> in the result. A record that fails to be added to a stream includes <code>ErrorCode</code> * and <code>ErrorMessage</code> in the result. * </p> * * @param records * An array of successfully and unsuccessfully processed record results, correlated with the request by * natural ordering. A record that is successfully added to a stream includes <code>SequenceNumber</code> and * <code>ShardId</code> in the result. A record that fails to be added to a stream includes * <code>ErrorCode</code> and <code>ErrorMessage</code> in the result. * @return Returns a reference to this object so that method calls can be chained together. */ public PutRecordsResult withRecords(java.util.Collection<PutRecordsResultEntry> records) { setRecords(records); return this; }
/** * <p> * An array of successfully and unsuccessfully processed record results, correlated with the request by natural * ordering. A record that is successfully added to a stream includes <code>SequenceNumber</code> and * <code>ShardId</code> in the result. A record that fails to be added to a stream includes <code>ErrorCode</code> * and <code>ErrorMessage</code> in the result. * </p> * <p> * <b>NOTE:</b> This method appends the values to the existing list (if any). Use * {@link #setRecords(java.util.Collection)} or {@link #withRecords(java.util.Collection)} if you want to override * the existing values. * </p> * * @param records * An array of successfully and unsuccessfully processed record results, correlated with the request by * natural ordering. A record that is successfully added to a stream includes <code>SequenceNumber</code> and * <code>ShardId</code> in the result. A record that fails to be added to a stream includes * <code>ErrorCode</code> and <code>ErrorMessage</code> in the result. * @return Returns a reference to this object so that method calls can be chained together. */ public PutRecordsResult withRecords(PutRecordsResultEntry... records) { if (this.records == null) { setRecords(new com.amazonaws.internal.SdkInternalList<PutRecordsResultEntry>(records.length)); } for (PutRecordsResultEntry ele : records) { this.records.add(ele); } return this; }
putRecordsResult.setRecords(new ListUnmarshaller<PutRecordsResultEntry>(PutRecordsResultEntryJsonUnmarshaller.getInstance()) .unmarshall(context));