Search in sources :

Example 1 with StoreFencedException

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

the class TestRMHA method testTransitionedToStandbyShouldNotHang.

@Test
public void testTransitionedToStandbyShouldNotHang() throws Exception {
    configuration.setBoolean(YarnConfiguration.AUTO_FAILOVER_ENABLED, false);
    Configuration conf = new YarnConfiguration(configuration);
    MemoryRMStateStore memStore = new MemoryRMStateStore() {

        @Override
        public void updateApplicationState(ApplicationStateData appState) {
            notifyStoreOperationFailed(new StoreFencedException());
        }
    };
    memStore.init(conf);
    rm = new MockRM(conf, memStore) {

        @Override
        void stopActiveServices() {
            try {
                Thread.sleep(10000);
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
            super.stopActiveServices();
        }
    };
    rm.init(conf);
    final StateChangeRequestInfo requestInfo = new StateChangeRequestInfo(HAServiceProtocol.RequestSource.REQUEST_BY_USER);
    assertEquals(STATE_ERR, HAServiceState.INITIALIZING, rm.adminService.getServiceStatus().getState());
    assertFalse("RM is ready to become active before being started", rm.adminService.getServiceStatus().isReadyToBecomeActive());
    checkMonitorHealth();
    rm.start();
    checkMonitorHealth();
    checkStandbyRMFunctionality();
    // 2. Transition to Active.
    rm.adminService.transitionToActive(requestInfo);
    // 3. Try Transition to standby
    Thread t = new Thread(new Runnable() {

        @Override
        public void run() {
            try {
                rm.transitionToStandby(true);
            } catch (IOException e) {
                e.printStackTrace();
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    });
    t.start();
    rm.getRMContext().getStateStore().updateApplicationState(null);
    // wait for thread to finish
    t.join();
    rm.adminService.transitionToStandby(requestInfo);
    checkStandbyRMFunctionality();
    rm.stop();
}
Also used : YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) Configuration(org.apache.hadoop.conf.Configuration) ApplicationStateData(org.apache.hadoop.yarn.server.resourcemanager.recovery.records.ApplicationStateData) IOException(java.io.IOException) StoreFencedException(org.apache.hadoop.yarn.server.resourcemanager.recovery.StoreFencedException) ServiceFailedException(org.apache.hadoop.ha.ServiceFailedException) HealthCheckFailedException(org.apache.hadoop.ha.HealthCheckFailedException) IOException(java.io.IOException) YarnRuntimeException(org.apache.hadoop.yarn.exceptions.YarnRuntimeException) JSONException(org.codehaus.jettison.json.JSONException) AccessControlException(org.apache.hadoop.security.AccessControlException) StoreFencedException(org.apache.hadoop.yarn.server.resourcemanager.recovery.StoreFencedException) MemoryRMStateStore(org.apache.hadoop.yarn.server.resourcemanager.recovery.MemoryRMStateStore) YarnRuntimeException(org.apache.hadoop.yarn.exceptions.YarnRuntimeException) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) StateChangeRequestInfo(org.apache.hadoop.ha.HAServiceProtocol.StateChangeRequestInfo) Test(org.junit.Test)

Aggregations

IOException (java.io.IOException)1 Configuration (org.apache.hadoop.conf.Configuration)1 StateChangeRequestInfo (org.apache.hadoop.ha.HAServiceProtocol.StateChangeRequestInfo)1 HealthCheckFailedException (org.apache.hadoop.ha.HealthCheckFailedException)1 ServiceFailedException (org.apache.hadoop.ha.ServiceFailedException)1 AccessControlException (org.apache.hadoop.security.AccessControlException)1 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)1 YarnRuntimeException (org.apache.hadoop.yarn.exceptions.YarnRuntimeException)1 MemoryRMStateStore (org.apache.hadoop.yarn.server.resourcemanager.recovery.MemoryRMStateStore)1 StoreFencedException (org.apache.hadoop.yarn.server.resourcemanager.recovery.StoreFencedException)1 ApplicationStateData (org.apache.hadoop.yarn.server.resourcemanager.recovery.records.ApplicationStateData)1 JSONException (org.codehaus.jettison.json.JSONException)1 Test (org.junit.Test)1