use of io.crate.exceptions.InvalidArgumentException in project crate by crate.
the class S3Service method buildCredentials.
// pkg private for tests
static AWSCredentialsProvider buildCredentials(Logger logger, S3ClientSettings clientSettings) {
final AWSCredentials credentials = clientSettings.credentials;
if (credentials == null) {
logger.debug("Using instance profile credentials");
var ec2ContainerCredentialsProviderWrapper = new EC2ContainerCredentialsProviderWrapper();
try {
// Check if credentials are available
ec2ContainerCredentialsProviderWrapper.getCredentials();
return ec2ContainerCredentialsProviderWrapper;
} catch (SdkClientException e) {
throw new InvalidArgumentException("Cannot find required credentials to create a repository of type s3. " + "Credentials must be provided either as repository options access_key and secret_key or AWS IAM roles.");
}
} else {
logger.debug("Using basic key/secret credentials");
return new AWSStaticCredentialsProvider(credentials);
}
}
use of io.crate.exceptions.InvalidArgumentException in project crate by crate.
the class BlobStoreRepository method blobStore.
/**
* maintains single lazy instance of {@link BlobStore}
*/
public BlobStore blobStore() {
assertSnapshotOrGenericThread();
BlobStore store = blobStore.get();
if (store == null) {
synchronized (lock) {
store = blobStore.get();
if (store == null) {
if (lifecycle.started() == false) {
throw new RepositoryException(metadata.name(), "repository is not in started state");
}
try {
store = createBlobStore();
} catch (RepositoryException | InvalidArgumentException e) {
throw e;
} catch (Exception e) {
throw new RepositoryException(metadata.name(), "cannot create blob store: " + e.getMessage(), e);
}
blobStore.set(store);
}
}
}
return store;
}
Aggregations