|
@@ -22,8 +22,10 @@ import org.apache.commons.logging.LogFactory;
|
|
import org.apache.hadoop.conf.Configuration;
|
|
import org.apache.hadoop.conf.Configuration;
|
|
import org.apache.hadoop.ha.ClientBaseWithFixes;
|
|
import org.apache.hadoop.ha.ClientBaseWithFixes;
|
|
import org.apache.hadoop.ha.ServiceFailedException;
|
|
import org.apache.hadoop.ha.ServiceFailedException;
|
|
|
|
+import org.apache.hadoop.service.ServiceStateException;
|
|
import org.apache.hadoop.test.GenericTestUtils;
|
|
import org.apache.hadoop.test.GenericTestUtils;
|
|
import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
|
import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
|
|
|
+import org.junit.Assert;
|
|
import org.junit.Before;
|
|
import org.junit.Before;
|
|
import org.junit.Test;
|
|
import org.junit.Test;
|
|
|
|
|
|
@@ -304,6 +306,26 @@ public class TestRMEmbeddedElector extends ClientBaseWithFixes {
|
|
verify(as, times(1)).transitionToStandby(any());
|
|
verify(as, times(1)).transitionToStandby(any());
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Test that active elector service triggers a fatal RM Event when connection
|
|
|
|
+ * to ZK fails. YARN-8409
|
|
|
|
+ */
|
|
|
|
+ @Test
|
|
|
|
+ public void testFailureToConnectToZookeeper() throws Exception {
|
|
|
|
+ stopServer();
|
|
|
|
+ Configuration myConf = new Configuration(conf);
|
|
|
|
+ ResourceManager rm = new MockRM(conf);
|
|
|
|
+
|
|
|
|
+ ActiveStandbyElectorBasedElectorService ees =
|
|
|
|
+ new ActiveStandbyElectorBasedElectorService(rm);
|
|
|
|
+ try {
|
|
|
|
+ ees.init(myConf);
|
|
|
|
+ Assert.fail("expect failure to connect to Zookeeper");
|
|
|
|
+ } catch (ServiceStateException sse) {
|
|
|
|
+ Assert.assertTrue(sse.getMessage().contains("ConnectionLoss"));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
private class MockRMWithElector extends MockRM {
|
|
private class MockRMWithElector extends MockRM {
|
|
private long delayMs = 0;
|
|
private long delayMs = 0;
|
|
|
|
|