ZKFailoverController { void gracefulFailoverToYou() throws ServiceFailedException, IOException { try { UserGroupInformation.getLoginUser().doAs(new PrivilegedExceptionAction<Void>() { @Override public Void run() throws Exception { doGracefulFailover(); return null; } }); } catch (InterruptedException e) { throw new IOException(e); } } protected  ZKFailoverController(Configuration conf, HAServiceTarget localTarget); HAServiceTarget getLocalTarget(); int run(final String[] args); static final String ZK_QUORUM_KEY; static final String ZK_ACL_KEY; static final String ZK_AUTH_KEY; }
@Test public void testOneOfEverything() throws Exception { cluster.start(); LOG.info("====== Failing over by session expiration"); cluster.expireAndVerifyFailover(0, 1); cluster.expireAndVerifyFailover(1, 0); LOG.info("====== Restarting server"); stopServer(); waitForServerDown(hostPort, CONNECTION_TIMEOUT); startServer(); waitForServerUp(hostPort, CONNECTION_TIMEOUT); cluster.setHealthy(0, false); cluster.waitForHAState(0, HAServiceState.INITIALIZING); cluster.waitForHAState(1, HAServiceState.ACTIVE); cluster.setHealthy(1, true); cluster.setHealthy(0, false); cluster.waitForHAState(1, HAServiceState.ACTIVE); cluster.waitForHAState(0, HAServiceState.INITIALIZING); cluster.setHealthy(0, true); cluster.waitForHealthState(0, State.SERVICE_HEALTHY); cluster.getZkfc(1).gracefulFailoverToYou(); cluster.getZkfc(0).gracefulFailoverToYou(); }
@Test(timeout=30000) public void testOneOfEverything() throws Exception { try { cluster.start(); LOG.info("====== Failing over by session expiration"); cluster.expireAndVerifyFailover(0, 1); cluster.expireAndVerifyFailover(1, 0); LOG.info("====== Restarting server"); stopServer(); waitForServerDown(hostPort, CONNECTION_TIMEOUT); startServer(); waitForServerUp(hostPort, CONNECTION_TIMEOUT); cluster.setHealthy(0, false); cluster.waitForHAState(0, HAServiceState.INITIALIZING); cluster.waitForHAState(1, HAServiceState.ACTIVE); cluster.setHealthy(1, true); cluster.setHealthy(0, false); cluster.waitForHAState(1, HAServiceState.ACTIVE); cluster.waitForHAState(0, HAServiceState.INITIALIZING); cluster.setHealthy(0, true); cluster.waitForHealthState(0, State.SERVICE_HEALTHY); cluster.getZkfc(1).gracefulFailoverToYou(); cluster.getZkfc(0).gracefulFailoverToYou(); } finally { cluster.stop(); } }