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;
}
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");
}
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);
}
}
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);
}
}
Aggregations