use of com.microsoft.azure.storage.blob.CloudBlobClient in project kylo by Teradata.
the class AzureNativeFileSystemProvider method createBlobClient.
@Nonnull
private CloudBlobClient createBlobClient(@Nonnull final URI uri, @Nonnull final Configuration conf) {
// Determine endpoint
final String httpScheme = StringUtils.equalsAnyIgnoreCase(uri.getScheme(), "asvs", "wasbs") ? "https" : "http";
final URI blobEndPoint = URI.create(httpScheme + "://" + uri.getRawAuthority());
// Create client
final CloudBlobClient client = new CloudBlobClient(blobEndPoint, getCredentials(uri, conf));
final RetryPolicyFactory retryPolicyFactory = new RetryExponentialRetry(conf.getInt("fs.azure.io.retry.min.backoff.interval", 3 * 1000), conf.getInt("fs.azure.io.retry.backoff.interval", 3 * 1000), conf.getInt("fs.azure.io.retry.max.backoff.interval", 30 * 1000), conf.getInt("fs.azure.io.retry.max.retries", 30));
client.getDefaultRequestOptions().setRetryPolicyFactory(retryPolicyFactory);
final int storageConnectionTimeout = conf.getInt("fs.azure.storage.timeout", 0);
if (storageConnectionTimeout > 0) {
client.getDefaultRequestOptions().setTimeoutIntervalInMs(storageConnectionTimeout * 1000);
}
return client;
}
use of com.microsoft.azure.storage.blob.CloudBlobClient in project kylo by Teradata.
the class AzureNativeFileSystemProviderTest method listFiles.
/**
* Verify listing containers using the wasb scheme.
*/
@Test
@SuppressWarnings("unchecked")
public void listFiles() {
// Test listing containers
final AzureNativeFileSystemProvider provider = new AzureNativeFileSystemProvider() {
@Nonnull
@Override
protected Iterable<CloudBlobContainer> listContainers(@Nonnull final CloudBlobClient client) {
return Arrays.asList(createContainer("container1", client), createContainer("container2", client));
}
};
final List<DataSetFile> files = provider.listFiles(new Path(WASB), new Configuration(false));
Assert.assertThat(files, CoreMatchers.hasItems(isDataSetFile("container1"), isDataSetFile("container2")));
Assert.assertEquals(2, files.size());
}
use of com.microsoft.azure.storage.blob.CloudBlobClient in project druid by druid-io.
the class AzureStorageDruidModuleTest method testBothAccountKeyAndSAStokenUnset.
@Test
public void testBothAccountKeyAndSAStokenUnset() {
Properties properties = initializePropertes();
properties.remove("druid.azure.key");
expectedException.expect(ProvisionException.class);
expectedException.expectMessage("Either set 'key' or 'sharedAccessStorageToken' in the azure config but not both");
makeInjectorWithProperties(properties).getInstance(Key.get(new TypeLiteral<Supplier<CloudBlobClient>>() {
}));
}
use of com.microsoft.azure.storage.blob.CloudBlobClient in project druid by druid-io.
the class AzureStorageDruidModuleTest method testGetBlobClientExpectedClient.
@Test
public void testGetBlobClientExpectedClient() {
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());
}
use of com.microsoft.azure.storage.blob.CloudBlobClient in project druid by druid-io.
the class AzureStorageDruidModuleTest method testBothAccountKeyAndSAStokenSet.
@Test
public void testBothAccountKeyAndSAStokenSet() {
Properties properties = initializePropertes();
properties.setProperty("druid.azure.sharedAccessStorageToken", AZURE_SHARED_ACCESS_TOKEN);
expectedException.expect(ProvisionException.class);
expectedException.expectMessage("Either set 'key' or 'sharedAccessStorageToken' in the azure config but not both");
makeInjectorWithProperties(properties).getInstance(Key.get(new TypeLiteral<Supplier<CloudBlobClient>>() {
}));
}
Aggregations