Search in sources :

Example 36 with RepositoryMetaData

use of org.elasticsearch.cluster.metadata.RepositoryMetaData in project crate by crate.

the class CreateDropRepositoryAnalyzerTest method init.

@Before
public void init() throws Exception {
    RepositoriesMetaData repositoriesMetaData = new RepositoriesMetaData(new RepositoryMetaData("my_repo", "fs", Settings.builder().put("location", "/tmp/my_repo").build()));
    ClusterState clusterState = ClusterState.builder(new ClusterName("testing")).metaData(MetaData.builder().putCustom(RepositoriesMetaData.TYPE, repositoriesMetaData)).build();
    NoopClusterService clusterService = new NoopClusterService(clusterState);
    e = SQLExecutor.builder(clusterService).build();
}
Also used : RepositoriesMetaData(org.elasticsearch.cluster.metadata.RepositoriesMetaData) ClusterState(org.elasticsearch.cluster.ClusterState) RepositoryMetaData(org.elasticsearch.cluster.metadata.RepositoryMetaData) ClusterName(org.elasticsearch.cluster.ClusterName) NoopClusterService(org.elasticsearch.test.cluster.NoopClusterService) Before(org.junit.Before)

Example 37 with RepositoryMetaData

use of org.elasticsearch.cluster.metadata.RepositoryMetaData in project crate by crate.

the class AzureRepositorySettingsTests method azureRepository.

private AzureRepository azureRepository(Settings settings) {
    Settings internalSettings = Settings.builder().put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toAbsolutePath()).putList(Environment.PATH_DATA_SETTING.getKey(), tmpPaths()).put(settings).build();
    final AzureRepository azureRepository = new AzureRepository(new RepositoryMetadata("foo", "azure", internalSettings), NamedXContentRegistry.EMPTY, mock(AzureStorageService.class), BlobStoreTestUtil.mockClusterService());
    assertThat(azureRepository.getBlobStore(), is(nullValue()));
    return azureRepository;
}
Also used : RepositoryMetadata(org.elasticsearch.cluster.metadata.RepositoryMetadata) Settings(org.elasticsearch.common.settings.Settings)

Example 38 with RepositoryMetaData

use of org.elasticsearch.cluster.metadata.RepositoryMetaData in project crate by crate.

the class S3BlobStoreTests method randomMockS3BlobStore.

/**
 * Creates a new {@link S3BlobStore} with random settings.
 * <p>
 * The blobstore uses a {@link MockAmazonS3} client.
 */
public static S3BlobStore randomMockS3BlobStore() {
    String bucket = randomAlphaOfLength(randomIntBetween(1, 10)).toLowerCase(Locale.ROOT);
    ByteSizeValue bufferSize = new ByteSizeValue(randomIntBetween(5, 100), ByteSizeUnit.MB);
    boolean serverSideEncryption = randomBoolean();
    String cannedACL = null;
    if (randomBoolean()) {
        cannedACL = randomFrom(CannedAccessControlList.values()).toString();
    }
    String storageClass = null;
    if (randomBoolean()) {
        storageClass = randomValueOtherThan(StorageClass.Glacier, () -> randomFrom(StorageClass.values())).toString();
    }
    final AmazonS3 client = new MockAmazonS3(new ConcurrentHashMap<>(), bucket, serverSideEncryption, cannedACL, storageClass);
    final S3Service service = new S3Service() {

        @Override
        public synchronized AmazonS3Reference client(RepositoryMetadata metadata) {
            return new AmazonS3Reference(client);
        }
    };
    return new S3BlobStore(service, bucket, serverSideEncryption, bufferSize, cannedACL, storageClass, new RepositoryMetadata(bucket, "s3", Settings.EMPTY));
}
Also used : AmazonS3(com.amazonaws.services.s3.AmazonS3) RepositoryMetadata(org.elasticsearch.cluster.metadata.RepositoryMetadata) ByteSizeValue(org.elasticsearch.common.unit.ByteSizeValue)

Example 39 with RepositoryMetaData

use of org.elasticsearch.cluster.metadata.RepositoryMetaData in project crate by crate.

the class AzureBlobStoreTests method newBlobStore.

@Override
protected BlobStore newBlobStore() {
    RepositoryMetadata repositoryMetadata = new RepositoryMetadata("azure", "ittest", Settings.EMPTY);
    AzureStorageServiceMock client = new AzureStorageServiceMock();
    try (AzureBlobStore azureBlobStore = new AzureBlobStore(repositoryMetadata, client)) {
        return azureBlobStore;
    }
}
Also used : RepositoryMetadata(org.elasticsearch.cluster.metadata.RepositoryMetadata)

Example 40 with RepositoryMetaData

use of org.elasticsearch.cluster.metadata.RepositoryMetaData in project crate by crate.

the class CreateDropRepositoryAnalyzerTest method prepare.

@Before
public void prepare() {
    RepositoriesMetadata repositoriesMetadata = new RepositoriesMetadata(Collections.singletonList(new RepositoryMetadata("my_repo", "fs", Settings.builder().put("location", "/tmp/my_repo").build())));
    ClusterState clusterState = ClusterState.builder(new ClusterName("testing")).metadata(Metadata.builder().putCustom(RepositoriesMetadata.TYPE, repositoriesMetadata)).build();
    ClusterServiceUtils.setState(clusterService, clusterState);
    e = SQLExecutor.builder(clusterService).build();
    plannerContext = e.getPlannerContext(clusterService.state());
    repositoryParamValidator = new RepositoryParamValidator(Map.of("fs", new TypeSettings(FsRepository.mandatorySettings(), FsRepository.optionalSettings())));
}
Also used : RepositoryParamValidator(io.crate.analyze.repositories.RepositoryParamValidator) RepositoriesMetadata(org.elasticsearch.cluster.metadata.RepositoriesMetadata) ClusterState(org.elasticsearch.cluster.ClusterState) RepositoryMetadata(org.elasticsearch.cluster.metadata.RepositoryMetadata) ClusterName(org.elasticsearch.cluster.ClusterName) TypeSettings(io.crate.analyze.repositories.TypeSettings) Before(org.junit.Before)

Aggregations

RepositoryMetadata (org.elasticsearch.cluster.metadata.RepositoryMetadata)29 RepositoryMetaData (org.elasticsearch.cluster.metadata.RepositoryMetaData)24 ClusterState (org.elasticsearch.cluster.ClusterState)13 RepositoriesMetadata (org.elasticsearch.cluster.metadata.RepositoriesMetadata)13 ArrayList (java.util.ArrayList)11 Settings (org.elasticsearch.common.settings.Settings)11 RepositoriesMetaData (org.elasticsearch.cluster.metadata.RepositoriesMetaData)10 IOException (java.io.IOException)8 ClusterName (org.elasticsearch.cluster.ClusterName)8 Before (org.junit.Before)7 HashMap (java.util.HashMap)6 BlobStoreRepository (org.elasticsearch.repositories.blobstore.BlobStoreRepository)6 ByteArrayInputStream (java.io.ByteArrayInputStream)5 ParameterizedMessage (org.apache.logging.log4j.message.ParameterizedMessage)5 ActionListener (org.elasticsearch.action.ActionListener)5 BlobContainer (org.elasticsearch.common.blobstore.BlobContainer)5 RepositoryException (org.elasticsearch.repositories.RepositoryException)5 Test (org.junit.Test)5 List (java.util.List)4 Map (java.util.Map)4