Skip to content

Commit d1f5976

Browse files
snvijayasteveloughran
authored andcommitted
HADOOP-16699. Add verbose TRACE logging to ABFS.
Contributed by Sneha Vijayarajan, Change-Id: Ic616a10406e6e9f11616c9cc05d8630ebbedaf65
1 parent bc366d4 commit d1f5976

File tree

5 files changed

+35
-2
lines changed

5 files changed

+35
-2
lines changed

hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/AbfsConfiguration.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@
6363
import org.apache.hadoop.security.ProviderUtils;
6464
import org.apache.hadoop.util.ReflectionUtils;
6565

66+
import org.slf4j.Logger;
67+
import org.slf4j.LoggerFactory;
68+
6669
import static org.apache.hadoop.fs.azurebfs.constants.ConfigurationKeys.*;
6770
import static org.apache.hadoop.fs.azurebfs.constants.FileSystemConfigurations.*;
6871

@@ -76,6 +79,7 @@ public class AbfsConfiguration{
7679
private final Configuration rawConfig;
7780
private final String accountName;
7881
private final boolean isSecure;
82+
private static final Logger LOG = LoggerFactory.getLogger(AbfsConfiguration.class);
7983

8084
@IntegerConfigurationValidatorAnnotation(ConfigurationKey = AZURE_WRITE_BUFFER_SIZE,
8185
MinValue = MIN_BUFFER_SIZE,
@@ -505,11 +509,13 @@ public AccessTokenProvider getTokenProvider() throws TokenAccessProviderExceptio
505509
String clientId = getPasswordString(FS_AZURE_ACCOUNT_OAUTH_CLIENT_ID);
506510
String clientSecret = getPasswordString(FS_AZURE_ACCOUNT_OAUTH_CLIENT_SECRET);
507511
tokenProvider = new ClientCredsTokenProvider(authEndpoint, clientId, clientSecret);
512+
LOG.trace("ClientCredsTokenProvider initialized");
508513
} else if (tokenProviderClass == UserPasswordTokenProvider.class) {
509514
String authEndpoint = getPasswordString(FS_AZURE_ACCOUNT_OAUTH_CLIENT_ENDPOINT);
510515
String username = getPasswordString(FS_AZURE_ACCOUNT_OAUTH_USER_NAME);
511516
String password = getPasswordString(FS_AZURE_ACCOUNT_OAUTH_USER_PASSWORD);
512517
tokenProvider = new UserPasswordTokenProvider(authEndpoint, username, password);
518+
LOG.trace("UserPasswordTokenProvider initialized");
513519
} else if (tokenProviderClass == MsiTokenProvider.class) {
514520
String authEndpoint = getTrimmedPasswordString(
515521
FS_AZURE_ACCOUNT_OAUTH_MSI_ENDPOINT,
@@ -522,6 +528,7 @@ public AccessTokenProvider getTokenProvider() throws TokenAccessProviderExceptio
522528
authority = appendSlashIfNeeded(authority);
523529
tokenProvider = new MsiTokenProvider(authEndpoint, tenantGuid,
524530
clientId, authority);
531+
LOG.trace("MsiTokenProvider initialized");
525532
} else if (tokenProviderClass == RefreshTokenBasedTokenProvider.class) {
526533
String authEndpoint = getTrimmedPasswordString(
527534
FS_AZURE_ACCOUNT_OAUTH_REFRESH_TOKEN_ENDPOINT,
@@ -530,6 +537,7 @@ public AccessTokenProvider getTokenProvider() throws TokenAccessProviderExceptio
530537
String clientId = getPasswordString(FS_AZURE_ACCOUNT_OAUTH_CLIENT_ID);
531538
tokenProvider = new RefreshTokenBasedTokenProvider(authEndpoint,
532539
clientId, refreshToken);
540+
LOG.trace("RefreshTokenBasedTokenProvider initialized");
533541
} else {
534542
throw new IllegalArgumentException("Failed to initialize " + tokenProviderClass);
535543
}
@@ -554,7 +562,9 @@ public AccessTokenProvider getTokenProvider() throws TokenAccessProviderExceptio
554562
if (azureTokenProvider == null) {
555563
throw new IllegalArgumentException("Failed to initialize " + customTokenProviderClass);
556564
}
565+
LOG.trace("Initializing {}", customTokenProviderClass.getName());
557566
azureTokenProvider.initialize(rawConfig, accountName);
567+
LOG.trace("{} init complete", customTokenProviderClass.getName());
558568
return new CustomTokenProviderAdapter(azureTokenProvider);
559569
} catch(IllegalArgumentException e) {
560570
throw e;
@@ -581,7 +591,9 @@ public AbfsAuthorizer getAbfsAuthorizer() throws IOException {
581591
@SuppressWarnings("unchecked")
582592
Class<AbfsAuthorizer> authClass = (Class<AbfsAuthorizer>) rawConfig.getClassByName(authClassName);
583593
authorizer = authClass.getConstructor(new Class[] {Configuration.class}).newInstance(rawConfig);
594+
LOG.trace("Initializing {}", authClassName);
584595
authorizer.init();
596+
LOG.trace("{} init complete", authClassName);
585597
}
586598
} catch (
587599
IllegalAccessException

hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/AzureBlobFileSystem.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ public void initialize(URI uri, Configuration configuration)
107107

108108
this.uri = URI.create(uri.getScheme() + "://" + uri.getAuthority());
109109
this.abfsStore = new AzureBlobFileSystemStore(uri, this.isSecureScheme(), configuration);
110+
LOG.trace("AzureBlobFileSystemStore init complete");
111+
110112
final AbfsConfiguration abfsConfiguration = abfsStore.getAbfsConfiguration();
111113

112114
this.setWorkingDirectory(this.getHomeDirectory());
@@ -121,6 +123,7 @@ public void initialize(URI uri, Configuration configuration)
121123
}
122124
}
123125

126+
LOG.trace("Initiate check for delegation token manager");
124127
if (UserGroupInformation.isSecurityEnabled()) {
125128
this.delegationTokenEnabled = abfsConfiguration.isDelegationTokenManagerEnabled();
126129

@@ -137,6 +140,7 @@ public void initialize(URI uri, Configuration configuration)
137140
// Initialize ABFS authorizer
138141
//
139142
this.authorizer = abfsConfiguration.getAbfsAuthorizer();
143+
LOG.debug("Initializing AzureBlobFileSystem for {} complete", uri);
140144
}
141145

142146
@Override

hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/AzureBlobFileSystemStore.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,12 @@ public AzureBlobFileSystemStore(URI uri, boolean isSecureScheme, Configuration c
148148
} catch (IllegalAccessException exception) {
149149
throw new FileSystemOperationUnhandledException(exception);
150150
}
151+
152+
LOG.trace("AbfsConfiguration init complete");
153+
151154
this.userGroupInformation = UserGroupInformation.getCurrentUser();
152155
this.userName = userGroupInformation.getShortUserName();
156+
LOG.trace("UGI init complete");
153157
if (!abfsConfiguration.getSkipUserGroupMetadataDuringInitialization()) {
154158
try {
155159
this.primaryUserGroup = userGroupInformation.getPrimaryGroupName();
@@ -161,6 +165,7 @@ public AzureBlobFileSystemStore(URI uri, boolean isSecureScheme, Configuration c
161165
//Provide a default group name
162166
this.primaryUserGroup = userName;
163167
}
168+
LOG.trace("primaryUserGroup is {}", this.primaryUserGroup);
164169

165170
this.azureAtomicRenameDirSet = new HashSet<>(Arrays.asList(
166171
abfsConfiguration.getAzureAtomicRenameDirs().split(AbfsHttpConstants.COMMA)));
@@ -170,6 +175,7 @@ public AzureBlobFileSystemStore(URI uri, boolean isSecureScheme, Configuration c
170175
this.abfsPerfTracker = new AbfsPerfTracker(fileSystemName, accountName, this.abfsConfiguration);
171176
initializeClient(uri, fileSystemName, accountName, useHttps);
172177
this.identityTransformer = new IdentityTransformer(abfsConfiguration.getRawConfiguration());
178+
LOG.trace("IdentityTransformer init complete");
173179
}
174180

175181
/**
@@ -296,6 +302,7 @@ public Hashtable<String, String> getFilesystemProperties() throws AzureBlobFileS
296302
public void setFilesystemProperties(final Hashtable<String, String> properties)
297303
throws AzureBlobFileSystemException {
298304
if (properties == null || properties.isEmpty()) {
305+
LOG.trace("setFilesystemProperties no properties present");
299306
return;
300307
}
301308

@@ -1116,6 +1123,7 @@ private void initializeClient(URI uri, String fileSystemName, String accountName
11161123
AccessTokenProvider tokenProvider = null;
11171124

11181125
if (abfsConfiguration.getAuthType(accountName) == AuthType.SharedKey) {
1126+
LOG.trace("Fetching SharedKey credentials");
11191127
int dotIndex = accountName.indexOf(AbfsHttpConstants.DOT);
11201128
if (dotIndex <= 0) {
11211129
throw new InvalidUriException(
@@ -1124,14 +1132,17 @@ private void initializeClient(URI uri, String fileSystemName, String accountName
11241132
creds = new SharedKeyCredentials(accountName.substring(0, dotIndex),
11251133
abfsConfiguration.getStorageAccountKey());
11261134
} else {
1135+
LOG.trace("Fetching token provider");
11271136
tokenProvider = abfsConfiguration.getTokenProvider();
11281137
ExtensionHelper.bind(tokenProvider, uri,
11291138
abfsConfiguration.getRawConfiguration());
11301139
}
11311140

1132-
this.client = new AbfsClient(baseUrl, creds, abfsConfiguration,
1141+
LOG.trace("Initializing AbfsClient for {}", baseUrl);
1142+
this.client = new AbfsClient(baseUrl, creds, abfsConfiguration,
11331143
new ExponentialRetryPolicy(abfsConfiguration.getMaxIoRetries()),
11341144
tokenProvider, abfsPerfTracker);
1145+
LOG.trace("AbfsClient init complete");
11351146
}
11361147

11371148
private String getOctalNotation(FsPermission fsPermission) {

hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsClient.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,14 @@ public AbfsClient(final URL baseUrl, final SharedKeyCredentials sharedKeyCredent
8181

8282
if (this.baseUrl.toString().startsWith(HTTPS_SCHEME)) {
8383
try {
84+
LOG.trace("Initializing DelegatingSSLSocketFactory with {} SSL "
85+
+ "Channel Mode", this.abfsConfiguration.getPreferredSSLFactoryOption());
8486
DelegatingSSLSocketFactory.initializeDefaultFactory(this.abfsConfiguration.getPreferredSSLFactoryOption());
8587
sslProviderName = DelegatingSSLSocketFactory.getDefaultFactory().getProviderName();
8688
} catch (IOException e) {
8789
// Suppress exception. Failure to init DelegatingSSLSocketFactory would have only performance impact.
90+
LOG.trace("NonCritFailure: DelegatingSSLSocketFactory Init failed : "
91+
+ "{}", e.getMessage());
8892
}
8993
}
9094

hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsRestOperation.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ void execute() throws AzureBlobFileSystemException {
145145
throw new AbfsRestOperationException(result.getStatusCode(), result.getStorageErrorCode(),
146146
result.getStorageErrorMessage(), null, result);
147147
}
148+
149+
LOG.trace("{} REST operation complete", operationType);
148150
}
149151

150152
/**
@@ -210,7 +212,7 @@ private boolean executeHttpOperation(final int retryCount) throws AzureBlobFileS
210212
AbfsClientThrottlingIntercept.updateMetrics(operationType, httpOperation);
211213
}
212214

213-
LOG.debug("HttpRequest: " + httpOperation.toString());
215+
LOG.debug("HttpRequest: {}", httpOperation.toString());
214216

215217
if (client.getRetryPolicy().shouldRetry(retryCount, httpOperation.getStatusCode())) {
216218
return false;

0 commit comments

Comments
 (0)