mq模式下adapter配置增加groupId属性对应

This commit is contained in:
mcy
2019-02-01 15:18:16 +08:00
parent 597a08ac37
commit 10276e254a
7 changed files with 33 additions and 35 deletions

View File

@@ -86,8 +86,9 @@ public class RdbAdapter implements OuterAdapter {
String configName = entry.getKey();
MappingConfig mappingConfig = entry.getValue();
if (!mappingConfig.getDbMapping().getMirrorDb()) {
String key = StringUtils.trimToEmpty(mappingConfig.getDestination()) + "."
+ mappingConfig.getDbMapping().getDatabase() + "."
String key = StringUtils.trimToEmpty(mappingConfig.getDestination()) + "-"
+ StringUtils.trimToEmpty(mappingConfig.getGroupId()) + "_"
+ mappingConfig.getDbMapping().getDatabase() + "-"
+ mappingConfig.getDbMapping().getTable();
Map<String, MappingConfig> configMap = mappingConfigCache.computeIfAbsent(key,
k1 -> new ConcurrentHashMap<>());

View File

@@ -147,9 +147,11 @@ public class RdbSyncService {
} else {
// DML
String destination = StringUtils.trimToEmpty(dml.getDestination());
String groupId = StringUtils.trimToEmpty(dml.getGroupId());
String database = dml.getDatabase();
String table = dml.getTable();
Map<String, MappingConfig> configMap = mappingConfig.get(destination + "." + database + "." + table);
Map<String, MappingConfig> configMap = mappingConfig
.get(destination + "-" + groupId + "_" + database + "-" + table);
if (configMap == null) {
return false;
@@ -169,7 +171,6 @@ public class RdbSyncService {
return false;
}
boolean executed = false;
for (MappingConfig config : configs) {
if (config.getConcurrent()) {
List<SingleDml> singleDmls = SingleDml.dml2SingleDmls(dml);
@@ -186,9 +187,8 @@ public class RdbSyncService {
dmlsPartition[hash].add(syncItem);
});
}
executed = true;
}
return executed;
return true;
}
});
}

View File

@@ -1,11 +1,12 @@
dataSourceKey: defaultDS
destination: example
outerAdapterKey: oracle1
groupId: g1
outerAdapterKey: mysql1
concurrent: true
dbMapping:
database: mytest
table: user
targetTable: mytest.tb_user
targetTable: mytest2.user
targetPk:
id: id
# mapAll: true
@@ -17,9 +18,10 @@ dbMapping:
test1:
# Mirror schema synchronize config
## Mirror schema synchronize config
#dataSourceKey: defaultDS
#destination: example
#groupId: g1
#outerAdapterKey: mysql1
#concurrent: true
#dbMapping: