Java Code Examples for com.alibaba.otter.canal.store.helper.CanalEventUtils#min()
The following examples show how to use
com.alibaba.otter.canal.store.helper.CanalEventUtils#min() .
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: MetaLogPositionManager.java From canal-1.1.3 with Apache License 2.0 | 6 votes |
@Override public LogPosition getLatestIndexBy(String destination) { List<ClientIdentity> clientIdentities = metaManager.listAllSubscribeInfo(destination); LogPosition result = null; if (!CollectionUtils.isEmpty(clientIdentities)) { // 尝试找到一个最小的logPosition for (ClientIdentity clientIdentity : clientIdentities) { LogPosition position = (LogPosition) metaManager.getCursor(clientIdentity); if (position == null) { continue; } if (result == null) { result = position; } else { result = CanalEventUtils.min(result, position); } } } return result; }
Example 2
Source File: GatewayMetaManager.java From DataLink with Apache License 2.0 | 6 votes |
/** * 需要加同步锁,保证在获取最小Position的时候,metaManager是不可变的 * * @throws CanalMetaManagerException */ @Override public synchronized Position getCursor(ClientIdentity clientIdentity) throws CanalMetaManagerException { // 入参clientIdentity没有什么作用,因为该方法需要返回所有"Sub Meta Manager"中最小的Position List<ClientIdentity> clientIdentities = listAllSubscribeInfo(""); LogPosition result = null; if (!CollectionUtils.isEmpty(clientIdentities)) { // 尝试找到一个最小的logPosition for (ClientIdentity item : clientIdentities) { LogPosition position = (LogPosition) attachedMetaManagers.get(item.getDestination()).getCursor(item); if (position == null) { continue; } if (result == null) { result = position; } else { result = CanalEventUtils.min(result, position); } } } return result; }
Example 3
Source File: MetaLogPositionManager.java From canal with Apache License 2.0 | 6 votes |
@Override public LogPosition getLatestIndexBy(String destination) { List<ClientIdentity> clientIdentities = metaManager.listAllSubscribeInfo(destination); LogPosition result = null; if (!CollectionUtils.isEmpty(clientIdentities)) { // 尝试找到一个最小的logPosition for (ClientIdentity clientIdentity : clientIdentities) { LogPosition position = (LogPosition) metaManager.getCursor(clientIdentity); if (position == null) { continue; } if (result == null) { result = position; } else { result = CanalEventUtils.min(result, position); } } } return result; }