ZKFailoverController { public int run(final String[] args) throws Exception { if (!localTarget.isAutoFailoverEnabled()) { LOG.error("Automatic failover is not enabled for " + localTarget + "." + " Please ensure that automatic failover is enabled in the " + "configuration before running the ZK failover controller."); return ERR_CODE_AUTO_FAILOVER_NOT_ENABLED; } loginAsFCUser(); try { return SecurityUtil.doAsLoginUserOrFatal(new PrivilegedAction<Integer>() { @Override public Integer run() { try { return doRun(args); } catch (Exception t) { throw new RuntimeException(t); } finally { if (elector != null) { elector.terminateConnection(); } } } }); } catch (RuntimeException rte) { throw (Exception)rte.getCause(); } } 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 testFormatOneClusterLeavesOtherClustersAlone() throws Exception { DummyHAService svc = cluster.getService(1); DummyZKFC zkfcInOtherCluster = new DummyZKFC(conf, cluster.getService(1)) { @Override protected String getScopeInsideParentNode() { return "other-scope"; } }; assertEquals(ZKFailoverController.ERR_CODE_NO_PARENT_ZNODE, runFC(svc)); assertEquals(0, runFC(svc, "-formatZK")); assertEquals(ZKFailoverController.ERR_CODE_NO_PARENT_ZNODE, zkfcInOtherCluster.run(new String[]{})); assertEquals(0, zkfcInOtherCluster.run(new String[]{"-formatZK"})); assertEquals(ZKFailoverController.ERR_CODE_FORMAT_DENIED, runFC(svc, "-formatZK", "-nonInteractive")); }