merge code

This commit is contained in:
jianghang.loujh
2025-12-25 11:54:25 +08:00
parent 8a4199a7b0
commit c0619c4217
2 changed files with 19 additions and 26 deletions

View File

@@ -76,6 +76,5 @@ public class MariaGtid {
sb.append(domainId).append("-"); sb.append(domainId).append("-");
sb.append(serverId).append("-"); sb.append(serverId).append("-");
return sb.append(sequence).toString(); return sb.append(sequence).toString();
// return String.format("%s-%s-%s", domainId, serverId, sequence);
} }
} }

View File

@@ -18,11 +18,7 @@ import com.alibaba.otter.canal.parse.inbound.ErosaConnection;
import com.alibaba.otter.canal.parse.inbound.MultiStageCoprocessor; import com.alibaba.otter.canal.parse.inbound.MultiStageCoprocessor;
import com.alibaba.otter.canal.parse.inbound.SinkFunction; import com.alibaba.otter.canal.parse.inbound.SinkFunction;
import com.alibaba.otter.canal.parse.inbound.mysql.local.BinLogFileQueue; import com.alibaba.otter.canal.parse.inbound.mysql.local.BinLogFileQueue;
import com.taobao.tddl.dbsync.binlog.FileLogFetcher; import com.taobao.tddl.dbsync.binlog.*;
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.LogPosition;
import com.taobao.tddl.dbsync.binlog.event.QueryLogEvent; import com.taobao.tddl.dbsync.binlog.event.QueryLogEvent;
/** /**
@@ -33,19 +29,16 @@ import com.taobao.tddl.dbsync.binlog.event.QueryLogEvent;
public class LocalBinLogConnection implements ErosaConnection { public class LocalBinLogConnection implements ErosaConnection {
private static final Logger logger = LoggerFactory.getLogger(LocalBinLogConnection.class); private static final Logger logger = LoggerFactory.getLogger(LocalBinLogConnection.class);
/** rdsOosMode 主从信息 */
private final Set<Long> rdsOssMasterSlaveInfo = new HashSet<>(4);
private BinLogFileQueue binlogs = null; private BinLogFileQueue binlogs = null;
private boolean needWait; private boolean needWait;
private String directory; private String directory;
private int bufferSize = 16 * 1024; private int bufferSize = 16 * 1024;
private boolean running = false; private boolean running = false;
private long serverId; private long serverId;
/** rdsOosMode binlog 的 serverId 是两个 */ /** rdsOosMode binlog 的 serverId 是两个 */
private boolean isRdsOssMode = false; private boolean isRdsOssMode = false;
/** rdsOosMode 主从信息 */
private final Set<Long> rdsOssMasterSlaveInfo = new HashSet<>(4);
private boolean firstUpdateRdsOssMasterSlave = true; private boolean firstUpdateRdsOssMasterSlave = true;
private FileParserListener parserListener; private FileParserListener parserListener;
@@ -53,6 +46,11 @@ public class LocalBinLogConnection implements ErosaConnection {
public LocalBinLogConnection(){ public LocalBinLogConnection(){
} }
public LocalBinLogConnection(String directory, boolean needWait){
this.needWait = needWait;
this.directory = directory;
}
public boolean isRdsOssMode() { public boolean isRdsOssMode() {
return isRdsOssMode; return isRdsOssMode;
} }
@@ -61,11 +59,6 @@ public class LocalBinLogConnection implements ErosaConnection {
isRdsOssMode = rdsOssMode; isRdsOssMode = rdsOssMode;
} }
public LocalBinLogConnection(String directory, boolean needWait){
this.needWait = needWait;
this.directory = directory;
}
@Override @Override
public void connect() throws IOException { public void connect() throws IOException {
if (this.binlogs == null) { if (this.binlogs == null) {
@@ -117,7 +110,7 @@ public class LocalBinLogConnection implements ErosaConnection {
List<LogEvent> iterateEvents = decoder.processIterateDecode(event, context); List<LogEvent> iterateEvents = decoder.processIterateDecode(event, context);
if (!iterateEvents.isEmpty()) { if (!iterateEvents.isEmpty()) {
// 处理compress event // 处理compress event
for(LogEvent itEvent : iterateEvents) { for (LogEvent itEvent : iterateEvents) {
if (!func.sink(itEvent)) { if (!func.sink(itEvent)) {
needContinue = false; needContinue = false;
break; break;
@@ -158,9 +151,10 @@ public class LocalBinLogConnection implements ErosaConnection {
} }
/** /**
* 1. 非 rdsOos 模式下需要要校验 serverId 是否一致 防止解析其他实例的 binlog * 1. 非 rdsOos 模式下需要要校验 serverId 是否一致 防止解析其他实例的 binlog <br/>
* 2. rdsOos 高可用模式下解析 binlog 会有两个 serverId,分别对应着主从节点 binlog解析出来的 serverId * 2. rdsOos 高可用模式下解析 binlog
* 主从的关系可能会变, 但是 serverId一直都会是这两个 serverId * 会有两个 serverId,分别对应着主从节点 binlog解析出来的 serverId 主从的关系可能会变, 但是 serverId一直都会是这两个
* serverId
* *
* @param event * @param event
*/ */