Search in sources :

Example 11 with RepositoryMetaData

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

the class SysRepositoriesService method addRepositories.

private void addRepositories(@Nullable RepositoriesMetaData repositoriesMetaData) {
    if (repositoriesMetaData == null) {
        return;
    }
    for (RepositoryMetaData repositoryMetaData : repositoriesMetaData.repositories()) {
        SysRepository repository = new SysRepository(repositoryMetaData.name(), repositoryMetaData.type(), repositoryMetaData.settings().getAsStructuredMap());
        repositoriesTable.put(repositoryMetaData.name(), repository);
    }
}
Also used : RepositoryMetaData(org.elasticsearch.cluster.metadata.RepositoryMetaData)

Example 12 with RepositoryMetaData

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

the class AwsS3ServiceImplTests method testGetClientForSameSettingsReturnsCachedClient.

@Test
public void testGetClientForSameSettingsReturnsCachedClient() {
    RepositoryMetadata metadata = new RepositoryMetadata("", "", Settings.builder().put("access_key", "access_key").put("secret_key", "secret_key").build());
    var clientRef = service.client(metadata);
    assertThat(clientRef.refCount(), is(2));
    var newClientRef = service.client(metadata);
    assertThat(newClientRef.refCount(), is(3));
    assertThat(clientRef.client(), is(newClientRef.client()));
    clientRef.client().shutdown();
    newClientRef.client().shutdown();
}
Also used : RepositoryMetadata(org.elasticsearch.cluster.metadata.RepositoryMetadata) Test(org.junit.Test)

Example 13 with RepositoryMetaData

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

the class AwsS3ServiceImplTests method testGetClientForUpdatedSettingsReturnsNewClient.

@Test
public void testGetClientForUpdatedSettingsReturnsNewClient() {
    Settings settings = Settings.builder().put("access_key", "access_key").put("secret_key", "secret_key").build();
    Settings newSettings = Settings.builder().put("access_key", "access_key").put("secret_key", "new_secret_key").build();
    RepositoryMetadata metadata = new RepositoryMetadata("", "", settings);
    RepositoryMetadata newMetadata = new RepositoryMetadata("", "", newSettings);
    AmazonS3Reference clientRef = service.client(metadata);
    assertThat(clientRef.refCount(), is(2));
    AmazonS3Reference newClientRef = service.client(newMetadata);
    assertThat(newClientRef.refCount(), is(2));
    assertThat(clientRef.client(), is(not(newClientRef.client())));
    clientRef.client().shutdown();
    newClientRef.client().shutdown();
}
Also used : RepositoryMetadata(org.elasticsearch.cluster.metadata.RepositoryMetadata) Settings(org.elasticsearch.common.settings.Settings) Test(org.junit.Test)

Example 14 with RepositoryMetaData

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

the class S3RepositoryPluginAnalyzerTest 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("s3", new TypeSettings(List.of(), S3Repository.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)

Example 15 with RepositoryMetaData

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

the class AzureBlobStoreContainerTests 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)

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