Skip to content

Commit 9727057

Browse files
committed
chore: Remove redundant SinkError and its related test cases
1 parent 042d133 commit 9727057

7 files changed

Lines changed: 36 additions & 253 deletions

File tree

deploy-pom.xml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.taosdata.flink</groupId>
88
<artifactId>flink-connector-tdengine</artifactId>
9-
<version>2.1.4</version>
9+
<version>2.1.5</version>
1010
<packaging>jar</packaging>
1111

1212
<name>flink-connector-tdengine</name>
@@ -42,13 +42,13 @@
4242
<product.version>3.0.0.0</product.version>
4343
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
4444
<java.version>1.8</java.version>
45-
<flink.version>1.20.0</flink.version>
45+
<flink.version>1.20.3</flink.version>
4646
<scala.binary.version>2.12</scala.binary.version>
4747
<maven-compiler-plugin.version>3.6.0</maven-compiler-plugin.version>
4848
<hamcrest.version>1.3</hamcrest.version>
4949
<powermock.version>2.0.9</powermock.version>
5050
<jackson.version>2.18.0</jackson.version>
51-
<taos.jdbcdriver.version>3.7.3</taos.jdbcdriver.version>
51+
<taos.jdbcdriver.version>3.8.1</taos.jdbcdriver.version>
5252
</properties>
5353

5454
<dependencyManagement>
@@ -85,6 +85,17 @@
8585
<artifactId>log4j-core</artifactId>
8686
<version>2.17.1</version>
8787
</dependency>
88+
89+
<dependency>
90+
<groupId>org.apache.commons</groupId>
91+
<artifactId>commons-lang3</artifactId>
92+
<version>3.18.0</version>
93+
</dependency>
94+
<dependency>
95+
<groupId>org.lz4</groupId>
96+
<artifactId>lz4-java</artifactId>
97+
<version>1.8.1</version>
98+
</dependency>
8899
</dependencies>
89100
</dependencyManagement>
90101

pom.xml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.taosdata.flink</groupId>
88
<artifactId>flink-connector-tdengine</artifactId>
9-
<version>2.1.4</version>
9+
<version>2.1.5</version>
1010
<packaging>jar</packaging>
1111
<name>flink-connector-tdengine</name>
1212
<url>https://github.com/taosdata/flink-connect-tdengine</url>
@@ -40,12 +40,13 @@
4040
<product.version>3.0.0.0</product.version>
4141
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
4242
<java.version>1.8</java.version>
43-
<flink.version>1.20.0</flink.version>
43+
<flink.version>1.20.3</flink.version>
4444
<scala.binary.version>2.12</scala.binary.version>
4545
<maven-compiler-plugin.version>3.6.0</maven-compiler-plugin.version>
4646
<hamcrest.version>1.3</hamcrest.version>
4747
<powermock.version>2.0.9</powermock.version>
4848
<jackson.version>2.18.0</jackson.version>
49+
<taos.jdbcdriver.version>3.8.1</taos.jdbcdriver.version>
4950
</properties>
5051

5152
<dependencyManagement>
@@ -84,13 +85,11 @@
8485
</dependency>
8586
</dependencies>
8687
</dependencyManagement>
87-
88-
8988
<dependencies>
9089
<dependency>
9190
<groupId>com.taosdata.jdbc</groupId>
9291
<artifactId>taos-jdbcdriver</artifactId>
93-
<version>3.7.3</version>
92+
<version>${taos.jdbcdriver.version}</version>
9493
</dependency>
9594

9695
<!-- Core -->
@@ -261,6 +260,11 @@
261260
<groupId>org.jacoco</groupId>
262261
<artifactId>jacoco-maven-plugin</artifactId>
263262
<version>0.8.12</version>
263+
<configuration>
264+
<excludes>
265+
<exclude>io/netty/**/*</exclude>
266+
</excludes>
267+
</configuration>
264268
<executions>
265269
<!-- Prepare JaCoCo agent before tests run -->
266270
<execution>

src/main/java/com/taosdata/flink/common/Utils.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,8 @@ public static String trimBackticks(String input) throws SQLException {
3838

3939
return input.substring(start, end);
4040
}
41+
42+
public static boolean isJDBCError(int errorCode) {
43+
return errorCode >= 0x2300 && errorCode <= 0x23ff;
44+
}
4145
}

src/main/java/com/taosdata/flink/sink/entity/SinkError.java

Lines changed: 6 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,9 @@
22

33
import com.taosdata.jdbc.TSDBErrorNumbers;
44

5-
import java.sql.SQLClientInfoException;
65
import java.sql.SQLException;
7-
import java.sql.SQLFeatureNotSupportedException;
8-
import java.sql.SQLWarning;
96
import java.util.HashMap;
107
import java.util.Map;
11-
import java.util.concurrent.TimeoutException;
128

139
public class SinkError {
1410
private static final Map<Integer, String> SinkErrorMap = new HashMap<>();
@@ -18,88 +14,20 @@ public class SinkError {
1814
SinkErrorMap.put(SinkErrorNumbers.ERROR_TABLE_NAME_NULL, "table name must be set");
1915
SinkErrorMap.put(SinkErrorNumbers.ERROR_INVALID_VALUE_DESERIALIZER, "invalid serialization type");
2016
SinkErrorMap.put(SinkErrorNumbers.ERROR_INVALID_SINK_FIELD_NAME, "invalid field name");
17+
SinkErrorMap.put(SinkErrorNumbers.ERROR_INVALID_SINK_FIELD_NAME, "invalid field name");
18+
SinkErrorMap.put(TSDBErrorNumbers.ERROR_UNKNOWN, "unknown error");
2119
}
2220

2321
public static SQLException createSQLException(int errorCode) {
24-
String message;
25-
if (SinkErrorNumbers.contains(errorCode))
26-
message = SinkErrorMap.get(errorCode);
27-
else
28-
message = SinkErrorMap.get(TSDBErrorNumbers.ERROR_UNKNOWN);
29-
return createSQLException(errorCode, message);
30-
}
31-
32-
public static SQLException createSQLException(int errorCode, String message) {
33-
// throw SQLFeatureNotSupportedException
34-
if (errorCode == TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD)
35-
return new SQLFeatureNotSupportedException(message, "", errorCode);
36-
// throw SQLClientInfoException
37-
if (errorCode == TSDBErrorNumbers.ERROR_SQLCLIENT_EXCEPTION_ON_CONNECTION_CLOSED)
38-
return new SQLClientInfoException(message, null);
39-
40-
if (errorCode > 0x2300 && errorCode < 0x2350)
41-
// JDBC exception's error number is less than 0x2350
42-
return new SQLException("ERROR (0x" + Integer.toHexString(errorCode) + "): " + message, "", errorCode);
43-
if (errorCode > 0x2350 && errorCode < 0x2370)
44-
// JNI exception's error number is large than 0x2350
45-
return new SQLException("JNI ERROR (0x" + Integer.toHexString(errorCode) + "): " + message, "", errorCode);
46-
47-
if (errorCode > 0x2370 && errorCode < 0x2400)
48-
return new SQLException("Consumer ERROR (0x" + Integer.toHexString(errorCode) + "): " + message, "", errorCode);
49-
50-
return new SQLException("TDengine ERROR (0x" + Integer.toHexString(errorCode) + "): " + message, "", errorCode);
51-
}
52-
53-
public static RuntimeException createRuntimeException(int errorCode, Throwable t) {
5422
String message = SinkErrorMap.get(errorCode);
55-
return new RuntimeException("ERROR (0x" + Integer.toHexString(errorCode) + "): " + message, t);
56-
}
57-
58-
public static SQLWarning createSQLWarning(String message) {
59-
return new SQLWarning(message);
60-
}
61-
6223

63-
// paramter size is greater than 1
64-
public static SQLException undeterminedExecutionError() {
65-
return new SQLException("Please either call clearBatch() to clean up context first, or use executeBatch() instead", (String) null);
66-
}
67-
68-
public static IllegalArgumentException createIllegalArgumentException(int errorCode) {
69-
String message;
70-
if (TSDBErrorNumbers.contains(errorCode))
71-
message = SinkErrorMap.get(errorCode);
72-
else
73-
message = SinkErrorMap.get(TSDBErrorNumbers.ERROR_UNKNOWN);
74-
75-
return new IllegalArgumentException("ERROR (0x" + Integer.toHexString(errorCode) + "): " + message);
76-
}
77-
78-
public static RuntimeException createRuntimeException(int errorCode) {
79-
String message;
80-
if (TSDBErrorNumbers.contains(errorCode))
81-
message = SinkErrorMap.get(errorCode);
82-
else
24+
if (message == null)
8325
message = SinkErrorMap.get(TSDBErrorNumbers.ERROR_UNKNOWN);
8426

85-
return new RuntimeException("ERROR (0x" + Integer.toHexString(errorCode) + "): " + message);
86-
}
87-
88-
public static RuntimeException createRuntimeException(int errorCode, String message) {
89-
return new RuntimeException("ERROR (0x" + Integer.toHexString(errorCode) + "): " + message);
90-
}
91-
92-
public static IllegalStateException createIllegalStateException(int errorCode) {
93-
String message;
94-
if (TSDBErrorNumbers.contains(errorCode))
95-
message = SinkErrorMap.get(errorCode);
96-
else
97-
message = SinkErrorMap.get(TSDBErrorNumbers.ERROR_UNKNOWN);
98-
99-
return new IllegalStateException("ERROR (0x" + Integer.toHexString(errorCode) + "): " + message);
27+
return createSQLException(errorCode, message);
10028
}
10129

102-
public static TimeoutException createTimeoutException(int errorCode, String message) {
103-
return new TimeoutException("ERROR (0x" + Integer.toHexString(errorCode) + "): " + message);
30+
public static SQLException createSQLException(int errorCode, String message) {
31+
return new SQLException("TDengine ERROR (0x" + Integer.toHexString(errorCode) + "): " + message, "", errorCode);
10432
}
10533
}

src/main/java/com/taosdata/flink/sink/entity/SinkErrorNumbers.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,4 @@ public class SinkErrorNumbers {
2727

2828
private SinkErrorNumbers() {
2929
}
30-
31-
public static boolean contains(int errorNumber) {
32-
return errorNumbers.contains(errorNumber);
33-
}
3430
}

src/main/java/com/taosdata/flink/source/entity/SourceError.java

Lines changed: 0 additions & 105 deletions
This file was deleted.

0 commit comments

Comments
 (0)