org.I0Itec.zkclient.ZkClient.subscribeDataChanges()方法的使用及代码示例

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

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

ZkClient.subscribeDataChanges介绍

暂无

代码示例

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

protected void addTargetDataListener(String path, IZkDataListener listener) {
  zkClient.subscribeDataChanges(path, listener);
}

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

protected void addTargetDataListener(String path, IZkDataListener listener) {
  zkClient.subscribeDataChanges(path, listener);
}

代码示例来源:origin: networknt/light-4j

@Override
public void subscribeDataChanges(String path, IZkDataListener listener) {
  zkClient.subscribeDataChanges(path, listener);
}

代码示例来源:origin: weibocom/motan

zkClient.subscribeDataChanges(commandPath, zkDataListener);
  LoggerUtil.info(String.format("[ZookeeperRegistry] subscribe command: path=%s, info=%s", commandPath, url.toFullStr()));
} catch (Throwable e) {

代码示例来源:origin: apache/incubator-pinot

public DynamicBrokerSelector(String zkServers) {
 ZkClient zkClient = new ZkClient(zkServers);
 zkClient.setZkSerializer(new BytesPushThroughSerializer());
 zkClient.waitUntilConnected(60, TimeUnit.SECONDS);
 zkClient.subscribeDataChanges(ExternalViewReader.BROKER_EXTERNAL_VIEW_PATH, this);
 evReader = new ExternalViewReader(zkClient);
 refresh();
}

代码示例来源:origin: Dromara/soul

private void subscribeAppAuthDataChanges(final String realPath) {
  zkClient.subscribeDataChanges(realPath, new IZkDataListener() {
    @Override
    public void handleDataChange(final String dataPath, final Object data) {
      Optional.ofNullable(data)
          .ifPresent(o -> AUTH_MAP.put(((AppAuthZkDTO) o).getAppKey(), (AppAuthZkDTO) o));
    }
    @Override
    public void handleDataDeleted(final String dataPath) {
      final String key = dataPath.substring(ZkPathConstants.APP_AUTH_PARENT.length() + 1);
      AUTH_MAP.remove(key);
    }
  });
}

代码示例来源:origin: Dromara/soul

private void subscribeSelectorDataChanges(final String path) {
  zkClient.subscribeDataChanges(path, new IZkDataListener() {
    @Override
    public void handleDataChange(final String dataPath, final Object data) {

代码示例来源:origin: Dromara/soul

private void subscribeRuleDataChanges(final String path) {
  zkClient.subscribeDataChanges(path, new IZkDataListener() {
    @Override
    public void handleDataChange(final String dataPath, final Object data) {

代码示例来源:origin: Dromara/soul

private void loadWatcherPlugin() {
  Arrays.stream(PluginEnum.values()).forEach(pluginEnum -> {
    String pluginPath = ZkPathConstants.buildPluginPath(pluginEnum.getName());
    if (!zkClient.exists(pluginPath)) {
      zkClient.createPersistent(pluginPath, true);
    }
    PluginZkDTO data = zkClient.readData(pluginPath);
    Optional.ofNullable(data).ifPresent(d -> PLUGIN_MAP.put(pluginEnum.getName(), data));
    zkClient.subscribeDataChanges(pluginPath, new IZkDataListener() {
      @Override
      public void handleDataChange(final String dataPath, final Object data) {
        Optional.ofNullable(data)
            .ifPresent(o -> {
              PluginZkDTO dto = (PluginZkDTO) o;
              PLUGIN_MAP.put(dto.getName(), dto);
            });
      }
      @Override
      public void handleDataDeleted(final String dataPath) {
        PLUGIN_MAP.remove(pluginEnum.getName());
      }
    });
  });
}

代码示例来源:origin: com.101tec/zkclient

public void start() {
  _zkClient.subscribeDataChanges(_fileName, this);
  readData();
  LOG.debug("Started ContentWatcher");
}

代码示例来源:origin: apache/samza

public void subscribeDataChanges(String path, IZkDataListener dataListener) {
 zkClient.subscribeDataChanges(path, dataListener);
 metrics.subscriptions.inc();
}

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

public void start() {
  _zkClient.subscribeDataChanges(_fileName, this);
  readData();
  LOG.debug("Started ContentWatcher");
}

代码示例来源:origin: apache/samza

/**
 * subscribe for changes of JobModel version
 * @param dataListener describe this
 */
public void subscribeToJobModelVersionChange(GenerationAwareZkDataListener dataListener) {
 LOG.info(" subscribing for jm version change at:" + keyBuilder.getJobModelVersionPath());
 zkClient.subscribeDataChanges(keyBuilder.getJobModelVersionPath(), dataListener);
 metrics.subscriptions.inc();
}

代码示例来源:origin: strimzi/strimzi-kafka-operator

@Override
public Zk watchData(String path, Handler<AsyncResult<byte[]>> watcher) {
  workerPool().executeBlocking(
    future -> {
      try {
        IZkDataListener listener = new DataWatchAdapter(watcher);
        dataWatches.put(path, listener);
        zookeeper.subscribeDataChanges(path, listener);
        future.complete();
      } catch (Throwable t) {
        future.fail(t);
      }
    },
    log("watchData"));
  return this;
}

代码示例来源:origin: org.apache.samza/samza-core_2.12

/**
 * subscribe for changes of JobModel version
 * @param dataListener describe this
 */
public void subscribeToJobModelVersionChange(GenerationAwareZkDataListener dataListener) {
 LOG.info(" subscribing for jm version change at:" + keyBuilder.getJobModelVersionPath());
 zkClient.subscribeDataChanges(keyBuilder.getJobModelVersionPath(), dataListener);
 metrics.subscriptions.inc();
}

代码示例来源:origin: org.apache.samza/samza-core_2.11

/**
 * subscribe for changes of JobModel version
 * @param dataListener describe this
 */
public void subscribeToJobModelVersionChange(GenerationAwareZkDataListener dataListener) {
 LOG.info(" subscribing for jm version change at:" + keyBuilder.getJobModelVersionPath());
 zkClient.subscribeDataChanges(keyBuilder.getJobModelVersionPath(), dataListener);
 metrics.subscriptions.inc();
}

代码示例来源:origin: javachen/learning-hadoop

public void subscribe(String key, ConfigChangeListener listener) {
  String path = ZkUtils.getZkPath(this.rootNode, key);
  if (!this.zkClient.exists(path)) {
    throw new RuntimeException(
        "配置("
            + path
            + ")不存在, 必须先定义配置才能监听配置的变化, 请检查配置的key是否正确, 如果确认配置key正确, 那么需要保证先使用配置发布命令发布配置! ");
  }
  this.zkClient.subscribeDataChanges(path, new DataListenerAdapter(
      listener));
}

代码示例来源:origin: org.apache.samza/samza-core_2.10

/**
 * subscribe for changes of JobModel version
 * @param dataListener describe this
 */
public void subscribeToJobModelVersionChange(GenerationAwareZkDataListener dataListener) {
 LOG.info(" subscribing for jm version change at:" + keyBuilder.getJobModelVersionPath());
 zkClient.subscribeDataChanges(keyBuilder.getJobModelVersionPath(), dataListener);
 metrics.subscriptions.inc();
}

代码示例来源:origin: org.apache.samza/samza-core

/**
 * subscribe for changes of JobModel version
 * @param dataListener describe this
 */
public void subscribeToJobModelVersionChange(GenerationAwareZkDataListener dataListener) {
 LOG.info(" subscribing for jm version change at:" + keyBuilder.getJobModelVersionPath());
 zkClient.subscribeDataChanges(keyBuilder.getJobModelVersionPath(), dataListener);
 metrics.subscriptions.inc();
}

代码示例来源:origin: youtongluan/sumk

public static NamePairs readAndListen(String zkUrl, String path, IZkDataListener listener) {
    ZkClient client = ZkClientHolder.getZkClient(zkUrl);
    if (!client.exists(path)) {
      return null;
    }
    String data = ZkClientHolder.data2String(client.readData(path));
    if (listener != null) {
      client.subscribeDataChanges(path, listener);
    }
    return new NamePairs(data);
  }
}

相关文章