mirror of
https://github.com/alibaba/canal.git
synced 2026-11-04 00:30:15 +08:00
add support for polardbx multi binlog streams (#4660)
* AbstractCanalInstance的subscribeChange方法,增加对AbstractEventParser的类型判断,以支持用户的自定义CanalEventParser * MysqlEventParser对Gtid模式的处理需要考虑兼容性,支持系统平滑的从非gtid模式升级为gtid模式 * add support for polardbx multi binlog streams #4657 * support auto generate instance names #4657
This commit is contained in:
@@ -72,6 +72,8 @@ public class MysqlEventParser extends AbstractMysqlEventParser implements CanalE
|
||||
private boolean autoResetLatestPosMode = false; // true:
|
||||
// binlog被删除之后,自动按最新的数据订阅
|
||||
|
||||
private boolean multiStreamEnable;//support for polardbx binlog-x
|
||||
|
||||
protected ErosaConnection buildErosaConnection() {
|
||||
return buildMysqlConnection(this.runningInfo);
|
||||
}
|
||||
@@ -666,10 +668,12 @@ public class MysqlEventParser extends AbstractMysqlEventParser implements CanalE
|
||||
*/
|
||||
private EntryPosition findEndPosition(MysqlConnection mysqlConnection) {
|
||||
try {
|
||||
ResultSetPacket packet = mysqlConnection.query("show master status");
|
||||
String showSql = multiStreamEnable ? "show master status with " + destination : "show master status";
|
||||
ResultSetPacket packet = mysqlConnection.query(showSql);
|
||||
List<String> fields = packet.getFieldValues();
|
||||
if (CollectionUtils.isEmpty(fields)) {
|
||||
throw new CanalParseException("command : 'show master status' has an error! pls check. you need (at least one of) the SUPER,REPLICATION CLIENT privilege(s) for this operation");
|
||||
throw new CanalParseException(
|
||||
"command : 'show master status' has an error! pls check. you need (at least one of) the SUPER,REPLICATION CLIENT privilege(s) for this operation");
|
||||
}
|
||||
EntryPosition endPosition = new EntryPosition(fields.get(0), Long.valueOf(fields.get(1)));
|
||||
if (isGTIDMode() && fields.size() > 4) {
|
||||
@@ -694,10 +698,13 @@ public class MysqlEventParser extends AbstractMysqlEventParser implements CanalE
|
||||
*/
|
||||
private EntryPosition findStartPosition(MysqlConnection mysqlConnection) {
|
||||
try {
|
||||
ResultSetPacket packet = mysqlConnection.query("show binlog events limit 1");
|
||||
String showSql = multiStreamEnable ?
|
||||
"show binlog events with " + destination + " limit 1" : "show binlog events limit 1";
|
||||
ResultSetPacket packet = mysqlConnection.query(showSql);
|
||||
List<String> fields = packet.getFieldValues();
|
||||
if (CollectionUtils.isEmpty(fields)) {
|
||||
throw new CanalParseException("command : 'show binlog events limit 1' has an error! pls check. you need (at least one of) the SUPER,REPLICATION CLIENT privilege(s) for this operation");
|
||||
throw new CanalParseException(
|
||||
"command : 'show binlog events limit 1' has an error! pls check. you need (at least one of) the SUPER,REPLICATION CLIENT privilege(s) for this operation");
|
||||
}
|
||||
EntryPosition endPosition = new EntryPosition(fields.get(0), Long.valueOf(fields.get(1)));
|
||||
return endPosition;
|
||||
@@ -966,4 +973,8 @@ public class MysqlEventParser extends AbstractMysqlEventParser implements CanalE
|
||||
public void setAutoResetLatestPosMode(boolean autoResetLatestPosMode) {
|
||||
this.autoResetLatestPosMode = autoResetLatestPosMode;
|
||||
}
|
||||
|
||||
public void setMultiStreamEnable(boolean multiStreamEnable) {
|
||||
this.multiStreamEnable = multiStreamEnable;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user