This is an automated email from the ASF dual-hosted git repository.

wanghailin pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/seatunnel.git


The following commit(s) were added to refs/heads/dev by this push:
     new 4abc80e11 [BugFix] [Connector-V2] [MySQL-CDC] serverId from int to 
long (#5033) (#5035)
4abc80e11 is described below

commit 4abc80e1116a1a742e7d161a7fd367690d443c4f
Author: 司马琦昂 <[email protected]>
AuthorDate: Tue Jul 11 15:48:45 2023 +0800

    [BugFix] [Connector-V2] [MySQL-CDC] serverId from int to long (#5033) 
(#5035)
    
    * [bugfix] change MySQL CDC serverId from int to long (#5033)
    
    * style: 🎨 optimize code style
---
 .../cdc/mysql/config/MySqlSourceConfigFactory.java |  2 +-
 .../seatunnel/cdc/mysql/config/ServerIdRange.java  | 24 +++++++++++-----------
 2 files changed, 13 insertions(+), 13 deletions(-)

diff --git 
a/seatunnel-connectors-v2/connector-cdc/connector-cdc-mysql/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/mysql/config/MySqlSourceConfigFactory.java
 
b/seatunnel-connectors-v2/connector-cdc/connector-cdc-mysql/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/mysql/config/MySqlSourceConfigFactory.java
index ef697f2e1..7317b040f 100644
--- 
a/seatunnel-connectors-v2/connector-cdc/connector-cdc-mysql/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/mysql/config/MySqlSourceConfigFactory.java
+++ 
b/seatunnel-connectors-v2/connector-cdc/connector-cdc-mysql/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/mysql/config/MySqlSourceConfigFactory.java
@@ -89,7 +89,7 @@ public class MySqlSourceConfigFactory extends 
JdbcSourceConfigFactory {
 
         if (serverIdRange != null) {
             props.setProperty("database.server.id.range", 
String.valueOf(serverIdRange));
-            int serverId = serverIdRange.getServerId(subtaskId);
+            long serverId = serverIdRange.getServerId(subtaskId);
             props.setProperty("database.server.id", String.valueOf(serverId));
         }
         if (databaseList != null) {
diff --git 
a/seatunnel-connectors-v2/connector-cdc/connector-cdc-mysql/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/mysql/config/ServerIdRange.java
 
b/seatunnel-connectors-v2/connector-cdc/connector-cdc-mysql/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/mysql/config/ServerIdRange.java
index 55ac9c14b..c3319f8a8 100644
--- 
a/seatunnel-connectors-v2/connector-cdc/connector-cdc-mysql/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/mysql/config/ServerIdRange.java
+++ 
b/seatunnel-connectors-v2/connector-cdc/connector-cdc-mysql/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/mysql/config/ServerIdRange.java
@@ -32,27 +32,27 @@ public class ServerIdRange implements Serializable {
     private static final long serialVersionUID = 1L;
 
     /** Start of the range (inclusive). */
-    private final int startServerId;
+    private final long startServerId;
 
     /** End of the range (inclusive). */
-    private final int endServerId;
+    private final long endServerId;
 
-    public ServerIdRange(int startServerId, int endServerId) {
+    public ServerIdRange(long startServerId, long endServerId) {
         this.startServerId = startServerId;
         this.endServerId = endServerId;
     }
 
-    public int getStartServerId() {
+    public long getStartServerId() {
         return startServerId;
     }
 
-    public int getEndServerId() {
+    public long getEndServerId() {
         return endServerId;
     }
 
-    public int getServerId(int subTaskId) {
+    public long getServerId(int subTaskId) {
         checkArgument(subTaskId >= 0, "Subtask ID %s shouldn't be a negative 
number.", subTaskId);
-        if (subTaskId > getNumberOfServerIds()) {
+        if ((long) subTaskId > getNumberOfServerIds()) {
             throw new IllegalArgumentException(
                     String.format(
                             "Subtask ID %s is out of server id range %s, "
@@ -64,8 +64,8 @@ public class ServerIdRange implements Serializable {
         return startServerId + subTaskId;
     }
 
-    public int getNumberOfServerIds() {
-        return endServerId - startServerId + 1;
+    public long getNumberOfServerIds() {
+        return endServerId - startServerId + 1L;
     }
 
     @Override
@@ -96,14 +96,14 @@ public class ServerIdRange implements Serializable {
             return new ServerIdRange(
                     parseServerId(idArray[0].trim()), 
parseServerId(idArray[1].trim()));
         } else {
-            int serverId = parseServerId(range);
+            long serverId = parseServerId(range);
             return new ServerIdRange(serverId, serverId);
         }
     }
 
-    private static int parseServerId(String serverIdValue) {
+    private static long parseServerId(String serverIdValue) {
         try {
-            return Integer.parseInt(serverIdValue);
+            return Long.parseLong(serverIdValue);
         } catch (NumberFormatException e) {
             throw new IllegalStateException(
                     String.format("The server id %s is not a valid numeric.", 
serverIdValue), e);

Reply via email to