yuqi1129 commented on code in PR #5974:
URL: https://github.com/apache/gravitino/pull/5974#discussion_r1907067331
##########
bundles/azure/src/main/java/org/apache/gravitino/abs/fs/AzureFileSystemProvider.java:
##########
@@ -58,15 +64,49 @@ public FileSystem getFileSystem(@Nonnull Path path,
@Nonnull Map<String, String>
config.get(AzureProperties.GRAVITINO_AZURE_STORAGE_ACCOUNT_KEY));
}
- if (!config.containsKey(ABFS_IMPL_KEY)) {
+ if (!hadoopConfMap.containsKey(ABFS_IMPL_KEY)) {
configuration.set(ABFS_IMPL_KEY, ABFS_IMPL);
}
hadoopConfMap.forEach(configuration::set);
+ if (enableCredentialProvidedByGravitino(hadoopConfMap)) {
+ try {
+ AzureSasCredentialsProvider azureSasCredentialsProvider = new
AzureSasCredentialsProvider();
+ azureSasCredentialsProvider.initialize(configuration, null);
+ String sas = azureSasCredentialsProvider.getSASToken(null, null, null,
null);
+ if (sas != null) {
+ String accountName =
+ String.format(
+ "%s.dfs.core.windows.net",
+
config.get(AzureProperties.GRAVITINO_AZURE_STORAGE_ACCOUNT_NAME));
+
+ configuration.set(
+ FS_AZURE_ACCOUNT_AUTH_TYPE_PROPERTY_NAME + "." + accountName,
AuthType.SAS.name());
+ configuration.set(
+ FS_AZURE_SAS_TOKEN_PROVIDER_TYPE + "." + accountName,
+ AzureSasCredentialsProvider.class.getName());
+ configuration.set(FS_AZURE_ACCOUNT_IS_HNS_ENABLED, "true");
+ } else if (azureSasCredentialsProvider.getAzureStorageAccountKey() !=
null
+ && azureSasCredentialsProvider.getAzureStorageAccountName() !=
null) {
+ configuration.set(
+ String.format(
+ "fs.azure.account.key.%s.dfs.core.windows.net",
+ azureSasCredentialsProvider.getAzureStorageAccountName()),
+ azureSasCredentialsProvider.getAzureStorageAccountKey());
+ }
+ } catch (Exception e) {
+ throw new IOException("Failed to get SAS token from
AzureSasCredentialsProvider", e);
+ }
+ }
+
return FileSystem.get(path.toUri(), configuration);
}
+ private boolean enableCredentialProvidedByGravitino(Map<String, String>
config) {
Review Comment:
OK
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]