Example usage for org.apache.hadoop.fs.azure AzureNativeFileSystemStore getAccountKeyFromConfiguration

List of usage examples for org.apache.hadoop.fs.azure AzureNativeFileSystemStore getAccountKeyFromConfiguration

Introduction

In this page you can find the example usage for org.apache.hadoop.fs.azure AzureNativeFileSystemStore getAccountKeyFromConfiguration.

Prototype

@VisibleForTesting
    public static String getAccountKeyFromConfiguration(String accountName, Configuration conf)
            throws KeyProviderException 

Source Link

Usage

From source file:com.thinkbiganalytics.kylo.catalog.azure.AzureNativeFileSystemProvider.java

License:Apache License

@Nullable
private StorageCredentials getCredentials(@Nonnull final URI uri, @Nonnull final Configuration conf) {
    // Find account name
    final String accountName = uri.getHost();
    if (StringUtils.isEmpty(accountName)) {
        throw new CatalogException("catalog.fs.azure.missingAccountName");
    }// www.  ja va  2s.c  om

    // Find account key
    final String accountKey;
    try {
        accountKey = AzureNativeFileSystemStore.getAccountKeyFromConfiguration(accountName, conf);
    } catch (final KeyProviderException e) {
        throw new CatalogException("catalog.fs.azure.invalidAccountKey");
    }

    // Create credentials
    if (StringUtils.isNotEmpty(accountKey)) {
        final String rawAccountName = accountName.split("\\.")[0];
        return new StorageCredentialsAccountAndKey(rawAccountName, accountKey);
    } else {
        return null;
    }
}