Search in sources :

Example 16 with RepositoryMetadata

use of org.opensearch.cluster.metadata.RepositoryMetadata in project OpenSearch by opensearch-project.

the class SnapshotClientDocumentationIT method testSnapshotGetRepository.

public void testSnapshotGetRepository() throws IOException {
    RestHighLevelClient client = highLevelClient();
    createTestRepositories();
    // tag::get-repository-request
    GetRepositoriesRequest request = new GetRepositoriesRequest();
    // end::get-repository-request
    // tag::get-repository-request-repositories
    String[] repositories = new String[] { repositoryName };
    // <1>
    request.repositories(repositories);
    // end::get-repository-request-repositories
    // tag::get-repository-request-local
    // <1>
    request.local(true);
    // end::get-repository-request-local
    // tag::get-repository-request-masterTimeout
    // <1>
    request.masterNodeTimeout(TimeValue.timeValueMinutes(1));
    // <2>
    request.masterNodeTimeout("1m");
    // end::get-repository-request-masterTimeout
    // tag::get-repository-execute
    GetRepositoriesResponse response = client.snapshot().getRepository(request, RequestOptions.DEFAULT);
    // end::get-repository-execute
    // tag::get-repository-response
    List<RepositoryMetadata> repositoryMetadataResponse = response.repositories();
    // end::get-repository-response
    assertThat(1, equalTo(repositoryMetadataResponse.size()));
    assertThat(repositoryName, equalTo(repositoryMetadataResponse.get(0).name()));
}
Also used : RepositoryMetadata(org.opensearch.cluster.metadata.RepositoryMetadata) RestHighLevelClient(org.opensearch.client.RestHighLevelClient) GetRepositoriesRequest(org.opensearch.action.admin.cluster.repositories.get.GetRepositoriesRequest) GetRepositoriesResponse(org.opensearch.action.admin.cluster.repositories.get.GetRepositoriesResponse)

Example 17 with RepositoryMetadata

use of org.opensearch.cluster.metadata.RepositoryMetadata in project OpenSearch by opensearch-project.

the class S3BlobContainerRetriesTests method createBlobContainer.

@Override
protected BlobContainer createBlobContainer(@Nullable final Integer maxRetries, @Nullable final TimeValue readTimeout, @Nullable final Boolean disableChunkedEncoding, @Nullable final ByteSizeValue bufferSize) {
    final Settings.Builder clientSettings = Settings.builder();
    final String clientName = randomAlphaOfLength(5).toLowerCase(Locale.ROOT);
    final InetSocketAddress address = httpServer.getAddress();
    final String endpoint = "http://" + InetAddresses.toUriString(address.getAddress()) + ":" + address.getPort();
    clientSettings.put(ENDPOINT_SETTING.getConcreteSettingForNamespace(clientName).getKey(), endpoint);
    if (maxRetries != null) {
        clientSettings.put(MAX_RETRIES_SETTING.getConcreteSettingForNamespace(clientName).getKey(), maxRetries);
    }
    if (readTimeout != null) {
        clientSettings.put(READ_TIMEOUT_SETTING.getConcreteSettingForNamespace(clientName).getKey(), readTimeout);
    }
    if (disableChunkedEncoding != null) {
        clientSettings.put(DISABLE_CHUNKED_ENCODING.getConcreteSettingForNamespace(clientName).getKey(), disableChunkedEncoding);
    }
    final MockSecureSettings secureSettings = new MockSecureSettings();
    secureSettings.setString(S3ClientSettings.ACCESS_KEY_SETTING.getConcreteSettingForNamespace(clientName).getKey(), "access");
    secureSettings.setString(S3ClientSettings.SECRET_KEY_SETTING.getConcreteSettingForNamespace(clientName).getKey(), "secret");
    clientSettings.setSecureSettings(secureSettings);
    service.refreshAndClearCache(S3ClientSettings.load(clientSettings.build()));
    final RepositoryMetadata repositoryMetadata = new RepositoryMetadata("repository", S3Repository.TYPE, Settings.builder().put(S3Repository.CLIENT_NAME.getKey(), clientName).build());
    return new S3BlobContainer(BlobPath.cleanPath(), new S3BlobStore(service, "bucket", S3Repository.SERVER_SIDE_ENCRYPTION_SETTING.getDefault(Settings.EMPTY), bufferSize == null ? S3Repository.BUFFER_SIZE_SETTING.getDefault(Settings.EMPTY) : bufferSize, S3Repository.CANNED_ACL_SETTING.getDefault(Settings.EMPTY), S3Repository.STORAGE_CLASS_SETTING.getDefault(Settings.EMPTY), repositoryMetadata)) {

        @Override
        public InputStream readBlob(String blobName) throws IOException {
            return new AssertingInputStream(super.readBlob(blobName), blobName);
        }

        @Override
        public InputStream readBlob(String blobName, long position, long length) throws IOException {
            return new AssertingInputStream(super.readBlob(blobName, position, length), blobName, position, length);
        }
    };
}
Also used : InetSocketAddress(java.net.InetSocketAddress) RepositoryMetadata(org.opensearch.cluster.metadata.RepositoryMetadata) Matchers.containsString(org.hamcrest.Matchers.containsString) MockSecureSettings(org.opensearch.common.settings.MockSecureSettings) Settings(org.opensearch.common.settings.Settings) MockSecureSettings(org.opensearch.common.settings.MockSecureSettings)

Example 18 with RepositoryMetadata

use of org.opensearch.cluster.metadata.RepositoryMetadata in project OpenSearch by opensearch-project.

the class S3RepositoryTests method testDefaultBufferSize.

public void testDefaultBufferSize() {
    final RepositoryMetadata metadata = new RepositoryMetadata("dummy-repo", "mock", Settings.EMPTY);
    try (S3Repository s3repo = createS3Repo(metadata)) {
        assertThat(s3repo.getBlobStore(), is(nullValue()));
        s3repo.start();
        final long defaultBufferSize = ((S3BlobStore) s3repo.blobStore()).bufferSizeInBytes();
        assertThat(s3repo.getBlobStore(), not(nullValue()));
        assertThat(defaultBufferSize, Matchers.lessThanOrEqualTo(100L * 1024 * 1024));
        assertThat(defaultBufferSize, Matchers.greaterThanOrEqualTo(5L * 1024 * 1024));
    }
}
Also used : RepositoryMetadata(org.opensearch.cluster.metadata.RepositoryMetadata)

Example 19 with RepositoryMetadata

use of org.opensearch.cluster.metadata.RepositoryMetadata in project OpenSearch by opensearch-project.

the class S3ServiceTests method testCachedClientsAreReleased.

public void testCachedClientsAreReleased() {
    final S3Service s3Service = new S3Service();
    final Settings settings = Settings.builder().put("endpoint", "http://first").build();
    final RepositoryMetadata metadata1 = new RepositoryMetadata("first", "s3", settings);
    final RepositoryMetadata metadata2 = new RepositoryMetadata("second", "s3", settings);
    final S3ClientSettings clientSettings = s3Service.settings(metadata2);
    final S3ClientSettings otherClientSettings = s3Service.settings(metadata2);
    assertSame(clientSettings, otherClientSettings);
    final AmazonS3Reference reference = s3Service.client(metadata1);
    reference.close();
    s3Service.close();
    final AmazonS3Reference referenceReloaded = s3Service.client(metadata1);
    assertNotSame(referenceReloaded, reference);
    referenceReloaded.close();
    s3Service.close();
    final S3ClientSettings clientSettingsReloaded = s3Service.settings(metadata1);
    assertNotSame(clientSettings, clientSettingsReloaded);
}
Also used : RepositoryMetadata(org.opensearch.cluster.metadata.RepositoryMetadata) Settings(org.opensearch.common.settings.Settings)

Example 20 with RepositoryMetadata

use of org.opensearch.cluster.metadata.RepositoryMetadata in project OpenSearch by opensearch-project.

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(), new RecoverySettings(settings, new ClusterSettings(settings, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS)));
    assertThat(azureRepository.getBlobStore(), is(nullValue()));
    return azureRepository;
}
Also used : ClusterSettings(org.opensearch.common.settings.ClusterSettings) RepositoryMetadata(org.opensearch.cluster.metadata.RepositoryMetadata) RecoverySettings(org.opensearch.indices.recovery.RecoverySettings) Settings(org.opensearch.common.settings.Settings) ClusterSettings(org.opensearch.common.settings.ClusterSettings) RecoverySettings(org.opensearch.indices.recovery.RecoverySettings)

Aggregations

RepositoryMetadata (org.opensearch.cluster.metadata.RepositoryMetadata)37 Settings (org.opensearch.common.settings.Settings)16 RepositoriesMetadata (org.opensearch.cluster.metadata.RepositoriesMetadata)12 RecoverySettings (org.opensearch.indices.recovery.RecoverySettings)11 ArrayList (java.util.ArrayList)8 BlobContainer (org.opensearch.common.blobstore.BlobContainer)8 ClusterSettings (org.opensearch.common.settings.ClusterSettings)8 IOException (java.io.IOException)7 BlobStoreRepository (org.opensearch.repositories.blobstore.BlobStoreRepository)7 ByteArrayInputStream (java.io.ByteArrayInputStream)6 ParameterizedMessage (org.apache.logging.log4j.message.ParameterizedMessage)6 ClusterState (org.opensearch.cluster.ClusterState)6 Metadata (org.opensearch.cluster.metadata.Metadata)6 ClusterService (org.opensearch.cluster.service.ClusterService)6 Collections (java.util.Collections)5 Path (java.nio.file.Path)4 Collection (java.util.Collection)4 List (java.util.List)4 Map (java.util.Map)4 Collectors (java.util.stream.Collectors)4