Skip to content

Commit a7e176e

Browse files
authored
Merge pull request #258 from taosdata/main
sync from main
2 parents d348fd6 + eda986b commit a7e176e

169 files changed

Lines changed: 7269 additions & 1408 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ jobs:
5656
run: sudo taosadapter &
5757

5858
- name: checkout
59-
uses: actions/checkout@v3
59+
uses: actions/checkout@v4
60+
with:
61+
path: 'jdbc-workspace'
6062

6163
- name: set up java
6264
uses: actions/setup-java@v3
@@ -66,6 +68,7 @@ jobs:
6668
java-package: jdk
6769

6870
- name: Test
71+
working-directory: jdbc-workspace
6972
env:
7073
TDENGINE_CLOUD_URL: ${{ secrets.TDENGINE_CLOUD_URL }}
7174
run: mvn -B clean verify --file pom.xml
@@ -74,7 +77,7 @@ jobs:
7477
uses: codecov/codecov-action@v4
7578
with:
7679
token: ${{ secrets.CODECOV_TOKEN }}
77-
files: target/site/jacoco/jacoco.xml
80+
files: jdbc-workspace/target/site/jacoco/jacoco.xml
7881
flags: unittests
7982
name: codecov-umbrella
8083
fail_ci_if_error: false
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: build
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- '3.0'
8+
paths-ignore:
9+
- 'LICENSE'
10+
- '*.md'
11+
- '*.txt'
12+
pull_request:
13+
branches:
14+
- main
15+
- '3.0'
16+
paths-ignore:
17+
- 'LICENSE'
18+
- '*.md'
19+
- '*.txt'
20+
21+
jobs:
22+
build:
23+
strategy:
24+
matrix:
25+
# os: [ ubuntu-latest,macos-latest,windows-latest ]
26+
os: [ Ubuntu-22.04 ]
27+
java: [ 8 ]
28+
maven: [ '3.6.3' ]
29+
runs-on: ${{ matrix.os }}
30+
steps:
31+
- name: get TDengine
32+
run: |
33+
wget https://github.com/taosdata/TDengine/releases/download/ver-3.3.6.0/TDengine-server-3.3.6.0-Linux-x64.tar.gz
34+
35+
- name: install
36+
run: |
37+
tar -zxf TDengine-server-3.3.6.0-Linux-x64.tar.gz
38+
cd TDengine-server-3.3.6.0
39+
sudo ./install.sh -e no
40+
41+
- name: shell
42+
run: |
43+
cat >start.sh<<EOF
44+
ulimit -n 65535 && TAOS_SUPPORT_VNODES=256 taosd
45+
EOF
46+
47+
- name: taosd
48+
run: nohup sudo sh ./start.sh &
49+
50+
- name: start taosadapter
51+
run: sudo taosadapter &
52+
53+
- name: checkout
54+
uses: actions/checkout@v4
55+
with:
56+
path: 'jdbc-workspace'
57+
58+
- name: set up java
59+
uses: actions/setup-java@v3
60+
with:
61+
distribution: 'temurin' # See 'Supported distributions' for available options
62+
java-version: ${{ matrix.java }}
63+
java-package: jdk
64+
65+
- name: Test
66+
working-directory: jdbc-workspace
67+
env:
68+
TDENGINE_CLOUD_URL: ${{ secrets.TDENGINE_CLOUD_URL }}
69+
run: mvn -B clean verify --file pom.xml
70+
71+
72+

CHANGELOG.md

Lines changed: 426 additions & 0 deletions
Large diffs are not rendered by default.

cliff.toml

Lines changed: 471 additions & 0 deletions
Large diffs are not rendered by default.

deploy-pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55

66
<groupId>com.taosdata.jdbc</groupId>
77
<artifactId>taos-jdbcdriver</artifactId>
8-
<version>3.5.3</version>
8+
<version>3.7.0-SNAPSHOT</version>
99
<packaging>jar</packaging>
1010

1111
<name>JDBCDriver</name>
1212
<url>https://github.com/taosdata/taos-connector-jdbc</url>
13-
<description>TDengine JDBC Driver</description>
13+
<description>The official TDengine JDBC connector</description>
1414

1515
<licenses>
1616
<license>

pom.xml

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>com.taosdata.jdbc</groupId>
55
<artifactId>taos-jdbcdriver</artifactId>
6-
<version>3.6.0</version>
6+
<version>3.7.0-SNAPSHOT</version>
77

88
<packaging>jar</packaging>
99
<name>JDBCDriver</name>
1010
<url>https://github.com/taosdata/taos-connector-jdbc</url>
1111

12-
<description>TDengine JDBC Driver</description>
12+
<description>The official TDengine JDBC connector</description>
1313
<licenses>
1414
<license>
1515
<name>MIT License</name>
@@ -40,8 +40,9 @@
4040
<jackson.version>2.18.0</jackson.version>
4141
<httpclient.version>4.5.13</httpclient.version>
4242
<guava.version>32.1.3-jre</guava.version>
43-
<Java-WebSocket.version>1.5.4</Java-WebSocket.version>
43+
<netty-all.version>4.1.119.Final</netty-all.version>
4444
<junit.version>4.13.2</junit.version>
45+
<slf4j.version>1.7.36</slf4j.version>
4546
</properties>
4647
<dependencies>
4748
<dependency>
@@ -65,30 +66,22 @@
6566
<version>${guava.version}</version>
6667
</dependency>
6768
<dependency>
68-
<groupId>org.java-websocket</groupId>
69-
<artifactId>Java-WebSocket</artifactId>
70-
<version>${Java-WebSocket.version}</version>
69+
<groupId>io.netty</groupId>
70+
<artifactId>netty-all</artifactId>
71+
<version>${netty-all.version}</version>
7172
</dependency>
73+
<dependency>
74+
<groupId>org.slf4j</groupId>
75+
<artifactId>slf4j-api</artifactId>
76+
<version>${slf4j.version}</version>
77+
</dependency>
78+
7279
<dependency>
7380
<groupId>junit</groupId>
7481
<artifactId>junit</artifactId>
7582
<version>${junit.version}</version>
7683
<scope>test</scope>
7784
</dependency>
78-
79-
<!-- <dependency>-->
80-
<!-- <groupId>org.slf4j</groupId>-->
81-
<!-- <artifactId>slf4j-api</artifactId>-->
82-
<!-- <version>1.7.25</version>-->
83-
<!-- </dependency>-->
84-
85-
<!-- &lt;!&ndash; logback依赖 &ndash;&gt;-->
86-
<!-- <dependency>-->
87-
<!-- <groupId>ch.qos.logback</groupId>-->
88-
<!-- <artifactId>logback-classic</artifactId>-->
89-
<!-- <version>1.2.3</version>-->
90-
<!-- </dependency>-->
91-
9285
</dependencies>
9386

9487
<build>
@@ -194,7 +187,11 @@
194187
<artifactId>maven-surefire-plugin</artifactId>
195188
<version>3.0.0-M6</version>
196189
<configuration>
197-
<forkMode>pertest</forkMode>
190+
<parallel>classes</parallel>
191+
<threadCount>1</threadCount>
192+
<useUnlimitedThreads>false</useUnlimitedThreads>
193+
<perCoreThreadCount>false</perCoreThreadCount>
194+
198195
<includes>
199196
<include>**/*Test.java</include>
200197
</includes>

src/main/java/com/taosdata/jdbc/AbstractDriver.java

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,25 @@
66
import com.fasterxml.jackson.databind.ObjectReader;
77
import com.taosdata.jdbc.enums.WSFunction;
88
import com.taosdata.jdbc.rs.ConnectionParam;
9-
import com.taosdata.jdbc.utils.JsonUtil;
10-
import com.taosdata.jdbc.utils.StringUtils;
9+
import com.taosdata.jdbc.utils.*;
1110
import com.taosdata.jdbc.ws.FutureResponse;
1211
import com.taosdata.jdbc.ws.InFlightRequest;
1312
import com.taosdata.jdbc.ws.Transport;
1413
import com.taosdata.jdbc.ws.WSConnection;
1514
import com.taosdata.jdbc.ws.entity.*;
1615
import org.slf4j.LoggerFactory;
1716

18-
import java.nio.ByteOrder;
17+
import java.nio.charset.StandardCharsets;
1918
import java.sql.Connection;
2019
import java.sql.Driver;
2120
import java.sql.DriverPropertyInfo;
2221
import java.sql.SQLException;
2322
import java.util.Properties;
2423

24+
import static com.taosdata.jdbc.TSDBConstants.MIN_SUPPORT_VERSION;
25+
2526
public abstract class AbstractDriver implements Driver {
26-
private final org.slf4j.Logger log = LoggerFactory.getLogger(AbstractDriver.class);
27+
private static final org.slf4j.Logger log = LoggerFactory.getLogger(AbstractDriver.class);
2728

2829
protected DriverPropertyInfo[] getPropertyInfo(Properties info) {
2930
DriverPropertyInfo hostProp = new DriverPropertyInfo(TSDBDriver.PROPERTY_KEY_HOST, info.getProperty(TSDBDriver.PROPERTY_KEY_HOST));
@@ -54,28 +55,18 @@ protected DriverPropertyInfo[] getPropertyInfo(Properties info) {
5455
propertyInfo[4] = passwordProp;
5556
return propertyInfo;
5657
}
57-
58-
protected Properties parseURL(String url, Properties defaults) {
59-
return StringUtils.parseUrl(url, defaults);
60-
}
61-
62-
63-
6458
protected Connection getWSConnection(String url, ConnectionParam param, Properties props) throws SQLException {
6559
if (log.isDebugEnabled()){
6660
log.debug("getWSConnection, url = {}", StringUtils.getBasicUrl(url));
6761
try {
68-
ObjectMapper objectMapper = new ObjectMapper();
62+
ObjectMapper objectMapper = JsonUtil.getObjectMapper();
6963
log.debug("getWSConnection, ConnectionParam = {}", objectMapper.writeValueAsString(param));
7064
} catch (JsonProcessingException e) {
7165
log.error("Error serializing ConnectionParam", e);
7266
}
7367
}
74-
7568
InFlightRequest inFlightRequest = new InFlightRequest(param.getRequestTimeout(), param.getMaxRequest());
76-
Transport transport = new Transport(WSFunction.WS, param, inFlightRequest);
77-
78-
transport.setTextMessageHandler(message -> {
69+
param.setTextMessageHandler(message -> {
7970
try {
8071
log.trace("received message: {}", message);
8172
JsonNode jsonObject = JsonUtil.getObjectReader().readTree(message);
@@ -90,17 +81,20 @@ protected Connection getWSConnection(String url, ConnectionParam param, Properti
9081
log.error("Error processing message", e);
9182
}
9283
});
93-
transport.setBinaryMessageHandler(byteBuffer -> {
94-
byteBuffer.order(ByteOrder.LITTLE_ENDIAN);
95-
byteBuffer.position(26);
96-
long id = byteBuffer.getLong();
97-
byteBuffer.position(8);
84+
85+
param.setBinaryMessageHandler(byteBuf -> {
86+
byteBuf.readerIndex(26);
87+
long id = byteBuf.readLongLE();
88+
byteBuf.readerIndex(8);
89+
9890
FutureResponse remove = inFlightRequest.remove(Action.FETCH_BLOCK_NEW.getAction(), id);
9991
if (null != remove) {
100-
FetchBlockNewResp fetchBlockResp = new FetchBlockNewResp(byteBuffer);
92+
Utils.retainByteBuf(byteBuf);
93+
FetchBlockNewResp fetchBlockResp = new FetchBlockNewResp(byteBuf);
10194
remove.getFuture().complete(fetchBlockResp);
10295
}
10396
});
97+
Transport transport = new Transport(WSFunction.WS, param, inFlightRequest);
10498

10599
transport.checkConnection(param.getConnectTimeout());
106100

@@ -112,7 +106,8 @@ protected Connection getWSConnection(String url, ConnectionParam param, Properti
112106
throw new SQLException("(0x" + Integer.toHexString(auth.getCode()) + "):" + "auth failure:" + auth.getMessage());
113107
}
114108

115-
TaosGlobalConfig.setCharset(props.getProperty(TSDBDriver.PROPERTY_KEY_CHARSET));
109+
VersionUtil.checkVersion(auth.getVersion(), transport);
110+
TaosGlobalConfig.setCharset(StandardCharsets.UTF_8.name());
116111
return new WSConnection(url, props, transport, param);
117112
}
118113

0 commit comments

Comments
 (0)