|
@@ -109,6 +109,7 @@ import org.apache.hadoop.yarn.server.resourcemanager.scheduler.YarnScheduler;
|
|
|
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler;
|
|
|
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerApp;
|
|
|
import org.apache.hadoop.yarn.server.security.ApplicationACLsManager;
|
|
|
+import org.apache.hadoop.yarn.server.timelineservice.collector.TimelineCollectorContext;
|
|
|
import org.apache.hadoop.yarn.server.utils.BuilderUtils;
|
|
|
import org.apache.hadoop.yarn.util.ConverterUtils;
|
|
|
import org.apache.log4j.Level;
|
|
@@ -1125,6 +1126,68 @@ public class TestRMRestart extends ParameterizedSchedulerTestBase {
|
|
|
Assert.assertNull(rmAppState.get(app2.getApplicationId()).getState());
|
|
|
}
|
|
|
|
|
|
+ @Test (timeout = 60000)
|
|
|
+ public void testRMRestartTimelineCollectorContext() throws Exception {
|
|
|
+ conf.setBoolean(YarnConfiguration.TIMELINE_SERVICE_ENABLED, true);
|
|
|
+ conf.setFloat(YarnConfiguration.TIMELINE_SERVICE_VERSION, 2.0f);
|
|
|
+ MemoryRMStateStore memStore = new MemoryRMStateStore();
|
|
|
+ memStore.init(conf);
|
|
|
+ RMState rmState = memStore.getState();
|
|
|
+ Map<ApplicationId, ApplicationStateData> rmAppState =
|
|
|
+ rmState.getApplicationState();
|
|
|
+ MockRM rm1 = null;
|
|
|
+ MockRM rm2 = null;
|
|
|
+ try {
|
|
|
+ rm1 = createMockRM(conf, memStore);
|
|
|
+ rm1.start();
|
|
|
+ MockNM nm1 =
|
|
|
+ new MockNM("127.0.0.1:1234", 15120, rm1.getResourceTrackerService());
|
|
|
+ nm1.registerNode();
|
|
|
+
|
|
|
+ // submit an app.
|
|
|
+ RMApp app = rm1.submitApp(200, "name", "user",
|
|
|
+ new HashMap<ApplicationAccessType, String>(), false, "default", -1,
|
|
|
+ null);
|
|
|
+ // Check if app info has been saved.
|
|
|
+ ApplicationStateData appState = rmAppState.get(app.getApplicationId());
|
|
|
+ Assert.assertNotNull(appState);
|
|
|
+ Assert.assertEquals(0, appState.getAttemptCount());
|
|
|
+ Assert.assertEquals(appState.getApplicationSubmissionContext()
|
|
|
+ .getApplicationId(), app.getApplicationSubmissionContext()
|
|
|
+ .getApplicationId());
|
|
|
+
|
|
|
+ // Allocate the AM
|
|
|
+ nm1.nodeHeartbeat(true);
|
|
|
+ RMAppAttempt attempt = app.getCurrentAppAttempt();
|
|
|
+ ApplicationAttemptId attemptId1 = attempt.getAppAttemptId();
|
|
|
+ rm1.waitForState(attemptId1, RMAppAttemptState.ALLOCATED);
|
|
|
+
|
|
|
+ ApplicationId appId = app.getApplicationId();
|
|
|
+ TimelineCollectorContext contextBeforeRestart =
|
|
|
+ rm1.getRMContext().getRMTimelineCollectorManager().get(appId).
|
|
|
+ getTimelineEntityContext();
|
|
|
+
|
|
|
+ // Restart RM.
|
|
|
+ rm2 = createMockRM(conf, memStore);
|
|
|
+ rm2.start();
|
|
|
+ Assert.assertEquals(1, rm2.getRMContext().getRMApps().size());
|
|
|
+ rm2.waitForState(app.getApplicationId(), RMAppState.ACCEPTED);
|
|
|
+ TimelineCollectorContext contextAfterRestart =
|
|
|
+ rm2.getRMContext().getRMTimelineCollectorManager().get(appId).
|
|
|
+ getTimelineEntityContext();
|
|
|
+ Assert.assertEquals("Collector contexts for an app should be same " +
|
|
|
+ "across restarts", contextBeforeRestart, contextAfterRestart);
|
|
|
+ } finally {
|
|
|
+ conf.setBoolean(YarnConfiguration.TIMELINE_SERVICE_ENABLED, false);
|
|
|
+ if (rm1 != null) {
|
|
|
+ rm1.close();
|
|
|
+ }
|
|
|
+ if (rm2 != null) {
|
|
|
+ rm2.close();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Test (timeout = 60000)
|
|
|
public void testDelegationTokenRestoredInDelegationTokenRenewer()
|
|
|
throws Exception {
|