Java Code Examples for com.alibaba.otter.canal.common.utils.JsonUtils#marshalToByte()
The following examples show how to use
com.alibaba.otter.canal.common.utils.JsonUtils#marshalToByte() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ZooKeeperMetaManager.java From canal-1.1.3 with Apache License 2.0 | 5 votes |
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);// 第一次节点不存在,则尝试重建 } }
Example 2
Source File: ZooKeeperMetaManager.java From canal-1.1.3 with Apache License 2.0 | 5 votes |
public Long addBatch(ClientIdentity clientIdentity, PositionRange positionRange) throws CanalMetaManagerException { String path = ZookeeperPathUtils.getBatchMarkPath(clientIdentity.getDestination(), clientIdentity.getClientId()); byte[] data = JsonUtils.marshalToByte(positionRange, SerializerFeature.WriteClassName); String batchPath = zkClientx .createPersistentSequential(path + ZookeeperPathUtils.ZOOKEEPER_SEPARATOR, data, true); String batchIdString = StringUtils.substringAfterLast(batchPath, ZookeeperPathUtils.ZOOKEEPER_SEPARATOR); return ZookeeperPathUtils.getBatchMarkId(batchIdString); }
Example 3
Source File: ZooKeeperMetaManager.java From canal-1.1.3 with Apache License 2.0 | 5 votes |
public void addBatch(ClientIdentity clientIdentity, PositionRange positionRange, Long batchId) throws CanalMetaManagerException { String path = ZookeeperPathUtils .getBatchMarkWithIdPath(clientIdentity.getDestination(), clientIdentity.getClientId(), batchId); byte[] data = JsonUtils.marshalToByte(positionRange, SerializerFeature.WriteClassName); zkClientx.createPersistent(path, data, true); }
Example 4
Source File: ClientRunningMonitor.java From canal-1.1.3 with Apache License 2.0 | 5 votes |
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); } }
Example 5
Source File: ZooKeeperLogPositionManager.java From canal-1.1.3 with Apache License 2.0 | 5 votes |
@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); } }
Example 6
Source File: ZooKeeperMetaManager.java From canal with Apache License 2.0 | 5 votes |
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);// 第一次节点不存在,则尝试重建 } }
Example 7
Source File: ZooKeeperMetaManager.java From canal with Apache License 2.0 | 5 votes |
public Long addBatch(ClientIdentity clientIdentity, PositionRange positionRange) throws CanalMetaManagerException { String path = ZookeeperPathUtils.getBatchMarkPath(clientIdentity.getDestination(), clientIdentity.getClientId()); byte[] data = JsonUtils.marshalToByte(positionRange, SerializerFeature.WriteClassName); String batchPath = zkClientx .createPersistentSequential(path + ZookeeperPathUtils.ZOOKEEPER_SEPARATOR, data, true); String batchIdString = StringUtils.substringAfterLast(batchPath, ZookeeperPathUtils.ZOOKEEPER_SEPARATOR); return ZookeeperPathUtils.getBatchMarkId(batchIdString); }
Example 8
Source File: ZooKeeperMetaManager.java From canal with Apache License 2.0 | 5 votes |
public void addBatch(ClientIdentity clientIdentity, PositionRange positionRange, Long batchId) throws CanalMetaManagerException { String path = ZookeeperPathUtils .getBatchMarkWithIdPath(clientIdentity.getDestination(), clientIdentity.getClientId(), batchId); byte[] data = JsonUtils.marshalToByte(positionRange, SerializerFeature.WriteClassName); zkClientx.createPersistent(path, data, true); }
Example 9
Source File: ClientRunningMonitor.java From canal with Apache License 2.0 | 5 votes |
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); } }
Example 10
Source File: ZooKeeperLogPositionManager.java From canal with Apache License 2.0 | 5 votes |
@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); } }