From a1afbc48b53f6bdbd30dc8eb56a7621d49c5d6db Mon Sep 17 00:00:00 2001 From: Jian He Date: Mon, 13 Apr 2015 14:07:17 -0700 Subject: [PATCH] YARN-3472. Fixed possible leak in DelegationTokenRenewer#allTokens. Contributed by Rohith Sharmaks --- hadoop-yarn-project/CHANGES.txt | 3 +++ .../security/DelegationTokenRenewer.java | 1 + .../security/TestDelegationTokenRenewer.java | 11 ++++++++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index ef9ba9024b..8396f62ac7 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -180,6 +180,9 @@ Release 2.8.0 - UNRELEASED YARN-3382. Some of UserMetricsInfo metrics are incorrectly set to root queue metrics. (Rohit Agarwal via jianhe) + YARN-3472. Fixed possible leak in DelegationTokenRenewer#allTokens. + (Rohith Sharmaks via jianhe) + Release 2.7.1 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/security/DelegationTokenRenewer.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/security/DelegationTokenRenewer.java index d49ecfc5e2..e307645127 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/security/DelegationTokenRenewer.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/security/DelegationTokenRenewer.java @@ -577,6 +577,7 @@ private void requestNewHdfsDelegationTokenIfNeeded( DelegationTokenToRenew t = iter.next(); if (t.token.getKind().equals(new Text("HDFS_DELEGATION_TOKEN"))) { iter.remove(); + allTokens.remove(t.token); t.cancelTimer(); LOG.info("Removed expiring token " + t); } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/security/TestDelegationTokenRenewer.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/security/TestDelegationTokenRenewer.java index bc9c295107..f2c0a301eb 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/security/TestDelegationTokenRenewer.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/security/TestDelegationTokenRenewer.java @@ -906,7 +906,16 @@ protected Token[] obtainSystemTokensForUser(String user, new HashMap(), false, "default", 1, credentials); - // wait for the initial expiring hdfs token to be removed. + // wait for the initial expiring hdfs token to be removed from allTokens + GenericTestUtils.waitFor(new Supplier() { + public Boolean get() { + return + rm.getRMContext().getDelegationTokenRenewer().getAllTokens() + .get(token1) == null; + } + }, 1000, 20000); + + // wait for the initial expiring hdfs token to be removed from appTokens GenericTestUtils.waitFor(new Supplier() { public Boolean get() { return !rm.getRMContext().getDelegationTokenRenewer()