Java Code Examples for org.apache.hadoop.yarn.server.resourcemanager.ResourceManager#handleTransitionToStandBy()
The following examples show how to use
org.apache.hadoop.yarn.server.resourcemanager.ResourceManager#handleTransitionToStandBy() .
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: hadoop File: TestRMFailover.java License: Apache License 2.0 | 5 votes |
@Test public void testAutomaticFailover() throws YarnException, InterruptedException, IOException { conf.set(YarnConfiguration.RM_CLUSTER_ID, "yarn-test-cluster"); conf.set(YarnConfiguration.RM_ZK_ADDRESS, hostPort); conf.setInt(YarnConfiguration.RM_ZK_TIMEOUT_MS, 2000); cluster.init(conf); cluster.start(); assertFalse("RM never turned active", -1 == cluster.getActiveRMIndex()); verifyConnections(); failover(); verifyConnections(); failover(); verifyConnections(); // Make the current Active handle an RMFatalEvent, // so it transitions to standby. ResourceManager rm = cluster.getResourceManager( cluster.getActiveRMIndex()); rm.handleTransitionToStandBy(); 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(); }
Example 2
Source Project: big-c File: TestRMFailover.java License: Apache License 2.0 | 5 votes |
@Test public void testAutomaticFailover() throws YarnException, InterruptedException, IOException { conf.set(YarnConfiguration.RM_CLUSTER_ID, "yarn-test-cluster"); conf.set(YarnConfiguration.RM_ZK_ADDRESS, hostPort); conf.setInt(YarnConfiguration.RM_ZK_TIMEOUT_MS, 2000); cluster.init(conf); cluster.start(); assertFalse("RM never turned active", -1 == cluster.getActiveRMIndex()); verifyConnections(); failover(); verifyConnections(); failover(); verifyConnections(); // Make the current Active handle an RMFatalEvent, // so it transitions to standby. ResourceManager rm = cluster.getResourceManager( cluster.getActiveRMIndex()); rm.handleTransitionToStandBy(); 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(); }