Search in sources :

Example 1 with ParallelTransferOptions

use of com.azure.storage.blob.models.ParallelTransferOptions in project OpenSearch by opensearch-project.

the class AzureBlobContainerRetriesTests method createBlobContainer.

private BlobContainer createBlobContainer(final int maxRetries) {
    final Settings.Builder clientSettings = Settings.builder();
    final String clientName = randomAlphaOfLength(5).toLowerCase(Locale.ROOT);
    final InetSocketAddress address = httpServer.getAddress();
    final String endpoint = "ignored;DefaultEndpointsProtocol=http;BlobEndpoint=http://" + InetAddresses.toUriString(address.getAddress()) + ":" + address.getPort() + "/";
    clientSettings.put(ENDPOINT_SUFFIX_SETTING.getConcreteSettingForNamespace(clientName).getKey(), endpoint);
    clientSettings.put(MAX_RETRIES_SETTING.getConcreteSettingForNamespace(clientName).getKey(), maxRetries);
    clientSettings.put(TIMEOUT_SETTING.getConcreteSettingForNamespace(clientName).getKey(), TimeValue.timeValueMillis(2000));
    final MockSecureSettings secureSettings = new MockSecureSettings();
    secureSettings.setString(ACCOUNT_SETTING.getConcreteSettingForNamespace(clientName).getKey(), "account");
    final String key = Base64.getEncoder().encodeToString(randomAlphaOfLength(10).getBytes(UTF_8));
    secureSettings.setString(KEY_SETTING.getConcreteSettingForNamespace(clientName).getKey(), key);
    clientSettings.setSecureSettings(secureSettings);
    service = new AzureStorageService(clientSettings.build()) {

        @Override
        RequestRetryOptions createRetryPolicy(final AzureStorageSettings azureStorageSettings, String secondaryHost) {
            return new RequestRetryOptions(RetryPolicyType.EXPONENTIAL, azureStorageSettings.getMaxRetries(), 1, 10L, 100L, secondaryHost);
        }

        @Override
        ParallelTransferOptions getBlobRequestOptionsForWriteBlob() {
            return new ParallelTransferOptions().setMaxSingleUploadSizeLong(ByteSizeUnit.MB.toBytes(1));
        }
    };
    final RepositoryMetadata repositoryMetadata = new RepositoryMetadata("repository", AzureRepository.TYPE, Settings.builder().put(CONTAINER_SETTING.getKey(), "container").put(ACCOUNT_SETTING.getKey(), clientName).build());
    return new AzureBlobContainer(BlobPath.cleanPath(), new AzureBlobStore(repositoryMetadata, service, threadPool), threadPool);
}
Also used : RequestRetryOptions(com.azure.storage.common.policy.RequestRetryOptions) InetSocketAddress(java.net.InetSocketAddress) Matchers.containsString(org.hamcrest.Matchers.containsString) MockSecureSettings(org.opensearch.common.settings.MockSecureSettings) RepositoryMetadata(org.opensearch.cluster.metadata.RepositoryMetadata) ParallelTransferOptions(com.azure.storage.blob.models.ParallelTransferOptions) MockSecureSettings(org.opensearch.common.settings.MockSecureSettings) Settings(org.opensearch.common.settings.Settings)

Aggregations

ParallelTransferOptions (com.azure.storage.blob.models.ParallelTransferOptions)1 RequestRetryOptions (com.azure.storage.common.policy.RequestRetryOptions)1 InetSocketAddress (java.net.InetSocketAddress)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1 RepositoryMetadata (org.opensearch.cluster.metadata.RepositoryMetadata)1 MockSecureSettings (org.opensearch.common.settings.MockSecureSettings)1 Settings (org.opensearch.common.settings.Settings)1