use of com.amazonaws.services.s3.model.S3Object in project exhibitor by soabase.
the class S3ClientImpl method getObject.
@Override
public S3Object getObject(String bucket, String key) throws Exception {
RefCountedClient holder = client.get();
AmazonS3Client amazonS3Client = holder.useClient();
try {
return amazonS3Client.getObject(bucket, key);
} finally {
holder.release();
}
}
use of com.amazonaws.services.s3.model.S3Object in project exhibitor by soabase.
the class S3ConfigProvider method loadConfig.
@Override
public LoadedInstanceConfig loadConfig() throws Exception {
Date lastModified;
Properties properties = new Properties();
S3Object object = getConfigObject();
if (object != null) {
try {
lastModified = object.getObjectMetadata().getLastModified();
properties.load(object.getObjectContent());
} finally {
CloseableUtils.closeQuietly(object.getObjectContent());
}
} else {
lastModified = new Date(0L);
}
PropertyBasedInstanceConfig config = new PropertyBasedInstanceConfig(properties, defaults);
return new LoadedInstanceConfig(config, lastModified.getTime());
}
use of com.amazonaws.services.s3.model.S3Object in project ignite by apache.
the class S3CheckpointSpi method read.
/**
* Reads checkpoint data.
*
* @param key Key name to read data from.
* @return Checkpoint data object.
* @throws IgniteCheckedException Thrown if an error occurs while unmarshalling.
* @throws AmazonClientException If an error occurs while querying Amazon S3.
*/
@Nullable
private S3CheckpointData read(String key) throws IgniteCheckedException, AmazonClientException {
assert !F.isEmpty(key);
if (log.isDebugEnabled())
log.debug("Reading data from S3 [bucket=" + bucketName + ", key=" + key + ']');
try {
S3Object obj = s3.getObject(bucketName, key);
InputStream in = obj.getObjectContent();
try {
return S3CheckpointData.fromStream(in);
} catch (IOException e) {
throw new IgniteCheckedException("Failed to unmarshal S3CheckpointData [bucketName=" + bucketName + ", key=" + key + ']', e);
} finally {
U.closeQuiet(in);
}
} catch (AmazonServiceException e) {
if (e.getStatusCode() != 404)
throw e;
}
return null;
}
use of com.amazonaws.services.s3.model.S3Object in project jackrabbit by apache.
the class S3Backend method read.
@Override
public InputStream read(DataIdentifier identifier) throws DataStoreException {
long start = System.currentTimeMillis();
String key = getKeyName(identifier);
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
S3Object object = s3service.getObject(bucket, key);
InputStream in = object.getObjectContent();
LOG.debug("[{}] read took [{}]ms", identifier, (System.currentTimeMillis() - start));
return in;
} catch (AmazonServiceException e) {
throw new DataStoreException("Object not found: " + key, e);
} finally {
if (contextClassLoader != null) {
Thread.currentThread().setContextClassLoader(contextClassLoader);
}
}
}
use of com.amazonaws.services.s3.model.S3Object in project jackrabbit-oak by apache.
the class S3Backend method read.
@Override
public InputStream read(DataIdentifier identifier) throws DataStoreException {
long start = System.currentTimeMillis();
String key = getKeyName(identifier);
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
S3Object object = s3service.getObject(bucket, key);
InputStream in = object.getObjectContent();
LOG.debug("[{}] read took [{}]ms", identifier, (System.currentTimeMillis() - start));
return in;
} catch (AmazonServiceException e) {
throw new DataStoreException("Object not found: " + key, e);
} finally {
if (contextClassLoader != null) {
Thread.currentThread().setContextClassLoader(contextClassLoader);
}
}
}
Aggregations