浏览代码

fix

Signed-off-by: AE86 <836391306@qq.com>
AE86 1 年之前
父节点
当前提交
a11404eae8

+ 4 - 3
dbsyncer-connector/dbsyncer-connector-base/src/test/java/ConnectionTest.java

@@ -235,15 +235,16 @@ public class ConnectionTest {
 
         long begin = Instant.now().toEpochMilli();
         final int threadSize = 10;
-        final int num = 100;
-        final int batch = 100;
+        final int num = 10;
+        final int batch = 2;
         final ExecutorService pool = Executors.newFixedThreadPool(threadSize);
         final CountDownLatch latch = new CountDownLatch(threadSize);
         final String insert = "INSERT INTO `vote_records_test` (`id`, `user_id`, `vote_num`, `group_id`, `status`, `create_time`) VALUES (?, ?, ?, ?, ?, ?)";
         final String update = "UPDATE `test`.`vote_records_test` SET `user_id` = ?, `create_time` = now() WHERE `id` = ?";
         final String delete = "DELETE from `test`.`vote_records_test` WHERE `id` = ?";
 
-        logger.info("-----------------模拟总数:{}", threadSize * threadSize * num);
+        // 模拟单表增删改事件,每个事件间隔2条数据
+        logger.info("-----------------模拟总数:{}", threadSize * batch * num * 3);
         for (int i = 0; i < threadSize; i++) {
             final int offset = i == 0 ? 0 : i * threadSize;
             pool.submit(() -> {

+ 1 - 11
dbsyncer-sdk/src/main/java/org/dbsyncer/sdk/util/PrimaryKeyUtil.java

@@ -37,7 +37,7 @@ public abstract class PrimaryKeyUtil {
         }
 
         // 获取表同步的主键字段
-        List<String> primaryKeys = findPrimaryKeys(table.getColumn());
+        List<String> primaryKeys = findPrimaryKeyFields(table.getColumn()).stream().map(f -> f.getName()).collect(Collectors.toList());
 
         // 如果存在表字段映射关系,没有配置主键则抛出异常提示
         if (!CollectionUtils.isEmpty(table.getColumn()) && CollectionUtils.isEmpty(primaryKeys)) {
@@ -46,16 +46,6 @@ public abstract class PrimaryKeyUtil {
         return primaryKeys;
     }
 
-    /**
-     * 返回主键名称
-     *
-     * @param fields
-     * @return
-     */
-    public static List<String> findPrimaryKeys(List<Field> fields) {
-        return findPrimaryKeyFields(fields).stream().map(f -> f.getName()).collect(Collectors.toList());
-    }
-
     /**
      * 返回主键属性字段集合
      *