Skip to content

Commit 75a6aa6

Browse files
authored
Merge pull request #800 from zhicwu/patch-release
Prepare 0.3.2-patch1 release
2 parents 6e4b5a7 + 6f4b879 commit 75a6aa6

File tree

12 files changed

+498
-18
lines changed

12 files changed

+498
-18
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ Java 8 or higher is required in order to use Java client([clickhouse-client](htt
9999
<groupId>com.clickhouse</groupId>
100100
<!-- or clickhouse-grpc-client if you prefer gRPC -->
101101
<artifactId>clickhouse-http-client</artifactId>
102-
<version>0.3.2</version>
102+
<version>0.3.2-patch1</version>
103103
</dependency>
104104
```
105105

@@ -135,7 +135,7 @@ try (ClickHouseClient client = ClickHouseClient.newInstance(preferredProtocol);
135135
<!-- will stop using ru.yandex.clickhouse starting from 0.4.0 -->
136136
<groupId>com.clickhouse</groupId>
137137
<artifactId>clickhouse-jdbc</artifactId>
138-
<version>0.3.2</version>
138+
<version>0.3.2-patch1</version>
139139
<!-- below is only needed when all you want is a shaded jar -->
140140
<classifier>http</classifier>
141141
<exclusions>

clickhouse-client/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Async Java client for ClickHouse. `clickhouse-client` is an abstract module, so
99
<dependency>
1010
<groupId>com.clickhouse</groupId>
1111
<artifactId>clickhouse-http-client</artifactId>
12-
<version>0.3.2</version>
12+
<version>0.3.2-patch1</version>
1313
</dependency>
1414
```
1515

clickhouse-grpc-client/src/main/java/com/clickhouse/client/grpc/ClickHouseGrpcClient.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,9 @@ protected CompletableFuture<ClickHouseResponse> executeAsync(ClickHouseRequest<?
245245
// return new ClickHouseGrpcFuture(server, sealedRequest, requestObserver,
246246
// responseObserver);
247247
return CompletableFuture.supplyAsync(() -> {
248-
int timeout = sealedRequest.getConfig().getConnectionTimeout() / 1000
249-
+ sealedRequest.getConfig().getMaxExecutionTime();
248+
ClickHouseConfig config = sealedRequest.getConfig();
249+
int timeout = config.getConnectionTimeout() / 1000
250+
+ Math.max(config.getSocketTimeout() / 1000, config.getMaxExecutionTime());
250251
try {
251252
if (!responseObserver.await(timeout, TimeUnit.SECONDS)) {
252253
if (!Context.current().withCancellation().cancel(new StatusException(Status.CANCELLED))) {

clickhouse-grpc-client/src/main/java/com/clickhouse/client/grpc/ClickHouseGrpcFuture.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import io.grpc.StatusException;
1111
import io.grpc.stub.StreamObserver;
1212
import com.clickhouse.client.ClickHouseChecker;
13+
import com.clickhouse.client.ClickHouseConfig;
1314
import com.clickhouse.client.ClickHouseNode;
1415
import com.clickhouse.client.ClickHouseRequest;
1516
import com.clickhouse.client.ClickHouseResponse;
@@ -63,7 +64,10 @@ public boolean isDone() {
6364
@Override
6465
public ClickHouseResponse get() throws InterruptedException, ExecutionException {
6566
try {
66-
return get(request.getConfig().getConnectionTimeout() / 1000 + request.getConfig().getMaxExecutionTime(),
67+
ClickHouseConfig config = request.getConfig();
68+
return get(
69+
config.getConnectionTimeout() / 1000
70+
+ Math.max(config.getSocketTimeout() / 1000, config.getMaxExecutionTime()),
6771
TimeUnit.SECONDS);
6872
} catch (TimeoutException e) {
6973
cancel(true);

clickhouse-grpc-client/src/main/java/com/clickhouse/client/grpc/ClickHouseStreamObserver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ protected void setError(Throwable error) {
6464
protected boolean updateStatus(Result result) {
6565
summary.update();
6666

67-
log.info(() -> {
67+
log.debug(() -> {
6868
for (LogEntry e : result.getLogsList()) {
6969
String logLevel = e.getLevel().name();
7070
int index = logLevel.indexOf('_');

clickhouse-jdbc/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Keep in mind that `clickhouse-jdbc` is synchronous, and in general it has more o
1111
<!-- will stop using ru.yandex.clickhouse starting from 0.4.0 -->
1212
<groupId>com.clickhouse</groupId>
1313
<artifactId>clickhouse-jdbc</artifactId>
14-
<version>0.3.2</version>
14+
<version>0.3.2-patch1</version>
1515
</dependency>
1616
```
1717

examples/grpc/pom.xml

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<groupId>com.clickhouse</groupId>
6+
<artifactId>grpc-examples</artifactId>
7+
<version>1.0.0</version>
8+
<packaging>jar</packaging>
9+
10+
<name>grpc-examples</name>
11+
<description>gRPC Examples</description>
12+
<url>https://github.com/ClickHouse/clickhouse-jdbc</url>
13+
<inceptionYear>2022</inceptionYear>
14+
15+
<organization>
16+
<name>ClickHouse, Inc.</name>
17+
<url>https://clickhouse.com/</url>
18+
</organization>
19+
20+
<licenses>
21+
<license>
22+
<name>The Apache Software License, Version 2.0</name>
23+
<url>http://www.apache.org/licenses/LICENSE-2.0</url>
24+
<distribution>repo</distribution>
25+
</license>
26+
</licenses>
27+
28+
<developers>
29+
<developer>
30+
<id>zhicwu</id>
31+
<name>Zhichun Wu</name>
32+
<email>[email protected]</email>
33+
<timezone>+8</timezone>
34+
</developer>
35+
</developers>
36+
37+
<scm>
38+
<url>https://github.com/ClickHouse/clickhouse-jdbc</url>
39+
<connection>scm:[email protected]:ClickHouse/clickhouse-jdbc.git</connection>
40+
<developerConnection>scm:[email protected]:ClickHouse/clickhouse-jdbc.git</developerConnection>
41+
<tag>HEAD</tag>
42+
</scm>
43+
44+
<issueManagement>
45+
<system>Github</system>
46+
<url>https://github.com/ClickHouse/clickhouse-jdbc/issues</url>
47+
</issueManagement>
48+
49+
<ciManagement>
50+
<system>Github</system>
51+
<url>https://github.com/ClickHouse/clickhouse-jdbc/actions</url>
52+
</ciManagement>
53+
54+
<properties>
55+
<project.current.year>2022</project.current.year>
56+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
57+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
58+
59+
<clickhouse-grpc.version>0.3.2</clickhouse-grpc.version>
60+
61+
<compiler-plugin.version>3.8.1</compiler-plugin.version>
62+
63+
<minJdk>1.8</minJdk>
64+
</properties>
65+
66+
<dependencies>
67+
<dependency>
68+
<groupId>com.clickhouse</groupId>
69+
<artifactId>clickhouse-grpc-client</artifactId>
70+
<version>${clickhouse-grpc.version}</version>
71+
<classifier>shaded</classifier>
72+
<exclusions>
73+
<exclusion>
74+
<groupId>*</groupId>
75+
<artifactId>*</artifactId>
76+
</exclusion>
77+
</exclusions>
78+
</dependency>
79+
</dependencies>
80+
81+
<build>
82+
<plugins>
83+
<plugin>
84+
<groupId>org.apache.maven.plugins</groupId>
85+
<artifactId>maven-compiler-plugin</artifactId>
86+
<version>${compiler-plugin.version}</version>
87+
<configuration>
88+
<source>${minJdk}</source>
89+
<target>${minJdk}</target>
90+
<showWarnings>true</showWarnings>
91+
<compilerArgs>
92+
<arg>-Xlint:all</arg>
93+
<!-- arg>-Werror</arg -->
94+
</compilerArgs>
95+
</configuration>
96+
</plugin>
97+
</plugins>
98+
</build>
99+
</project>
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
package com.clickhouse.examples.jdbc;
2+
3+
import java.io.IOException;
4+
import java.util.UUID;
5+
import java.util.concurrent.CompletableFuture;
6+
import java.util.concurrent.ExecutionException;
7+
8+
import com.clickhouse.client.ClickHouseClient;
9+
import com.clickhouse.client.ClickHouseConfig;
10+
import com.clickhouse.client.ClickHouseCredentials;
11+
import com.clickhouse.client.ClickHouseException;
12+
import com.clickhouse.client.ClickHouseFormat;
13+
import com.clickhouse.client.ClickHouseNode;
14+
import com.clickhouse.client.ClickHouseProtocol;
15+
import com.clickhouse.client.ClickHouseRecord;
16+
import com.clickhouse.client.ClickHouseRequest;
17+
import com.clickhouse.client.ClickHouseResponse;
18+
import com.clickhouse.client.ClickHouseResponseSummary;
19+
import com.clickhouse.client.data.BinaryStreamUtils;
20+
import com.clickhouse.client.data.ClickHousePipedStream;
21+
22+
public class Main {
23+
static void dropAndCreateTable(ClickHouseNode server, String table) throws ClickHouseException {
24+
try (ClickHouseClient client = ClickHouseClient.newInstance(server.getProtocol())) {
25+
ClickHouseRequest<?> request = client.connect(server);
26+
// or use future chaining
27+
request.query("drop table if exists " + table).execute().get();
28+
request.query("create table " + table + "(a String, b Nullable(String)) engine=MergeTree() order by a")
29+
.execute().get();
30+
} catch (InterruptedException e) {
31+
Thread.currentThread().interrupt();
32+
throw ClickHouseException.forCancellation(e, server);
33+
} catch (ExecutionException e) {
34+
throw ClickHouseException.of(e, server);
35+
}
36+
}
37+
38+
static long insert(ClickHouseNode server, String table) throws ClickHouseException {
39+
try (ClickHouseClient client = ClickHouseClient.newInstance(server.getProtocol())) {
40+
ClickHouseRequest.Mutation request = client.connect(server).write().table(table)
41+
.format(ClickHouseFormat.RowBinary);
42+
ClickHouseConfig config = request.getConfig();
43+
CompletableFuture<ClickHouseResponse> future;
44+
// back-pressuring is not supported, you can adjust the first two arguments
45+
try (ClickHousePipedStream stream = new ClickHousePipedStream(config.getMaxBufferSize(),
46+
config.getMaxQueuedBuffers(), config.getSocketTimeout())) {
47+
// in async mode, which is default, execution happens in a worker thread
48+
future = request.data(stream.getInput()).execute();
49+
50+
// writing happens in main thread
51+
for (int i = 0; i < 1000000; i++) {
52+
BinaryStreamUtils.writeString(stream, String.valueOf(i % 16));
53+
BinaryStreamUtils.writeNonNull(stream);
54+
BinaryStreamUtils.writeString(stream, UUID.randomUUID().toString());
55+
}
56+
}
57+
58+
// response should be always closed
59+
try (ClickHouseResponse response = future.get()) {
60+
ClickHouseResponseSummary summary = response.getSummary();
61+
return summary.getWrittenRows();
62+
}
63+
} catch (InterruptedException e) {
64+
Thread.currentThread().interrupt();
65+
throw ClickHouseException.forCancellation(e, server);
66+
} catch (ExecutionException | IOException e) {
67+
throw ClickHouseException.of(e, server);
68+
}
69+
}
70+
71+
static int query(ClickHouseNode server, String table) throws ClickHouseException {
72+
try (ClickHouseClient client = ClickHouseClient.newInstance(server.getProtocol());
73+
ClickHouseResponse response = client.connect(server).query("select * from " + table).execute().get()) {
74+
int count = 0;
75+
// or use stream API via response.stream()
76+
for (ClickHouseRecord rec : response.records()) {
77+
count++;
78+
}
79+
return count;
80+
} catch (InterruptedException e) {
81+
Thread.currentThread().interrupt();
82+
throw ClickHouseException.forCancellation(e, server);
83+
} catch (ExecutionException e) {
84+
throw ClickHouseException.of(e, server);
85+
}
86+
}
87+
88+
public static void main(String[] args) {
89+
ClickHouseNode server = ClickHouseNode.builder()
90+
.host(System.getProperty("chHost", "192.168.3.16"))
91+
.port(ClickHouseProtocol.GRPC, Integer.parseInt(System.getProperty("chPort", "9100")))
92+
.database("system").credentials(ClickHouseCredentials.fromUserAndPassword(
93+
System.getProperty("chUser", "default"), System.getProperty("chPassword", "")))
94+
.build();
95+
96+
String table = "grpc_example_table";
97+
98+
try {
99+
dropAndCreateTable(server, table);
100+
101+
insert(server, table);
102+
103+
query(server, table);
104+
} catch (ClickHouseException e) {
105+
e.printStackTrace();
106+
}
107+
}
108+
}

examples/jdbc/pom.xml

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<groupId>com.clickhouse</groupId>
6+
<artifactId>jdbc-examples</artifactId>
7+
<version>1.0.0</version>
8+
<packaging>jar</packaging>
9+
10+
<name>jdbc-examples</name>
11+
<description>JDBC Examples</description>
12+
<url>https://github.com/ClickHouse/clickhouse-jdbc</url>
13+
<inceptionYear>2022</inceptionYear>
14+
15+
<organization>
16+
<name>ClickHouse, Inc.</name>
17+
<url>https://clickhouse.com/</url>
18+
</organization>
19+
20+
<licenses>
21+
<license>
22+
<name>The Apache Software License, Version 2.0</name>
23+
<url>http://www.apache.org/licenses/LICENSE-2.0</url>
24+
<distribution>repo</distribution>
25+
</license>
26+
</licenses>
27+
28+
<developers>
29+
<developer>
30+
<id>zhicwu</id>
31+
<name>Zhichun Wu</name>
32+
<email>[email protected]</email>
33+
<timezone>+8</timezone>
34+
</developer>
35+
</developers>
36+
37+
<scm>
38+
<url>https://github.com/ClickHouse/clickhouse-jdbc</url>
39+
<connection>scm:[email protected]:ClickHouse/clickhouse-jdbc.git</connection>
40+
<developerConnection>scm:[email protected]:ClickHouse/clickhouse-jdbc.git</developerConnection>
41+
<tag>HEAD</tag>
42+
</scm>
43+
44+
<issueManagement>
45+
<system>Github</system>
46+
<url>https://github.com/ClickHouse/clickhouse-jdbc/issues</url>
47+
</issueManagement>
48+
49+
<ciManagement>
50+
<system>Github</system>
51+
<url>https://github.com/ClickHouse/clickhouse-jdbc/actions</url>
52+
</ciManagement>
53+
54+
<properties>
55+
<project.current.year>2022</project.current.year>
56+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
57+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
58+
59+
<clickhouse-jdbc.version>0.3.2</clickhouse-jdbc.version>
60+
61+
<compiler-plugin.version>3.8.1</compiler-plugin.version>
62+
63+
<minJdk>1.8</minJdk>
64+
</properties>
65+
66+
<dependencies>
67+
<dependency>
68+
<groupId>com.clickhouse</groupId>
69+
<artifactId>clickhouse-jdbc</artifactId>
70+
<version>${clickhouse-jdbc.version}</version>
71+
<classifier>http</classifier>
72+
<exclusions>
73+
<exclusion>
74+
<groupId>*</groupId>
75+
<artifactId>*</artifactId>
76+
</exclusion>
77+
</exclusions>
78+
</dependency>
79+
</dependencies>
80+
81+
<build>
82+
<plugins>
83+
<plugin>
84+
<groupId>org.apache.maven.plugins</groupId>
85+
<artifactId>maven-compiler-plugin</artifactId>
86+
<version>${compiler-plugin.version}</version>
87+
<configuration>
88+
<source>${minJdk}</source>
89+
<target>${minJdk}</target>
90+
<showWarnings>true</showWarnings>
91+
<compilerArgs>
92+
<arg>-Xlint:all</arg>
93+
<!-- arg>-Werror</arg -->
94+
</compilerArgs>
95+
</configuration>
96+
</plugin>
97+
</plugins>
98+
</build>
99+
</project>

0 commit comments

Comments
 (0)