Search in sources :

Example 1 with TestDispatcher

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

the class TestZKRMStateStoreZKClientConnections method testZKClientRetry.

@Test(timeout = 20000)
public void testZKClientRetry() throws Exception {
    TestZKClient zkClientTester = new TestZKClient();
    final String path = "/test";
    YarnConfiguration conf = new YarnConfiguration();
    conf.setInt(YarnConfiguration.RM_ZK_TIMEOUT_MS, ZK_TIMEOUT_MS);
    conf.setLong(YarnConfiguration.RM_ZK_RETRY_INTERVAL_MS, 100);
    final ZKRMStateStore store = (ZKRMStateStore) zkClientTester.getRMStateStore(conf);
    TestDispatcher dispatcher = new TestDispatcher();
    store.setRMDispatcher(dispatcher);
    final AtomicBoolean assertionFailedInThread = new AtomicBoolean(false);
    testingServer.stop();
    Thread clientThread = new Thread() {

        @Override
        public void run() {
            try {
                store.getData(path);
            } catch (Exception e) {
                e.printStackTrace();
                assertionFailedInThread.set(true);
            }
        }
    };
    Thread.sleep(2000);
    testingServer.start();
    clientThread.join();
    Assert.assertFalse(assertionFailedInThread.get());
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) TestDispatcher(org.apache.hadoop.yarn.server.resourcemanager.recovery.RMStateStoreTestBase.TestDispatcher) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) Test(org.junit.Test)

Aggregations

NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)1 TestDispatcher (org.apache.hadoop.yarn.server.resourcemanager.recovery.RMStateStoreTestBase.TestDispatcher)1 Test (org.junit.Test)1