gpt4 book ai didi

com.github.ltsopensource.zookeeper.ZookeeperTransporter类的使用及代码示例

转载 作者:知者 更新时间:2024-03-13 12:33:02 26 4
gpt4 key购买 nike

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

ZookeeperTransporter介绍

暂无

代码示例

代码示例来源:origin: ltsopensource/light-task-scheduler

public ZookeeperRegistry(final AppContext appContext) {
  super(appContext);
  this.clusterName = appContext.getConfig().getClusterName();
  this.cachedChildrenNodeMap = new ConcurrentHashMap<String, List<String>>();
  ZookeeperTransporter zookeeperTransporter = ServiceLoader.load(ZookeeperTransporter.class, appContext.getConfig());
  this.zkClient = zookeeperTransporter.connect(appContext.getConfig());
  this.zkListeners = new ConcurrentHashMap<Node, ConcurrentMap<NotifyListener, ChildListener>>();
  // 默认是连成功的(用zkclient时候,第一次不会有state changed事件暴露给用户,
  // 他居然在new ZkClient的时候就直接连接了,给个提供listener的构造函数或者把启动改为start方法都ok呀,蛋疼)
  appContext.getRegistryStatMonitor().setAvailable(true);
  zkClient.addStateListener(new StateListener() {
    @Override
    public void stateChanged(int state) {
      if (state == DISCONNECTED) {
        appContext.getRegistryStatMonitor().setAvailable(false);
      } else if (state == CONNECTED) {
        appContext.getRegistryStatMonitor().setAvailable(true);
      } else if (state == RECONNECTED) {
        try {
          appContext.getRegistryStatMonitor().setAvailable(true);
          recover();
        } catch (Exception e) {
          LOGGER.error(e.getMessage(), e);
        }
      }
    }
  });
}

代码示例来源:origin: ltsopensource/light-task-scheduler

public ZookeeperRegistry(final AppContext appContext) {
  super(appContext);
  this.clusterName = appContext.getConfig().getClusterName();
  this.cachedChildrenNodeMap = new ConcurrentHashMap<String, List<String>>();
  ZookeeperTransporter zookeeperTransporter = ServiceLoader.load(ZookeeperTransporter.class, appContext.getConfig());
  this.zkClient = zookeeperTransporter.connect(appContext.getConfig());
  this.zkListeners = new ConcurrentHashMap<Node, ConcurrentMap<NotifyListener, ChildListener>>();
  // 默认是连成功的(用zkclient时候,第一次不会有state changed事件暴露给用户,
  // 他居然在new ZkClient的时候就直接连接了,给个提供listener的构造函数或者把启动改为start方法都ok呀,蛋疼)
  appContext.getRegistryStatMonitor().setAvailable(true);
  zkClient.addStateListener(new StateListener() {
    @Override
    public void stateChanged(int state) {
      if (state == DISCONNECTED) {
        appContext.getRegistryStatMonitor().setAvailable(false);
      } else if (state == CONNECTED) {
        appContext.getRegistryStatMonitor().setAvailable(true);
      } else if (state == RECONNECTED) {
        try {
          appContext.getRegistryStatMonitor().setAvailable(true);
          recover();
        } catch (Exception e) {
          LOGGER.error(e.getMessage(), e);
        }
      }
    }
  });
}

代码示例来源:origin: com.github.ltsopensource/lts-core

public ZookeeperRegistry(final AppContext appContext) {
  super(appContext);
  this.clusterName = appContext.getConfig().getClusterName();
  this.cachedChildrenNodeMap = new ConcurrentHashMap<String, List<String>>();
  ZookeeperTransporter zookeeperTransporter = ServiceLoader.load(ZookeeperTransporter.class, appContext.getConfig());
  this.zkClient = zookeeperTransporter.connect(appContext.getConfig());
  this.zkListeners = new ConcurrentHashMap<Node, ConcurrentMap<NotifyListener, ChildListener>>();
  // 默认是连成功的(用zkclient时候,第一次不会有state changed事件暴露给用户,
  // 他居然在new ZkClient的时候就直接连接了,给个提供listener的构造函数或者把启动改为start方法都ok呀,蛋疼)
  appContext.getRegistryStatMonitor().setAvailable(true);
  zkClient.addStateListener(new StateListener() {
    @Override
    public void stateChanged(int state) {
      if (state == DISCONNECTED) {
        appContext.getRegistryStatMonitor().setAvailable(false);
      } else if (state == CONNECTED) {
        appContext.getRegistryStatMonitor().setAvailable(true);
      } else if (state == RECONNECTED) {
        try {
          appContext.getRegistryStatMonitor().setAvailable(true);
          recover();
        } catch (Exception e) {
          LOGGER.error(e.getMessage(), e);
        }
      }
    }
  });
}

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