gpt4 book ai didi

com.twitter.finagle.common.zookeeper.ZooKeeperClient.close()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-13 11:06:42 25 4
gpt4 key购买 nike

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

ZooKeeperClient.close介绍

[英]Closes the current connection if any expiring the current ZooKeeper session. Any subsequent calls to this method will no-op until the next successful #get.
[中]如果当前ZooKeeper会话过期,则关闭当前连接。在下一次成功#get之前,对该方法的任何后续调用都不会执行。

代码示例

代码示例来源:origin: com.twitter/finagle-serversets

/**
 * Checks to see if the client might reasonably re-try an operation given the exception thrown
 * while attempting it.  If the ZooKeeper session should be expired to enable the re-try to
 * succeed this method will expire it as a side-effect.
 *
 * @param e the exception to test
 * @return true if a retry can be attempted
 */
public boolean shouldRetry(KeeperException e) {
 if (e instanceof SessionExpiredException) {
  close();
 }
 return ZooKeeperUtils.isRetryable(e);
}

代码示例来源:origin: com.twitter/finagle-serversets_2.11

@Override public void process(WatchedEvent event) {
  switch (event.getType()) {
   // Guard the None type since this watch may be used as the default watch on calls by
   // the client outside our control.
   case None:
    switch (event.getState()) {
     case Expired:
      LOG.info("Zookeeper session expired. Event: " + event);
      close();
      break;
     case SyncConnected:
      connected.countDown();
      break;
     default:
      break; // nop
    }
    break;
   default:
    break; // nop
  }
  eventQueue.offer(event);
 }
};

代码示例来源:origin: com.twitter/finagle-serversets_2.11

/**
 * Checks to see if the client might reasonably re-try an operation given the exception thrown
 * while attempting it.  If the ZooKeeper session should be expired to enable the re-try to
 * succeed this method will expire it as a side-effect.
 *
 * @param e the exception to test
 * @return true if a retry can be attempted
 */
public boolean shouldRetry(KeeperException e) {
 if (e instanceof SessionExpiredException) {
  close();
 }
 return ZooKeeperUtils.isRetryable(e);
}

代码示例来源:origin: com.twitter/finagle-serversets

@Override public void process(WatchedEvent event) {
  switch (event.getType()) {
   // Guard the None type since this watch may be used as the default watch on calls by
   // the client outside our control.
   case None:
    switch (event.getState()) {
     case Expired:
      LOG.info("Zookeeper session expired. Event: " + event);
      close();
      break;
     case SyncConnected:
      connected.countDown();
      break;
     default:
      break; // nop
    }
    break;
   default:
    break; // nop
  }
  eventQueue.offer(event);
 }
};

代码示例来源:origin: com.twitter/finagle-serversets_2.11

close();
 throw new TimeoutException("Timed out waiting for a ZK connection after "
               + connectionTimeout);
} catch (InterruptedException ex) {
 LOG.info("Interrupted while waiting to connect to zooKeeper");
 close();
 throw ex;

代码示例来源:origin: com.twitter/finagle-serversets

close();
 throw new TimeoutException("Timed out waiting for a ZK connection after "
               + connectionTimeout);
} catch (InterruptedException ex) {
 LOG.info("Interrupted while waiting to connect to zooKeeper");
 close();
 throw ex;

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com