gpt4 book ai didi

com.alibaba.otter.canal.common.zookeeper.ZkClientx.subscribeDataChanges()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-15 07:49:31 27 4
gpt4 key购买 nike

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

ZkClientx.subscribeDataChanges介绍

暂无

代码示例

代码示例来源:origin: alibaba/canal

public void start() {
  super.start();
  String path = ZookeeperPathUtils.getDestinationClientRunning(this.destination, clientData.getClientId());
  zkClient.subscribeDataChanges(path, dataListener);
  initRunning();
}

代码示例来源:origin: alibaba/canal

public synchronized void start() {
  super.start();
  try {
    processStart();
    if (zkClient != null) {
      // 如果需要尽可能释放instance资源,不需要监听running节点,不然即使stop了这台机器,另一台机器立马会start
      String path = ZookeeperPathUtils.getDestinationServerRunning(destination);
      zkClient.subscribeDataChanges(path, dataListener);
      initRunning();
    } else {
      processActiveEnter();// 没有zk,直接启动
    }
  } catch (Exception e) {
    logger.error("start failed", e);
    // 没有正常启动,重置一下状态,避免干扰下一次start
    stop();
  }
}

代码示例来源:origin: alibaba/canal

public ClusterNodeAccessStrategy(String destination, ZkClientx zkClient){
  this.destination = destination;
  this.zkClient = zkClient;
  childListener = new IZkChildListener() {
    public void handleChildChange(String parentPath, List<String> currentChilds) throws Exception {
      initClusters(currentChilds);
    }
  };
  dataListener = new IZkDataListener() {
    public void handleDataDeleted(String dataPath) throws Exception {
      runningAddress = null;
    }
    public void handleDataChange(String dataPath, Object data) throws Exception {
      initRunning(data);
    }
  };
  String clusterPath = ZookeeperPathUtils.getDestinationClusterRoot(destination);
  this.zkClient.subscribeChildChanges(clusterPath, childListener);
  initClusters(this.zkClient.getChildren(clusterPath));
  String runningPath = ZookeeperPathUtils.getDestinationServerRunning(destination);
  this.zkClient.subscribeDataChanges(runningPath, dataListener);
  initRunning(this.zkClient.readData(runningPath, true));
}

代码示例来源:origin: com.alibaba.otter/canal.client

public void start() {
  super.start();
  String path = ZookeeperPathUtils.getDestinationClientRunning(this.destination, clientData.getClientId());
  zkClient.subscribeDataChanges(path, dataListener);
  initRunning();
}

代码示例来源:origin: com.alibaba.otter/canal.client

public ClusterNodeAccessStrategy(String destination, ZkClientx zkClient){
  this.zkClient = zkClient;
  childListener = new IZkChildListener() {
    public void handleChildChange(String parentPath, List<String> currentChilds) throws Exception {
      initClusters(currentChilds);
    }
  };
  dataListener = new IZkDataListener() {
    public void handleDataDeleted(String dataPath) throws Exception {
      runningAddress = null;
    }
    public void handleDataChange(String dataPath, Object data) throws Exception {
      initRunning(data);
    }
  };
  String clusterPath = ZookeeperPathUtils.getDestinationClusterRoot(destination);
  this.zkClient.subscribeChildChanges(clusterPath, childListener);
  initClusters(this.zkClient.getChildren(clusterPath));
  String runningPath = ZookeeperPathUtils.getDestinationServerRunning(destination);
  this.zkClient.subscribeDataChanges(runningPath, dataListener);
  initRunning(this.zkClient.readData(runningPath, true));
}

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