@Override public boolean exec() throws CliException { try { zk.close(); } catch (Exception ex) { throw new CliWrapperException(ex); } return false; }
public void restartClient(int clientIndex, Watcher watcher) throws IOException, InterruptedException { if (zk[clientIndex] != null) { zk[clientIndex].close(); } zk[clientIndex] = new ZooKeeper("127.0.0.1:" + clientPorts[clientIndex], ClientBase.CONNECTION_TIMEOUT, watcher); }
private void utestPrep(int port) throws IOException, InterruptedException, KeeperException { ZooKeeper zk = new ZooKeeper("127.0.0.1:" + port, CONNECTION_TIMEOUT, this); for (int i = 0; i < 10000; i++) { zk.create("/" + i, null, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT); } zk.close(); }
private void utestChildren(int port) throws IOException, InterruptedException, KeeperException { ZooKeeper zk = new ZooKeeper("127.0.0.1:" + port, CONNECTION_TIMEOUT, this); for (int i = 0; i < 10000; i++) { zk.getChildren("/" + i, true); } zk.close(); }
@Override public void tearDown() throws Exception { super.tearDown(); zk.close(); }
@Override public void tearDown() throws Exception { super.tearDown(); zk.close(); }
public static void closeAllHandles(ZooKeeper[] zkArr, ZooKeeperAdmin[] zkAdminArr) throws InterruptedException { if (zkArr != null) { for (ZooKeeper zk : zkArr) if (zk != null) zk.close(); } if (zkAdminArr != null) { for (ZooKeeperAdmin zkAdmin : zkAdminArr) if (zkAdmin != null) zkAdmin.close(); } }
@Override public void tearDown() throws Exception { super.tearDown(); zk.close(); }
@Override public void tearDown() throws Exception { super.tearDown(); zk.close(); }
@Override public void tearDown() throws Exception { super.tearDown(); zk.close(); }
@Override public void tearDown() throws Exception { if (zk != null) { zk.close(); } super.tearDown(); }
protected void connectToZK(String newHost) throws InterruptedException, IOException { if (zk != null && zk.getState().isAlive()) { zk.close(); } host = newHost; boolean readOnly = cl.getOption("readonly") != null; if (cl.getOption("secure") != null) { System.setProperty(ZKClientConfig.SECURE_CLIENT, "true"); System.out.println("Secure connection is enabled"); } zk = new ZooKeeperAdmin(host, Integer.parseInt(cl.getOption("timeout")), new MyWatcher(), readOnly); }
@Test public void testAuth() throws Exception { ZooKeeper zk = createClient(); try { zk.create("/path1", null, Ids.CREATOR_ALL_ACL, CreateMode.PERSISTENT); Thread.sleep(1000); } finally { zk.close(); } }
@After @Override public void tearDown() throws Exception { zk.close(); super.tearDown(); LOG.info("Test clients shutting down"); }
@After public void tearDown() throws Exception { LOG.info("tearDown starting"); for (int i = 0; i < zkClients.length; i++) { zkClients[i].close(); } qu.shutdownAll(); }
private void verifySessionTimeOut(int sessionTimeout, int expectedSessionTimeout, String HOSTPORT) throws IOException, KeeperException, InterruptedException { clientConnected = new CountDownLatch(1); ZooKeeper zk = new ZooKeeper(HOSTPORT, sessionTimeout, this); Assert.assertTrue("Failed to establish zkclient connection!", clientConnected.await(sessionTimeout, TimeUnit.MILLISECONDS)); Assert.assertEquals("Not able to configure the sessionTimeout values", expectedSessionTimeout, zk.getSessionTimeout()); zk.close(); }
private void verifyQuorumConfig(int sid, List<String> joiningServers, List<String> leavingServers) throws Exception { ZooKeeper zk = ClientBase.createZKClient("127.0.0.1:" + clientPorts.get(sid)); ReconfigTest.testNormalOperation(zk, zk); ReconfigTest.testServerHasConfig(zk, joiningServers, leavingServers); zk.close(); }
@Test public void testWatcherAutoResetWithGlobal() throws Exception { ZooKeeper zk = null; MyWatcher watcher = new MyWatcher(); zk = createClient(watcher, hostPort, TIMEOUT); testWatcherAutoReset(zk, watcher, watcher); zk.close(); }