mirror of
https://github.com/alibaba/canal.git
synced 2026-11-04 00:30:15 +08:00
通过groupId过滤对应的adapter配置
This commit is contained in:
@@ -8,6 +8,7 @@ import java.util.regex.Pattern;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.elasticsearch.action.search.SearchResponse;
|
||||
import org.elasticsearch.client.transport.TransportClient;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
@@ -133,7 +134,19 @@ public class ESAdapter implements OuterAdapter {
|
||||
String table = dml.getTable();
|
||||
Map<String, ESSyncConfig> configMap = dbTableEsSyncConfig.get(database + "-" + table);
|
||||
if (configMap != null) {
|
||||
esSyncService.sync(configMap.values(), dml);
|
||||
List<ESSyncConfig> configs = new ArrayList<>();
|
||||
configMap.values().forEach(esConfig -> {
|
||||
if (StringUtils.isNotEmpty(esConfig.getGroupId())) {
|
||||
if (esConfig.getGroupId().equals(dml.getGroupId())) {
|
||||
configs.add(esConfig);
|
||||
}
|
||||
} else {
|
||||
configs.add(esConfig);
|
||||
}
|
||||
});
|
||||
if (!configs.isEmpty()) {
|
||||
esSyncService.sync(configs, dml);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,8 @@ public class ESSyncConfig {
|
||||
|
||||
private String outerAdapterKey; // adapter key
|
||||
|
||||
private String groupId; // group id
|
||||
|
||||
private String destination; // canal destination
|
||||
|
||||
private ESMapping esMapping;
|
||||
@@ -52,6 +54,14 @@ public class ESSyncConfig {
|
||||
this.outerAdapterKey = outerAdapterKey;
|
||||
}
|
||||
|
||||
public String getGroupId() {
|
||||
return groupId;
|
||||
}
|
||||
|
||||
public void setGroupId(String groupId) {
|
||||
this.groupId = groupId;
|
||||
}
|
||||
|
||||
public String getDestination() {
|
||||
return destination;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user