gpt4 book ai didi

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

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

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

ZooKeeperClient.registerExpirationHandler介绍

[英]Clients that need to re-establish state after session expiration can register an onExpired command to execute.
[中]需要在会话过期后重新建立状态的客户端可以注册一个onExpired命令来执行。

代码示例

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

synchronized void setMembers(Iterable<String> members) {
  if (stopped) {
   LOG.info("Suppressing membership update, no longer watching " + this);
   return;
  }
  if (this.members == null) {
   // Reset our watch on the group if session expires - only needs to be registered once.
   zkClient.registerExpirationHandler(new Runnable() {
    @Override public void run() {
     tryWatchGroup();
    }
   });
  }
  Set<String> membership = new HashSet<>();
  members.iterator().forEachRemaining(membership::add);
  if (!membership.equals(this.members)) {
   groupChangeListener.onGroupChange(members);
   this.members = Collections.unmodifiableSet(membership);
  }
 }
}

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

synchronized void setMembers(Iterable<String> members) {
  if (stopped) {
   LOG.info("Suppressing membership update, no longer watching " + this);
   return;
  }
  if (this.members == null) {
   // Reset our watch on the group if session expires - only needs to be registered once.
   zkClient.registerExpirationHandler(new Runnable() {
    @Override public void run() {
     tryWatchGroup();
    }
   });
  }
  Set<String> membership = new HashSet<>();
  members.iterator().forEachRemaining(membership::add);
  if (!membership.equals(this.members)) {
   groupChangeListener.onGroupChange(members);
   this.members = Collections.unmodifiableSet(membership);
  }
 }
}

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

zkClient.registerExpirationHandler(new Runnable() {
 @Override public void run() {
  tryJoin();

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

zkClient.registerExpirationHandler(new Runnable() {
 @Override public void run() {
  tryJoin();

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

public Runnable watch() throws WatchException, InterruptedException {
 Watcher onExpirationWatcher = zkClient.registerExpirationHandler(new Runnable() {
  @Override public void run() {
   // Servers may have changed Status while we were disconnected from ZooKeeper, check and
   // re-register our node watches.
   rebuildServerSet();
  }
 });
 try {
  return group.watch(new GroupChangeListener() {
   @Override public void onGroupChange(Iterable<String> memberIds) {
    notifyGroupChange(memberIds);
   }
  });
 } catch (WatchException e) {
  zkClient.unregister(onExpirationWatcher);
  throw e;
 } catch (InterruptedException e) {
  zkClient.unregister(onExpirationWatcher);
  throw e;
 }
}

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

public Runnable watch() throws WatchException, InterruptedException {
 Watcher onExpirationWatcher = zkClient.registerExpirationHandler(new Runnable() {
  @Override public void run() {
   // Servers may have changed Status while we were disconnected from ZooKeeper, check and
   // re-register our node watches.
   rebuildServerSet();
  }
 });
 try {
  return group.watch(new GroupChangeListener() {
   @Override public void onGroupChange(Iterable<String> memberIds) {
    notifyGroupChange(memberIds);
   }
  });
 } catch (WatchException e) {
  zkClient.unregister(onExpirationWatcher);
  throw e;
 } catch (InterruptedException e) {
  zkClient.unregister(onExpirationWatcher);
  throw e;
 }
}

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