Search in sources :

Example 36 with CloudBlobClient

use of com.microsoft.azure.storage.blob.CloudBlobClient in project crate by crate.

the class AzureStorageServiceTests method testGetSelectedClientBackoffPolicyNbRetries.

public void testGetSelectedClientBackoffPolicyNbRetries() {
    final Settings timeoutSettings = Settings.builder().put(buildClientCredSettings()).put("max_retries", 7).build();
    final AzureStorageService azureStorageService = storageServiceWithSettings(timeoutSettings);
    final CloudBlobClient client = azureStorageService.client().v1();
    assertThat(client.getDefaultRequestOptions().getRetryPolicyFactory(), is(notNullValue()));
    assertThat(client.getDefaultRequestOptions().getRetryPolicyFactory(), instanceOf(RetryExponentialRetry.class));
}
Also used : CloudBlobClient(com.microsoft.azure.storage.blob.CloudBlobClient) RetryExponentialRetry(com.microsoft.azure.storage.RetryExponentialRetry) Settings(org.elasticsearch.common.settings.Settings)

Example 37 with CloudBlobClient

use of com.microsoft.azure.storage.blob.CloudBlobClient in project druid by druid-io.

the class AzureStorageDruidModuleTest method testGetAzureStorageContainerWithSASExpectedClient.

@Test
public void testGetAzureStorageContainerWithSASExpectedClient() {
    Properties properties = initializePropertes();
    properties.setProperty("druid.azure.sharedAccessStorageToken", AZURE_SHARED_ACCESS_TOKEN);
    properties.remove("druid.azure.key");
    injector = makeInjectorWithProperties(properties);
    Supplier<CloudBlobClient> cloudBlobClient = injector.getInstance(Key.get(new TypeLiteral<Supplier<CloudBlobClient>>() {
    }));
    AzureAccountConfig azureAccountConfig = injector.getInstance(AzureAccountConfig.class);
    Assert.assertEquals(AZURE_SHARED_ACCESS_TOKEN, azureAccountConfig.getSharedAccessStorageToken());
    AzureStorage azureStorage = injector.getInstance(AzureStorage.class);
    Assert.assertSame(cloudBlobClient.get(), azureStorage.getCloudBlobClient());
}
Also used : CloudBlobClient(com.microsoft.azure.storage.blob.CloudBlobClient) TypeLiteral(com.google.inject.TypeLiteral) Properties(java.util.Properties) Test(org.junit.Test)

Example 38 with CloudBlobClient

use of com.microsoft.azure.storage.blob.CloudBlobClient in project druid by druid-io.

the class AzureStorageDruidModuleTest method testGetAzureStorageContainerExpectedClient.

@Test
public void testGetAzureStorageContainerExpectedClient() {
    injector = makeInjectorWithProperties(PROPERTIES);
    Supplier<CloudBlobClient> cloudBlobClient = injector.getInstance(Key.get(new TypeLiteral<Supplier<CloudBlobClient>>() {
    }));
    StorageCredentials storageCredentials = cloudBlobClient.get().getCredentials();
    Assert.assertEquals(AZURE_ACCOUNT_NAME, storageCredentials.getAccountName());
    AzureStorage azureStorage = injector.getInstance(AzureStorage.class);
    Assert.assertSame(cloudBlobClient.get(), azureStorage.getCloudBlobClient());
}
Also used : CloudBlobClient(com.microsoft.azure.storage.blob.CloudBlobClient) StorageCredentials(com.microsoft.azure.storage.StorageCredentials) TypeLiteral(com.google.inject.TypeLiteral) Test(org.junit.Test)

Example 39 with CloudBlobClient

use of com.microsoft.azure.storage.blob.CloudBlobClient in project elasticsearch by elastic.

the class AzureStorageServiceTests method testGetSelectedClientDefault.

public void testGetSelectedClientDefault() {
    AzureStorageServiceImpl azureStorageService = new AzureStorageServiceMock(settings);
    CloudBlobClient client = azureStorageService.getSelectedClient(null, LocationMode.PRIMARY_ONLY);
    assertThat(client.getEndpoint(), is(URI.create("https://azure1")));
}
Also used : CloudBlobClient(com.microsoft.azure.storage.blob.CloudBlobClient)

Example 40 with CloudBlobClient

use of com.microsoft.azure.storage.blob.CloudBlobClient in project elasticsearch by elastic.

the class AzureStorageServiceTests method testGetDefaultClientWithPrimaryAndSecondaries.

public void testGetDefaultClientWithPrimaryAndSecondaries() {
    AzureStorageServiceImpl azureStorageService = new AzureStorageServiceMock(settings);
    CloudBlobClient client = azureStorageService.getSelectedClient(null, LocationMode.PRIMARY_ONLY);
    assertThat(client.getEndpoint(), is(URI.create("https://azure1")));
}
Also used : CloudBlobClient(com.microsoft.azure.storage.blob.CloudBlobClient)

Aggregations

CloudBlobClient (com.microsoft.azure.storage.blob.CloudBlobClient)71 CloudBlobContainer (com.microsoft.azure.storage.blob.CloudBlobContainer)40 CloudStorageAccount (com.microsoft.azure.storage.CloudStorageAccount)19 StorageException (com.microsoft.azure.storage.StorageException)19 URISyntaxException (java.net.URISyntaxException)17 CloudBlockBlob (com.microsoft.azure.storage.blob.CloudBlockBlob)16 ListBlobItem (com.microsoft.azure.storage.blob.ListBlobItem)10 Supplier (java.util.function.Supplier)9 CloudBlob (com.microsoft.azure.storage.blob.CloudBlob)8 URI (java.net.URI)8 InvalidKeyException (java.security.InvalidKeyException)8 Test (org.junit.Test)7 ArrayList (java.util.ArrayList)6 ParameterizedMessage (org.apache.logging.log4j.message.ParameterizedMessage)6 TypeLiteral (com.google.inject.TypeLiteral)5 BlobListingDetails (com.microsoft.azure.storage.blob.BlobListingDetails)5 IOException (java.io.IOException)5 BlobProperties (com.microsoft.azure.storage.blob.BlobProperties)4 HashMap (java.util.HashMap)4 Settings (org.elasticsearch.common.settings.Settings)4