mysql semi support and mariadb gtid parse

This commit is contained in:
lucifax301
2017-12-18 14:10:53 +08:00
parent ac773009f8
commit d66839c965
8 changed files with 164 additions and 4 deletions

View File

@@ -20,6 +20,7 @@ public class LogBuffer {
protected int origin, limit;
protected int position;
protected int semival;
protected LogBuffer(){
}

View File

@@ -104,6 +104,9 @@ public final class LogDecoder {
try {
/* Decoding binary-log to event */
event = decode(buffer, header, context);
if(event!=null){
event.setSemival(buffer.semival);
}
} catch (IOException e) {
if (logger.isWarnEnabled()) logger.warn("Decoding " + LogEvent.getTypeName(header.getType())
+ " failed from: " + context.getLogPosition(), e);

View File

@@ -359,8 +359,23 @@ public abstract class LogEvent {
protected static final Log logger = LogFactory.getLog(LogEvent.class);
protected final LogHeader header;
/**
* mysql半同步semi标识 0不需要semi ack 给mysql, 1需要semi ack给mysql
*/
protected int semival;
protected LogEvent(LogHeader header){
public int getSemival() {
return semival;
}
public void setSemival(int semival) {
this.semival = semival;
}
protected LogEvent(LogHeader header){
this.header = header;
}

View File

@@ -13,9 +13,35 @@ import com.taobao.tddl.dbsync.binlog.event.LogHeader;
*/
public class MariaGtidLogEvent extends IgnorableLogEvent {
private long gtid;
/**
* mariadb gtidlog event format
*
uint<8> GTID sequence
uint<4> Replication Domain ID
uint<1> Flags
if flag & FL_GROUP_COMMIT_ID
uint<8> commit_id
else
uint<6> 0
*
*/
public MariaGtidLogEvent(LogHeader header, LogBuffer buffer, FormatDescriptionLogEvent descriptionEvent){
super(header, buffer, descriptionEvent);
gtid=buffer.getUlong64().longValue();
// do nothing , just ignore log event
}
public long getGtid() {
return gtid;
}
}