mirror of
https://github.com/alibaba/canal.git
synced 2026-11-04 00:30:15 +08:00
fixed semi sync format & refactor
This commit is contained in:
@@ -108,8 +108,10 @@ public final class LogDecoder {
|
||||
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 */
|
||||
|
||||
@@ -361,7 +361,12 @@ 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;
|
||||
|
||||
|
||||
@@ -16,21 +16,17 @@ public class MariaGtidLogEvent extends IgnorableLogEvent {
|
||||
private long gtid;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* mariadb gtidlog event format
|
||||
* uint<8> GTID sequence
|
||||
* uint<4> Replication Domain ID
|
||||
* uint<1> Flags
|
||||
*
|
||||
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
|
||||
|
||||
*
|
||||
* if flag & FL_GROUP_COMMIT_ID
|
||||
* uint<8> commit_id
|
||||
* else
|
||||
* uint<6> 0
|
||||
* </pre>
|
||||
*/
|
||||
|
||||
public MariaGtidLogEvent(LogHeader header, LogBuffer buffer, FormatDescriptionLogEvent descriptionEvent){
|
||||
@@ -43,5 +39,4 @@ public class MariaGtidLogEvent extends IgnorableLogEvent {
|
||||
return gtid;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -10,13 +10,12 @@ import com.alibaba.otter.canal.parse.driver.mysql.utils.ByteHelper;
|
||||
|
||||
/**
|
||||
* semi ack command
|
||||
* @author amos_chen
|
||||
*
|
||||
* @author amos_chen
|
||||
*/
|
||||
public class SemiAckCommandPacket extends CommandPacket {
|
||||
|
||||
public long binlogPosition;
|
||||
|
||||
public String binlogFileName;
|
||||
|
||||
public SemiAckCommandPacket(){
|
||||
@@ -25,8 +24,6 @@ public class SemiAckCommandPacket extends CommandPacket {
|
||||
|
||||
@Override
|
||||
public void fromBytes(byte[] data) throws IOException {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -25,7 +25,6 @@ import com.alibaba.otter.canal.parse.support.AuthenticationInfo;
|
||||
import com.taobao.tddl.dbsync.binlog.LogContext;
|
||||
import com.taobao.tddl.dbsync.binlog.LogDecoder;
|
||||
import com.taobao.tddl.dbsync.binlog.LogEvent;
|
||||
import com.taobao.tddl.dbsync.binlog.event.RotateLogEvent;
|
||||
|
||||
public class MysqlConnection implements ErosaConnection {
|
||||
|
||||
@@ -37,8 +36,6 @@ public class MysqlConnection implements ErosaConnection {
|
||||
private BinlogFormat binlogFormat;
|
||||
private BinlogImage binlogImage;
|
||||
|
||||
private String binlogfilename;
|
||||
|
||||
// tsdb releated
|
||||
private AuthenticationInfo authInfo;
|
||||
protected int connTimeout = 5 * 1000; // 5秒
|
||||
@@ -146,17 +143,12 @@ public class MysqlConnection implements ErosaConnection {
|
||||
throw new CanalParseException("parse failed");
|
||||
}
|
||||
|
||||
//binlog日志文件发生变化
|
||||
if(event.getHeader().getType()==LogEvent.ROTATE_EVENT){
|
||||
binlogfilename=((RotateLogEvent)event).getFilename();
|
||||
}
|
||||
|
||||
if (!func.sink(event)) {
|
||||
break;
|
||||
}else{
|
||||
if(event.getSemival()==1){
|
||||
sendSemiAck(binlogfilename, binlogPosition);
|
||||
}
|
||||
|
||||
if (event.getSemival() == 1) {
|
||||
sendSemiAck(context.getLogPosition().getFileName(), binlogPosition);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user