mirror of
https://github.com/alibaba/canal.git
synced 2026-11-04 00:30:15 +08:00
specified mq dynamic topic
This commit is contained in:
@@ -189,7 +189,7 @@ public class RdbSyncService {
|
||||
} else if (type != null && type.equalsIgnoreCase("DELETE")) {
|
||||
delete(batchExecutor, config, dml);
|
||||
} else if (type != null && type.equalsIgnoreCase("TRUNCATE")) {
|
||||
truncate(batchExecutor, config, dml);
|
||||
truncate(batchExecutor, config);
|
||||
}
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("DML: {}", JSON.toJSONString(dml, SerializerFeature.WriteMapNullValue));
|
||||
@@ -353,15 +353,13 @@ public class RdbSyncService {
|
||||
*
|
||||
* @param config
|
||||
*/
|
||||
private void truncate(BatchExecutor batchExecutor, MappingConfig config, SingleDml dml) throws SQLException {
|
||||
if (dml.getIsTruncate()) {
|
||||
DbMapping dbMapping = config.getDbMapping();
|
||||
StringBuilder sql = new StringBuilder();
|
||||
sql.append("TRUNCATE TABLE ").append(SyncUtil.getDbTableName(dbMapping));
|
||||
batchExecutor.execute(sql.toString(), new ArrayList<>());
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("Truncate target table, sql: {}", sql);
|
||||
}
|
||||
private void truncate(BatchExecutor batchExecutor, MappingConfig config) throws SQLException {
|
||||
DbMapping dbMapping = config.getDbMapping();
|
||||
StringBuilder sql = new StringBuilder();
|
||||
sql.append("TRUNCATE TABLE ").append(SyncUtil.getDbTableName(dbMapping));
|
||||
batchExecutor.execute(sql.toString(), new ArrayList<>());
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("Truncate target table, sql: {}", sql);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@ public class SingleDml {
|
||||
private String type;
|
||||
private Map<String, Object> data;
|
||||
private Map<String, Object> old;
|
||||
private boolean isTruncate = false;
|
||||
|
||||
public String getDestination() {
|
||||
return destination;
|
||||
@@ -64,18 +63,10 @@ public class SingleDml {
|
||||
this.old = old;
|
||||
}
|
||||
|
||||
public boolean getIsTruncate() {
|
||||
return isTruncate;
|
||||
}
|
||||
|
||||
public void setIsTruncate(boolean isTruncate) {
|
||||
this.isTruncate = isTruncate;
|
||||
}
|
||||
|
||||
public static List<SingleDml> dml2SingleDmls(Dml dml) {
|
||||
int size = dml.getData() == null ? 0 : dml.getData().size();
|
||||
List<SingleDml> singleDmls = new ArrayList<>();
|
||||
if (size > 0) {
|
||||
if (dml.getData() != null) {
|
||||
int size = dml.getData().size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
SingleDml singleDml = new SingleDml();
|
||||
singleDml.setDestination(dml.getDestination());
|
||||
@@ -94,7 +85,6 @@ public class SingleDml {
|
||||
singleDml.setDatabase(dml.getDatabase());
|
||||
singleDml.setTable(dml.getTable());
|
||||
singleDml.setType(dml.getType());
|
||||
singleDml.setIsTruncate(true);
|
||||
singleDmls.add(singleDml);
|
||||
}
|
||||
return singleDmls;
|
||||
|
||||
Reference in New Issue
Block a user