本文整理了Java中org.apache.hadoop.hbase.zookeeper.ZKWatcher.close()
方法的一些代码示例,展示了ZKWatcher.close()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZKWatcher.close()
方法的具体详情如下:
包路径:org.apache.hadoop.hbase.zookeeper.ZKWatcher
类名称:ZKWatcher
方法名:close
[英]Close the connection to ZooKeeper.
[中]关闭与ZooKeeper的连接。
代码示例来源:origin: apache/hbase
protected synchronized void disconnect() {
if (zkw != null) {
zkw.close();
}
}
代码示例来源:origin: apache/hbase
/**
* Stop this tracker and the passed zookeeper
*/
public void stop() {
if (this.stopped) return;
this.stopped = true;
this.watcher.close();
}
}
代码示例来源:origin: apache/hbase
@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();
}
}
代码示例来源:origin: apache/hbase
public void stop() {
if (!this.stopped) {
this.stopped = true;
LOG.debug("Stopping HFileArchiveManager...");
this.zooKeeper.close();
}
}
代码示例来源:origin: apache/hbase
@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();
}
}
代码示例来源:origin: apache/hbase
@Override
public void stop(String why) {
this.zkw.close();
}
代码示例来源:origin: apache/hbase
@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);
}
}
代码示例来源:origin: apache/hbase
LOG.error("Problem setting up task", e);
} finally {
if (zkw != null) zkw.close();
代码示例来源:origin: apache/hbase
/**
* 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();
}
}
代码示例来源:origin: apache/hbase
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();
}
}
代码示例来源:origin: apache/hbase
@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();
}
代码示例来源:origin: apache/hbase
@Override
public void stop(String why) {
stopped = true;
abdicate();
Threads.sleep(100);
watcher.close();
}
代码示例来源:origin: apache/hbase
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();
}
}
}
代码示例来源:origin: apache/hbase
/**
* 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));
}
代码示例来源:origin: apache/hbase
/**
* 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;
}
}
代码示例来源:origin: apache/hbase
/**
* 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;
}
}
代码示例来源:origin: apache/hbase
/**
* 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();
}
}
代码示例来源:origin: apache/hbase
server.startsWith(hostName.toLowerCase(Locale.ROOT)+","));
zkw.close();
} finally {
TEST_UTIL.shutdownMiniCluster();
代码示例来源:origin: apache/hbase
@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();
}
代码示例来源:origin: apache/hbase
admin.createTable(htd, SPLIT_KEYS);
TEST_UTIL.waitUntilNoRegionsInTransition(60000);
m.getZooKeeper().close();
MockLoadBalancer.retainAssignCalled = false;
final int expectedNumOfListeners = countPermanentListeners(zkw);
内容来源于网络,如有侵权,请联系作者删除!