HADOOP-13641. Update UGI#spawnAutoRenewalThreadForUserCreds to reduce indentation. Contributed by Huafeng Wang

This commit is contained in:
Kai Zheng 2016-10-10 11:44:04 +06:00
parent 5c96ef365d
commit ad0659557b
1 changed files with 49 additions and 49 deletions

View File

@ -934,16 +934,18 @@ public class UserGroupInformation {
/**Spawn a thread to do periodic renewals of kerberos credentials*/ /**Spawn a thread to do periodic renewals of kerberos credentials*/
private void spawnAutoRenewalThreadForUserCreds() { private void spawnAutoRenewalThreadForUserCreds() {
if (isSecurityEnabled()) { if (!isSecurityEnabled()
|| user.getAuthenticationMethod() != AuthenticationMethod.KERBEROS
|| isKeytab) {
return;
}
//spawn thread only if we have kerb credentials //spawn thread only if we have kerb credentials
if (user.getAuthenticationMethod() == AuthenticationMethod.KERBEROS &&
!isKeytab) {
Thread t = new Thread(new Runnable() { Thread t = new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {
String cmd = conf.get("hadoop.kerberos.kinit.command", String cmd = conf.get("hadoop.kerberos.kinit.command", "kinit");
"kinit");
KerberosTicket tgt = getTGT(); KerberosTicket tgt = getTGT();
if (tgt == null) { if (tgt == null) {
return; return;
@ -987,8 +989,6 @@ public class UserGroupInformation {
t.setName("TGT Renewer for " + getUserName()); t.setName("TGT Renewer for " + getUserName());
t.start(); t.start();
} }
}
}
/** /**
* Log a user in from a keytab file. Loads a user identity from a keytab * Log a user in from a keytab file. Loads a user identity from a keytab
* file and logs them in. They become the currently logged-in user. * file and logs them in. They become the currently logged-in user.