Author: kihwal Date: Mon Apr 15 20:37:17 2013 New Revision: 1468216 URL: http://svn.apache.org/r1468216 Log: HDFS-4690. Namenode exits if entering safemode while secret manager is edit logging. Contributed by Daryn Sharp.
Modified: hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/token/delegation/AbstractDelegationTokenSecretManager.java Modified: hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/token/delegation/AbstractDelegationTokenSecretManager.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/token/delegation/AbstractDelegationTokenSecretManager.java?rev=1468216&r1=1468215&r2=1468216&view=diff ============================================================================== --- hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/token/delegation/AbstractDelegationTokenSecretManager.java (original) +++ hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/token/delegation/AbstractDelegationTokenSecretManager.java Mon Apr 15 20:37:17 2013 @@ -84,6 +84,12 @@ extends AbstractDelegationTokenIdentifie private Thread tokenRemoverThread; protected volatile boolean running; + /** + * If the delegation token update thread holds this lock, it will + * not get interrupted. + */ + protected Object noInterruptsLock = new Object(); + public AbstractDelegationTokenSecretManager(long delegationKeyUpdateInterval, long delegationTokenMaxLifetime, long delegationTokenRenewInterval, long delegationTokenRemoverScanInterval) { @@ -364,12 +370,20 @@ extends AbstractDelegationTokenIdentifie } } - public synchronized void stopThreads() { + public void stopThreads() { if (LOG.isDebugEnabled()) LOG.debug("Stopping expired delegation token remover thread"); running = false; if (tokenRemoverThread != null) { - tokenRemoverThread.interrupt(); + synchronized (noInterruptsLock) { + tokenRemoverThread.interrupt(); + } + try { + tokenRemoverThread.join(); + } catch (InterruptedException e) { + throw new RuntimeException( + "Unable to join on token removal thread", e); + } } } @@ -397,7 +411,7 @@ extends AbstractDelegationTokenIdentifie rollMasterKey(); lastMasterKeyUpdate = now; } catch (IOException e) { - LOG.error("Master key updating failed: ", e); + LOG.error("Master key updating failed: " + e.getMessage()); } } if (lastTokenCacheCleanup + tokenRemoverScanInterval < now) {