mirror of
https://github.com/alibaba/canal.git
synced 2026-11-04 00:30:15 +08:00
optimizer filter
This commit is contained in:
@@ -125,4 +125,8 @@ public class AviaterRegexFilter implements CanalEventFilter<String> {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return pattern;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ 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.DatabaseTableMeta;
|
||||
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.TableMetaTSDBFactory;
|
||||
@@ -64,9 +65,30 @@ public abstract class AbstractMysqlEventParser extends AbstractEventParser {
|
||||
super.setEventFilter(eventFilter);
|
||||
|
||||
// 触发一下filter变更
|
||||
if (eventFilter != null && eventFilter instanceof AviaterRegexFilter && binlogParser instanceof LogEventConvert) {
|
||||
if (eventFilter != null && eventFilter instanceof AviaterRegexFilter) {
|
||||
if (binlogParser instanceof LogEventConvert) {
|
||||
((LogEventConvert) binlogParser).setNameFilter((AviaterRegexFilter) eventFilter);
|
||||
}
|
||||
|
||||
if (tableMetaTSDB != null && tableMetaTSDB instanceof DatabaseTableMeta) {
|
||||
((DatabaseTableMeta) tableMetaTSDB).setFilter(eventFilter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setEventBlackFilter(CanalEventFilter eventBlackFilter) {
|
||||
super.setEventBlackFilter(eventBlackFilter);
|
||||
|
||||
// 触发一下filter变更
|
||||
if (eventBlackFilter != null && eventBlackFilter instanceof AviaterRegexFilter) {
|
||||
if (binlogParser instanceof LogEventConvert) {
|
||||
((LogEventConvert) binlogParser).setNameBlackFilter((AviaterRegexFilter) eventBlackFilter);
|
||||
}
|
||||
|
||||
if (tableMetaTSDB != null && tableMetaTSDB instanceof DatabaseTableMeta) {
|
||||
((DatabaseTableMeta) tableMetaTSDB).setBlackFilter(eventBlackFilter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -115,16 +137,6 @@ public abstract class AbstractMysqlEventParser extends AbstractEventParser {
|
||||
super.stop();
|
||||
}
|
||||
|
||||
public void setEventBlackFilter(CanalEventFilter eventBlackFilter) {
|
||||
super.setEventBlackFilter(eventBlackFilter);
|
||||
|
||||
// 触发一下filter变更
|
||||
if (eventBlackFilter != null && eventBlackFilter instanceof AviaterRegexFilter
|
||||
&& binlogParser instanceof LogEventConvert) {
|
||||
((LogEventConvert) binlogParser).setNameBlackFilter((AviaterRegexFilter) eventBlackFilter);
|
||||
}
|
||||
}
|
||||
|
||||
protected MultiStageCoprocessor buildMultiStageCoprocessor() {
|
||||
MysqlMultiStageCoprocessor mysqlMultiStageCoprocessor = new MysqlMultiStageCoprocessor(parallelBufferSize,
|
||||
parallelThreadSize,
|
||||
|
||||
@@ -506,8 +506,8 @@ public class MysqlConnection implements ErosaConnection {
|
||||
ResultSetPacket rs = null;
|
||||
try {
|
||||
rs = query("select @@global.binlog_checksum");
|
||||
} catch (IOException e) {
|
||||
throw new CanalParseException(e);
|
||||
} catch (Throwable e) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
List<String> columnValues = rs.getFieldValues();
|
||||
|
||||
@@ -974,10 +974,12 @@ public class LogEventConvert extends AbstractCanalLifeCycle implements BinlogPar
|
||||
|
||||
public void setNameFilter(AviaterRegexFilter nameFilter) {
|
||||
this.nameFilter = nameFilter;
|
||||
logger.warn("--> init table filter : " + nameFilter.toString());
|
||||
}
|
||||
|
||||
public void setNameBlackFilter(AviaterRegexFilter nameBlackFilter) {
|
||||
this.nameBlackFilter = nameBlackFilter;
|
||||
logger.warn("--> init table black filter : " + nameBlackFilter.toString());
|
||||
}
|
||||
|
||||
public void setTableMetaCache(TableMetaCache tableMetaCache) {
|
||||
|
||||
2
pom.xml
2
pom.xml
@@ -381,6 +381,7 @@
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- javadoc -->
|
||||
<!--
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
@@ -399,6 +400,7 @@
|
||||
<additionalparam>-Xdoclint:none</additionalparam>
|
||||
</configuration>
|
||||
</plugin>
|
||||
-->
|
||||
</plugins>
|
||||
<sourceDirectory>src/main/java</sourceDirectory>
|
||||
<testSourceDirectory>src/test/java</testSourceDirectory>
|
||||
|
||||
Reference in New Issue
Block a user