use of com.amazonaws.internal.StaticCredentialsProvider in project archaius by Netflix.
the class S3ConfigurationSourceTest method setup.
@Before
public void setup() throws Exception {
fakeS3 = createHttpServer();
client = new AmazonS3Client(new StaticCredentialsProvider(new AnonymousAWSCredentials()));
client.setS3ClientOptions(new S3ClientOptions().withPathStyleAccess(true));
client.setEndpoint("http://localhost:8069");
}
use of com.amazonaws.internal.StaticCredentialsProvider in project beam by apache.
the class KinesisUploader method uploadAll.
public static void uploadAll(List<String> data, KinesisTestOptions options) {
AmazonKinesisClient client = new AmazonKinesisClient(new StaticCredentialsProvider(new BasicAWSCredentials(options.getAwsAccessKey(), options.getAwsSecretKey()))).withRegion(Regions.fromName(options.getAwsKinesisRegion()));
List<List<String>> partitions = Lists.partition(data, MAX_NUMBER_OF_RECORDS_IN_BATCH);
for (List<String> partition : partitions) {
List<PutRecordsRequestEntry> allRecords = newArrayList();
for (String row : partition) {
allRecords.add(new PutRecordsRequestEntry().withData(ByteBuffer.wrap(row.getBytes(Charsets.UTF_8))).withPartitionKey(Integer.toString(row.hashCode())));
}
PutRecordsResult result;
do {
result = client.putRecords(new PutRecordsRequest().withStreamName(options.getAwsKinesisStream()).withRecords(allRecords));
List<PutRecordsRequestEntry> failedRecords = newArrayList();
int i = 0;
for (PutRecordsResultEntry row : result.getRecords()) {
if (row.getErrorCode() != null) {
failedRecords.add(allRecords.get(i));
}
++i;
}
allRecords = failedRecords;
} while (result.getFailedRecordCount() > 0);
}
}
Aggregations