Java Code Examples for com.alibaba.otter.canal.protocol.position.LogPosition#setIdentity()
The following examples show how to use
com.alibaba.otter.canal.protocol.position.LogPosition#setIdentity() .
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: AbstractEventParser.java From canal-1.1.3 with Apache License 2.0 | 6 votes |
protected LogPosition buildLastPosition(CanalEntry.Entry entry) { // 初始化一下 LogPosition logPosition = new LogPosition(); EntryPosition position = new EntryPosition(); position.setJournalName(entry.getHeader().getLogfileName()); position.setPosition(entry.getHeader().getLogfileOffset()); position.setTimestamp(entry.getHeader().getExecuteTime()); // add serverId at 2016-06-28 position.setServerId(entry.getHeader().getServerId()); // set gtid position.setGtid(entry.getHeader().getGtid()); logPosition.setPostion(position); LogIdentity identity = new LogIdentity(runningInfo.getAddress(), -1L); logPosition.setIdentity(identity); return logPosition; }
Example 2
Source File: CanalEventUtils.java From canal-1.1.3 with Apache License 2.0 | 6 votes |
/** * 根据entry创建对应的Position对象 */ public static LogPosition createPosition(Event event) { EntryPosition position = new EntryPosition(); position.setJournalName(event.getJournalName()); position.setPosition(event.getPosition()); position.setTimestamp(event.getExecuteTime()); // add serverId at 2016-06-28 position.setServerId(event.getServerId()); // add gtid position.setGtid(event.getGtid()); LogPosition logPosition = new LogPosition(); logPosition.setPostion(position); logPosition.setIdentity(event.getLogIdentity()); return logPosition; }
Example 3
Source File: AbstractEventParser.java From canal with Apache License 2.0 | 6 votes |
protected LogPosition buildLastPosition(CanalEntry.Entry entry) { // 初始化一下 LogPosition logPosition = new LogPosition(); EntryPosition position = new EntryPosition(); position.setJournalName(entry.getHeader().getLogfileName()); position.setPosition(entry.getHeader().getLogfileOffset()); position.setTimestamp(entry.getHeader().getExecuteTime()); // add serverId at 2016-06-28 position.setServerId(entry.getHeader().getServerId()); // set gtid position.setGtid(entry.getHeader().getGtid()); logPosition.setPostion(position); LogIdentity identity = new LogIdentity(runningInfo.getAddress(), -1L); logPosition.setIdentity(identity); return logPosition; }
Example 4
Source File: CanalEventUtils.java From canal with Apache License 2.0 | 6 votes |
/** * 根据entry创建对应的Position对象 */ public static LogPosition createPosition(Event event) { EntryPosition position = new EntryPosition(); position.setJournalName(event.getJournalName()); position.setPosition(event.getPosition()); position.setTimestamp(event.getExecuteTime()); // add serverId at 2016-06-28 position.setServerId(event.getServerId()); // add gtid position.setGtid(event.getGtid()); LogPosition logPosition = new LogPosition(); logPosition.setPostion(position); logPosition.setIdentity(event.getLogIdentity()); return logPosition; }
Example 5
Source File: CanalEventUtils.java From canal with Apache License 2.0 | 6 votes |
/** * 根据entry创建对应的Position对象 */ public static LogPosition createPosition(Event event, boolean included) { EntryPosition position = new EntryPosition(); position.setJournalName(event.getJournalName()); position.setPosition(event.getPosition()); position.setTimestamp(event.getExecuteTime()); position.setIncluded(included); // add serverId at 2016-06-28 position.setServerId(event.getServerId()); // add gtid position.setGtid(event.getGtid()); LogPosition logPosition = new LogPosition(); logPosition.setPostion(position); logPosition.setIdentity(event.getLogIdentity()); return logPosition; }
Example 6
Source File: AbstractMetaManagerTest.java From canal-1.1.3 with Apache License 2.0 | 5 votes |
private PositionRange<LogPosition> buildRange(int number) { LogPosition start = new LogPosition(); start.setIdentity(new LogIdentity(new InetSocketAddress(MYSQL_ADDRESS, 3306), 1234L)); start.setPostion(new EntryPosition("mysql-bin.000000" + number, 106L, new Date().getTime())); LogPosition end = new LogPosition(); end.setIdentity(new LogIdentity(new InetSocketAddress(MYSQL_ADDRESS, 3306), 1234L)); end.setPostion(new EntryPosition("mysql-bin.000000" + (number + 1), 106L, (new Date().getTime()) + 1000 * 1000L)); return new PositionRange<LogPosition>(start, end); }
Example 7
Source File: MetaLogPositionManagerTest.java From canal-1.1.3 with Apache License 2.0 | 5 votes |
private PositionRange<LogPosition> buildRange(int number) { LogPosition start = new LogPosition(); start.setIdentity(new LogIdentity(new InetSocketAddress(MYSQL_ADDRESS, 3306), 1234L)); start.setPostion(new EntryPosition("mysql-bin.000000" + number, 106L, new Date().getTime())); LogPosition end = new LogPosition(); end.setIdentity(new LogIdentity(new InetSocketAddress(MYSQL_ADDRESS, 3306), 1234L)); end.setPostion(new EntryPosition("mysql-bin.000000" + (number + 1), 106L, (new Date().getTime()) + 1000 * 1000L)); return new PositionRange<LogPosition>(start, end); }
Example 8
Source File: CanalEventUtils.java From canal-1.1.3 with Apache License 2.0 | 5 votes |
/** * 根据entry创建对应的Position对象 */ public static LogPosition createPosition(Event event, boolean included) { EntryPosition position = new EntryPosition(); position.setJournalName(event.getJournalName()); position.setPosition(event.getPosition()); position.setTimestamp(event.getExecuteTime()); position.setIncluded(included); LogPosition logPosition = new LogPosition(); logPosition.setPostion(position); logPosition.setIdentity(event.getLogIdentity()); return logPosition; }
Example 9
Source File: MysqlTaskPositionManager.java From DataLink with Apache License 2.0 | 5 votes |
public LogPosition translateToLogPosition(MysqlReaderPosition cp) { LogIdentity logIdentity = new LogIdentity(cp.getSourceAddress(), cp.getSlaveId()); EntryPosition entryPosition = new EntryPosition(cp.getJournalName(), cp.getPosition(), cp.getTimestamp(), cp.getServerId()); entryPosition.setIncluded(cp.isIncluded()); entryPosition.setGtid(cp.getGtid()); LogPosition logPosition = new LogPosition(); logPosition.setIdentity(logIdentity); logPosition.setPostion(entryPosition); return logPosition; }
Example 10
Source File: AbstractEventParser.java From DBus with Apache License 2.0 | 5 votes |
protected LogPosition buildLastPosition(CanalEntry.Entry entry) { // 初始化一下 LogPosition logPosition = new LogPosition(); EntryPosition position = new EntryPosition(); position.setJournalName(entry.getHeader().getLogfileName()); position.setPosition(entry.getHeader().getLogfileOffset()); position.setTimestamp(entry.getHeader().getExecuteTime()); // add serverId at 2016-06-28 position.setServerId(entry.getHeader().getServerId()); logPosition.setPostion(position); LogIdentity identity = new LogIdentity(runningInfo.getAddress(), -1L); logPosition.setIdentity(identity); return logPosition; }
Example 11
Source File: AbstractMetaManagerTest.java From canal with Apache License 2.0 | 5 votes |
private PositionRange<LogPosition> buildRange(int number) { LogPosition start = new LogPosition(); start.setIdentity(new LogIdentity(new InetSocketAddress(MYSQL_ADDRESS, 3306), 1234L)); start.setPostion(new EntryPosition("mysql-bin.000000" + number, 106L, new Date().getTime())); LogPosition end = new LogPosition(); end.setIdentity(new LogIdentity(new InetSocketAddress(MYSQL_ADDRESS, 3306), 1234L)); end.setPostion(new EntryPosition("mysql-bin.000000" + (number + 1), 106L, (new Date().getTime()) + 1000 * 1000L)); return new PositionRange<LogPosition>(start, end); }
Example 12
Source File: MetaLogPositionManagerTest.java From canal with Apache License 2.0 | 5 votes |
private PositionRange<LogPosition> buildRange(int number) { LogPosition start = new LogPosition(); start.setIdentity(new LogIdentity(new InetSocketAddress(MYSQL_ADDRESS, 3306), 1234L)); start.setPostion(new EntryPosition("mysql-bin.000000" + number, 106L, new Date().getTime())); LogPosition end = new LogPosition(); end.setIdentity(new LogIdentity(new InetSocketAddress(MYSQL_ADDRESS, 3306), 1234L)); end.setPostion(new EntryPosition("mysql-bin.000000" + (number + 1), 106L, (new Date().getTime()) + 1000 * 1000L)); return new PositionRange<LogPosition>(start, end); }
Example 13
Source File: RdsLocalBinlogEventParser.java From canal-1.1.3 with Apache License 2.0 | 4 votes |
@Override public void onFinish(String fileName) { try { binlogDownloadQueue.downOne(); File needDeleteFile = new File(directory + File.separator + fileName); if (needDeleteFile.exists()) { needDeleteFile.delete(); } // 处理下logManager位点问题 LogPosition logPosition = logPositionManager.getLatestIndexBy(destination); Long timestamp = 0L; if (logPosition != null && logPosition.getPostion() != null) { timestamp = logPosition.getPostion().getTimestamp(); EntryPosition position = logPosition.getPostion(); LogPosition newLogPosition = new LogPosition(); String journalName = position.getJournalName(); int sepIdx = journalName.indexOf("."); String fileIndex = journalName.substring(sepIdx + 1); int index = NumberUtils.toInt(fileIndex) + 1; String newJournalName = journalName.substring(0, sepIdx) + "." + StringUtils.leftPad(String.valueOf(index), fileIndex.length(), "0"); newLogPosition.setPostion(new EntryPosition(newJournalName, 4L, position.getTimestamp(), position.getServerId())); newLogPosition.setIdentity(logPosition.getIdentity()); logPositionManager.persistLogPosition(destination, newLogPosition); } if (binlogDownloadQueue.isLastFile(fileName)) { logger.warn("last file : " + fileName + " , timestamp : " + timestamp + " , all file parse complete, switch to mysql parser!"); finishListener.onFinish(); return; } else { logger.warn("parse local binlog file : " + fileName + " , timestamp : " + timestamp + " , try the next binlog !"); } binlogDownloadQueue.prepare(); } catch (Exception e) { logger.error("prepare download binlog file failed!", e); throw new RuntimeException(e); } }
Example 14
Source File: AbstractLogPositionManagerTest.java From canal-1.1.3 with Apache License 2.0 | 4 votes |
protected LogPosition buildPosition(int number) { LogPosition position = new LogPosition(); position.setIdentity(new LogIdentity(new InetSocketAddress(MYSQL_ADDRESS, 3306), 1234L)); position.setPostion(new EntryPosition("mysql-bin.000000" + number, 106L, new Date().getTime())); return position; }
Example 15
Source File: RdsLocalBinlogEventParser.java From canal with Apache License 2.0 | 4 votes |
@Override public void onFinish(String fileName) { try { binlogDownloadQueue.downOne(); File needDeleteFile = new File(directory + File.separator + fileName); if (needDeleteFile.exists()) { needDeleteFile.delete(); } // 处理下logManager位点问题 LogPosition logPosition = logPositionManager.getLatestIndexBy(destination); Long timestamp = 0L; if (logPosition != null && logPosition.getPostion() != null) { timestamp = logPosition.getPostion().getTimestamp(); EntryPosition position = logPosition.getPostion(); LogPosition newLogPosition = new LogPosition(); String journalName = position.getJournalName(); int sepIdx = journalName.indexOf("."); String fileIndex = journalName.substring(sepIdx + 1); int index = NumberUtils.toInt(fileIndex) + 1; String newJournalName = journalName.substring(0, sepIdx) + "." + StringUtils.leftPad(String.valueOf(index), fileIndex.length(), "0"); newLogPosition.setPostion(new EntryPosition(newJournalName, 4L, position.getTimestamp(), position.getServerId())); newLogPosition.setIdentity(logPosition.getIdentity()); logPositionManager.persistLogPosition(destination, newLogPosition); } if (binlogDownloadQueue.isLastFile(fileName)) { logger.warn("last file : " + fileName + " , timestamp : " + timestamp + " , all file parse complete, switch to mysql parser!"); finishListener.onFinish(); return; } else { logger.warn("parse local binlog file : " + fileName + " , timestamp : " + timestamp + " , try the next binlog !"); } binlogDownloadQueue.prepare(); } catch (Exception e) { logger.error("prepare download binlog file failed!", e); throw new RuntimeException(e); } }
Example 16
Source File: AbstractLogPositionManagerTest.java From canal with Apache License 2.0 | 4 votes |
protected LogPosition buildPosition(int number) { LogPosition position = new LogPosition(); position.setIdentity(new LogIdentity(new InetSocketAddress(MYSQL_ADDRESS, 3306), 1234L)); position.setPostion(new EntryPosition("mysql-bin.000000" + number, 106L, new Date().getTime())); return position; }