com.alibaba.otter.canal.protocol.position.LogIdentity Java Examples
The following examples show how to use
com.alibaba.otter.canal.protocol.position.LogIdentity.
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: 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 #3
Source File: MemoryEventStoreBase.java From canal with Apache License 2.0 | 5 votes |
protected Event buildEvent(String binlogFile, long offset, long timestamp, long eventLenght) { Header.Builder headerBuilder = Header.newBuilder(); headerBuilder.setLogfileName(binlogFile); headerBuilder.setLogfileOffset(offset); headerBuilder.setExecuteTime(timestamp); headerBuilder.setEventLength(eventLenght); Entry.Builder entryBuilder = Entry.newBuilder(); entryBuilder.setHeader(headerBuilder.build()); Entry entry = entryBuilder.build(); return new Event(new LogIdentity(new InetSocketAddress(MYSQL_ADDRESS, 3306), 1234L), entry); }
Example #4
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 #5
Source File: MemoryEventStoreBase.java From canal with Apache License 2.0 | 5 votes |
protected Event buildEvent(String binlogFile, long offset, long timestamp) { Header.Builder headerBuilder = Header.newBuilder(); headerBuilder.setLogfileName(binlogFile); headerBuilder.setLogfileOffset(offset); headerBuilder.setExecuteTime(timestamp); headerBuilder.setEventLength(1024); Entry.Builder entryBuilder = Entry.newBuilder(); entryBuilder.setHeader(headerBuilder.build()); Entry entry = entryBuilder.build(); return new Event(new LogIdentity(new InetSocketAddress(MYSQL_ADDRESS, 3306), 1234L), entry); }
Example #6
Source File: Event.java From canal with Apache License 2.0 | 5 votes |
public Event(LogIdentity logIdentity, CanalEntry.Entry entry, boolean raw){ this.logIdentity = logIdentity; this.entryType = entry.getEntryType(); this.executeTime = entry.getHeader().getExecuteTime(); this.journalName = entry.getHeader().getLogfileName(); this.position = entry.getHeader().getLogfileOffset(); this.serverId = entry.getHeader().getServerId(); this.gtid = entry.getHeader().getGtid(); this.eventType = entry.getHeader().getEventType(); if (entryType == EntryType.ROWDATA) { List<CanalEntry.Pair> props = entry.getHeader().getPropsList(); if (props != null) { for (CanalEntry.Pair p : props) { if ("rowsCount".equals(p.getKey())) { rowsCount = Integer.parseInt(p.getValue()); break; } } } } if (raw) { // build raw this.rawEntry = entry.toByteString(); this.rawLength = rawEntry.size(); } else { this.entry = entry; // 按照6倍的event length预估 this.rawLength = entry.getHeader().getEventLength() * 6; } }
Example #7
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 #8
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 #9
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 #10
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 #11
Source File: MemoryEventStoreBase.java From canal-1.1.3 with Apache License 2.0 | 5 votes |
protected Event buildEvent(String binlogFile, long offset, long timestamp, long eventLenght) { Header.Builder headerBuilder = Header.newBuilder(); headerBuilder.setLogfileName(binlogFile); headerBuilder.setLogfileOffset(offset); headerBuilder.setExecuteTime(timestamp); headerBuilder.setEventLength(eventLenght); Entry.Builder entryBuilder = Entry.newBuilder(); entryBuilder.setHeader(headerBuilder.build()); Entry entry = entryBuilder.build(); return new Event(new LogIdentity(new InetSocketAddress(MYSQL_ADDRESS, 3306), 1234L), entry); }
Example #12
Source File: MemoryEventStoreBase.java From canal-1.1.3 with Apache License 2.0 | 5 votes |
protected Event buildEvent(String binlogFile, long offset, long timestamp) { Header.Builder headerBuilder = Header.newBuilder(); headerBuilder.setLogfileName(binlogFile); headerBuilder.setLogfileOffset(offset); headerBuilder.setExecuteTime(timestamp); headerBuilder.setEventLength(1024); Entry.Builder entryBuilder = Entry.newBuilder(); entryBuilder.setHeader(headerBuilder.build()); Entry entry = entryBuilder.build(); return new Event(new LogIdentity(new InetSocketAddress(MYSQL_ADDRESS, 3306), 1234L), entry); }
Example #13
Source File: Event.java From canal-1.1.3 with Apache License 2.0 | 5 votes |
public Event(LogIdentity logIdentity, CanalEntry.Entry entry, boolean raw){ this.logIdentity = logIdentity; this.entryType = entry.getEntryType(); this.executeTime = entry.getHeader().getExecuteTime(); this.journalName = entry.getHeader().getLogfileName(); this.position = entry.getHeader().getLogfileOffset(); this.serverId = entry.getHeader().getServerId(); this.gtid = entry.getHeader().getGtid(); this.eventType = entry.getHeader().getEventType(); if (entryType == EntryType.ROWDATA) { List<CanalEntry.Pair> props = entry.getHeader().getPropsList(); if (props != null) { for (CanalEntry.Pair p : props) { if ("rowsCount".equals(p.getKey())) { rowsCount = Integer.parseInt(p.getValue()); break; } } } } if (raw) { // build raw this.rawEntry = entry.toByteString(); this.rawLength = rawEntry.size(); } else { this.entry = entry; // 按照6倍的event length预估 this.rawLength = entry.getHeader().getEventLength() * 6; } }
Example #14
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 #15
Source File: Event.java From canal-1.1.3 with Apache License 2.0 | 4 votes |
public void setLogIdentity(LogIdentity logIdentity) { this.logIdentity = logIdentity; }
Example #16
Source File: Event.java From canal-1.1.3 with Apache License 2.0 | 4 votes |
public LogIdentity getLogIdentity() { return logIdentity; }
Example #17
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; }
Example #18
Source File: Event.java From canal with Apache License 2.0 | 4 votes |
public Event(LogIdentity logIdentity, CanalEntry.Entry entry){ this(logIdentity, entry, true); }
Example #19
Source File: Event.java From canal-1.1.3 with Apache License 2.0 | 4 votes |
public Event(LogIdentity logIdentity, CanalEntry.Entry entry){ this(logIdentity, entry, true); }
Example #20
Source File: Event.java From canal with Apache License 2.0 | 4 votes |
public LogIdentity getLogIdentity() { return logIdentity; }
Example #21
Source File: Event.java From canal with Apache License 2.0 | 4 votes |
public void setLogIdentity(LogIdentity logIdentity) { this.logIdentity = logIdentity; }
Example #22
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; }