Repository: hadoop Updated Branches: refs/heads/YARN-2915 adbba7f2d -> 2f4191c50 (forced update)
YARN-6565. Fix memory leak and finish app trigger in AMRMProxy. (Botong Huang via Subru). Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/d6eed5ac Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/d6eed5ac Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/d6eed5ac Branch: refs/heads/YARN-2915 Commit: d6eed5acca222a281401c1d524824f0460ea7826 Parents: e4f34ec Author: Subru Krishnan <su...@apache.org> Authored: Fri May 5 16:27:49 2017 -0700 Committer: Subru Krishnan <su...@apache.org> Committed: Fri May 5 16:27:49 2017 -0700 ---------------------------------------------------------------------- .../nodemanager/amrmproxy/AMRMProxyService.java | 6 +- .../TestAMRMProxyTokenSecretManager.java | 81 ++++++++++++++++++++ 2 files changed, 86 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/d6eed5ac/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/amrmproxy/AMRMProxyService.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/amrmproxy/AMRMProxyService.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/amrmproxy/AMRMProxyService.java index 5e91a20..9f2d9a1 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/amrmproxy/AMRMProxyService.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/amrmproxy/AMRMProxyService.java @@ -320,6 +320,10 @@ public class AMRMProxyService extends AbstractService implements LOG.info("Request to stop an application that does not exist. Id:" + applicationId); } else { + // Remove the appAttempt in AMRMTokenSecretManager + this.secretManager + .applicationMasterFinished(pipeline.getApplicationAttemptId()); + LOG.info("Stopping the request processing pipeline for application: " + applicationId); try { @@ -548,7 +552,7 @@ public class AMRMProxyService extends AbstractService implements event.getApplicationID()); if (app != null) { switch (event.getType()) { - case FINISH_APPLICATION: + case APPLICATION_RESOURCES_CLEANEDUP: LOG.info("Application stop event received for stopping AppId:" + event.getApplicationID().toString()); AMRMProxyService.this.stopApplication(event.getApplicationID()); http://git-wip-us.apache.org/repos/asf/hadoop/blob/d6eed5ac/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/amrmproxy/TestAMRMProxyTokenSecretManager.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/amrmproxy/TestAMRMProxyTokenSecretManager.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/amrmproxy/TestAMRMProxyTokenSecretManager.java new file mode 100644 index 0000000..927563e --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/amrmproxy/TestAMRMProxyTokenSecretManager.java @@ -0,0 +1,81 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hadoop.yarn.server.nodemanager.amrmproxy; + +import java.io.ByteArrayInputStream; +import java.io.DataInputStream; +import java.io.IOException; + +import org.apache.hadoop.security.token.SecretManager.InvalidToken; +import org.apache.hadoop.security.token.Token; +import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; +import org.apache.hadoop.yarn.api.records.ApplicationId; +import org.apache.hadoop.yarn.conf.YarnConfiguration; +import org.apache.hadoop.yarn.security.AMRMTokenIdentifier; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +/** + * Unit test for AMRMProxyTokenSecretManager. + */ +public class TestAMRMProxyTokenSecretManager { + + private YarnConfiguration conf; + private AMRMProxyTokenSecretManager secretManager; + + @Before + public void setup() { + conf = new YarnConfiguration(); + secretManager = new AMRMProxyTokenSecretManager(conf); + secretManager.start(); + } + + @After + public void breakdown() { + if (secretManager != null) { + secretManager.stop(); + } + } + + @Test + public void testNormalCase() throws IOException { + ApplicationId appId = ApplicationId.newInstance(1, 1); + ApplicationAttemptId attemptId = ApplicationAttemptId.newInstance(appId, 1); + + Token<AMRMTokenIdentifier> localToken = + secretManager.createAndGetAMRMToken(attemptId); + + AMRMTokenIdentifier identifier = secretManager.createIdentifier(); + identifier.readFields(new DataInputStream( + new ByteArrayInputStream(localToken.getIdentifier()))); + + secretManager.retrievePassword(identifier); + + secretManager.applicationMasterFinished(attemptId); + + try { + secretManager.retrievePassword(identifier); + Assert.fail("Expect InvalidToken exception"); + } catch (InvalidToken e) { + } + } + +} --------------------------------------------------------------------- To unsubscribe, e-mail: common-commits-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-commits-h...@hadoop.apache.org