Search in sources :

Example 1 with InvalidArgumentException

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);
    }
}
Also used : AWSStaticCredentialsProvider(com.amazonaws.auth.AWSStaticCredentialsProvider) InvalidArgumentException(io.crate.exceptions.InvalidArgumentException) SdkClientException(com.amazonaws.SdkClientException) AWSCredentials(com.amazonaws.auth.AWSCredentials) EC2ContainerCredentialsProviderWrapper(com.amazonaws.auth.EC2ContainerCredentialsProviderWrapper)

Example 2 with InvalidArgumentException

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;
}
Also used : InvalidArgumentException(io.crate.exceptions.InvalidArgumentException) RepositoryException(org.elasticsearch.repositories.RepositoryException) BlobStore(org.elasticsearch.common.blobstore.BlobStore) IndexShardSnapshotFailedException(org.elasticsearch.index.snapshots.IndexShardSnapshotFailedException) IndexFormatTooNewException(org.apache.lucene.index.IndexFormatTooNewException) InvalidArgumentException(io.crate.exceptions.InvalidArgumentException) SnapshotException(org.elasticsearch.snapshots.SnapshotException) IOException(java.io.IOException) SnapshotMissingException(org.elasticsearch.snapshots.SnapshotMissingException) NoSuchFileException(java.nio.file.NoSuchFileException) ConcurrentSnapshotExecutionException(org.elasticsearch.snapshots.ConcurrentSnapshotExecutionException) CorruptIndexException(org.apache.lucene.index.CorruptIndexException) IndexShardRestoreFailedException(org.elasticsearch.index.snapshots.IndexShardRestoreFailedException) RepositoryException(org.elasticsearch.repositories.RepositoryException) NotXContentException(org.elasticsearch.common.compress.NotXContentException) IndexShardSnapshotException(org.elasticsearch.index.snapshots.IndexShardSnapshotException) RepositoryVerificationException(org.elasticsearch.repositories.RepositoryVerificationException) IndexFormatTooOldException(org.apache.lucene.index.IndexFormatTooOldException)

Aggregations

InvalidArgumentException (io.crate.exceptions.InvalidArgumentException)2 SdkClientException (com.amazonaws.SdkClientException)1 AWSCredentials (com.amazonaws.auth.AWSCredentials)1 AWSStaticCredentialsProvider (com.amazonaws.auth.AWSStaticCredentialsProvider)1 EC2ContainerCredentialsProviderWrapper (com.amazonaws.auth.EC2ContainerCredentialsProviderWrapper)1 IOException (java.io.IOException)1 NoSuchFileException (java.nio.file.NoSuchFileException)1 CorruptIndexException (org.apache.lucene.index.CorruptIndexException)1 IndexFormatTooNewException (org.apache.lucene.index.IndexFormatTooNewException)1 IndexFormatTooOldException (org.apache.lucene.index.IndexFormatTooOldException)1 BlobStore (org.elasticsearch.common.blobstore.BlobStore)1 NotXContentException (org.elasticsearch.common.compress.NotXContentException)1 IndexShardRestoreFailedException (org.elasticsearch.index.snapshots.IndexShardRestoreFailedException)1 IndexShardSnapshotException (org.elasticsearch.index.snapshots.IndexShardSnapshotException)1 IndexShardSnapshotFailedException (org.elasticsearch.index.snapshots.IndexShardSnapshotFailedException)1 RepositoryException (org.elasticsearch.repositories.RepositoryException)1 RepositoryVerificationException (org.elasticsearch.repositories.RepositoryVerificationException)1 ConcurrentSnapshotExecutionException (org.elasticsearch.snapshots.ConcurrentSnapshotExecutionException)1 SnapshotException (org.elasticsearch.snapshots.SnapshotException)1 SnapshotMissingException (org.elasticsearch.snapshots.SnapshotMissingException)1