gpt4 book ai didi

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

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

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

ZkClientx.writeData介绍

暂无

代码示例

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

private void processActiveEnter() {
  if (listener != null) {
    // 触发回调,建立与server的socket链接
    InetSocketAddress connectAddress = listener.processActiveEnter();
    String address = connectAddress.getAddress().getHostAddress() + ":" + connectAddress.getPort();
    this.clientData.setAddress(address);
    String path = ZookeeperPathUtils.getDestinationClientRunning(this.destination,
      this.clientData.getClientId());
    // 序列化
    byte[] bytes = JsonUtils.marshalToByte(clientData);
    zkClient.writeData(path, bytes);
  }
}

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

@Override
public void persistLogPosition(String destination, LogPosition logPosition) throws CanalParseException {
  String path = ZookeeperPathUtils.getParsePath(destination);
  byte[] data = JsonUtils.marshalToByte(logPosition);
  try {
    zkClientx.writeData(path, data);
  } catch (ZkNoNodeException e) {
    zkClientx.createPersistent(path, data, true);
  }
}

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

public void updateCursor(ClientIdentity clientIdentity, Position position) throws CanalMetaManagerException {
  String path = ZookeeperPathUtils.getCursorPath(clientIdentity.getDestination(), clientIdentity.getClientId());
  byte[] data = JsonUtils.marshalToByte(position, SerializerFeature.WriteClassName);
  try {
    zkClientx.writeData(path, data);
  } catch (ZkNoNodeException e) {
    zkClientx.createPersistent(path, data, true);// 第一次节点不存在,则尝试重建
  }
}

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

public void subscribe(ClientIdentity clientIdentity) throws CanalMetaManagerException {
  String path = ZookeeperPathUtils.getClientIdNodePath(clientIdentity.getDestination(),
    clientIdentity.getClientId());
  try {
    zkClientx.createPersistent(path, true);
  } catch (ZkNodeExistsException e) {
    // ignore
  }
  if (clientIdentity.hasFilter()) {
    String filterPath = ZookeeperPathUtils.getFilterPath(clientIdentity.getDestination(),
      clientIdentity.getClientId());
    byte[] bytes = null;
    try {
      bytes = clientIdentity.getFilter().getBytes(ENCODE);
    } catch (UnsupportedEncodingException e) {
      throw new CanalMetaManagerException(e);
    }
    try {
      zkClientx.createPersistent(filterPath, bytes);
    } catch (ZkNodeExistsException e) {
      // ignore
      zkClientx.writeData(filterPath, bytes);
    }
  }
}

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

private void processActiveEnter() {
  if (listener != null) {
    // 触发回调,建立与server的socket链接
    InetSocketAddress connectAddress = listener.processActiveEnter();
    String address = connectAddress.getAddress().getHostAddress() + ":" + connectAddress.getPort();
    this.clientData.setAddress(address);
    String path = ZookeeperPathUtils.getDestinationClientRunning(this.destination,
      this.clientData.getClientId());
    // 序列化
    byte[] bytes = JsonUtils.marshalToByte(clientData);
    zkClient.writeData(path, bytes);
  }
}

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