HADOOP-13641. Update UGI#spawnAutoRenewalThreadForUserCreds to reduce indentation. Contributed by Huafeng Wang
This commit is contained in:
parent
bea004eaeb
commit
3d59b18d49
|
@ -946,16 +946,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;
|
||||||
|
@ -964,7 +966,7 @@ public class UserGroupInformation {
|
||||||
while (true) {
|
while (true) {
|
||||||
try {
|
try {
|
||||||
long now = Time.now();
|
long now = Time.now();
|
||||||
if(LOG.isDebugEnabled()) {
|
if (LOG.isDebugEnabled()) {
|
||||||
LOG.debug("Current time is " + now);
|
LOG.debug("Current time is " + now);
|
||||||
LOG.debug("Next refresh is " + nextRefresh);
|
LOG.debug("Next refresh is " + nextRefresh);
|
||||||
}
|
}
|
||||||
|
@ -972,7 +974,7 @@ public class UserGroupInformation {
|
||||||
Thread.sleep(nextRefresh - now);
|
Thread.sleep(nextRefresh - now);
|
||||||
}
|
}
|
||||||
Shell.execCommand(cmd, "-R");
|
Shell.execCommand(cmd, "-R");
|
||||||
if(LOG.isDebugEnabled()) {
|
if (LOG.isDebugEnabled()) {
|
||||||
LOG.debug("renewed ticket");
|
LOG.debug("renewed ticket");
|
||||||
}
|
}
|
||||||
reloginFromTicketCache();
|
reloginFromTicketCache();
|
||||||
|
@ -999,8 +1001,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.
|
||||||
|
|
Loading…
Reference in New Issue