From 9b673227e4fb7468e82795ae2c2c5fffb77a22e1 Mon Sep 17 00:00:00 2001 From: David Mollitor Date: Tue, 12 Nov 2019 10:26:29 -0500 Subject: [PATCH] HADOOP-16692: UserGroupInformation Sets kerberosMinSecondsBeforeRelogin as Millis --- .../hadoop/security/UserGroupInformation.java | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/UserGroupInformation.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/UserGroupInformation.java index 91c51f2a32f..9e9646838e6 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/UserGroupInformation.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/UserGroupInformation.java @@ -336,7 +336,7 @@ public class UserGroupInformation { } } try { - kerberosMinSecondsBeforeRelogin = 1000L * conf.getLong( + kerberosMinSecondsBeforeRelogin = conf.getLong( HADOOP_KERBEROS_MIN_SECONDS_BEFORE_RELOGIN, HADOOP_KERBEROS_MIN_SECONDS_BEFORE_RELOGIN_DEFAULT); } @@ -389,7 +389,7 @@ public class UserGroupInformation { authenticationMethod = null; conf = null; groups = null; - kerberosMinSecondsBeforeRelogin = 0; + kerberosMinSecondsBeforeRelogin = 0L; kerberosKeyTabLoginRenewalEnabled = false; kerberosLoginRenewalExecutor = Optional.empty(); setLoginUser(null); @@ -1009,7 +1009,7 @@ public class UserGroupInformation { return; } nextRefresh = Math.max(getRefreshTime(tgt), - now + kerberosMinSecondsBeforeRelogin); + now + TimeUnit.SECONDS.toMillis(kerberosMinSecondsBeforeRelogin)); metrics.renewalFailures.set(0); rp = null; } catch (InterruptedException ie) { @@ -1051,7 +1051,7 @@ public class UserGroupInformation { // The final retry time will be later limited within the // tgt endTime in getNextTgtRenewalTime. rp = RetryPolicies.exponentialBackoffRetry(Long.SIZE - 2, - kerberosMinSecondsBeforeRelogin, TimeUnit.MILLISECONDS); + kerberosMinSecondsBeforeRelogin, TimeUnit.SECONDS); } try { nextRefresh = getNextTgtRenewalTime(tgtEndTime, now, rp); @@ -1130,7 +1130,8 @@ public class UserGroupInformation { @VisibleForTesting static long getNextTgtRenewalTime(final long tgtEndTime, final long now, final RetryPolicy rp) throws Exception { - final long lastRetryTime = tgtEndTime - kerberosMinSecondsBeforeRelogin; + final long lastRetryTime = + tgtEndTime - TimeUnit.SECONDS.toMillis(kerberosMinSecondsBeforeRelogin); final RetryPolicy.RetryAction ra = rp.shouldRetry(null, metrics.renewalFailures.value(), 0, false); return Math.min(lastRetryTime, now + ra.delayMillis); @@ -1378,10 +1379,11 @@ public class UserGroupInformation { private boolean hasSufficientTimeElapsed(long now) { if (!shouldRenewImmediatelyForTests && - now - user.getLastLogin() < kerberosMinSecondsBeforeRelogin ) { - LOG.warn("Not attempting to re-login since the last re-login was " + - "attempted less than " + (kerberosMinSecondsBeforeRelogin/1000) + - " seconds before. Last Login=" + user.getLastLogin()); + (now - user.getLastLogin()) < TimeUnit.SECONDS + .toMillis(kerberosMinSecondsBeforeRelogin)) { + LOG.warn("Not attempting to re-login since the last re-login was " + + "attempted less than " + kerberosMinSecondsBeforeRelogin + + " seconds before. Last Login=" + user.getLastLogin()); return false; } return true;