diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index c2077eb6e03..b3dbd7795b8 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -181,6 +181,9 @@ Release 2.0.3-alpha - Unreleased HADOOP-9126. FormatZK and ZKFC startup can fail due to zkclient connection establishment delay. (Rakesh R and todd via todd) + HADOOP-9113. o.a.h.fs.TestDelegationTokenRenewer is failing intermittently. + (Karthik Kambatla via eli) + Release 2.0.2-alpha - 2012-09-07 INCOMPATIBLE CHANGES diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/DelegationTokenRenewer.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/DelegationTokenRenewer.java index b60507afa34..6e45a1ea6ae 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/DelegationTokenRenewer.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/DelegationTokenRenewer.java @@ -18,6 +18,8 @@ package org.apache.hadoop.fs; +import com.google.common.annotations.VisibleForTesting; + import java.io.IOException; import java.lang.ref.WeakReference; import java.util.concurrent.DelayQueue; @@ -147,6 +149,12 @@ public class DelegationTokenRenewer /** Queue to maintain the RenewActions to be processed by the {@link #run()} */ private volatile DelayQueue> queue = new DelayQueue>(); + /** For testing purposes */ + @VisibleForTesting + protected int getRenewQueueLength() { + return queue.size(); + } + /** * Create the singleton instance. However, the thread can be started lazily in * {@link #addRenewAction(FileSystem)} diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestDelegationTokenRenewer.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestDelegationTokenRenewer.java index 86a580c5258..3f1d34e99b7 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestDelegationTokenRenewer.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestDelegationTokenRenewer.java @@ -4,6 +4,7 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.net.URI; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.mock; @@ -133,6 +134,8 @@ public class TestDelegationTokenRenewer { InterruptedException { TestFileSystem tfs = new TestFileSystem(); renewer.addRenewAction(tfs); + assertEquals("FileSystem not added to DelegationTokenRenewer", 1, + renewer.getRenewQueueLength()); for (int i = 0; i < 60; i++) { Thread.sleep(RENEW_CYCLE); @@ -144,7 +147,8 @@ public class TestDelegationTokenRenewer { assertTrue("Token not renewed even after 1 minute", (tfs.testToken.renewCount > 0)); - assertTrue("Token not removed", (tfs.testToken.renewCount < MAX_RENEWALS)); + assertEquals("FileSystem not removed from DelegationTokenRenewer", 0, + renewer.getRenewQueueLength()); assertTrue("Token not cancelled", tfs.testToken.cancelled); } }