gpt4 book ai didi

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

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

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

ZkClientx.readData介绍

暂无

代码示例

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

@Override
public LogPosition getLatestIndexBy(String destination) {
  String path = ZookeeperPathUtils.getParsePath(destination);
  byte[] data = zkClientx.readData(path, true);
  if (data == null || data.length == 0) {
    return null;
  }
  return JsonUtils.unmarshalFromByte(data, LogPosition.class);
}

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

for (Short clientId : clientIds) {
  path = ZookeeperPathUtils.getFilterPath(destination, clientId);
  byte[] bytes = zkClientx.readData(path, true);
  String filter = null;
  if (bytes != null) {

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

public Position getCursor(ClientIdentity clientIdentity) throws CanalMetaManagerException {
  String path = ZookeeperPathUtils.getCursorPath(clientIdentity.getDestination(), clientIdentity.getClientId());
  byte[] data = zkClientx.readData(path, true);
  if (data == null || data.length == 0) {
    return null;
  }
  return JsonUtils.unmarshalFromByte(data, Position.class);
}

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

public PositionRange getBatch(ClientIdentity clientIdentity, Long batchId) throws CanalMetaManagerException {
  String path = ZookeeperPathUtils
    .getBatchMarkWithIdPath(clientIdentity.getDestination(), clientIdentity.getClientId(), batchId);
  byte[] data = zkClientx.readData(path, true);
  if (data == null) {
    return null;
  }
  PositionRange positionRange = JsonUtils.unmarshalFromByte(data, PositionRange.class);
  return positionRange;
}

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

/**
 * 检查当前的状态
 */
public boolean check() {
  String path = ZookeeperPathUtils.getDestinationServerRunning(destination);
  try {
    byte[] bytes = zkClient.readData(path);
    ServerRunningData eventData = JsonUtils.unmarshalFromByte(bytes, ServerRunningData.class);
    activeData = eventData;// 更新下为最新值
    // 检查下nid是否为自己
    boolean result = isMine(activeData.getAddress());
    if (!result) {
      logger.warn("canal is running in node[{}] , but not in node[{}]",
        activeData.getCid(),
        serverData.getCid());
    }
    return result;
  } catch (ZkNoNodeException e) {
    logger.warn("canal is not run any in node");
    return false;
  } catch (ZkInterruptedException e) {
    logger.warn("canal check is interrupt");
    Thread.interrupted();// 清除interrupt标记
    return check();
  } catch (ZkException e) {
    logger.warn("canal check is failed");
    return false;
  }
}

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

/**
 * 检查当前的状态
 */
public boolean check() {
  String path = ZookeeperPathUtils.getDestinationClientRunning(this.destination, clientData.getClientId());
  try {
    byte[] bytes = zkClient.readData(path);
    ClientRunningData eventData = JsonUtils.unmarshalFromByte(bytes, ClientRunningData.class);
    activeData = eventData;// 更新下为最新值
    // 检查下nid是否为自己
    boolean result = isMine(activeData.getAddress());
    if (!result) {
      logger.warn("canal is running in [{}] , but not in [{}]",
        activeData.getAddress(),
        clientData.getAddress());
    }
    return result;
  } catch (ZkNoNodeException e) {
    logger.warn("canal is not run any in node");
    return false;
  } catch (ZkInterruptedException e) {
    logger.warn("canal check is interrupt");
    Thread.interrupted();// 清除interrupt标记
    return check();
  } catch (ZkException e) {
    logger.warn("canal check is failed");
    return false;
  }
}

代码示例来源: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: alibaba/canal

mutex.set(true);
} catch (ZkNodeExistsException e) {
  bytes = zkClient.readData(path, true);
  if (bytes == null) {// 如果不存在节点,立即尝试一次
    initRunning();

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

private void initRunning() {
  if (!isStart()) {
    return;
  }
  String path = ZookeeperPathUtils.getDestinationServerRunning(destination);
  // 序列化
  byte[] bytes = JsonUtils.marshalToByte(serverData);
  try {
    mutex.set(false);
    zkClient.create(path, bytes, CreateMode.EPHEMERAL);
    activeData = serverData;
    processActiveEnter();// 触发一下事件
    mutex.set(true);
  } catch (ZkNodeExistsException e) {
    bytes = zkClient.readData(path, true);
    if (bytes == null) {// 如果不存在节点,立即尝试一次
      initRunning();
    } else {
      activeData = JsonUtils.unmarshalFromByte(bytes, ServerRunningData.class);
    }
  } catch (ZkNoNodeException e) {
    zkClient.createPersistent(ZookeeperPathUtils.getDestinationPath(destination), true); // 尝试创建父节点
    initRunning();
  }
}

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

/**
 * 检查当前的状态
 */
public boolean check() {
  String path = ZookeeperPathUtils.getDestinationClientRunning(this.destination, clientData.getClientId());
  try {
    byte[] bytes = zkClient.readData(path);
    ClientRunningData eventData = JsonUtils.unmarshalFromByte(bytes, ClientRunningData.class);
    activeData = eventData;// 更新下为最新值
    // 检查下nid是否为自己
    boolean result = isMine(activeData.getAddress());
    if (!result) {
      logger.warn("canal is running in [{}] , but not in [{}]",
        activeData.getAddress(),
        clientData.getAddress());
    }
    return result;
  } catch (ZkNoNodeException e) {
    logger.warn("canal is not run any in node");
    return false;
  } catch (ZkInterruptedException e) {
    logger.warn("canal check is interrupt");
    Thread.interrupted();// 清除interrupt标记
    return check();
  } catch (ZkException e) {
    logger.warn("canal check is failed");
    return false;
  }
}

代码示例来源: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));
}

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

mutex.set(true);
} catch (ZkNodeExistsException e) {
  bytes = zkClient.readData(path, true);
  if (bytes == null) {// 如果不存在节点,立即尝试一次
    initRunning();

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