|
@@ -27,7 +27,6 @@ import com.google.common.annotations.VisibleForTesting;
|
|
|
import org.apache.hadoop.classification.InterfaceAudience;
|
|
|
import org.apache.hadoop.classification.InterfaceStability;
|
|
|
import org.apache.hadoop.conf.Configuration;
|
|
|
-import org.apache.hadoop.fs.azurebfs.constants.FileSystemConfigurations;
|
|
|
import org.apache.hadoop.fs.azurebfs.contracts.annotations.ConfigurationValidationAnnotations.IntegerConfigurationValidatorAnnotation;
|
|
|
import org.apache.hadoop.fs.azurebfs.contracts.annotations.ConfigurationValidationAnnotations.LongConfigurationValidatorAnnotation;
|
|
|
import org.apache.hadoop.fs.azurebfs.contracts.annotations.ConfigurationValidationAnnotations.StringConfigurationValidatorAnnotation;
|
|
@@ -43,13 +42,14 @@ import org.apache.hadoop.fs.azurebfs.diagnostics.BooleanConfigurationBasicValida
|
|
|
import org.apache.hadoop.fs.azurebfs.diagnostics.IntegerConfigurationBasicValidator;
|
|
|
import org.apache.hadoop.fs.azurebfs.diagnostics.LongConfigurationBasicValidator;
|
|
|
import org.apache.hadoop.fs.azurebfs.diagnostics.StringConfigurationBasicValidator;
|
|
|
+import org.apache.hadoop.fs.azurebfs.extensions.CustomTokenProviderAdaptee;
|
|
|
import org.apache.hadoop.fs.azurebfs.oauth2.AccessTokenProvider;
|
|
|
import org.apache.hadoop.fs.azurebfs.oauth2.ClientCredsTokenProvider;
|
|
|
-import org.apache.hadoop.fs.azurebfs.oauth2.CustomTokenProviderAdaptee;
|
|
|
import org.apache.hadoop.fs.azurebfs.oauth2.CustomTokenProviderAdapter;
|
|
|
import org.apache.hadoop.fs.azurebfs.oauth2.MsiTokenProvider;
|
|
|
import org.apache.hadoop.fs.azurebfs.oauth2.RefreshTokenBasedTokenProvider;
|
|
|
import org.apache.hadoop.fs.azurebfs.oauth2.UserPasswordTokenProvider;
|
|
|
+import org.apache.hadoop.fs.azurebfs.security.AbfsDelegationTokenManager;
|
|
|
import org.apache.hadoop.fs.azurebfs.services.AuthType;
|
|
|
import org.apache.hadoop.fs.azurebfs.services.KeyProvider;
|
|
|
import org.apache.hadoop.fs.azurebfs.services.SimpleKeyProvider;
|
|
@@ -57,7 +57,7 @@ import org.apache.hadoop.fs.azurebfs.utils.SSLSocketFactoryEx;
|
|
|
import org.apache.hadoop.util.ReflectionUtils;
|
|
|
|
|
|
import static org.apache.hadoop.fs.azurebfs.constants.ConfigurationKeys.*;
|
|
|
-import static org.apache.hadoop.fs.azurebfs.constants.FileSystemConfigurations.DEFAULT_FS_AZURE_SSL_CHANNEL_MODE;
|
|
|
+import static org.apache.hadoop.fs.azurebfs.constants.FileSystemConfigurations.*;
|
|
|
|
|
|
/**
|
|
|
* Configuration for Azure Blob FileSystem.
|
|
@@ -69,83 +69,86 @@ public class AbfsConfiguration{
|
|
|
private final boolean isSecure;
|
|
|
|
|
|
@IntegerConfigurationValidatorAnnotation(ConfigurationKey = AZURE_WRITE_BUFFER_SIZE,
|
|
|
- MinValue = FileSystemConfigurations.MIN_BUFFER_SIZE,
|
|
|
- MaxValue = FileSystemConfigurations.MAX_BUFFER_SIZE,
|
|
|
- DefaultValue = FileSystemConfigurations.DEFAULT_WRITE_BUFFER_SIZE)
|
|
|
+ MinValue = MIN_BUFFER_SIZE,
|
|
|
+ MaxValue = MAX_BUFFER_SIZE,
|
|
|
+ DefaultValue = DEFAULT_WRITE_BUFFER_SIZE)
|
|
|
private int writeBufferSize;
|
|
|
|
|
|
@IntegerConfigurationValidatorAnnotation(ConfigurationKey = AZURE_READ_BUFFER_SIZE,
|
|
|
- MinValue = FileSystemConfigurations.MIN_BUFFER_SIZE,
|
|
|
- MaxValue = FileSystemConfigurations.MAX_BUFFER_SIZE,
|
|
|
- DefaultValue = FileSystemConfigurations.DEFAULT_READ_BUFFER_SIZE)
|
|
|
+ MinValue = MIN_BUFFER_SIZE,
|
|
|
+ MaxValue = MAX_BUFFER_SIZE,
|
|
|
+ DefaultValue = DEFAULT_READ_BUFFER_SIZE)
|
|
|
private int readBufferSize;
|
|
|
|
|
|
@IntegerConfigurationValidatorAnnotation(ConfigurationKey = AZURE_MIN_BACKOFF_INTERVAL,
|
|
|
- DefaultValue = FileSystemConfigurations.DEFAULT_MIN_BACKOFF_INTERVAL)
|
|
|
+ DefaultValue = DEFAULT_MIN_BACKOFF_INTERVAL)
|
|
|
private int minBackoffInterval;
|
|
|
|
|
|
@IntegerConfigurationValidatorAnnotation(ConfigurationKey = AZURE_MAX_BACKOFF_INTERVAL,
|
|
|
- DefaultValue = FileSystemConfigurations.DEFAULT_MAX_BACKOFF_INTERVAL)
|
|
|
+ DefaultValue = DEFAULT_MAX_BACKOFF_INTERVAL)
|
|
|
private int maxBackoffInterval;
|
|
|
|
|
|
@IntegerConfigurationValidatorAnnotation(ConfigurationKey = AZURE_BACKOFF_INTERVAL,
|
|
|
- DefaultValue = FileSystemConfigurations.DEFAULT_BACKOFF_INTERVAL)
|
|
|
+ DefaultValue = DEFAULT_BACKOFF_INTERVAL)
|
|
|
private int backoffInterval;
|
|
|
|
|
|
@IntegerConfigurationValidatorAnnotation(ConfigurationKey = AZURE_MAX_IO_RETRIES,
|
|
|
MinValue = 0,
|
|
|
- DefaultValue = FileSystemConfigurations.DEFAULT_MAX_RETRY_ATTEMPTS)
|
|
|
+ DefaultValue = DEFAULT_MAX_RETRY_ATTEMPTS)
|
|
|
private int maxIoRetries;
|
|
|
|
|
|
@LongConfigurationValidatorAnnotation(ConfigurationKey = AZURE_BLOCK_SIZE_PROPERTY_NAME,
|
|
|
MinValue = 0,
|
|
|
- MaxValue = FileSystemConfigurations.MAX_AZURE_BLOCK_SIZE,
|
|
|
- DefaultValue = FileSystemConfigurations.MAX_AZURE_BLOCK_SIZE)
|
|
|
+ MaxValue = MAX_AZURE_BLOCK_SIZE,
|
|
|
+ DefaultValue = MAX_AZURE_BLOCK_SIZE)
|
|
|
private long azureBlockSize;
|
|
|
|
|
|
@StringConfigurationValidatorAnnotation(ConfigurationKey = AZURE_BLOCK_LOCATION_HOST_PROPERTY_NAME,
|
|
|
- DefaultValue = FileSystemConfigurations.AZURE_BLOCK_LOCATION_HOST_DEFAULT)
|
|
|
+ DefaultValue = AZURE_BLOCK_LOCATION_HOST_DEFAULT)
|
|
|
private String azureBlockLocationHost;
|
|
|
|
|
|
@IntegerConfigurationValidatorAnnotation(ConfigurationKey = AZURE_CONCURRENT_CONNECTION_VALUE_OUT,
|
|
|
MinValue = 1,
|
|
|
- DefaultValue = FileSystemConfigurations.MAX_CONCURRENT_WRITE_THREADS)
|
|
|
+ DefaultValue = MAX_CONCURRENT_WRITE_THREADS)
|
|
|
private int maxConcurrentWriteThreads;
|
|
|
|
|
|
@IntegerConfigurationValidatorAnnotation(ConfigurationKey = AZURE_CONCURRENT_CONNECTION_VALUE_IN,
|
|
|
MinValue = 1,
|
|
|
- DefaultValue = FileSystemConfigurations.MAX_CONCURRENT_READ_THREADS)
|
|
|
+ DefaultValue = MAX_CONCURRENT_READ_THREADS)
|
|
|
private int maxConcurrentReadThreads;
|
|
|
|
|
|
@BooleanConfigurationValidatorAnnotation(ConfigurationKey = AZURE_TOLERATE_CONCURRENT_APPEND,
|
|
|
- DefaultValue = FileSystemConfigurations.DEFAULT_READ_TOLERATE_CONCURRENT_APPEND)
|
|
|
+ DefaultValue = DEFAULT_READ_TOLERATE_CONCURRENT_APPEND)
|
|
|
private boolean tolerateOobAppends;
|
|
|
|
|
|
@StringConfigurationValidatorAnnotation(ConfigurationKey = FS_AZURE_ATOMIC_RENAME_KEY,
|
|
|
- DefaultValue = FileSystemConfigurations.DEFAULT_FS_AZURE_ATOMIC_RENAME_DIRECTORIES)
|
|
|
+ DefaultValue = DEFAULT_FS_AZURE_ATOMIC_RENAME_DIRECTORIES)
|
|
|
private String azureAtomicDirs;
|
|
|
|
|
|
@BooleanConfigurationValidatorAnnotation(ConfigurationKey = AZURE_CREATE_REMOTE_FILESYSTEM_DURING_INITIALIZATION,
|
|
|
- DefaultValue = FileSystemConfigurations.DEFAULT_AZURE_CREATE_REMOTE_FILESYSTEM_DURING_INITIALIZATION)
|
|
|
+ DefaultValue = DEFAULT_AZURE_CREATE_REMOTE_FILESYSTEM_DURING_INITIALIZATION)
|
|
|
private boolean createRemoteFileSystemDuringInitialization;
|
|
|
|
|
|
@BooleanConfigurationValidatorAnnotation(ConfigurationKey = AZURE_SKIP_USER_GROUP_METADATA_DURING_INITIALIZATION,
|
|
|
- DefaultValue = FileSystemConfigurations.DEFAULT_AZURE_SKIP_USER_GROUP_METADATA_DURING_INITIALIZATION)
|
|
|
+ DefaultValue = DEFAULT_AZURE_SKIP_USER_GROUP_METADATA_DURING_INITIALIZATION)
|
|
|
private boolean skipUserGroupMetadataDuringInitialization;
|
|
|
|
|
|
-
|
|
|
@IntegerConfigurationValidatorAnnotation(ConfigurationKey = FS_AZURE_READ_AHEAD_QUEUE_DEPTH,
|
|
|
- DefaultValue = FileSystemConfigurations.DEFAULT_READ_AHEAD_QUEUE_DEPTH)
|
|
|
+ DefaultValue = DEFAULT_READ_AHEAD_QUEUE_DEPTH)
|
|
|
private int readAheadQueueDepth;
|
|
|
|
|
|
@BooleanConfigurationValidatorAnnotation(ConfigurationKey = FS_AZURE_ENABLE_FLUSH,
|
|
|
- DefaultValue = FileSystemConfigurations.DEFAULT_ENABLE_FLUSH)
|
|
|
+ DefaultValue = DEFAULT_ENABLE_FLUSH)
|
|
|
private boolean enableFlush;
|
|
|
|
|
|
@StringConfigurationValidatorAnnotation(ConfigurationKey = FS_AZURE_USER_AGENT_PREFIX_KEY,
|
|
|
- DefaultValue = "")
|
|
|
+ DefaultValue = "")
|
|
|
private String userAgentId;
|
|
|
|
|
|
+ @BooleanConfigurationValidatorAnnotation(ConfigurationKey = FS_AZURE_ENABLE_DELEGATION_TOKEN,
|
|
|
+ DefaultValue = DEFAULT_ENABLE_DELEGATION_TOKEN)
|
|
|
+ private boolean enableDelegationToken;
|
|
|
+
|
|
|
private Map<String, String> storageAccountKeys;
|
|
|
|
|
|
public AbfsConfiguration(final Configuration configuration) throws IllegalAccessException, InvalidConfigurationValueException {
|
|
@@ -292,6 +295,14 @@ public class AbfsConfiguration{
|
|
|
return configuration.getEnum(FS_AZURE_ACCOUNT_AUTH_TYPE_PROPERTY_NAME + accountName, AuthType.SharedKey);
|
|
|
}
|
|
|
|
|
|
+ public boolean isDelegationTokenManagerEnabled() {
|
|
|
+ return enableDelegationToken;
|
|
|
+ }
|
|
|
+
|
|
|
+ public AbfsDelegationTokenManager getDelegationTokenManager() throws IOException {
|
|
|
+ return new AbfsDelegationTokenManager(configuration);
|
|
|
+ }
|
|
|
+
|
|
|
public AccessTokenProvider getTokenProvider(final String accountName) throws TokenAccessProviderException {
|
|
|
AuthType authType = configuration.getEnum(FS_AZURE_ACCOUNT_AUTH_TYPE_PROPERTY_NAME + accountName, AuthType.SharedKey);
|
|
|
if (authType == AuthType.OAuth) {
|