Ver código fonte

!323 merge
Merge pull request !323 from AE86/v_2.0

AE86 4 meses atrás
pai
commit
ad281ecbaa
14 arquivos alterados com 20 adições e 51 exclusões
  1. 1 3
      README.md
  2. 8 10
      dbsyncer-connector/dbsyncer-connector-mysql/src/main/java/org/dbsyncer/connector/mysql/cdc/MySQLListener.java
  3. 1 5
      dbsyncer-connector/dbsyncer-connector-mysql/src/main/java/org/dbsyncer/connector/mysql/schema/support/MySQLDecimalType.java
  4. 1 8
      dbsyncer-connector/dbsyncer-connector-mysql/src/main/java/org/dbsyncer/connector/mysql/schema/support/MySQLDoubleType.java
  5. 2 6
      dbsyncer-connector/dbsyncer-connector-mysql/src/main/java/org/dbsyncer/connector/mysql/schema/support/MySQLFloatType.java
  6. 0 5
      dbsyncer-connector/dbsyncer-connector-mysql/src/main/java/org/dbsyncer/connector/mysql/schema/support/MySQLIntType.java
  7. 1 3
      dbsyncer-connector/dbsyncer-connector-mysql/src/main/java/org/dbsyncer/connector/mysql/schema/support/MySQLLongType.java
  8. 0 1
      dbsyncer-connector/dbsyncer-connector-mysql/src/main/java/org/dbsyncer/connector/mysql/schema/support/MySQLShortType.java
  9. 1 1
      dbsyncer-parser/src/main/java/org/dbsyncer/parser/consumer/impl/LogConsumer.java
  10. 1 1
      dbsyncer-parser/src/main/java/org/dbsyncer/parser/consumer/impl/QuartzConsumer.java
  11. 1 1
      dbsyncer-parser/src/main/java/org/dbsyncer/parser/flush/impl/TableGroupBufferActuator.java
  12. 1 1
      dbsyncer-sdk/src/main/java/org/dbsyncer/sdk/enums/ChangedEventTypeEnum.java
  13. 0 6
      dbsyncer-sdk/src/main/java/org/dbsyncer/sdk/schema/support/DecimalType.java
  14. 2 0
      dbsyncer-web/src/main/java/org/dbsyncer/web/Application.java

+ 1 - 3
README.md

@@ -108,7 +108,5 @@ $ ./build.sh
 4) 开源不易,感谢粉丝朋友们的支持![【捐赠者名单】](https://gitee.com/ghi/dbsyncer/issues/I4HL3C) 
 
 <p>
-<img src="https://foruda.gitee.com/images/1734712597822804473/12d5531f_376718.png" title="微信扫码" width="258px" height="290px" />
-<img src="https://foruda.gitee.com/images/1734712794453541544/e3f937fb_376718.png" title="微信扫码" width="265px" height="310px" />
-<img src="https://foruda.gitee.com/images/1710433659737550167/452d76c9_376718.png" title="DBSyncer款项用于研发推广" width="265px" height="340px" />
+<img src="https://foruda.gitee.com/images/1736348493470674811/5761f9e8_13999669.png "二维码_01.png"" title="微信扫码" width="258px" height="283.8px" /><img src="https://foruda.gitee.com/images/1736348568894927308/12fe6e2d_13999669.png "二维码_02.png"" title="微信扫码" width="258px" height="283.8px" /><img src="https://foruda.gitee.com/images/1710433659737550167/452d76c9_376718.png" title="DBSyncer款项用于研发推广" width="223.2px" height="286.4px" />
 <p>

+ 8 - 10
dbsyncer-connector/dbsyncer-connector-mysql/src/main/java/org/dbsyncer/connector/mysql/cdc/MySQLListener.java

@@ -61,10 +61,8 @@ public class MySQLListener extends AbstractDatabaseListener {
 
     private final String BINLOG_FILENAME = "fileName";
     private final String BINLOG_POSITION = "position";
-    private final int MASTER = 0;
-    private Map<Long, TableMapEventData> tables = new HashMap<>();
+    private final Map<Long, TableMapEventData> tables = new HashMap<>();
     private BinaryLogClient client;
-    private List<Host> cluster;
     private String database;
     private final Lock connectLock = new ReentrantLock();
 
@@ -110,9 +108,10 @@ public class MySQLListener extends AbstractDatabaseListener {
             throw new MySQLException("url is invalid");
         }
         database = DatabaseUtil.getDatabaseName(config.getUrl());
-        cluster = readNodes(config.getUrl());
+        List<Host> cluster = readNodes(config.getUrl());
         Assert.notEmpty(cluster, "MySQL连接地址有误.");
 
+        int MASTER = 0;
         final Host host = cluster.get(MASTER);
         final String username = config.getUsername();
         final String password = config.getPassword();
@@ -141,9 +140,8 @@ public class MySQLListener extends AbstractDatabaseListener {
 
         List<Host> cluster = new ArrayList<>();
         String[] arr = StringUtil.split(url, ",");
-        int size = arr.length;
-        for (int i = 0; i < size; i++) {
-            String[] host = StringUtil.split(arr[i], ":");
+        for (String s : arr) {
+            String[] host = StringUtil.split(s, ":");
             if (2 == host.length) {
                 cluster.add(new Host(host[0], Integer.parseInt(host[1])));
             }
@@ -190,9 +188,9 @@ public class MySQLListener extends AbstractDatabaseListener {
         }
     }
 
-    final class Host {
-        private String ip;
-        private int port;
+    static final class Host {
+        private final String ip;
+        private final int port;
 
         public Host(String ip, int port) {
             this.ip = ip;

+ 1 - 5
dbsyncer-connector/dbsyncer-connector-mysql/src/main/java/org/dbsyncer/connector/mysql/schema/support/MySQLDecimalType.java

@@ -21,11 +21,7 @@ public final class MySQLDecimalType extends DecimalType {
     private enum TypeEnum {
         DECIMAL("DECIMAL"),
         DECIMAL_UNSIGNED("DECIMAL UNSIGNED"),
-        BIGINT_UNSIGNED("BIGINT UNSIGNED"),
-        BIGINT_UNSIGNED_ZEROFILL("BIGINT UNSIGNED ZEROFILL"),
-        NUMERIC("NUMERIC"),
-        NUMERIC_UNSIGNED("NUMERIC UNSIGNED"),
-        NUMERIC_UNSIGNED_ZEROFILL("NUMERIC UNSIGNED ZEROFILL");
+        BIGINT_UNSIGNED("BIGINT UNSIGNED");
 
         private final String value;
 

+ 1 - 8
dbsyncer-connector/dbsyncer-connector-mysql/src/main/java/org/dbsyncer/connector/mysql/schema/support/MySQLDoubleType.java

@@ -19,14 +19,7 @@ public final class MySQLDoubleType extends DoubleType {
 
     private enum TypeEnum {
         DOUBLE("DOUBLE"),
-        DOUBLE_UNSIGNED("DOUBLE UNSIGNED"),
-        DOUBLE_UNSIGNED_ZEROFILL("DOUBLE UNSIGNED ZEROFILL"),
-        DOUBLE_PRECISION("DOUBLE PRECISION"),
-        DOUBLE_PRECISION_UNSIGNED("DOUBLE PRECISION UNSIGNED"),
-        DOUBLE_PRECISION_UNSIGNED_ZEROFILL("DOUBLE PRECISION UNSIGNED ZEROFILL"),
-        REAL("REAL"),
-        REAL_UNSIGNED("REAL UNSIGNED"),
-        REAL_UNSIGNED_ZEROFILL("REAL UNSIGNED ZEROFILL");
+        DOUBLE_UNSIGNED("DOUBLE UNSIGNED");
 
         private final String value;
 

+ 2 - 6
dbsyncer-connector/dbsyncer-connector-mysql/src/main/java/org/dbsyncer/connector/mysql/schema/support/MySQLFloatType.java

@@ -19,8 +19,7 @@ public final class MySQLFloatType extends FloatType {
 
     private enum TypeEnum {
         FLOAT("FLOAT"),
-        FLOAT_UNSIGNED("FLOAT UNSIGNED"),
-        FLOAT_UNSIGNED_ZEROFILL("FLOAT UNSIGNED ZEROFILL");
+        FLOAT_UNSIGNED("FLOAT UNSIGNED");
 
         private final String value;
 
@@ -40,16 +39,13 @@ public final class MySQLFloatType extends FloatType {
 
     @Override
     protected Float merge(Object val, Field field) {
-        if (val instanceof Number) {
-            return ((Number) val).floatValue();
-        }
         return throwUnsupportedException(val, field);
     }
 
     @Override
     protected Object convert(Object val, Field field) {
         if (val instanceof Number) {
-            return ((Number) val).shortValue();
+            return ((Number) val).floatValue();
         }
         return throwUnsupportedException(val, field);
     }

+ 0 - 5
dbsyncer-connector/dbsyncer-connector-mysql/src/main/java/org/dbsyncer/connector/mysql/schema/support/MySQLIntType.java

@@ -21,10 +21,8 @@ public final class MySQLIntType extends IntType {
 
     private enum TypeEnum {
         SMALLINT_UNSIGNED("SMALLINT UNSIGNED"),
-        SMALLINT_UNSIGNED_ZEROFILL("SMALLINT UNSIGNED ZEROFILL"),
         MEDIUMINT("MEDIUMINT"),
         MEDIUMINT_UNSIGNED("MEDIUMINT UNSIGNED"),
-        MEDIUMINT_UNSIGNED_ZEROFILL("MEDIUMINT UNSIGNED ZEROFILL"),
         INT("INT"),
         INTEGER("INTEGER"),
         YEAR("YEAR");
@@ -53,9 +51,6 @@ public final class MySQLIntType extends IntType {
             calendar.setTime(d);
             return calendar.get(Calendar.YEAR);
         }
-        if (val instanceof Number) {
-            return ((Number) val).intValue();
-        }
         return throwUnsupportedException(val, field);
     }
 

+ 1 - 3
dbsyncer-connector/dbsyncer-connector-mysql/src/main/java/org/dbsyncer/connector/mysql/schema/support/MySQLLongType.java

@@ -19,9 +19,7 @@ public final class MySQLLongType extends LongType {
 
     private enum TypeEnum {
         BIGINT("BIGINT"),
-        INT_UNSIGNED("INT UNSIGNED"),
-        INT_UNSIGNED_ZEROFILL("INT UNSIGNED ZEROFILL"),
-        INTEGER_UNSIGNED("INTEGER UNSIGNED");
+        INT_UNSIGNED("INT UNSIGNED");
 
         private final String value;
 

+ 0 - 1
dbsyncer-connector/dbsyncer-connector-mysql/src/main/java/org/dbsyncer/connector/mysql/schema/support/MySQLShortType.java

@@ -19,7 +19,6 @@ public final class MySQLShortType extends ShortType {
 
     private enum TypeEnum {
         TINYINT_UNSIGNED("TINYINT UNSIGNED"),
-        TINYINT_UNSIGNED_ZEROFILL("TINYINT UNSIGNED ZEROFILL"),
         SMALLINT("SMALLINT");
 
         private final String value;

+ 1 - 1
dbsyncer-parser/src/main/java/org/dbsyncer/parser/consumer/impl/LogConsumer.java

@@ -27,7 +27,7 @@ import java.util.function.Consumer;
  * @Date 2023-11-12 02:25
  */
 public final class LogConsumer extends AbstractConsumer<RowChangedEvent> {
-    private Map<String, List<FieldPicker>> tablePicker = new LinkedHashMap<>();
+    private final Map<String, List<FieldPicker>> tablePicker = new LinkedHashMap<>();
 
     //判断上次是否为ddl,是ddl需要强制刷新下picker
     private boolean ddlChanged;

+ 1 - 1
dbsyncer-parser/src/main/java/org/dbsyncer/parser/consumer/impl/QuartzConsumer.java

@@ -20,7 +20,7 @@ import java.util.List;
  * @Date 2023-11-12 02:18
  */
 public final class QuartzConsumer extends AbstractConsumer<ScanChangedEvent> {
-    private List<FieldPicker> tablePicker = new LinkedList<>();
+    private final List<FieldPicker> tablePicker = new LinkedList<>();
 
     @Override
     public void postProcessBeforeInitialization() {

+ 1 - 1
dbsyncer-parser/src/main/java/org/dbsyncer/parser/flush/impl/TableGroupBufferActuator.java

@@ -61,7 +61,7 @@ public class TableGroupBufferActuator extends GeneralBufferActuator implements C
         int coreSize = tableGroupBufferConfig.getThreadCoreSize();
         int maxSize = tableGroupBufferConfig.getMaxThreadSize();
         int queueCapacity = tableGroupBufferConfig.getThreadQueueCapacity();
-        String threadNamePrefix = new StringBuilder("TableGroupExecutor-").append(tableGroupId).append(StringUtil.SYMBOL).toString();
+        String threadNamePrefix = "TableGroupExecutor-" + tableGroupId + StringUtil.SYMBOL;
         threadPoolTaskExecutor = ThreadPoolUtil.newThreadPoolTaskExecutor(coreSize, maxSize, queueCapacity, 30, threadNamePrefix);
         running = true;
         scheduledTaskService.start(taskKey, tableGroupBufferConfig.getBufferPeriodMillisecond(), this);

+ 1 - 1
dbsyncer-sdk/src/main/java/org/dbsyncer/sdk/enums/ChangedEventTypeEnum.java

@@ -22,7 +22,7 @@ public enum ChangedEventTypeEnum {
     ROW;
 
     public static boolean isDDL(ChangedEventTypeEnum event) {
-        return event != null && DDL == event;
+        return DDL == event;
     }
 
 }

+ 0 - 6
dbsyncer-sdk/src/main/java/org/dbsyncer/sdk/schema/support/DecimalType.java

@@ -15,12 +15,6 @@ import java.math.BigDecimal;
  */
 public abstract class DecimalType extends AbstractDataType<BigDecimal> {
 
-    // 精度:表示数值的总位数,包括小数点前后的位数。例如,数值 123.45 的精度是 5,因为它有 5 位数字。
-    private int precision;
-
-    // 刻度:表示小数点后的位数。例如,数值 123.45 的刻度是 2,因为小数点后有 2 位数字。
-    private int scale;
-
     @Override
     public DataTypeEnum getType() {
         return DataTypeEnum.DECIMAL;

+ 2 - 0
dbsyncer-web/src/main/java/org/dbsyncer/web/Application.java

@@ -15,6 +15,7 @@ import org.springframework.scheduling.annotation.EnableAsync;
 import org.springframework.scheduling.annotation.EnableScheduling;
 
 import java.io.IOException;
+import java.time.LocalDateTime;
 import java.time.ZoneId;
 import java.util.Properties;
 
@@ -41,6 +42,7 @@ public class Application {
             properties.put("info.app.build.time", buildTime);
         }
         properties.put("info.app.version", version);
+        properties.put("info.app.start.time", LocalDateTime.now().format(DateFormatUtil.CHINESE_STANDARD_TIME_FORMATTER));
         properties.put("spring.thymeleaf.prefix", "classpath:/public/");
         properties.put("management.endpoints.web.base-path", "/app");
         properties.put("management.endpoints.web.exposure.include", "*");