fixed semi sync format & refactor

This commit is contained in:
agapple
2017-12-27 16:53:09 +08:00
parent c6f4de9f88
commit 9595e6abbd
7 changed files with 81 additions and 90 deletions

View File

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

View File

@@ -104,12 +104,14 @@ public final class LogDecoder {
try {
/* Decoding binary-log to event */
event = decode(buffer, header, context);
if(event!=null){
event.setSemival(buffer.semival);
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);
if (logger.isWarnEnabled()) {
logger.warn("Decoding " + LogEvent.getTypeName(header.getType()) + " failed from: "
+ context.getLogPosition(), e);
}
throw e;
} finally {
buffer.limit(limit); /* Restore limit */

View File

@@ -361,9 +361,14 @@ public abstract class LogEvent {
protected final LogHeader header;
/**
* mysql半同步semi标识 0不需要semi ack 给mysql, 1需要semi ack给mysql
* mysql半同步semi标识
*
* <pre>
* 0不需要semi ack 给mysql
* 1需要semi ack给mysql
* </pre>
*/
protected int semival;
protected int semival;

View File

@@ -13,35 +13,30 @@ 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
private long gtid;
if flag & FL_GROUP_COMMIT_ID
uint<8> commit_id
else
uint<6> 0
/**
* <pre>
* 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
* </pre>
*/
*
*/
public MariaGtidLogEvent(LogHeader header, LogBuffer buffer, FormatDescriptionLogEvent descriptionEvent){
super(header, buffer, descriptionEvent);
gtid=buffer.getUlong64().longValue();
gtid = buffer.getUlong64().longValue();
// do nothing , just ignore log event
}
public long getGtid() {
return gtid;
}
public long getGtid() {
return gtid;
}
}