Search in sources :

Example 11 with CloudBlobClient

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

the class AzureStorageServiceTests method testGetSelectedClientSecondary2.

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

Example 12 with CloudBlobClient

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

the class AzureStorageServiceTests method testGetSelectedClientSecondary1.

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

Example 13 with CloudBlobClient

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

the class AzureStorageServiceTests method testGetSelectedClientWithNoSecondary.

public void testGetSelectedClientWithNoSecondary() {
    AzureStorageServiceImpl azureStorageService = new AzureStorageServiceMock(Settings.builder().put("cloud.azure.storage.azure1.account", "myaccount1").put("cloud.azure.storage.azure1.key", "mykey1").build());
    CloudBlobClient client = azureStorageService.getSelectedClient("azure1", LocationMode.PRIMARY_ONLY);
    assertThat(client.getEndpoint(), is(URI.create("https://azure1")));
}
Also used : CloudBlobClient(com.microsoft.azure.storage.blob.CloudBlobClient)

Example 14 with CloudBlobClient

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

the class AzureStorageServiceTests method testGetSelectedClientGlobalTimeout.

public void testGetSelectedClientGlobalTimeout() {
    Settings timeoutSettings = Settings.builder().put(settings).put(AzureStorageService.Storage.TIMEOUT_SETTING.getKey(), "10s").build();
    AzureStorageServiceImpl azureStorageService = new AzureStorageServiceMock(timeoutSettings);
    CloudBlobClient client1 = azureStorageService.getSelectedClient("azure1", LocationMode.PRIMARY_ONLY);
    assertThat(client1.getDefaultRequestOptions().getTimeoutIntervalInMs(), is(10 * 1000));
    CloudBlobClient client3 = azureStorageService.getSelectedClient("azure3", LocationMode.PRIMARY_ONLY);
    assertThat(client3.getDefaultRequestOptions().getTimeoutIntervalInMs(), is(30 * 1000));
}
Also used : CloudBlobClient(com.microsoft.azure.storage.blob.CloudBlobClient) Settings(org.elasticsearch.common.settings.Settings)

Example 15 with CloudBlobClient

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

the class LocalSASKeyGeneratorImpl method getContainerSASUri.

/**
   * Implementation to generate SAS Key for a container
   */
@Override
public URI getContainerSASUri(String accountName, String container) throws SASKeyGenerationException {
    try {
        CloudStorageAccount account = getSASKeyBasedStorageAccountInstance(accountName);
        CloudBlobClient client = account.createCloudBlobClient();
        return client.getCredentials().transformUri(client.getContainerReference(container).getUri());
    } catch (StorageException stoEx) {
        throw new SASKeyGenerationException("Encountered StorageException while" + " generating SAS Key for container " + container + " inside " + "storage account " + accountName, stoEx);
    } catch (URISyntaxException uriSyntaxEx) {
        throw new SASKeyGenerationException("Encountered URISyntaxException while" + " generating SAS Key for container " + container + " inside storage" + " account " + accountName, uriSyntaxEx);
    }
}
Also used : CloudBlobClient(com.microsoft.azure.storage.blob.CloudBlobClient) CloudStorageAccount(com.microsoft.azure.storage.CloudStorageAccount) URISyntaxException(java.net.URISyntaxException) StorageException(com.microsoft.azure.storage.StorageException)

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