You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by cn...@apache.org on 2016/10/12 20:12:46 UTC
[29/52] [abbrv] hadoop git commit: HADOOP-13641. Update
UGI#spawnAutoRenewalThreadForUserCreds to reduce indentation. Contributed by
Huafeng Wang
HADOOP-13641. Update UGI#spawnAutoRenewalThreadForUserCreds to reduce indentation. Contributed by Huafeng Wang
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/3d59b18d
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/3d59b18d
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/3d59b18d
Branch: refs/heads/HADOOP-13037
Commit: 3d59b18d49d98a293ae14c5b89d515ef83cc4ff7
Parents: bea004e
Author: Kai Zheng <ka...@intel.com>
Authored: Sun Oct 9 15:53:36 2016 +0600
Committer: Kai Zheng <ka...@intel.com>
Committed: Sun Oct 9 15:53:36 2016 +0600
----------------------------------------------------------------------
.../hadoop/security/UserGroupInformation.java | 98 ++++++++++----------
1 file changed, 49 insertions(+), 49 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/3d59b18d/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/UserGroupInformation.java
----------------------------------------------------------------------
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 329859d..e8711b0 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
@@ -946,60 +946,60 @@ public class UserGroupInformation {
/**Spawn a thread to do periodic renewals of kerberos credentials*/
private void spawnAutoRenewalThreadForUserCreds() {
- if (isSecurityEnabled()) {
- //spawn thread only if we have kerb credentials
- if (user.getAuthenticationMethod() == AuthenticationMethod.KERBEROS &&
- !isKeytab) {
- Thread t = new Thread(new Runnable() {
-
- @Override
- public void run() {
- String cmd = conf.get("hadoop.kerberos.kinit.command",
- "kinit");
- KerberosTicket tgt = getTGT();
+ if (!isSecurityEnabled()
+ || user.getAuthenticationMethod() != AuthenticationMethod.KERBEROS
+ || isKeytab) {
+ return;
+ }
+
+ //spawn thread only if we have kerb credentials
+ Thread t = new Thread(new Runnable() {
+
+ @Override
+ public void run() {
+ String cmd = conf.get("hadoop.kerberos.kinit.command", "kinit");
+ KerberosTicket tgt = getTGT();
+ if (tgt == null) {
+ return;
+ }
+ long nextRefresh = getRefreshTime(tgt);
+ while (true) {
+ try {
+ long now = Time.now();
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Current time is " + now);
+ LOG.debug("Next refresh is " + nextRefresh);
+ }
+ if (now < nextRefresh) {
+ Thread.sleep(nextRefresh - now);
+ }
+ Shell.execCommand(cmd, "-R");
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("renewed ticket");
+ }
+ reloginFromTicketCache();
+ tgt = getTGT();
if (tgt == null) {
+ LOG.warn("No TGT after renewal. Aborting renew thread for " +
+ getUserName());
return;
}
- long nextRefresh = getRefreshTime(tgt);
- while (true) {
- try {
- long now = Time.now();
- if(LOG.isDebugEnabled()) {
- LOG.debug("Current time is " + now);
- LOG.debug("Next refresh is " + nextRefresh);
- }
- if (now < nextRefresh) {
- Thread.sleep(nextRefresh - now);
- }
- Shell.execCommand(cmd, "-R");
- if(LOG.isDebugEnabled()) {
- LOG.debug("renewed ticket");
- }
- reloginFromTicketCache();
- tgt = getTGT();
- if (tgt == null) {
- LOG.warn("No TGT after renewal. Aborting renew thread for " +
- getUserName());
- return;
- }
- nextRefresh = Math.max(getRefreshTime(tgt),
- now + kerberosMinSecondsBeforeRelogin);
- } catch (InterruptedException ie) {
- LOG.warn("Terminating renewal thread");
- return;
- } catch (IOException ie) {
- LOG.warn("Exception encountered while running the" +
- " renewal command. Aborting renew thread. " + ie);
- return;
- }
- }
+ nextRefresh = Math.max(getRefreshTime(tgt),
+ now + kerberosMinSecondsBeforeRelogin);
+ } catch (InterruptedException ie) {
+ LOG.warn("Terminating renewal thread");
+ return;
+ } catch (IOException ie) {
+ LOG.warn("Exception encountered while running the" +
+ " renewal command. Aborting renew thread. " + ie);
+ return;
}
- });
- t.setDaemon(true);
- t.setName("TGT Renewer for " + getUserName());
- t.start();
+ }
}
- }
+ });
+ t.setDaemon(true);
+ t.setName("TGT Renewer for " + getUserName());
+ t.start();
}
/**
* Log a user in from a keytab file. Loads a user identity from a keytab
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org