protected synchronized void disconnect() { if (zkw != null) { zkw.close(); } }
/** * Stop this tracker and the passed zookeeper */ public void stop() { if (this.stopped) return; this.stopped = true; this.watcher.close(); } }
@Override public void stop(String why) { if (this.stopped) return; this.stopped = true; if (this.zkw != null) { LOG.info("Stopping " + this.zkw); this.zkw.close(); } }
public void stop() { if (!this.stopped) { this.stopped = true; LOG.debug("Stopping HFileArchiveManager..."); this.zooKeeper.close(); } }
@Override public void stop(String why) { if (this.stopped) { return; } this.stopped = true; if (this.zkw != null) { LOG.info("Stopping " + this.zkw); this.zkw.close(); } }
@Override public void stop(String why) { this.zkw.close(); }
@Override public void close() throws IOException { try { cleanupHbckZnode(); unlockHbck(); } catch (Exception io) { LOG.warn(io.toString(), io); } finally { if (zkw != null) { zkw.close(); zkw = null; } IOUtils.closeQuietly(admin); IOUtils.closeQuietly(meta); IOUtils.closeQuietly(connection); } }
LOG.error("Problem setting up task", e); } finally { if (zkw != null) zkw.close();
/** * Get the authentication token of the user for the cluster specified in the configuration * @return null if the user does not have the token, otherwise the auth token for the cluster. */ private static Token<AuthenticationTokenIdentifier> getAuthToken(Configuration conf, User user) throws IOException, InterruptedException { ZKWatcher zkw = new ZKWatcher(conf, "TokenUtil-getAuthToken", null); try { String clusterId = ZKClusterId.readClusterIdZNode(zkw); if (clusterId == null) { throw new IOException("Failed to get cluster ID"); } return new AuthenticationTokenSelector().selectToken(new Text(clusterId), user.getTokens()); } catch (KeeperException e) { throw new IOException(e); } finally { zkw.close(); } }
private static void resetAcls(final Configuration conf, boolean eraseAcls) throws Exception { ZKWatcher zkw = new ZKWatcher(conf, "ZKAclReset", null); try { LOG.info((eraseAcls ? "Erase" : "Set") + " HBase ACLs for " + zkw.getQuorum() + " " + zkw.getZNodePaths().baseZNode); resetAcls(zkw, zkw.getZNodePaths().baseZNode, eraseAcls); } finally { zkw.close(); } }
@After public void after() { try { // Clean out meta location or later tests will be confused... they presume // start fresh in zk. MetaTableLocator.deleteMetaLocation(this.watcher); } catch (KeeperException e) { LOG.warn("Unable to delete hbase:meta location", e); } this.watcher.close(); }
@Override public void stop(String why) { stopped = true; abdicate(); Threads.sleep(100); watcher.close(); }
private static Pair<ReplicationPeerConfig, Configuration> getPeerQuorumConfig( final Configuration conf, String peerId) throws IOException { ZKWatcher localZKW = null; try { localZKW = new ZKWatcher(conf, "VerifyReplication", new Abortable() { @Override public void abort(String why, Throwable e) { } @Override public boolean isAborted() { return false; } }); ReplicationPeerStorage storage = ReplicationStorageFactory.getReplicationPeerStorage(localZKW, conf); ReplicationPeerConfig peerConfig = storage.getPeerConfig(peerId); return Pair.newPair(peerConfig, ReplicationUtils.getPeerClusterConfiguration(peerConfig, conf)); } catch (ReplicationException e) { throw new IOException("An error occurred while trying to connect to the remote peer cluster", e); } finally { if (localZKW != null) { localZKW.close(); } } }
/** * Closes the current ZKW (if not null) and creates a new one * @throws IOException If anything goes wrong connecting */ synchronized void reloadZkWatcher() throws IOException { if (zkw != null) zkw.close(); zkw = new ZKWatcher(ctx.getConfiguration(), "connection to cluster: " + ctx.getPeerId(), this); getZkw().registerListener(new PeerRegionServerListener(this)); }
/** * Abruptly Shutdown HBase mini cluster. Does not shutdown zk or dfs if running. * @throws java.io.IOException throws in case command is unsuccessful */ public void killMiniHBaseCluster() throws IOException { cleanup(); if (this.hbaseCluster != null) { getMiniHBaseCluster().killAll(); this.hbaseCluster = null; } if (zooKeeperWatcher != null) { zooKeeperWatcher.close(); zooKeeperWatcher = null; } }
/** * Shutdown HBase mini cluster.Does not shutdown zk or dfs if running. * @throws java.io.IOException in case command is unsuccessful */ public void shutdownMiniHBaseCluster() throws IOException { cleanup(); if (this.hbaseCluster != null) { this.hbaseCluster.shutdown(); // Wait till hbase is down before going on to shutdown zk. this.hbaseCluster.waitUntilShutDown(); this.hbaseCluster = null; } if (zooKeeperWatcher != null) { zooKeeperWatcher.close(); zooKeeperWatcher = null; } }
/** * When zk is working both files should be returned * @throws Exception from ZK watcher */ @Test(timeout=10000) public void testZooKeeperNormal() throws Exception { Configuration conf = TEST_UTIL.getConfiguration(); ReplicationLogCleaner cleaner = new ReplicationLogCleaner(); List<FileStatus> dummyFiles = Lists.newArrayList( new FileStatus(100, false, 3, 100, System.currentTimeMillis(), new Path("log1")), new FileStatus(100, false, 3, 100, System.currentTimeMillis(), new Path("log2")) ); ZKWatcher zkw = new ZKWatcher(conf, "testZooKeeperAbort-normal", null); try { cleaner.setConf(conf, zkw); cleaner.preClean(); Iterable<FileStatus> filesToDelete = cleaner.getDeletableFiles(dummyFiles); Iterator<FileStatus> iter = filesToDelete.iterator(); assertTrue(iter.hasNext()); assertEquals(new Path("log1"), iter.next().getPath()); assertTrue(iter.hasNext()); assertEquals(new Path("log2"), iter.next().getPath()); assertFalse(iter.hasNext()); } finally { zkw.close(); } }
server.startsWith(hostName.toLowerCase(Locale.ROOT)+",")); zkw.close(); } finally { TEST_UTIL.shutdownMiniCluster();
@After public void tearDown() throws KeeperException, ZooKeeperConnectionException, IOException { // Make sure zk is clean before we run the next test. ZKWatcher zkw = new ZKWatcher(TESTUTIL.getConfiguration(), "@Before", new Abortable() { @Override public void abort(String why, Throwable e) { throw new RuntimeException(why, e); } @Override public boolean isAborted() { return false; } }); ZKUtil.deleteNodeRecursively(zkw, zkw.getZNodePaths().baseZNode); zkw.close(); }
admin.createTable(htd, SPLIT_KEYS); TEST_UTIL.waitUntilNoRegionsInTransition(60000); m.getZooKeeper().close(); MockLoadBalancer.retainAssignCalled = false; final int expectedNumOfListeners = countPermanentListeners(zkw);