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 tu...@apache.org on 2012/11/27 20:26:11 UTC
svn commit: r1414331 - in
/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common: ./
dev-support/ src/main/java/org/apache/hadoop/fs/
src/test/java/org/apache/hadoop/fs/
Author: tucu
Date: Tue Nov 27 19:26:09 2012
New Revision: 1414331
URL: http://svn.apache.org/viewvc?rev=1414331&view=rev
Log:
HADOOP-9084. Augment DelegationTokenRenewer API to cancel the tokens on calls to removeRenewAction. (kkambatl via tucu)
Modified:
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/CHANGES.txt
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/dev-support/findbugsExcludeFile.xml
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/DelegationTokenRenewer.java
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestDelegationTokenRenewer.java
Modified: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/CHANGES.txt?rev=1414331&r1=1414330&r2=1414331&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/CHANGES.txt (original)
+++ hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/CHANGES.txt Tue Nov 27 19:26:09 2012
@@ -158,6 +158,9 @@ Release 2.0.3-alpha - Unreleased
HADOOP-9049. DelegationTokenRenewer needs to be Singleton and FileSystems
should register/deregister to/from. (Karthik Kambatla via tomwhite)
+ HADOOP-9084. Augment DelegationTokenRenewer API to cancel the tokens on
+ calls to removeRenewAction. (kkambatl via tucu)
+
Release 2.0.2-alpha - 2012-09-07
INCOMPATIBLE CHANGES
Modified: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/dev-support/findbugsExcludeFile.xml
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/dev-support/findbugsExcludeFile.xml?rev=1414331&r1=1414330&r2=1414331&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/dev-support/findbugsExcludeFile.xml (original)
+++ hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/dev-support/findbugsExcludeFile.xml Tue Nov 27 19:26:09 2012
@@ -303,5 +303,13 @@
<Field name="previousSnapshot" />
<Bug pattern="IS2_INCONSISTENT_SYNC" />
</Match>
-
+ <!--
+ The method uses a generic type T that extends two other types
+ T1 and T2. Findbugs complains of a cast from T1 to T2.
+ -->
+ <Match>
+ <Class name="org.apache.hadoop.fs.DelegationTokenRenewer" />
+ <Method name="removeRenewAction" />
+ <Bug pattern="BC_UNCONFIRMED_CAST" />
+ </Match>
</FindBugsFilter>
Modified: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/DelegationTokenRenewer.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/DelegationTokenRenewer.java?rev=1414331&r1=1414330&r2=1414331&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/DelegationTokenRenewer.java (original)
+++ hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/DelegationTokenRenewer.java Tue Nov 27 19:26:09 2012
@@ -24,6 +24,8 @@ import java.util.concurrent.DelayQueue;
import java.util.concurrent.Delayed;
import java.util.concurrent.TimeUnit;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.security.token.Token;
import org.apache.hadoop.security.token.TokenIdentifier;
@@ -35,6 +37,9 @@ import org.apache.hadoop.util.Time;
@InterfaceAudience.Private
public class DelegationTokenRenewer
extends Thread {
+ private static final Log LOG = LogFactory
+ .getLog(DelegationTokenRenewer.class);
+
/** The renewable interface used by the renewer. */
public interface Renewable {
/** @return the renew token. */
@@ -168,11 +173,24 @@ public class DelegationTokenRenewer
}
}
- /** Remove the associated renew action from the queue */
+ /**
+ * Remove the associated renew action from the queue
+ *
+ * @throws IOException
+ */
public synchronized <T extends FileSystem & Renewable> void removeRenewAction(
- final T fs) {
+ final T fs) throws IOException {
for (RenewAction<?> action : queue) {
if (action.weakFs.get() == fs) {
+ try {
+ fs.getRenewToken().cancel(fs.getConf());
+ } catch (InterruptedException ie) {
+ LOG.error("Interrupted while canceling token for " + fs.getUri()
+ + "filesystem");
+ if (LOG.isDebugEnabled()) {
+ LOG.debug(ie.getStackTrace());
+ }
+ }
queue.remove(action);
return;
}
Modified: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestDelegationTokenRenewer.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestDelegationTokenRenewer.java?rev=1414331&r1=1414330&r2=1414331&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestDelegationTokenRenewer.java (original)
+++ hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestDelegationTokenRenewer.java Tue Nov 27 19:26:09 2012
@@ -23,6 +23,7 @@ public class TestDelegationTokenRenewer
@SuppressWarnings("rawtypes")
static class TestToken extends Token {
public volatile int renewCount = 0;
+ public volatile boolean cancelled = false;
@Override
public long renew(Configuration conf) {
@@ -33,6 +34,11 @@ public class TestDelegationTokenRenewer
}
return renewCount;
}
+
+ @Override
+ public void cancel(Configuration conf) {
+ cancelled = true;
+ }
}
static class TestFileSystem extends FileSystem implements
@@ -123,27 +129,12 @@ public class TestDelegationTokenRenewer
}
@Test
- public void testAddRenewAction() throws IOException, InterruptedException {
- TestFileSystem tfs = new TestFileSystem();
- renewer.addRenewAction(tfs);
-
- for (int i = 0; i < 10; i++) {
- Thread.sleep(RENEW_CYCLE);
- if (tfs.testToken.renewCount > 0) {
- return;
- }
- }
-
- assertTrue("Token not renewed even after 10 seconds",
- (tfs.testToken.renewCount > 0));
- }
-
- @Test
- public void testRemoveRenewAction() throws IOException, InterruptedException {
+ public void testAddRemoveRenewAction() throws IOException,
+ InterruptedException {
TestFileSystem tfs = new TestFileSystem();
renewer.addRenewAction(tfs);
- for (int i = 0; i < 10; i++) {
+ for (int i = 0; i < 60; i++) {
Thread.sleep(RENEW_CYCLE);
if (tfs.testToken.renewCount > 0) {
renewer.removeRenewAction(tfs);
@@ -151,9 +142,9 @@ public class TestDelegationTokenRenewer
}
}
- assertTrue("Token not renewed even once",
+ assertTrue("Token not renewed even after 1 minute",
(tfs.testToken.renewCount > 0));
- assertTrue("Token not removed",
- (tfs.testToken.renewCount < MAX_RENEWALS));
+ assertTrue("Token not removed", (tfs.testToken.renewCount < MAX_RENEWALS));
+ assertTrue("Token not cancelled", tfs.testToken.cancelled);
}
}