Search in sources :

Example 6 with S3ClientOptions

use of com.amazonaws.services.s3.S3ClientOptions in project h2o-3 by h2oai.

the class PersistS3 method configureClient.

static AmazonS3Client configureClient(AmazonS3Client s3Client) {
    if (System.getProperty(S3_REGION) != null) {
        String region = System.getProperty(S3_REGION);
        Log.debug("S3 region specified: ", region);
        s3Client.setRegion(RegionUtils.getRegion(region));
    }
    // Region overrides end-point settings
    if (System.getProperty(S3_END_POINT) != null) {
        String endPoint = System.getProperty(S3_END_POINT);
        Log.debug("S3 endpoint specified: ", endPoint);
        s3Client.setEndpoint(endPoint);
    }
    if (System.getProperty(S3_ENABLE_PATH_STYLE) != null && Boolean.valueOf(System.getProperty(S3_ENABLE_PATH_STYLE))) {
        Log.debug("S3 path style access enabled");
        S3ClientOptions sco = new S3ClientOptions();
        sco.setPathStyleAccess(true);
        s3Client.setS3ClientOptions(sco);
    }
    return s3Client;
}
Also used : S3ClientOptions(com.amazonaws.services.s3.S3ClientOptions)

Example 7 with S3ClientOptions

use of com.amazonaws.services.s3.S3ClientOptions 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");
}
Also used : AmazonS3Client(com.amazonaws.services.s3.AmazonS3Client) StaticCredentialsProvider(com.amazonaws.internal.StaticCredentialsProvider) S3ClientOptions(com.amazonaws.services.s3.S3ClientOptions) AnonymousAWSCredentials(com.amazonaws.auth.AnonymousAWSCredentials) Before(org.junit.Before)

Example 8 with S3ClientOptions

use of com.amazonaws.services.s3.S3ClientOptions in project hadoop by apache.

the class ITestS3AConfiguration method shouldBeAbleToSwitchOnS3PathStyleAccessViaConfigProperty.

@Test
public void shouldBeAbleToSwitchOnS3PathStyleAccessViaConfigProperty() throws Exception {
    conf = new Configuration();
    conf.set(Constants.PATH_STYLE_ACCESS, Boolean.toString(true));
    assertTrue(conf.getBoolean(Constants.PATH_STYLE_ACCESS, false));
    try {
        fs = S3ATestUtils.createTestFileSystem(conf);
        assertNotNull(fs);
        AmazonS3 s3 = fs.getAmazonS3Client();
        assertNotNull(s3);
        S3ClientOptions clientOptions = getField(s3, S3ClientOptions.class, "clientOptions");
        assertTrue("Expected to find path style access to be switched on!", clientOptions.isPathStyleAccess());
        byte[] file = ContractTestUtils.toAsciiByteArray("test file");
        ContractTestUtils.writeAndRead(fs, new Path("/path/style/access/testFile"), file, file.length, (int) conf.getLongBytes(Constants.FS_S3A_BLOCK_SIZE, file.length), false, true);
    } catch (final AWSS3IOException e) {
        LOG.error("Caught exception: ", e);
        // Catch/pass standard path style access behaviour when live bucket
        // isn't in the same region as the s3 client default. See
        // http://docs.aws.amazon.com/AmazonS3/latest/dev/VirtualHosting.html
        assertEquals(e.getStatusCode(), HttpStatus.SC_MOVED_PERMANENTLY);
    }
}
Also used : Path(org.apache.hadoop.fs.Path) AmazonS3(com.amazonaws.services.s3.AmazonS3) Configuration(org.apache.hadoop.conf.Configuration) ClientConfiguration(com.amazonaws.ClientConfiguration) S3ClientOptions(com.amazonaws.services.s3.S3ClientOptions) Test(org.junit.Test)

Example 9 with S3ClientOptions

use of com.amazonaws.services.s3.S3ClientOptions in project nifi by apache.

the class AbstractS3Processor method initalizeEndpointOverride.

private void initalizeEndpointOverride(final ProcessContext context, final AmazonS3Client s3) {
    // if ENDPOINT_OVERRIDE is set, use PathStyleAccess
    if (StringUtils.trimToEmpty(context.getProperty(ENDPOINT_OVERRIDE).evaluateAttributeExpressions().getValue()).isEmpty() == false) {
        final S3ClientOptions s3Options = new S3ClientOptions();
        s3Options.setPathStyleAccess(true);
        s3.setS3ClientOptions(s3Options);
    }
}
Also used : S3ClientOptions(com.amazonaws.services.s3.S3ClientOptions)

Aggregations

S3ClientOptions (com.amazonaws.services.s3.S3ClientOptions)9 AmazonS3Client (com.amazonaws.services.s3.AmazonS3Client)5 ClientConfiguration (com.amazonaws.ClientConfiguration)4 AWSCredentialsProvider (com.amazonaws.auth.AWSCredentialsProvider)2 AnonymousAWSCredentials (com.amazonaws.auth.AnonymousAWSCredentials)2 Configuration (org.apache.hadoop.conf.Configuration)2 Before (org.junit.Before)2 CheckedConsumer (com.adobe.acs.commons.functions.CheckedConsumer)1 AWSCredentials (com.amazonaws.auth.AWSCredentials)1 AWSCredentialsProviderChain (com.amazonaws.auth.AWSCredentialsProviderChain)1 BasicAWSCredentials (com.amazonaws.auth.BasicAWSCredentials)1 DefaultAWSCredentialsProviderChain (com.amazonaws.auth.DefaultAWSCredentialsProviderChain)1 StaticCredentialsProvider (com.amazonaws.internal.StaticCredentialsProvider)1 AmazonS3 (com.amazonaws.services.s3.AmazonS3)1 AccessControlList (com.amazonaws.services.s3.model.AccessControlList)1 TransferManager (com.amazonaws.services.s3.transfer.TransferManager)1 TransferManagerConfiguration (com.amazonaws.services.s3.transfer.TransferManagerConfiguration)1 AssetManager (com.day.cq.dam.api.AssetManager)1 URI (java.net.URI)1 ExecutorService (java.util.concurrent.ExecutorService)1