HADOOP-9113. o.a.h.fs.TestDelegationTokenRenewer is failing intermittently. Contributed by Karthik Kambatla
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1420495 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1fce56fd24
commit
3b15fe6686
|
@ -181,6 +181,9 @@ Release 2.0.3-alpha - Unreleased
|
||||||
HADOOP-9126. FormatZK and ZKFC startup can fail due to zkclient connection
|
HADOOP-9126. FormatZK and ZKFC startup can fail due to zkclient connection
|
||||||
establishment delay. (Rakesh R and todd via todd)
|
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
|
Release 2.0.2-alpha - 2012-09-07
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
|
|
||||||
package org.apache.hadoop.fs;
|
package org.apache.hadoop.fs;
|
||||||
|
|
||||||
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.concurrent.DelayQueue;
|
import java.util.concurrent.DelayQueue;
|
||||||
|
@ -147,6 +149,12 @@ public class DelegationTokenRenewer
|
||||||
/** Queue to maintain the RenewActions to be processed by the {@link #run()} */
|
/** Queue to maintain the RenewActions to be processed by the {@link #run()} */
|
||||||
private volatile DelayQueue<RenewAction<?>> queue = new DelayQueue<RenewAction<?>>();
|
private volatile DelayQueue<RenewAction<?>> queue = new DelayQueue<RenewAction<?>>();
|
||||||
|
|
||||||
|
/** For testing purposes */
|
||||||
|
@VisibleForTesting
|
||||||
|
protected int getRenewQueueLength() {
|
||||||
|
return queue.size();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the singleton instance. However, the thread can be started lazily in
|
* Create the singleton instance. However, the thread can be started lazily in
|
||||||
* {@link #addRenewAction(FileSystem)}
|
* {@link #addRenewAction(FileSystem)}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
|
|
||||||
|
@ -133,6 +134,8 @@ public class TestDelegationTokenRenewer {
|
||||||
InterruptedException {
|
InterruptedException {
|
||||||
TestFileSystem tfs = new TestFileSystem();
|
TestFileSystem tfs = new TestFileSystem();
|
||||||
renewer.addRenewAction(tfs);
|
renewer.addRenewAction(tfs);
|
||||||
|
assertEquals("FileSystem not added to DelegationTokenRenewer", 1,
|
||||||
|
renewer.getRenewQueueLength());
|
||||||
|
|
||||||
for (int i = 0; i < 60; i++) {
|
for (int i = 0; i < 60; i++) {
|
||||||
Thread.sleep(RENEW_CYCLE);
|
Thread.sleep(RENEW_CYCLE);
|
||||||
|
@ -144,7 +147,8 @@ public class TestDelegationTokenRenewer {
|
||||||
|
|
||||||
assertTrue("Token not renewed even after 1 minute",
|
assertTrue("Token not renewed even after 1 minute",
|
||||||
(tfs.testToken.renewCount > 0));
|
(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);
|
assertTrue("Token not cancelled", tfs.testToken.cancelled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue