Search in sources :

Example 1 with RMStateStoreRMDTEvent

use of org.apache.hadoop.yarn.server.resourcemanager.recovery.RMStateStoreRMDTEvent in project hadoop by apache.

the class TestRMRestart method testRMStateStoreDispatcherDrainedOnRMStop.

@Test(timeout = 60000)
public void testRMStateStoreDispatcherDrainedOnRMStop() throws Exception {
    MemoryRMStateStore memStore = new MemoryRMStateStore() {

        volatile boolean wait = true;

        @Override
        public void serviceStop() throws Exception {
            // Unblock app saving request.
            wait = false;
            super.serviceStop();
        }

        @Override
        protected void handleStoreEvent(RMStateStoreEvent event) {
            // Skip if synchronous updation of DTToken
            if (!(event instanceof RMStateStoreAMRMTokenEvent) && !(event instanceof RMStateStoreRMDTEvent) && !(event instanceof RMStateStoreRMDTMasterKeyEvent)) {
                while (wait) ;
            }
            super.handleStoreEvent(event);
        }
    };
    memStore.init(conf);
    // start RM
    final MockRM rm1 = createMockRM(conf, memStore);
    rm1.disableDrainEventsImplicitly();
    rm1.start();
    // create apps.
    final ArrayList<RMApp> appList = new ArrayList<RMApp>();
    final int NUM_APPS = 5;
    for (int i = 0; i < NUM_APPS; i++) {
        RMApp app = rm1.submitApp(200, "name", "user", new HashMap<ApplicationAccessType, String>(), false, "default", -1, null, "MAPREDUCE", false);
        appList.add(app);
        rm1.waitForState(app.getApplicationId(), RMAppState.NEW_SAVING);
    }
    // all apps's saving request are now enqueued to RMStateStore's dispatcher
    // queue, and will be processed once rm.stop() is called.
    // Nothing exist in state store before stop is called.
    Map<ApplicationId, ApplicationStateData> rmAppState = memStore.getState().getApplicationState();
    Assert.assertTrue(rmAppState.size() == 0);
    // stop rm
    rm1.stop();
    // request on dispatcher.
    for (RMApp app : appList) {
        ApplicationStateData appState = rmAppState.get(app.getApplicationId());
        Assert.assertNotNull(appState);
        Assert.assertEquals(0, appState.getAttemptCount());
        Assert.assertEquals(appState.getApplicationSubmissionContext().getApplicationId(), app.getApplicationSubmissionContext().getApplicationId());
    }
    Assert.assertTrue(rmAppState.size() == NUM_APPS);
}
Also used : RMStateStoreAMRMTokenEvent(org.apache.hadoop.yarn.server.resourcemanager.recovery.RMStateStoreAMRMTokenEvent) RMStateStoreRMDTMasterKeyEvent(org.apache.hadoop.yarn.server.resourcemanager.recovery.RMStateStoreRMDTMasterKeyEvent) RMApp(org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp) ArrayList(java.util.ArrayList) ApplicationStateData(org.apache.hadoop.yarn.server.resourcemanager.recovery.records.ApplicationStateData) RMStateStoreEvent(org.apache.hadoop.yarn.server.resourcemanager.recovery.RMStateStoreEvent) MemoryRMStateStore(org.apache.hadoop.yarn.server.resourcemanager.recovery.MemoryRMStateStore) ApplicationAccessType(org.apache.hadoop.yarn.api.records.ApplicationAccessType) RMStateStoreRMDTEvent(org.apache.hadoop.yarn.server.resourcemanager.recovery.RMStateStoreRMDTEvent) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)1 ApplicationAccessType (org.apache.hadoop.yarn.api.records.ApplicationAccessType)1 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)1 MemoryRMStateStore (org.apache.hadoop.yarn.server.resourcemanager.recovery.MemoryRMStateStore)1 RMStateStoreAMRMTokenEvent (org.apache.hadoop.yarn.server.resourcemanager.recovery.RMStateStoreAMRMTokenEvent)1 RMStateStoreEvent (org.apache.hadoop.yarn.server.resourcemanager.recovery.RMStateStoreEvent)1 RMStateStoreRMDTEvent (org.apache.hadoop.yarn.server.resourcemanager.recovery.RMStateStoreRMDTEvent)1 RMStateStoreRMDTMasterKeyEvent (org.apache.hadoop.yarn.server.resourcemanager.recovery.RMStateStoreRMDTMasterKeyEvent)1 ApplicationStateData (org.apache.hadoop.yarn.server.resourcemanager.recovery.records.ApplicationStateData)1 RMApp (org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp)1 Test (org.junit.Test)1