use of com.talend.shaded.com.amazonaws.services.s3.AmazonS3Client in project exhibitor by soabase.
the class S3ClientImpl method uploadPart.
@Override
public UploadPartResult uploadPart(UploadPartRequest request) throws Exception {
RefCountedClient holder = client.get();
AmazonS3Client amazonS3Client = holder.useClient();
try {
return amazonS3Client.uploadPart(request);
} finally {
holder.release();
}
}
use of com.talend.shaded.com.amazonaws.services.s3.AmazonS3Client in project exhibitor by soabase.
the class S3ClientImpl method initiateMultipartUpload.
@Override
public InitiateMultipartUploadResult initiateMultipartUpload(InitiateMultipartUploadRequest request) throws Exception {
RefCountedClient holder = client.get();
AmazonS3Client amazonS3Client = holder.useClient();
try {
return amazonS3Client.initiateMultipartUpload(request);
} finally {
holder.release();
}
}
use of com.talend.shaded.com.amazonaws.services.s3.AmazonS3Client in project presto by prestodb.
the class PrestoS3FileSystem method createAmazonS3Client.
private AmazonS3Client createAmazonS3Client(URI uri, Configuration hadoopConfig, ClientConfiguration clientConfig) {
AWSCredentialsProvider credentials = getAwsCredentialsProvider(uri, hadoopConfig);
Optional<EncryptionMaterialsProvider> emp = createEncryptionMaterialsProvider(hadoopConfig);
AmazonS3Client client;
String signerType = hadoopConfig.get(S3_SIGNER_TYPE);
if (signerType != null) {
clientConfig.withSignerOverride(signerType);
}
if (emp.isPresent()) {
client = new AmazonS3EncryptionClient(credentials, emp.get(), clientConfig, new CryptoConfiguration(), METRIC_COLLECTOR);
} else {
client = new AmazonS3Client(credentials, clientConfig, METRIC_COLLECTOR);
}
// use local region when running inside of EC2
if (pinS3ClientToCurrentRegion) {
Region region = Regions.getCurrentRegion();
if (region != null) {
client.setRegion(region);
}
}
String endpoint = hadoopConfig.get(S3_ENDPOINT);
if (endpoint != null) {
client.setEndpoint(endpoint);
}
return client;
}
use of com.talend.shaded.com.amazonaws.services.s3.AmazonS3Client in project YCSB by brianfrankcooper.
the class S3Client method init.
/**
* Initialize any state for the storage.
* Called once per S3 instance; If the client is not null it is re-used.
*/
@Override
public void init() throws DBException {
final int count = INIT_COUNT.incrementAndGet();
synchronized (S3Client.class) {
Properties propsCL = getProperties();
int recordcount = Integer.parseInt(propsCL.getProperty("recordcount"));
int operationcount = Integer.parseInt(propsCL.getProperty("operationcount"));
int numberOfOperations = 0;
if (recordcount > 0) {
if (recordcount > operationcount) {
numberOfOperations = recordcount;
} else {
numberOfOperations = operationcount;
}
} else {
numberOfOperations = operationcount;
}
if (count <= numberOfOperations) {
String accessKeyId = null;
String secretKey = null;
String endPoint = null;
String region = null;
String maxErrorRetry = null;
String maxConnections = null;
String protocol = null;
BasicAWSCredentials s3Credentials;
ClientConfiguration clientConfig;
if (s3Client != null) {
System.out.println("Reusing the same client");
return;
}
try {
InputStream propFile = S3Client.class.getClassLoader().getResourceAsStream("s3.properties");
Properties props = new Properties(System.getProperties());
props.load(propFile);
accessKeyId = props.getProperty("s3.accessKeyId");
if (accessKeyId == null) {
accessKeyId = propsCL.getProperty("s3.accessKeyId");
}
System.out.println(accessKeyId);
secretKey = props.getProperty("s3.secretKey");
if (secretKey == null) {
secretKey = propsCL.getProperty("s3.secretKey");
}
System.out.println(secretKey);
endPoint = props.getProperty("s3.endPoint");
if (endPoint == null) {
endPoint = propsCL.getProperty("s3.endPoint", "s3.amazonaws.com");
}
System.out.println(endPoint);
region = props.getProperty("s3.region");
if (region == null) {
region = propsCL.getProperty("s3.region", "us-east-1");
}
System.out.println(region);
maxErrorRetry = props.getProperty("s3.maxErrorRetry");
if (maxErrorRetry == null) {
maxErrorRetry = propsCL.getProperty("s3.maxErrorRetry", "15");
}
maxConnections = props.getProperty("s3.maxConnections");
if (maxConnections == null) {
maxConnections = propsCL.getProperty("s3.maxConnections");
}
protocol = props.getProperty("s3.protocol");
if (protocol == null) {
protocol = propsCL.getProperty("s3.protocol", "HTTPS");
}
sse = props.getProperty("s3.sse");
if (sse == null) {
sse = propsCL.getProperty("s3.sse", "false");
}
String ssec = props.getProperty("s3.ssec");
if (ssec == null) {
ssec = propsCL.getProperty("s3.ssec", null);
} else {
ssecKey = new SSECustomerKey(ssec);
}
} catch (Exception e) {
System.err.println("The file properties doesn't exist " + e.toString());
e.printStackTrace();
}
try {
System.out.println("Inizializing the S3 connection");
s3Credentials = new BasicAWSCredentials(accessKeyId, secretKey);
clientConfig = new ClientConfiguration();
clientConfig.setMaxErrorRetry(Integer.parseInt(maxErrorRetry));
if (protocol.equals("HTTP")) {
clientConfig.setProtocol(Protocol.HTTP);
} else {
clientConfig.setProtocol(Protocol.HTTPS);
}
if (maxConnections != null) {
clientConfig.setMaxConnections(Integer.parseInt(maxConnections));
}
s3Client = new AmazonS3Client(s3Credentials, clientConfig);
s3Client.setRegion(Region.getRegion(Regions.fromName(region)));
s3Client.setEndpoint(endPoint);
System.out.println("Connection successfully initialized");
} catch (Exception e) {
System.err.println("Could not connect to S3 storage: " + e.toString());
e.printStackTrace();
throw new DBException(e);
}
} else {
System.err.println("The number of threads must be less or equal than the operations");
throw new DBException(new Error("The number of threads must be less or equal than the operations"));
}
}
}
use of com.talend.shaded.com.amazonaws.services.s3.AmazonS3Client in project camel by apache.
the class S3Endpoint method createS3Client.
/**
* Provide the possibility to override this method for an mock implementation
*/
AmazonS3 createS3Client() {
AmazonS3Client client = null;
ClientConfiguration clientConfiguration = null;
boolean isClientConfigFound = false;
if (configuration.hasProxyConfiguration()) {
clientConfiguration = new ClientConfiguration();
clientConfiguration.setProxyHost(configuration.getProxyHost());
clientConfiguration.setProxyPort(configuration.getProxyPort());
isClientConfigFound = true;
}
if (configuration.getAccessKey() != null && configuration.getSecretKey() != null) {
AWSCredentials credentials = new BasicAWSCredentials(configuration.getAccessKey(), configuration.getSecretKey());
if (isClientConfigFound) {
client = new AmazonS3Client(credentials, clientConfiguration);
} else {
client = new AmazonS3Client(credentials);
}
} else {
if (isClientConfigFound) {
client = new AmazonS3Client();
} else {
client = new AmazonS3Client(clientConfiguration);
}
}
S3ClientOptions clientOptions = S3ClientOptions.builder().setPathStyleAccess(configuration.isPathStyleAccess()).build();
client.setS3ClientOptions(clientOptions);
return client;
}
Aggregations