From 52bcefca8bb13d3757009f1f08203e7dca3b1e16 Mon Sep 17 00:00:00 2001 From: Jian He Date: Tue, 2 Dec 2014 10:53:55 -0800 Subject: [PATCH] YARN-2136. Changed RMStateStore to ignore store opearations when fenced. Contributed by Varun Saxena --- hadoop-yarn-project/CHANGES.txt | 3 + .../recovery/RMStateStore.java | 62 ++++++++++-- .../recovery/RMStateStoreEventType.java | 3 +- .../recovery/ZKRMStateStore.java | 8 ++ .../recovery/TestZKRMStateStore.java | 94 +++++++++++++++++++ 5 files changed, 161 insertions(+), 9 deletions(-) diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index d95679ee9c..3744a1ecb6 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -109,6 +109,9 @@ Release 2.7.0 - UNRELEASED YARN-2907. SchedulerNode#toString should print all resource detail instead of only memory. (Rohith via junping_du) + YARN-2136. Changed RMStateStore to ignore store opearations when fenced. + (Varun Saxena via jianhe) + OPTIMIZATIONS BUG FIXES diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/recovery/RMStateStore.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/recovery/RMStateStore.java index 35a54c3ab6..00e1dfc387 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/recovery/RMStateStore.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/recovery/RMStateStore.java @@ -18,6 +18,7 @@ package org.apache.hadoop.yarn.server.resourcemanager.recovery; +import java.util.EnumSet; import java.util.HashMap; import java.util.HashSet; import java.util.Map; @@ -26,6 +27,7 @@ import javax.crypto.SecretKey; +import com.google.common.annotations.VisibleForTesting; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hadoop.classification.InterfaceAudience.Private; @@ -88,7 +90,8 @@ public abstract class RMStateStore extends AbstractService { public static final Log LOG = LogFactory.getLog(RMStateStore.class); private enum RMStateStoreState { - DEFAULT + ACTIVE, + FENCED }; private static final StateMachineFactory( - RMStateStoreState.DEFAULT) - .addTransition(RMStateStoreState.DEFAULT, RMStateStoreState.DEFAULT, + RMStateStoreState.ACTIVE) + .addTransition(RMStateStoreState.ACTIVE, RMStateStoreState.ACTIVE, RMStateStoreEventType.STORE_APP, new StoreAppTransition()) - .addTransition(RMStateStoreState.DEFAULT, RMStateStoreState.DEFAULT, + .addTransition(RMStateStoreState.ACTIVE, RMStateStoreState.ACTIVE, RMStateStoreEventType.UPDATE_APP, new UpdateAppTransition()) - .addTransition(RMStateStoreState.DEFAULT, RMStateStoreState.DEFAULT, + .addTransition(RMStateStoreState.ACTIVE, RMStateStoreState.ACTIVE, RMStateStoreEventType.REMOVE_APP, new RemoveAppTransition()) - .addTransition(RMStateStoreState.DEFAULT, RMStateStoreState.DEFAULT, + .addTransition(RMStateStoreState.ACTIVE, RMStateStoreState.ACTIVE, RMStateStoreEventType.STORE_APP_ATTEMPT, new StoreAppAttemptTransition()) - .addTransition(RMStateStoreState.DEFAULT, RMStateStoreState.DEFAULT, - RMStateStoreEventType.UPDATE_APP_ATTEMPT, new UpdateAppAttemptTransition()); + .addTransition(RMStateStoreState.ACTIVE, RMStateStoreState.ACTIVE, + RMStateStoreEventType.UPDATE_APP_ATTEMPT, new UpdateAppAttemptTransition()) + .addTransition(RMStateStoreState.ACTIVE, RMStateStoreState.FENCED, + RMStateStoreEventType.FENCED) + .addTransition(RMStateStoreState.FENCED, RMStateStoreState.FENCED, + EnumSet.of( + RMStateStoreEventType.STORE_APP, + RMStateStoreEventType.UPDATE_APP, + RMStateStoreEventType.REMOVE_APP, + RMStateStoreEventType.STORE_APP_ATTEMPT, + RMStateStoreEventType.UPDATE_APP_ATTEMPT, + RMStateStoreEventType.FENCED)); private final StateMachine