|
@@ -3,10 +3,10 @@ package com.taobao.tddl.dbsync.binlog;
|
|
|
import java.io.IOException;
|
|
|
import java.util.BitSet;
|
|
|
|
|
|
-import com.alibaba.otter.canal.parse.driver.mysql.packets.GTIDSet;
|
|
|
import org.apache.commons.logging.Log;
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
|
|
|
+import com.alibaba.otter.canal.parse.driver.mysql.packets.GTIDSet;
|
|
|
import com.taobao.tddl.dbsync.binlog.event.AppendBlockLogEvent;
|
|
|
import com.taobao.tddl.dbsync.binlog.event.BeginLoadQueryLogEvent;
|
|
|
import com.taobao.tddl.dbsync.binlog.event.CreateFileLogEvent;
|
|
@@ -47,7 +47,7 @@ import com.taobao.tddl.dbsync.binlog.event.mariadb.StartEncryptionLogEvent;
|
|
|
|
|
|
/**
|
|
|
* Implements a binary-log decoder.
|
|
|
- *
|
|
|
+ *
|
|
|
* <pre>
|
|
|
* LogDecoder decoder = new LogDecoder();
|
|
|
* decoder.handle(...);
|
|
@@ -62,7 +62,7 @@ import com.taobao.tddl.dbsync.binlog.event.mariadb.StartEncryptionLogEvent;
|
|
|
* while (event != null);
|
|
|
* // no more events in buffer.
|
|
|
* </pre>
|
|
|
- *
|
|
|
+ *
|
|
|
* @author <a href="mailto:changyuan.lh@taobao.com">Changyuan.lh</a>
|
|
|
* @version 1.0
|
|
|
*/
|
|
@@ -89,7 +89,7 @@ public final class LogDecoder {
|
|
|
|
|
|
/**
|
|
|
* Decoding an event from binary-log buffer.
|
|
|
- *
|
|
|
+ *
|
|
|
* @return <code>UknownLogEvent</code> if event type is unknown or skipped,
|
|
|
* <code>null</code> if buffer is not including a full event.
|
|
|
*/
|
|
@@ -141,7 +141,7 @@ public final class LogDecoder {
|
|
|
|
|
|
/**
|
|
|
* Deserialize an event from buffer.
|
|
|
- *
|
|
|
+ *
|
|
|
* @return <code>UknownLogEvent</code> if event type is unknown or skipped.
|
|
|
*/
|
|
|
public static LogEvent decode(LogBuffer buffer, LogHeader header, LogContext context) throws IOException {
|
|
@@ -160,6 +160,7 @@ public final class LogDecoder {
|
|
|
// remove checksum bytes
|
|
|
buffer.limit(header.getEventLen() - LogEvent.BINLOG_CHECKSUM_LEN);
|
|
|
}
|
|
|
+ GTIDSet gtidSet = context.getGtidSet();
|
|
|
switch (header.getType()) {
|
|
|
case LogEvent.QUERY_EVENT: {
|
|
|
QueryLogEvent event = new QueryLogEvent(header, buffer, descriptionEvent);
|
|
@@ -373,8 +374,11 @@ public final class LogDecoder {
|
|
|
GtidLogEvent event = new GtidLogEvent(header, buffer, descriptionEvent);
|
|
|
/* updating position in context */
|
|
|
logPosition.position = header.getLogPos();
|
|
|
- // update latest gtid
|
|
|
- context.putGtid(event);
|
|
|
+ if (gtidSet != null) {
|
|
|
+ gtidSet.update(event.getGtidStr());
|
|
|
+ // update latest gtid
|
|
|
+ header.putGtidStr(gtidSet);
|
|
|
+ }
|
|
|
return event;
|
|
|
}
|
|
|
case LogEvent.PREVIOUS_GTIDS_LOG_EVENT: {
|