|
@@ -14,27 +14,30 @@ import com.alibaba.otter.canal.parse.inbound.AbstractEventParser;
|
|
|
import com.alibaba.otter.canal.parse.inbound.BinlogParser;
|
|
|
import com.alibaba.otter.canal.parse.inbound.MultiStageCoprocessor;
|
|
|
import com.alibaba.otter.canal.parse.inbound.mysql.dbsync.LogEventConvert;
|
|
|
+import com.alibaba.otter.canal.parse.inbound.mysql.tsdb.DefaultTableMetaTSDBFactory;
|
|
|
import com.alibaba.otter.canal.parse.inbound.mysql.tsdb.TableMetaTSDB;
|
|
|
-import com.alibaba.otter.canal.parse.inbound.mysql.tsdb.TableMetaTSDBBuilder;
|
|
|
+import com.alibaba.otter.canal.parse.inbound.mysql.tsdb.TableMetaTSDBFactory;
|
|
|
import com.alibaba.otter.canal.protocol.position.EntryPosition;
|
|
|
|
|
|
public abstract class AbstractMysqlEventParser extends AbstractEventParser {
|
|
|
|
|
|
- protected final Logger logger = LoggerFactory.getLogger(this.getClass());
|
|
|
- protected static final long BINLOG_START_OFFEST = 4L;
|
|
|
+ protected final Logger logger = LoggerFactory.getLogger(this.getClass());
|
|
|
+ protected static final long BINLOG_START_OFFEST = 4L;
|
|
|
+
|
|
|
+ protected TableMetaTSDBFactory tableMetaTSDBFactory = new DefaultTableMetaTSDBFactory();
|
|
|
+ protected boolean enableTsdb = false;
|
|
|
+ protected String tsdbSpringXml;
|
|
|
+ protected TableMetaTSDB tableMetaTSDB;
|
|
|
|
|
|
- protected boolean enableTsdb = false;
|
|
|
- protected String tsdbSpringXml;
|
|
|
- protected TableMetaTSDB tableMetaTSDB;
|
|
|
// 编码信息
|
|
|
- protected byte connectionCharsetNumber = (byte) 33;
|
|
|
- protected Charset connectionCharset = Charset.forName("UTF-8");
|
|
|
- protected boolean filterQueryDcl = false;
|
|
|
- protected boolean filterQueryDml = false;
|
|
|
- protected boolean filterQueryDdl = false;
|
|
|
- protected boolean filterRows = false;
|
|
|
- protected boolean filterTableError = false;
|
|
|
- protected boolean useDruidDdlFilter = true;
|
|
|
+ protected byte connectionCharsetNumber = (byte) 33;
|
|
|
+ protected Charset connectionCharset = Charset.forName("UTF-8");
|
|
|
+ protected boolean filterQueryDcl = false;
|
|
|
+ protected boolean filterQueryDml = false;
|
|
|
+ protected boolean filterQueryDdl = false;
|
|
|
+ protected boolean filterRows = false;
|
|
|
+ protected boolean filterTableError = false;
|
|
|
+ protected boolean useDruidDdlFilter = true;
|
|
|
|
|
|
protected BinlogParser buildParser() {
|
|
|
LogEventConvert convert = new LogEventConvert();
|
|
@@ -97,7 +100,7 @@ public abstract class AbstractMysqlEventParser extends AbstractEventParser {
|
|
|
// 设置当前正在加载的通道,加载spring查找文件时会用到该变量
|
|
|
System.setProperty("canal.instance.destination", destination);
|
|
|
// 初始化
|
|
|
- tableMetaTSDB = TableMetaTSDBBuilder.build(destination, tsdbSpringXml);
|
|
|
+ tableMetaTSDB = tableMetaTSDBFactory.build(destination, tsdbSpringXml);
|
|
|
} finally {
|
|
|
System.setProperty("canal.instance.destination", "");
|
|
|
}
|
|
@@ -110,7 +113,7 @@ public abstract class AbstractMysqlEventParser extends AbstractEventParser {
|
|
|
|
|
|
public void stop() throws CanalParseException {
|
|
|
if (enableTsdb) {
|
|
|
- TableMetaTSDBBuilder.destory(destination);
|
|
|
+ tableMetaTSDBFactory.destory(destination);
|
|
|
tableMetaTSDB = null;
|
|
|
}
|
|
|
|
|
@@ -182,7 +185,7 @@ public abstract class AbstractMysqlEventParser extends AbstractEventParser {
|
|
|
if (this.enableTsdb) {
|
|
|
if (tableMetaTSDB == null) {
|
|
|
// 初始化
|
|
|
- tableMetaTSDB = TableMetaTSDBBuilder.build(destination, tsdbSpringXml);
|
|
|
+ tableMetaTSDB = tableMetaTSDBFactory.build(destination, tsdbSpringXml);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -192,9 +195,13 @@ public abstract class AbstractMysqlEventParser extends AbstractEventParser {
|
|
|
if (this.enableTsdb) {
|
|
|
if (tableMetaTSDB == null) {
|
|
|
// 初始化
|
|
|
- tableMetaTSDB = TableMetaTSDBBuilder.build(destination, tsdbSpringXml);
|
|
|
+ tableMetaTSDB = tableMetaTSDBFactory.build(destination, tsdbSpringXml);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public void setTableMetaTSDBFactory(TableMetaTSDBFactory tableMetaTSDBFactory) {
|
|
|
+ this.tableMetaTSDBFactory = tableMetaTSDBFactory;
|
|
|
+ }
|
|
|
+
|
|
|
}
|