hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vinayakum...@apache.org
Subject [02/50] [abbrv] hadoop git commit: YARN-2404. Removed ApplicationAttemptState and ApplicationState class in RMStateStore. Contributed by Tsuyoshi OZAWA
Date Wed, 03 Dec 2014 05:23:34 GMT
http://git-wip-us.apache.org/repos/asf/hadoop/blob/5805a81e/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRMRestart.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/TestRMRestart.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRMRestart.java
index a0f8627..a42170b 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRMRestart.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRMRestart.java
@@ -84,8 +84,6 @@ import org.apache.hadoop.yarn.server.api.protocolrecords.NodeHeartbeatResponse;
 import org.apache.hadoop.yarn.server.api.records.NodeAction;
 import org.apache.hadoop.yarn.server.resourcemanager.recovery.MemoryRMStateStore;
 import org.apache.hadoop.yarn.server.resourcemanager.recovery.RMStateStore;
-import org.apache.hadoop.yarn.server.resourcemanager.recovery.RMStateStore.ApplicationAttemptState;
-import org.apache.hadoop.yarn.server.resourcemanager.recovery.RMStateStore.ApplicationState;
 import org.apache.hadoop.yarn.server.resourcemanager.recovery.RMStateStore.RMState;
 import org.apache.hadoop.yarn.server.resourcemanager.recovery.RMStateStoreEvent;
 import org.apache.hadoop.yarn.server.resourcemanager.recovery.records.ApplicationAttemptStateData;
@@ -162,7 +160,7 @@ public class TestRMRestart extends ParameterizedSchedulerTestBase {
     MemoryRMStateStore memStore = new MemoryRMStateStore();
     memStore.init(conf);
     RMState rmState = memStore.getState();
-    Map<ApplicationId, ApplicationState> rmAppState = 
+    Map<ApplicationId, ApplicationStateData> rmAppState =
                                                   rmState.getApplicationState();
     
     
@@ -194,7 +192,7 @@ public class TestRMRestart extends ParameterizedSchedulerTestBase {
     // create app that gets launched and does allocate before RM restart
     RMApp app1 = rm1.submitApp(200);
     // assert app1 info is saved
-    ApplicationState appState = rmAppState.get(app1.getApplicationId());
+    ApplicationStateData appState = rmAppState.get(app1.getApplicationId());
     Assert.assertNotNull(appState);
     Assert.assertEquals(0, appState.getAttemptCount());
     Assert.assertEquals(appState.getApplicationSubmissionContext()
@@ -209,7 +207,7 @@ public class TestRMRestart extends ParameterizedSchedulerTestBase {
     ApplicationAttemptId attemptId1 = attempt1.getAppAttemptId();
     rm1.waitForState(attemptId1, RMAppAttemptState.ALLOCATED);
     Assert.assertEquals(1, appState.getAttemptCount());
-    ApplicationAttemptState attemptState = 
+    ApplicationAttemptStateData attemptState =
                                 appState.getAttempt(attemptId1);
     Assert.assertNotNull(attemptState);
     Assert.assertEquals(BuilderUtils.newContainerId(attemptId1, 1), 
@@ -429,7 +427,7 @@ public class TestRMRestart extends ParameterizedSchedulerTestBase {
     MemoryRMStateStore memStore = new MemoryRMStateStore();
     memStore.init(conf);
     RMState rmState = memStore.getState();
-    Map<ApplicationId, ApplicationState> rmAppState =
+    Map<ApplicationId, ApplicationStateData> rmAppState =
         rmState.getApplicationState();
 
     // start RM
@@ -450,7 +448,7 @@ public class TestRMRestart extends ParameterizedSchedulerTestBase {
     nm1.nodeHeartbeat(am0.getApplicationAttemptId(), 1, ContainerState.COMPLETE);
     am0.waitForState(RMAppAttemptState.FAILED);
 
-    ApplicationState appState = rmAppState.get(app0.getApplicationId());
+    ApplicationStateData appState = rmAppState.get(app0.getApplicationId());
     // assert the AM failed state is saved.
     Assert.assertEquals(RMAppAttemptState.FAILED,
       appState.getAttempt(am0.getApplicationAttemptId()).getState());
@@ -486,7 +484,7 @@ public class TestRMRestart extends ParameterizedSchedulerTestBase {
     MemoryRMStateStore memStore = new MemoryRMStateStore();
     memStore.init(conf);
     RMState rmState = memStore.getState();
-    Map<ApplicationId, ApplicationState> rmAppState =
+    Map<ApplicationId, ApplicationStateData> rmAppState =
         rmState.getApplicationState();
     
     // start RM
@@ -650,7 +648,7 @@ public class TestRMRestart extends ParameterizedSchedulerTestBase {
     };
     memStore.init(conf);
     RMState rmState = memStore.getState();
-    Map<ApplicationId, ApplicationState> rmAppState =
+    Map<ApplicationId, ApplicationStateData> rmAppState =
         rmState.getApplicationState();
 
     // start RM
@@ -689,7 +687,7 @@ public class TestRMRestart extends ParameterizedSchedulerTestBase {
     MemoryRMStateStore memStore = new MemoryRMStateStore();
     memStore.init(conf);
     RMState rmState = memStore.getState();
-    Map<ApplicationId, ApplicationState> rmAppState =
+    Map<ApplicationId, ApplicationStateData> rmAppState =
         rmState.getApplicationState();
 
     // start RM
@@ -709,7 +707,7 @@ public class TestRMRestart extends ParameterizedSchedulerTestBase {
     rm1.waitForState(app0.getApplicationId(), RMAppState.FAILED);
 
     // assert the app/attempt failed state is saved.
-    ApplicationState appState = rmAppState.get(app0.getApplicationId());
+    ApplicationStateData appState = rmAppState.get(app0.getApplicationId());
     Assert.assertEquals(RMAppState.FAILED, appState.getState());
     Assert.assertEquals(RMAppAttemptState.FAILED,
       appState.getAttempt(am0.getApplicationAttemptId()).getState());
@@ -737,7 +735,7 @@ public class TestRMRestart extends ParameterizedSchedulerTestBase {
     MemoryRMStateStore memStore = new MemoryRMStateStore();
     memStore.init(conf);
     RMState rmState = memStore.getState();
-    Map<ApplicationId, ApplicationState> rmAppState =
+    Map<ApplicationId, ApplicationStateData> rmAppState =
         rmState.getApplicationState();
 
     // start RM
@@ -757,7 +755,7 @@ public class TestRMRestart extends ParameterizedSchedulerTestBase {
     rm1.waitForState(am0.getApplicationAttemptId(), RMAppAttemptState.KILLED);
 
     // killed state is saved.
-    ApplicationState appState = rmAppState.get(app0.getApplicationId());
+    ApplicationStateData appState = rmAppState.get(app0.getApplicationId());
     Assert.assertEquals(RMAppState.KILLED, appState.getState());
     Assert.assertEquals(RMAppAttemptState.KILLED,
       appState.getAttempt(am0.getApplicationAttemptId()).getState());
@@ -823,7 +821,7 @@ public class TestRMRestart extends ParameterizedSchedulerTestBase {
     MemoryRMStateStore memStore = new MemoryRMStateStore();
     memStore.init(conf);
     RMState rmState = memStore.getState();
-    Map<ApplicationId, ApplicationState> rmAppState =
+    Map<ApplicationId, ApplicationStateData> rmAppState =
         rmState.getApplicationState();
 
     // start RM
@@ -844,8 +842,8 @@ public class TestRMRestart extends ParameterizedSchedulerTestBase {
     finishApplicationMaster(app0, rm1, nm1, am0, req);
  
     // check the state store about the unregistered info.
-    ApplicationState appState = rmAppState.get(app0.getApplicationId());
-    ApplicationAttemptState attemptState0 =
+    ApplicationStateData appState = rmAppState.get(app0.getApplicationId());
+    ApplicationAttemptStateData attemptState0 =
       appState.getAttempt(am0.getApplicationAttemptId());
     Assert.assertEquals("diagnostics", attemptState0.getDiagnostics());
     Assert.assertEquals(FinalApplicationStatus.SUCCEEDED,
@@ -995,7 +993,7 @@ public class TestRMRestart extends ParameterizedSchedulerTestBase {
       MockAM am, FinishApplicationMasterRequest req) throws Exception {
     RMState rmState =
         ((MemoryRMStateStore) rm.getRMContext().getStateStore()).getState();
-    Map<ApplicationId, ApplicationState> rmAppState =
+    Map<ApplicationId, ApplicationStateData> rmAppState =
         rmState.getApplicationState();
     am.unregisterAppAttempt(req,true);
     am.waitForState(RMAppAttemptState.FINISHING);
@@ -1003,7 +1001,7 @@ public class TestRMRestart extends ParameterizedSchedulerTestBase {
     am.waitForState(RMAppAttemptState.FINISHED);
     rm.waitForState(rmApp.getApplicationId(), RMAppState.FINISHED);
     // check that app/attempt is saved with the final state
-    ApplicationState appState = rmAppState.get(rmApp.getApplicationId());
+    ApplicationStateData appState = rmAppState.get(rmApp.getApplicationId());
     Assert
       .assertEquals(RMAppState.FINISHED, appState.getState());
     Assert.assertEquals(RMAppAttemptState.FINISHED,
@@ -1019,7 +1017,7 @@ public class TestRMRestart extends ParameterizedSchedulerTestBase {
     memStore.init(conf);
     RMState rmState = memStore.getState();
 
-    Map<ApplicationId, ApplicationState> rmAppState =
+    Map<ApplicationId, ApplicationStateData> rmAppState =
         rmState.getApplicationState();  
     MockRM rm1 = createMockRM(conf, memStore);
     rm1.start();
@@ -1037,7 +1035,7 @@ public class TestRMRestart extends ParameterizedSchedulerTestBase {
           null);
 
     // assert app1 info is saved
-    ApplicationState appState = rmAppState.get(app1.getApplicationId());
+    ApplicationStateData appState = rmAppState.get(app1.getApplicationId());
     Assert.assertNotNull(appState);
     Assert.assertEquals(0, appState.getAttemptCount());
     Assert.assertEquals(appState.getApplicationSubmissionContext()
@@ -1050,7 +1048,7 @@ public class TestRMRestart extends ParameterizedSchedulerTestBase {
     ApplicationAttemptId attemptId1 = attempt.getAppAttemptId();
     rm1.waitForState(attemptId1, RMAppAttemptState.ALLOCATED);
     Assert.assertEquals(1, appState.getAttemptCount());
-    ApplicationAttemptState attemptState = 
+    ApplicationAttemptStateData attemptState =
                                 appState.getAttempt(attemptId1);
     Assert.assertNotNull(attemptState);
     Assert.assertEquals(BuilderUtils.newContainerId(attemptId1, 1), 
@@ -1092,7 +1090,7 @@ public class TestRMRestart extends ParameterizedSchedulerTestBase {
     memStore.init(conf);
     RMState rmState = memStore.getState();
 
-    Map<ApplicationId, ApplicationState> rmAppState =
+    Map<ApplicationId, ApplicationStateData> rmAppState =
         rmState.getApplicationState();
     MockRM rm1 = new TestSecurityMockRM(conf, memStore);
     rm1.start();
@@ -1131,7 +1129,7 @@ public class TestRMRestart extends ParameterizedSchedulerTestBase {
         new HashMap<ApplicationAccessType, String>(), false, "default", 1, ts);
 
     // assert app info is saved
-    ApplicationState appState = rmAppState.get(app.getApplicationId());
+    ApplicationStateData appState = rmAppState.get(app.getApplicationId());
     Assert.assertNotNull(appState);
 
     // assert delegation tokens exist in rm1 DelegationTokenRenewr
@@ -1187,7 +1185,7 @@ public class TestRMRestart extends ParameterizedSchedulerTestBase {
     memStore.init(conf);
     RMState rmState = memStore.getState();
 
-    Map<ApplicationId, ApplicationState> rmAppState =
+    Map<ApplicationId, ApplicationStateData> rmAppState =
         rmState.getApplicationState();
     MockRM rm1 = new TestSecurityMockRM(conf, memStore);
     rm1.start();
@@ -1201,7 +1199,7 @@ public class TestRMRestart extends ParameterizedSchedulerTestBase {
           new HashMap<ApplicationAccessType, String>(), "default");
 
     // assert app info is saved
-    ApplicationState appState = rmAppState.get(app1.getApplicationId());
+    ApplicationStateData appState = rmAppState.get(app1.getApplicationId());
     Assert.assertNotNull(appState);
 
     // Allocate the AM
@@ -1211,7 +1209,7 @@ public class TestRMRestart extends ParameterizedSchedulerTestBase {
     rm1.waitForState(attemptId1, RMAppAttemptState.ALLOCATED);
 
     // assert attempt info is saved
-    ApplicationAttemptState attemptState = appState.getAttempt(attemptId1);
+    ApplicationAttemptStateData attemptState = appState.getAttempt(attemptId1);
     Assert.assertNotNull(attemptState);
     Assert.assertEquals(BuilderUtils.newContainerId(attemptId1, 1),
       attemptState.getMasterContainer().getId());
@@ -1222,7 +1220,7 @@ public class TestRMRestart extends ParameterizedSchedulerTestBase {
         attempt1.getClientTokenMasterKey().getEncoded();
 
     // assert application credentials are saved
-    Credentials savedCredentials = attemptState.getAppAttemptCredentials();
+    Credentials savedCredentials = attemptState.getAppAttemptTokens();
     Assert.assertArrayEquals("client token master key not saved",
         clientTokenMasterKey, savedCredentials.getSecretKey(
             RMStateStore.AM_CLIENT_TOKEN_MASTER_KEY_NAME));
@@ -1268,7 +1266,7 @@ public class TestRMRestart extends ParameterizedSchedulerTestBase {
     memStore.init(conf);
     RMState rmState = memStore.getState();
 
-    Map<ApplicationId, ApplicationState> rmAppState =
+    Map<ApplicationId, ApplicationStateData> rmAppState =
         rmState.getApplicationState();
     Map<RMDelegationTokenIdentifier, Long> rmDTState =
         rmState.getRMDTSecretManagerState().getTokenState();
@@ -1305,7 +1303,7 @@ public class TestRMRestart extends ParameterizedSchedulerTestBase {
         new HashMap<ApplicationAccessType, String>(), false, "default", 1, ts);
 
     // assert app info is saved
-    ApplicationState appState = rmAppState.get(app.getApplicationId());
+    ApplicationStateData appState = rmAppState.get(app.getApplicationId());
     Assert.assertNotNull(appState);
 
     // assert all master keys are saved
@@ -1479,7 +1477,7 @@ public class TestRMRestart extends ParameterizedSchedulerTestBase {
     // queue, and will be processed once rm.stop() is called.
 
     // Nothing exist in state store before stop is called.
-    Map<ApplicationId, ApplicationState> rmAppState =
+    Map<ApplicationId, ApplicationStateData> rmAppState =
         memStore.getState().getApplicationState();
     Assert.assertTrue(rmAppState.size() == 0);
 
@@ -1489,7 +1487,7 @@ public class TestRMRestart extends ParameterizedSchedulerTestBase {
     // Assert app info is still saved even if stop is called with pending saving
     // request on dispatcher.
     for (RMApp app : appList) {
-      ApplicationState appState = rmAppState.get(app.getApplicationId());
+      ApplicationStateData appState = rmAppState.get(app.getApplicationId());
       Assert.assertNotNull(appState);
       Assert.assertEquals(0, appState.getAttemptCount());
       Assert.assertEquals(appState.getApplicationSubmissionContext()
@@ -1523,7 +1521,7 @@ public class TestRMRestart extends ParameterizedSchedulerTestBase {
     nm1.setResourceTrackerService(rm2.getResourceTrackerService());
     nm1 = rm2.registerNode("127.0.0.1:1234", 15120);
 
-    Map<ApplicationId, ApplicationState> rmAppState =
+    Map<ApplicationId, ApplicationStateData> rmAppState =
         rmState.getApplicationState();
 
     // app0 exits in both state store and rmContext
@@ -1658,10 +1656,15 @@ public class TestRMRestart extends ParameterizedSchedulerTestBase
{
     memStore.init(conf);
 
     for (int i = 10; i > 0; i--) {
-      ApplicationState appState = mock(ApplicationState.class);
-      when(appState.getAppId()).thenReturn(ApplicationId.newInstance(1234, i));
-      memStore.getState().getApplicationState()
-        .put(appState.getAppId(), appState);
+      ApplicationStateData appState = mock(ApplicationStateData.class);
+      ApplicationSubmissionContext context =
+          mock(ApplicationSubmissionContext.class);
+      when(appState.getApplicationSubmissionContext()).thenReturn(context);
+      when(context.getApplicationId()).thenReturn(
+          ApplicationId.newInstance(1234, i));
+      memStore.getState().getApplicationState().put(
+          appState.getApplicationSubmissionContext().getApplicationId(),
+          appState);
     }
 
     MockRM rm1 = new MockRM(conf, memStore) {
@@ -1681,12 +1684,14 @@ public class TestRMRestart extends ParameterizedSchedulerTestBase
{
         }
 
         @Override
-        protected void recoverApplication(ApplicationState appState,
+        protected void recoverApplication(ApplicationStateData appState,
             RMState rmState) throws Exception {
           // check application is recovered in order.
           Assert.assertTrue(rmState.getApplicationState().size() > 0);
-          Assert.assertTrue(appState.getAppId().compareTo(prevId) > 0);
-          prevId = appState.getAppId();
+          Assert.assertTrue(appState.getApplicationSubmissionContext()
+              .getApplicationId().compareTo(prevId) > 0);
+          prevId =
+              appState.getApplicationSubmissionContext().getApplicationId();
         }
       }
     };
@@ -2030,4 +2035,5 @@ public class TestRMRestart extends ParameterizedSchedulerTestBase {
       // Do nothing.
     }
   }
+
 }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/5805a81e/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/TestAMRestart.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/applicationsmanager/TestAMRestart.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/TestAMRestart.java
index a93123e..49b1841 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/TestAMRestart.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/TestAMRestart.java
@@ -42,7 +42,7 @@ import org.apache.hadoop.yarn.server.resourcemanager.MockAM;
 import org.apache.hadoop.yarn.server.resourcemanager.MockNM;
 import org.apache.hadoop.yarn.server.resourcemanager.MockRM;
 import org.apache.hadoop.yarn.server.resourcemanager.recovery.MemoryRMStateStore;
-import org.apache.hadoop.yarn.server.resourcemanager.recovery.RMStateStore.ApplicationState;
+import org.apache.hadoop.yarn.server.resourcemanager.recovery.records.ApplicationStateData;
 import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp;
 import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppImpl;
 import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppState;
@@ -386,7 +386,7 @@ public class TestAMRestart {
     am1.waitForState(RMAppAttemptState.FAILED);
     Assert.assertTrue(! attempt1.shouldCountTowardsMaxAttemptRetry());
     rm1.waitForState(app1.getApplicationId(), RMAppState.ACCEPTED);
-    ApplicationState appState =
+    ApplicationStateData appState =
         memStore.getState().getApplicationState().get(app1.getApplicationId());
     // AM should be restarted even though max-am-attempt is 1.
     MockAM am2 =
@@ -497,7 +497,7 @@ public class TestAMRestart {
     rm1.waitForState(app1.getApplicationId(), RMAppState.ACCEPTED);
 
     // state store has 1 attempt stored.
-    ApplicationState appState =
+    ApplicationStateData appState =
         memStore.getState().getApplicationState().get(app1.getApplicationId());
     Assert.assertEquals(1, appState.getAttemptCount());
     // attempt stored has the preempted container exit status.
@@ -555,7 +555,7 @@ public class TestAMRestart {
     // Restart rm.
     MockRM rm2 = new MockRM(conf, memStore);
     rm2.start();
-    ApplicationState appState =
+    ApplicationStateData appState =
         memStore.getState().getApplicationState().get(app1.getApplicationId());
     // re-register the NM
     nm1.setResourceTrackerService(rm2.getResourceTrackerService());

http://git-wip-us.apache.org/repos/asf/hadoop/blob/5805a81e/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/recovery/RMStateStoreTestBase.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/recovery/RMStateStoreTestBase.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/recovery/RMStateStoreTestBase.java
index 00b60d3..8d6a7b6 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/recovery/RMStateStoreTestBase.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/recovery/RMStateStoreTestBase.java
@@ -58,8 +58,8 @@ import org.apache.hadoop.yarn.security.AMRMTokenIdentifier;
 import org.apache.hadoop.yarn.security.client.RMDelegationTokenIdentifier;
 import org.apache.hadoop.yarn.server.records.Version;
 import org.apache.hadoop.yarn.server.resourcemanager.RMContext;
-import org.apache.hadoop.yarn.server.resourcemanager.recovery.RMStateStore.ApplicationAttemptState;
-import org.apache.hadoop.yarn.server.resourcemanager.recovery.RMStateStore.ApplicationState;
+import org.apache.hadoop.yarn.server.resourcemanager.recovery.records.ApplicationStateData;
+import org.apache.hadoop.yarn.server.resourcemanager.recovery.records.ApplicationAttemptStateData;
 import org.apache.hadoop.yarn.server.resourcemanager.recovery.RMStateStore.RMDTSecretManagerState;
 import org.apache.hadoop.yarn.server.resourcemanager.recovery.RMStateStore.RMState;
 import org.apache.hadoop.yarn.server.resourcemanager.recovery.records.AMRMTokenSecretManagerState;
@@ -243,6 +243,7 @@ public class RMStateStoreTestBase extends ClientBaseWithFixes{
     when(mockRemovedApp.getSubmitTime()).thenReturn(submitTime);
     when(mockRemovedApp.getApplicationSubmissionContext()).thenReturn(context);
     when(mockRemovedApp.getAppAttempts()).thenReturn(attempts);
+    when(mockRemovedApp.getUser()).thenReturn("user1");
     RMAppAttempt mockRemovedAttempt = mock(RMAppAttempt.class);
     when(mockRemovedAttempt.getAppAttemptId()).thenReturn(attemptIdRemoved);
     when(mockRemovedAttempt.getRMAppAttemptMetrics())
@@ -269,10 +270,10 @@ public class RMStateStoreTestBase extends ClientBaseWithFixes{
     store = stateStoreHelper.getRMStateStore();
     store.setRMDispatcher(dispatcher);
     RMState state = store.loadState();
-    Map<ApplicationId, ApplicationState> rmAppState =
+    Map<ApplicationId, ApplicationStateData> rmAppState =
         state.getApplicationState();
 
-    ApplicationState appState = rmAppState.get(appId1);
+    ApplicationStateData appState = rmAppState.get(appId1);
     // app is loaded
     assertNotNull(appState);
     // app is loaded correctly
@@ -281,7 +282,7 @@ public class RMStateStoreTestBase extends ClientBaseWithFixes{
     // submission context is loaded correctly
     assertEquals(appId1,
                  appState.getApplicationSubmissionContext().getApplicationId());
-    ApplicationAttemptState attemptState = appState.getAttempt(attemptId1);
+    ApplicationAttemptStateData attemptState = appState.getAttempt(attemptId1);
     // attempt1 is loaded correctly
     assertNotNull(attemptState);
     assertEquals(attemptId1, attemptState.getAttemptId());
@@ -289,9 +290,10 @@ public class RMStateStoreTestBase extends ClientBaseWithFixes{
     // attempt1 container is loaded correctly
     assertEquals(containerId1, attemptState.getMasterContainer().getId());
     // attempt1 client token master key is loaded correctly
-    assertArrayEquals(clientTokenKey1.getEncoded(),
-        attemptState.getAppAttemptCredentials()
-        .getSecretKey(RMStateStore.AM_CLIENT_TOKEN_MASTER_KEY_NAME));
+    assertArrayEquals(
+        clientTokenKey1.getEncoded(),
+        attemptState.getAppAttemptTokens()
+            .getSecretKey(RMStateStore.AM_CLIENT_TOKEN_MASTER_KEY_NAME));
 
     attemptState = appState.getAttempt(attemptId2);
     // attempt2 is loaded correctly
@@ -300,27 +302,30 @@ public class RMStateStoreTestBase extends ClientBaseWithFixes{
     // attempt2 container is loaded correctly
     assertEquals(containerId2, attemptState.getMasterContainer().getId());
     // attempt2 client token master key is loaded correctly
-    assertArrayEquals(clientTokenKey2.getEncoded(),
-        attemptState.getAppAttemptCredentials()
-        .getSecretKey(RMStateStore.AM_CLIENT_TOKEN_MASTER_KEY_NAME));
+    assertArrayEquals(
+        clientTokenKey2.getEncoded(),
+        attemptState.getAppAttemptTokens()
+            .getSecretKey(RMStateStore.AM_CLIENT_TOKEN_MASTER_KEY_NAME));
 
     //******* update application/attempt state *******//
-    ApplicationState appState2 =
-        new ApplicationState(appState.submitTime, appState.startTime,
-          appState.context, appState.user, RMAppState.FINISHED,
-          "appDiagnostics", 1234);
+    ApplicationStateData appState2 =
+        ApplicationStateData.newInstance(appState.getSubmitTime(),
+            appState.getStartTime(), appState.getUser(),
+            appState.getApplicationSubmissionContext(), RMAppState.FINISHED,
+            "appDiagnostics", 1234);
     appState2.attempts.putAll(appState.attempts);
     store.updateApplicationState(appState2);
 
-    ApplicationAttemptState oldAttemptState = attemptState;
-    ApplicationAttemptState newAttemptState =
-        new ApplicationAttemptState(oldAttemptState.getAttemptId(),
-          oldAttemptState.getMasterContainer(),
-          oldAttemptState.getAppAttemptCredentials(),
-          oldAttemptState.getStartTime(), RMAppAttemptState.FINISHED,
-          "myTrackingUrl", "attemptDiagnostics",
-          FinalApplicationStatus.SUCCEEDED, 100,
-          oldAttemptState.getFinishTime(), 0, 0);
+    ApplicationAttemptStateData oldAttemptState = attemptState;
+    ApplicationAttemptStateData newAttemptState =
+        ApplicationAttemptStateData.newInstance(
+            oldAttemptState.getAttemptId(),
+            oldAttemptState.getMasterContainer(),
+            oldAttemptState.getAppAttemptTokens(),
+            oldAttemptState.getStartTime(), RMAppAttemptState.FINISHED,
+            "myTrackingUrl", "attemptDiagnostics",
+            FinalApplicationStatus.SUCCEEDED, 100,
+            oldAttemptState.getFinishTime(), 0, 0);
     store.updateApplicationAttemptState(newAttemptState);
 
     // test updating the state of an app/attempt whose initial state was not
@@ -329,22 +334,22 @@ public class RMStateStoreTestBase extends ClientBaseWithFixes{
     ApplicationSubmissionContext dummyContext =
         new ApplicationSubmissionContextPBImpl();
     dummyContext.setApplicationId(dummyAppId);
-    ApplicationState dummyApp =
-        new ApplicationState(appState.submitTime, appState.startTime,
-          dummyContext, appState.user, RMAppState.FINISHED, "appDiagnostics",
-          1234);
+    ApplicationStateData dummyApp =
+        ApplicationStateData.newInstance(appState.getSubmitTime(),
+            appState.getStartTime(), appState.getUser(), dummyContext,
+            RMAppState.FINISHED, "appDiagnostics", 1234);
     store.updateApplicationState(dummyApp);
 
     ApplicationAttemptId dummyAttemptId =
         ApplicationAttemptId.newInstance(dummyAppId, 6);
-    ApplicationAttemptState dummyAttempt =
-        new ApplicationAttemptState(dummyAttemptId,
-          oldAttemptState.getMasterContainer(),
-          oldAttemptState.getAppAttemptCredentials(),
-          oldAttemptState.getStartTime(), RMAppAttemptState.FINISHED,
-          "myTrackingUrl", "attemptDiagnostics",
-          FinalApplicationStatus.SUCCEEDED, 111,
-          oldAttemptState.getFinishTime(), 0, 0);
+    ApplicationAttemptStateData dummyAttempt =
+        ApplicationAttemptStateData.newInstance(dummyAttemptId,
+            oldAttemptState.getMasterContainer(),
+            oldAttemptState.getAppAttemptTokens(),
+            oldAttemptState.getStartTime(), RMAppAttemptState.FINISHED,
+            "myTrackingUrl", "attemptDiagnostics",
+            FinalApplicationStatus.SUCCEEDED, 111,
+            oldAttemptState.getFinishTime(), 0, 0);
     store.updateApplicationAttemptState(dummyAttempt);
 
     // let things settle down
@@ -355,11 +360,13 @@ public class RMStateStoreTestBase extends ClientBaseWithFixes{
     store = stateStoreHelper.getRMStateStore();
     store.setRMDispatcher(dispatcher);
     RMState newRMState = store.loadState();
-    Map<ApplicationId, ApplicationState> newRMAppState =
+    Map<ApplicationId, ApplicationStateData> newRMAppState =
         newRMState.getApplicationState();
-    assertNotNull(newRMAppState.get(dummyApp.getAppId()));
-    ApplicationState updatedAppState = newRMAppState.get(appId1);
-    assertEquals(appState.getAppId(),updatedAppState.getAppId());
+    assertNotNull(newRMAppState.get(
+        dummyApp.getApplicationSubmissionContext().getApplicationId()));
+    ApplicationStateData updatedAppState = newRMAppState.get(appId1);
+    assertEquals(appState.getApplicationSubmissionContext().getApplicationId(),
+        updatedAppState.getApplicationSubmissionContext().getApplicationId());
     assertEquals(appState.getSubmitTime(), updatedAppState.getSubmitTime());
     assertEquals(appState.getStartTime(), updatedAppState.getStartTime());
     assertEquals(appState.getUser(), updatedAppState.getUser());
@@ -369,16 +376,17 @@ public class RMStateStoreTestBase extends ClientBaseWithFixes{
     assertEquals(1234, updatedAppState.getFinishTime());
 
     // check updated attempt state
-    assertNotNull(newRMAppState.get(dummyApp.getAppId()).getAttempt(
-      dummyAttemptId));
-    ApplicationAttemptState updatedAttemptState =
+    assertNotNull(newRMAppState.get(dummyApp.getApplicationSubmissionContext
+        ().getApplicationId()).getAttempt(dummyAttemptId));
+    ApplicationAttemptStateData updatedAttemptState =
         updatedAppState.getAttempt(newAttemptState.getAttemptId());
     assertEquals(oldAttemptState.getAttemptId(),
       updatedAttemptState.getAttemptId());
     assertEquals(containerId2, updatedAttemptState.getMasterContainer().getId());
-    assertArrayEquals(clientTokenKey2.getEncoded(),
-      updatedAttemptState.getAppAttemptCredentials().getSecretKey(
-        RMStateStore.AM_CLIENT_TOKEN_MASTER_KEY_NAME));
+    assertArrayEquals(
+        clientTokenKey2.getEncoded(),
+        attemptState.getAppAttemptTokens()
+            .getSecretKey(RMStateStore.AM_CLIENT_TOKEN_MASTER_KEY_NAME));
     // new attempt state fields
     assertEquals(RMAppAttemptState.FINISHED, updatedAttemptState.getState());
     assertEquals("myTrackingUrl", updatedAttemptState.getFinalTrackingUrl());

http://git-wip-us.apache.org/repos/asf/hadoop/blob/5805a81e/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/TestRMAppTransitions.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/TestRMAppTransitions.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/TestRMAppTransitions.java
index 0a2f0d4..72f1dff 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/TestRMAppTransitions.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/TestRMAppTransitions.java
@@ -18,6 +18,7 @@
 
 package org.apache.hadoop.yarn.server.resourcemanager.rmapp;
 
+import org.apache.hadoop.yarn.server.resourcemanager.recovery.records.ApplicationStateData;
 import static org.mockito.Matchers.any;
 import static org.mockito.Matchers.anyLong;
 import static org.mockito.Mockito.doReturn;
@@ -62,7 +63,6 @@ import org.apache.hadoop.yarn.server.resourcemanager.RMServerUtils;
 import org.apache.hadoop.yarn.server.resourcemanager.ahs.RMApplicationHistoryWriter;
 import org.apache.hadoop.yarn.server.resourcemanager.metrics.SystemMetricsPublisher;
 import org.apache.hadoop.yarn.server.resourcemanager.recovery.RMStateStore;
-import org.apache.hadoop.yarn.server.resourcemanager.recovery.RMStateStore.ApplicationState;
 import org.apache.hadoop.yarn.server.resourcemanager.recovery.RMStateStore.RMState;
 import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.AMLivelinessMonitor;
 import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttempt;
@@ -326,11 +326,13 @@ public class TestRMAppTransitions {
   }
 
   private void assertAppFinalStateSaved(RMApp application){
-    verify(store, times(1)).updateApplicationState(any(ApplicationState.class));
+    verify(store, times(1)).updateApplicationState(
+        any(ApplicationStateData.class));
   }
 
   private void assertAppFinalStateNotSaved(RMApp application){
-    verify(store, times(0)).updateApplicationState(any(ApplicationState.class));
+    verify(store, times(0)).updateApplicationState(
+        any(ApplicationStateData.class));
   }
 
   private void assertKilled(RMApp application) {
@@ -395,11 +397,13 @@ public class TestRMAppTransitions {
     RMApp application = createNewTestApp(submissionContext);
     // NEW => SUBMITTED event RMAppEventType.RECOVER
     RMState state = new RMState();
-    ApplicationState appState = new ApplicationState(123, 123, null, "user");
+    ApplicationStateData appState =
+        ApplicationStateData.newInstance(123, 123, null, "user");
     state.getApplicationState().put(application.getApplicationId(), appState);
     RMAppEvent event =
         new RMAppRecoverEvent(application.getApplicationId(), state);
 
+
     application.handle(event);
     assertStartTimeSet(application);
     assertAppState(RMAppState.SUBMITTED, application);
@@ -946,22 +950,25 @@ public class TestRMAppTransitions {
   @Test(timeout = 30000)
   public void testAppsRecoveringStates() throws Exception {
     RMState state = new RMState();
-    Map<ApplicationId, ApplicationState> applicationState =
+    Map<ApplicationId, ApplicationStateData> applicationState =
         state.getApplicationState();
     createRMStateForApplications(applicationState, RMAppState.FINISHED);
     createRMStateForApplications(applicationState, RMAppState.KILLED);
     createRMStateForApplications(applicationState, RMAppState.FAILED);
-    for (ApplicationState appState : applicationState.values()) {
+    for (ApplicationStateData appState : applicationState.values()) {
       testRecoverApplication(appState, state);
     }
   }
   
-  public void testRecoverApplication(ApplicationState appState, RMState rmState)
+  public void testRecoverApplication(ApplicationStateData appState,
+      RMState rmState)
       throws Exception {
     ApplicationSubmissionContext submissionContext =
         appState.getApplicationSubmissionContext();
     RMAppImpl application =
-        new RMAppImpl(appState.getAppId(), rmContext, conf,
+        new RMAppImpl(
+            appState.getApplicationSubmissionContext().getApplicationId(),
+            rmContext, conf,
             submissionContext.getApplicationName(), null,
             submissionContext.getQueue(), submissionContext, null, null,
             appState.getSubmitTime(), submissionContext.getApplicationType(),
@@ -986,12 +993,12 @@ public class TestRMAppTransitions {
   }
   
   public void createRMStateForApplications(
-      Map<ApplicationId, ApplicationState> applicationState,
+      Map<ApplicationId, ApplicationStateData> applicationState,
       RMAppState rmAppState) {
     RMApp app = createNewTestApp(null);
-    ApplicationState appState =
-        new ApplicationState(app.getSubmitTime(), app.getStartTime(),
-            app.getApplicationSubmissionContext(), app.getUser(), rmAppState,
+    ApplicationStateData appState =
+        ApplicationStateData.newInstance(app.getSubmitTime(), app.getStartTime(),
+            app.getUser(), app.getApplicationSubmissionContext(), rmAppState,
             null, app.getFinishTime());
     applicationState.put(app.getApplicationId(), appState);
   }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/5805a81e/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 2b5c2b8..fc653dc 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
@@ -81,7 +81,7 @@ import org.apache.hadoop.yarn.server.resourcemanager.amlauncher.AMLauncherEventT
 import org.apache.hadoop.yarn.server.resourcemanager.amlauncher.ApplicationMasterLauncher;
 import org.apache.hadoop.yarn.server.resourcemanager.metrics.SystemMetricsPublisher;
 import org.apache.hadoop.yarn.server.resourcemanager.recovery.RMStateStore;
-import org.apache.hadoop.yarn.server.resourcemanager.recovery.RMStateStore.ApplicationAttemptState;
+import org.apache.hadoop.yarn.server.resourcemanager.recovery.records.ApplicationAttemptStateData;
 import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp;
 import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppEvent;
 import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppEventType;
@@ -1520,7 +1520,7 @@ public class TestRMAppAttemptTransitions {
 
   private void verifyAttemptFinalStateSaved() {
     verify(store, times(1)).updateApplicationAttemptState(
-      any(ApplicationAttemptState.class));
+      any(ApplicationAttemptStateData.class));
   }
 
   private void verifyAMHostAndPortInvalidated() {


Mime
View raw message