HADOOP-14959. DelegationTokenAuthenticator.authenticate() to wrap network exceptions. Contributed by Ajay Kumar.
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/32831b8f Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/32831b8f Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/32831b8f Branch: refs/heads/YARN-7055 Commit: 32831b8f32afa0c4f82a4d6e9062148b0b9bcb42 Parents: 211b2bb Author: Arpit Agarwal <a...@apache.org> Authored: Tue Feb 27 08:48:13 2018 -0800 Committer: Rohith Sharma K S <rohithsharm...@apache.org> Committed: Fri Mar 2 11:08:28 2018 +0530 ---------------------------------------------------------------------- .../web/DelegationTokenAuthenticator.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/32831b8f/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/token/delegation/web/DelegationTokenAuthenticator.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/token/delegation/web/DelegationTokenAuthenticator.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/token/delegation/web/DelegationTokenAuthenticator.java index a1c6003..617773b 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/token/delegation/web/DelegationTokenAuthenticator.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/token/delegation/web/DelegationTokenAuthenticator.java @@ -21,6 +21,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectReader; import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.classification.InterfaceStability; +import org.apache.hadoop.net.NetUtils; import org.apache.hadoop.security.SecurityUtil; import org.apache.hadoop.security.UserGroupInformation; import org.apache.hadoop.security.authentication.client.AuthenticatedURL; @@ -138,11 +139,17 @@ public abstract class DelegationTokenAuthenticator implements Authenticator { public void authenticate(URL url, AuthenticatedURL.Token token) throws IOException, AuthenticationException { if (!hasDelegationToken(url, token)) { - // check and renew TGT to handle potential expiration - UserGroupInformation.getCurrentUser().checkTGTAndReloginFromKeytab(); - LOG.debug("No delegation token found for url={}, token={}, authenticating" - + " with {}", url, token, authenticator.getClass()); - authenticator.authenticate(url, token); + try { + // check and renew TGT to handle potential expiration + UserGroupInformation.getCurrentUser().checkTGTAndReloginFromKeytab(); + LOG.debug("No delegation token found for url={}, token={}, " + + "authenticating with {}", url, token, authenticator.getClass()); + authenticator.authenticate(url, token); + } catch (IOException ex) { + throw NetUtils.wrapException(url.getHost(), url.getPort(), + null, 0, ex); + } + } else { LOG.debug("Authenticated from delegation token. url={}, token={}", url, token); --------------------------------------------------------------------- To unsubscribe, e-mail: common-commits-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-commits-h...@hadoop.apache.org