com.github.zkclient.ZkClient.close()方法的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(3.9k)|赞(0)|评价(0)|浏览(205)

本文整理了Java中com.github.zkclient.ZkClient.close()方法的一些代码示例,展示了ZkClient.close()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZkClient.close()方法的具体详情如下:
包路径:com.github.zkclient.ZkClient
类名称:ZkClient
方法名:close

ZkClient.close介绍

暂无

代码示例

代码示例来源:origin: adyliu/jafka

  1. public void close() {
  2. this.zkClient.close();
  3. }

代码示例来源:origin: adyliu/jafka

  1. /**
  2. *
  3. */
  4. public void close() {
  5. if (zkClient != null) {
  6. logger.info("closing zookeeper client...");
  7. zkClient.close();
  8. }
  9. }

代码示例来源:origin: adyliu/jafka

  1. public void close() throws IOException {
  2. synchronized (lock) {
  3. if (zkClient == null) {
  4. logger.warn("cannot shutdown already shutdown topic event watcher.");
  5. return;
  6. }
  7. stopWatchingTopicEvents();
  8. zkClient.close();
  9. zkClient = null;
  10. }
  11. }

代码示例来源:origin: adyliu/jafka

  1. static void tryCleanupZookeeper(String zkConnect, String groupId) {
  2. try {
  3. String dir = "/consumers/" + groupId;
  4. ZkClient zk = new ZkClient(zkConnect, 30 * 1000, 30 * 1000);
  5. zk.deleteRecursive(dir);
  6. zk.close();
  7. } catch (ZkInterruptedException e) {
  8. e.printStackTrace();
  9. }
  10. }
  11. }

代码示例来源:origin: adyliu/jafka

  1. public void close() throws IOException {
  2. if (isShuttingDown.compareAndSet(false, true)) {
  3. logger.info("ZkConsumerConnector shutting down");
  4. try {
  5. scheduler.shutdown();
  6. if (fetcher != null) {
  7. fetcher.stopConnectionsToAllBrokers();
  8. }
  9. sendShutdownToAllQueues();
  10. if (config.isAutoCommit()) {
  11. commitOffsets();
  12. }
  13. //waiting rebalance listener to closed and then shutdown the zkclient
  14. for (ZKRebalancerListener<?> listener : this.rebalancerListeners) {
  15. Closer.closeQuietly(listener);
  16. }
  17. if (this.zkClient != null) {
  18. this.zkClient.close();
  19. zkClient = null;
  20. }
  21. } catch (Exception e) {
  22. logger.error("error during consumer connector shutdown", e);
  23. }
  24. logger.info("ZkConsumerConnector shut down completed");
  25. }
  26. }

代码示例来源:origin: adyliu/zkclient

  1. _zkClient.close();
  2. } catch (ZkException e) {
  3. LOG.warn("Error on closing zkclient: " + e.getClass().getName());

代码示例来源:origin: com.github.adyliu/zkclient

  1. _zkClient.close();
  2. } catch (ZkException e) {
  3. LOG.warn("Error on closing zkclient: " + e.getClass().getName());

代码示例来源:origin: com.github.adyliu/zkclient

  1. public synchronized void connect(final long maxMsToWaitUntilConnected, Watcher watcher) {
  2. if (_eventThread != null) {
  3. return;
  4. }
  5. boolean started = false;
  6. try {
  7. getEventLock().lockInterruptibly();
  8. setShutdownTrigger(false);
  9. _eventThread = new ZkEventThread(_connection.getServers());
  10. _eventThread.start();
  11. _connection.connect(watcher);
  12. LOG.debug("Awaiting connection to Zookeeper server: " + maxMsToWaitUntilConnected);
  13. if (!waitUntilConnected(maxMsToWaitUntilConnected, TimeUnit.MILLISECONDS)) {
  14. throw new ZkTimeoutException(String.format(
  15. "Unable to connect to zookeeper server[%s] within timeout %dms", _connection.getServers(), maxMsToWaitUntilConnected));
  16. }
  17. started = true;
  18. } catch (InterruptedException e) {
  19. States state = _connection.getZookeeperState();
  20. throw new IllegalStateException("Not connected with zookeeper server yet. Current state is " + state);
  21. } finally {
  22. getEventLock().unlock();
  23. // we should close the zookeeper instance, otherwise it would keep
  24. // on trying to connect
  25. if (!started) {
  26. close();
  27. }
  28. }
  29. }

代码示例来源:origin: adyliu/zkclient

  1. public synchronized void connect(final long maxMsToWaitUntilConnected, Watcher watcher) {
  2. if (_eventThread != null) {
  3. return;
  4. }
  5. boolean started = false;
  6. try {
  7. getEventLock().lockInterruptibly();
  8. setShutdownTrigger(false);
  9. _eventThread = new ZkEventThread(_connection.getServers());
  10. _eventThread.start();
  11. _connection.connect(watcher);
  12. LOG.debug("Awaiting connection to Zookeeper server: " + maxMsToWaitUntilConnected);
  13. if (!waitUntilConnected(maxMsToWaitUntilConnected, TimeUnit.MILLISECONDS)) {
  14. throw new ZkTimeoutException(String.format(
  15. "Unable to connect to zookeeper server[%s] within timeout %dms", _connection.getServers(), maxMsToWaitUntilConnected));
  16. }
  17. started = true;
  18. } catch (InterruptedException e) {
  19. States state = _connection.getZookeeperState();
  20. throw new IllegalStateException("Not connected with zookeeper server yet. Current state is " + state);
  21. } finally {
  22. getEventLock().unlock();
  23. // we should close the zookeeper instance, otherwise it would keep
  24. // on trying to connect
  25. if (!started) {
  26. close();
  27. }
  28. }
  29. }

相关文章