|
@@ -34,6 +34,7 @@ import org.apache.commons.logging.LogFactory;
|
|
|
import org.apache.hadoop.conf.Configuration;
|
|
|
import org.apache.hadoop.ha.ClientBaseWithFixes;
|
|
|
import org.apache.hadoop.ha.HAServiceProtocol;
|
|
|
+import org.apache.hadoop.ha.HAServiceProtocol.HAServiceState;
|
|
|
import org.apache.hadoop.service.Service.STATE;
|
|
|
import org.apache.hadoop.yarn.api.records.ApplicationId;
|
|
|
import org.apache.hadoop.yarn.client.api.YarnClient;
|
|
@@ -42,6 +43,9 @@ import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
|
|
import org.apache.hadoop.yarn.exceptions.YarnException;
|
|
|
import org.apache.hadoop.yarn.server.MiniYARNCluster;
|
|
|
import org.apache.hadoop.yarn.server.resourcemanager.AdminService;
|
|
|
+import org.apache.hadoop.yarn.server.resourcemanager.RMFatalEvent;
|
|
|
+import org.apache.hadoop.yarn.server.resourcemanager.RMFatalEventType;
|
|
|
+import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager;
|
|
|
import org.apache.hadoop.yarn.server.webproxy.WebAppProxyServer;
|
|
|
import org.junit.After;
|
|
|
import org.junit.Assert;
|
|
@@ -169,6 +173,7 @@ public class TestRMFailover extends ClientBaseWithFixes {
|
|
|
verifyConnections();
|
|
|
}
|
|
|
|
|
|
+ @SuppressWarnings("unchecked")
|
|
|
@Test
|
|
|
public void testAutomaticFailover()
|
|
|
throws YarnException, InterruptedException, IOException {
|
|
@@ -186,6 +191,25 @@ public class TestRMFailover extends ClientBaseWithFixes {
|
|
|
|
|
|
failover();
|
|
|
verifyConnections();
|
|
|
+
|
|
|
+ // Make the current Active handle an RMFatalEvent,
|
|
|
+ // so it transitions to standby.
|
|
|
+ ResourceManager rm = cluster.getResourceManager(
|
|
|
+ cluster.getActiveRMIndex());
|
|
|
+ RMFatalEvent event =
|
|
|
+ new RMFatalEvent(RMFatalEventType.STATE_STORE_FENCED,
|
|
|
+ "Fake RMFatalEvent");
|
|
|
+ rm.getRMContext().getDispatcher().getEventHandler().handle(event);
|
|
|
+ int maxWaitingAttempts = 2000;
|
|
|
+ while (maxWaitingAttempts-- > 0 ) {
|
|
|
+ if (rm.getRMContext().getHAServiceState() == HAServiceState.STANDBY) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ Thread.sleep(1);
|
|
|
+ }
|
|
|
+ Assert.assertFalse("RM didn't transition to Standby ",
|
|
|
+ maxWaitingAttempts == 0);
|
|
|
+ verifyConnections();
|
|
|
}
|
|
|
|
|
|
@Test
|