Java Code Examples for com.alibaba.otter.canal.protocol.position.EntryPosition#setGtid()
The following examples show how to use
com.alibaba.otter.canal.protocol.position.EntryPosition#setGtid() .
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: MysqlEventParser.java From canal-1.1.3 with Apache License 2.0 | 6 votes |
/** * 查询当前的binlog位置 */ private EntryPosition findEndPosition(MysqlConnection mysqlConnection) { try { ResultSetPacket packet = mysqlConnection.query("show master status"); List<String> fields = packet.getFieldValues(); if (CollectionUtils.isEmpty(fields)) { throw new CanalParseException("command : 'show master status' has an error! pls check. you need (at least one of) the SUPER,REPLICATION CLIENT privilege(s) for this operation"); } EntryPosition endPosition = new EntryPosition(fields.get(0), Long.valueOf(fields.get(1))); if (isGTIDMode() && fields.size() > 4) { endPosition.setGtid(fields.get(4)); } return endPosition; } catch (IOException e) { throw new CanalParseException("command : 'show master status' has an error!", e); } }
Example 2
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 3
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 4
Source File: MysqlEventParser.java From canal with Apache License 2.0 | 6 votes |
/** * 查询当前的binlog位置 */ private EntryPosition findEndPosition(MysqlConnection mysqlConnection) { try { ResultSetPacket packet = mysqlConnection.query("show master status"); List<String> fields = packet.getFieldValues(); if (CollectionUtils.isEmpty(fields)) { throw new CanalParseException("command : 'show master status' has an error! pls check. you need (at least one of) the SUPER,REPLICATION CLIENT privilege(s) for this operation"); } EntryPosition endPosition = new EntryPosition(fields.get(0), Long.valueOf(fields.get(1))); if (isGTIDMode() && fields.size() > 4) { endPosition.setGtid(fields.get(4)); } return endPosition; } catch (IOException e) { throw new CanalParseException("command : 'show master status' has an error!", e); } }
Example 5
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 6
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 7
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 8
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; }