|
@@ -17,6 +17,8 @@
|
|
|
*/
|
|
|
package org.apache.hadoop.security;
|
|
|
|
|
|
+import static org.apache.hadoop.fs.CommonConfigurationKeys.HADOOP_KERBEROS_MIN_SECONDS_BEFORE_RELOGIN;
|
|
|
+import static org.apache.hadoop.fs.CommonConfigurationKeys.HADOOP_KERBEROS_MIN_SECONDS_BEFORE_RELOGIN_DEFAULT;
|
|
|
import static org.apache.hadoop.fs.CommonConfigurationKeys.HADOOP_USER_GROUP_METRICS_PERCENTILES_INTERVALS;
|
|
|
import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.HADOOP_TOKEN_FILES;
|
|
|
import static org.apache.hadoop.security.UGIExceptionMessages.*;
|
|
@@ -253,13 +255,11 @@ public class UserGroupInformation {
|
|
|
private static AuthenticationMethod authenticationMethod;
|
|
|
/** Server-side groups fetching service */
|
|
|
private static Groups groups;
|
|
|
+ /** Min time (in seconds) before relogin for Kerberos */
|
|
|
+ private static long kerberosMinSecondsBeforeRelogin;
|
|
|
/** The configuration to use */
|
|
|
private static Configuration conf;
|
|
|
|
|
|
-
|
|
|
- /** Leave 10 minutes between relogin attempts. */
|
|
|
- private static final long MIN_TIME_BEFORE_RELOGIN = 10 * 60 * 1000L;
|
|
|
-
|
|
|
/**Environment variable pointing to the token cache file*/
|
|
|
public static final String HADOOP_TOKEN_FILE_LOCATION =
|
|
|
"HADOOP_TOKEN_FILE_LOCATION";
|
|
@@ -293,6 +293,16 @@ public class UserGroupInformation {
|
|
|
"Problem with Kerberos auth_to_local name configuration", ioe);
|
|
|
}
|
|
|
}
|
|
|
+ try {
|
|
|
+ kerberosMinSecondsBeforeRelogin = 1000L * conf.getLong(
|
|
|
+ HADOOP_KERBEROS_MIN_SECONDS_BEFORE_RELOGIN,
|
|
|
+ HADOOP_KERBEROS_MIN_SECONDS_BEFORE_RELOGIN_DEFAULT);
|
|
|
+ }
|
|
|
+ catch(NumberFormatException nfe) {
|
|
|
+ throw new IllegalArgumentException("Invalid attribute value for " +
|
|
|
+ HADOOP_KERBEROS_MIN_SECONDS_BEFORE_RELOGIN + " of " +
|
|
|
+ conf.get(HADOOP_KERBEROS_MIN_SECONDS_BEFORE_RELOGIN));
|
|
|
+ }
|
|
|
// If we haven't set up testing groups, use the configuration to find it
|
|
|
if (!(groups instanceof TestingGroups)) {
|
|
|
groups = Groups.getUserToGroupsMappingService(conf);
|
|
@@ -973,7 +983,7 @@ public class UserGroupInformation {
|
|
|
return;
|
|
|
}
|
|
|
nextRefresh = Math.max(getRefreshTime(tgt),
|
|
|
- now + MIN_TIME_BEFORE_RELOGIN);
|
|
|
+ now + kerberosMinSecondsBeforeRelogin);
|
|
|
} catch (InterruptedException ie) {
|
|
|
LOG.warn("Terminating renewal thread");
|
|
|
return;
|
|
@@ -1265,10 +1275,10 @@ public class UserGroupInformation {
|
|
|
}
|
|
|
|
|
|
private boolean hasSufficientTimeElapsed(long now) {
|
|
|
- if (now - user.getLastLogin() < MIN_TIME_BEFORE_RELOGIN ) {
|
|
|
+ if (now - user.getLastLogin() < kerberosMinSecondsBeforeRelogin ) {
|
|
|
LOG.warn("Not attempting to re-login since the last re-login was " +
|
|
|
- "attempted less than " + (MIN_TIME_BEFORE_RELOGIN/1000) + " seconds"+
|
|
|
- " before. Last Login=" + user.getLastLogin());
|
|
|
+ "attempted less than " + (kerberosMinSecondsBeforeRelogin/1000) +
|
|
|
+ " seconds before. Last Login=" + user.getLastLogin());
|
|
|
return false;
|
|
|
}
|
|
|
return true;
|