private ZkTestSystem() { LOG.info("~~~~~~~~~~~~~~~ starting zk system ~~~~~~~~~~~~~~~"); try { _zkServer = new TestingServer(PORT); _zkClient = ZkTestSystem.createZkClient(_zkServer.getConnectString()); } catch (Exception e) { throw new RuntimeException(e); } LOG.info("~~~~~~~~~~~~~~~ zk system started ~~~~~~~~~~~~~~~"); }
public static ZkTestSystem getInstance() { if (_instance == null) { _instance = new ZkTestSystem(); _instance.cleanupZk(); Runtime.getRuntime() .addShutdownHook( new Thread() { @Override public void run() { LOG.info("shutting zk down"); try { getInstance().getZkClient().close(); getInstance().getZkServer().close(); } catch (IOException e) { throw new RuntimeException(e); } } }); } return _instance; }