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 jl...@apache.org on 2017/07/14 20:03:32 UTC
hadoop git commit: YARN-3260. AM attempt fail to register before RM
processes launch event. Contributed by Bibin A Chundatt
Repository: hadoop
Updated Branches:
refs/heads/trunk 75c0220b4 -> a5ae5ac50
YARN-3260. AM attempt fail to register before RM processes launch event. Contributed by Bibin A Chundatt
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/a5ae5ac5
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/a5ae5ac5
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/a5ae5ac5
Branch: refs/heads/trunk
Commit: a5ae5ac50e97cf829c41dcf01655cd9bd4d36a00
Parents: 75c0220
Author: Jason Lowe <jl...@yahoo-inc.com>
Authored: Fri Jul 14 14:56:00 2017 -0500
Committer: Jason Lowe <jl...@yahoo-inc.com>
Committed: Fri Jul 14 14:56:00 2017 -0500
----------------------------------------------------------------------
.../rmapp/attempt/RMAppAttemptImpl.java | 20 +++++++-----
.../attempt/TestRMAppAttemptTransitions.java | 33 ++++++++++----------
2 files changed, 28 insertions(+), 25 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/a5ae5ac5/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/attempt/RMAppAttemptImpl.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/attempt/RMAppAttemptImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/attempt/RMAppAttemptImpl.java
index d66a97d..4210c54 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/attempt/RMAppAttemptImpl.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/attempt/RMAppAttemptImpl.java
@@ -1205,6 +1205,8 @@ public class RMAppAttemptImpl implements RMAppAttempt, Recoverable {
@Override
public void transition(RMAppAttemptImpl appAttempt,
RMAppAttemptEvent event) {
+
+ appAttempt.registerClientToken();
appAttempt.launchAttempt();
}
}
@@ -1525,13 +1527,6 @@ public class RMAppAttemptImpl implements RMAppAttempt, Recoverable {
// Register with AMLivelinessMonitor
appAttempt.attemptLaunched();
- // register the ClientTokenMasterKey after it is saved in the store,
- // otherwise client may hold an invalid ClientToken after RM restarts.
- if (UserGroupInformation.isSecurityEnabled()) {
- appAttempt.rmContext.getClientToAMTokenSecretManager()
- .registerApplication(appAttempt.getAppAttemptId(),
- appAttempt.getClientTokenMasterKey());
- }
}
}
@@ -1598,11 +1593,20 @@ public class RMAppAttemptImpl implements RMAppAttempt, Recoverable {
appAttempt.amrmToken =
appAttempt.rmContext.getAMRMTokenSecretManager().createAndGetAMRMToken(
appAttempt.applicationAttemptId);
-
+ appAttempt.registerClientToken();
super.transition(appAttempt, event);
}
}
+ private void registerClientToken() {
+ // register the ClientTokenMasterKey after it is saved in the store,
+ // otherwise client may hold an invalid ClientToken after RM restarts.
+ if (UserGroupInformation.isSecurityEnabled()) {
+ rmContext.getClientToAMTokenSecretManager()
+ .registerApplication(getAppAttemptId(), getClientTokenMasterKey());
+ }
+ }
+
private static final class LaunchFailedTransition extends BaseFinalTransition {
public LaunchFailedTransition() {
http://git-wip-us.apache.org/repos/asf/hadoop/blob/a5ae5ac5/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/attempt/TestRMAppAttemptTransitions.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/attempt/TestRMAppAttemptTransitions.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/attempt/TestRMAppAttemptTransitions.java
index 9a4b6dc..7702ab1 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/attempt/TestRMAppAttemptTransitions.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/attempt/TestRMAppAttemptTransitions.java
@@ -663,21 +663,29 @@ public class TestRMAppAttemptTransitions {
assertEquals(RMAppAttemptState.ALLOCATED_SAVING,
applicationAttempt.getAppAttemptState());
+
+ if (UserGroupInformation.isSecurityEnabled()) {
+ // Before SAVED state, can't create ClientToken as at this time
+ // ClientTokenMasterKey has not been registered in the SecretManager
+ assertNull(applicationAttempt.createClientToken("some client"));
+ }
+
applicationAttempt.handle(
new RMAppAttemptEvent(applicationAttempt.getAppAttemptId(),
RMAppAttemptEventType.ATTEMPT_NEW_SAVED));
-
+
+ if (UserGroupInformation.isSecurityEnabled()) {
+ // Before SAVED state, can't create ClientToken as at this time
+ // ClientTokenMasterKey has not been registered in the SecretManager
+ assertNotNull(applicationAttempt.createClientToken("some client"));
+ }
+
testAppAttemptAllocatedState(container);
return container;
}
private void launchApplicationAttempt(Container container) {
- if (UserGroupInformation.isSecurityEnabled()) {
- // Before LAUNCHED state, can't create ClientToken as at this time
- // ClientTokenMasterKey has not been registered in the SecretManager
- assertNull(applicationAttempt.createClientToken("some client"));
- }
applicationAttempt.handle(
new RMAppAttemptEvent(applicationAttempt.getAppAttemptId(),
RMAppAttemptEventType.LAUNCHED));
@@ -1477,8 +1485,6 @@ public class TestRMAppAttemptTransitions {
Token<ClientToAMTokenIdentifier> token =
applicationAttempt.createClientToken(null);
Assert.assertNull(token);
- token = applicationAttempt.createClientToken("clientuser");
- Assert.assertNull(token);
launchApplicationAttempt(amContainer);
// after attempt is launched , can get ClientToken
@@ -1505,22 +1511,15 @@ public class TestRMAppAttemptTransitions {
public void testApplicationAttemptMasterKey() throws Exception {
Container amContainer = allocateApplicationAttempt();
ApplicationAttemptId appid = applicationAttempt.getAppAttemptId();
- boolean isMasterKeyExisted = false;
+ boolean isMasterKeyExisted = clientToAMTokenManager.hasMasterKey(appid);
- // before attempt is launched, can not get MasterKey
- isMasterKeyExisted = clientToAMTokenManager.hasMasterKey(appid);
- Assert.assertFalse(isMasterKeyExisted);
-
- launchApplicationAttempt(amContainer);
- // after attempt is launched and in secure mode, can get MasterKey
- isMasterKeyExisted = clientToAMTokenManager.hasMasterKey(appid);
if (isSecurityEnabled) {
Assert.assertTrue(isMasterKeyExisted);
Assert.assertNotNull(clientToAMTokenManager.getMasterKey(appid));
} else {
Assert.assertFalse(isMasterKeyExisted);
}
-
+ launchApplicationAttempt(amContainer);
applicationAttempt.handle(new RMAppAttemptEvent(applicationAttempt
.getAppAttemptId(), RMAppAttemptEventType.KILL));
assertEquals(YarnApplicationAttemptState.LAUNCHED,
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org