Search in sources :

Example 6 with NonRetryableException

use of org.komamitsu.fluency.NonRetryableException in project fluency by komamitsu.

the class AwsS3Sender method buildClient.

@VisibleForTesting
protected S3Client buildClient(S3ClientBuilder s3ClientBuilder) {
    if (config.getEndpoint() != null) {
        try {
            URI uri = new URI(config.getEndpoint());
            s3ClientBuilder.endpointOverride(uri);
        } catch (URISyntaxException e) {
            throw new NonRetryableException(String.format("Invalid endpoint. %s", config.getEndpoint()), e);
        }
    }
    if (config.getRegion() != null) {
        s3ClientBuilder.region(Region.of(config.getRegion()));
    }
    if (config.getAwsAccessKeyId() != null && config.getAwsSecretAccessKey() != null) {
        AwsBasicCredentials credentials = AwsBasicCredentials.create(config.getAwsAccessKeyId(), config.getAwsSecretAccessKey());
        s3ClientBuilder.credentialsProvider(StaticCredentialsProvider.create(credentials));
    }
    return s3ClientBuilder.build();
}
Also used : NonRetryableException(org.komamitsu.fluency.NonRetryableException) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) AwsBasicCredentials(software.amazon.awssdk.auth.credentials.AwsBasicCredentials) VisibleForTesting(org.msgpack.core.annotations.VisibleForTesting)

Aggregations

NonRetryableException (org.komamitsu.fluency.NonRetryableException)6 RetryableException (org.komamitsu.fluency.RetryableException)3 TDClientHttpException (com.treasuredata.client.TDClientHttpException)2 URI (java.net.URI)2 URISyntaxException (java.net.URISyntaxException)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 TDClientBuilder (com.treasuredata.client.TDClientBuilder)1 TDClientHttpConflictException (com.treasuredata.client.TDClientHttpConflictException)1 TDClientHttpNotFoundException (com.treasuredata.client.TDClientHttpNotFoundException)1 File (java.io.File)1 Test (org.junit.jupiter.api.Test)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1 VisibleForTesting (org.msgpack.core.annotations.VisibleForTesting)1 AwsBasicCredentials (software.amazon.awssdk.auth.credentials.AwsBasicCredentials)1 PutObjectRequest (software.amazon.awssdk.services.s3.model.PutObjectRequest)1