Skip to content

Commit

Permalink
Merge pull request ClickHouse#93 from zhicwu/develop
Browse files Browse the repository at this point in the history
Release 2.0.01
  • Loading branch information
zhicwu authored Feb 7, 2021
2 parents 677aadb + a201ae4 commit c6b30b9
Show file tree
Hide file tree
Showing 17 changed files with 90 additions and 69 deletions.
29 changes: 27 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ on:
- "misc/**"

jobs:
build:
java:
name: "Build and verify Java code..."
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
Expand All @@ -30,3 +30,28 @@ jobs:
java-version: 1.8
- name: Build with Maven
run: mvn --batch-mode --update-snapshots verify

docker:
name: "Build and verify Dockerfile..."
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Build Default Docker Image
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
push: false
tags: my/clickhouse-jdbc-bridge:latest
- name: Build All-in-one Docker Image
uses: docker/build-push-action@v2
with:
context: .
file: ./all-in-one.Dockerfile
push: false
tags: my/clickhouse-jdbc-bridge:latest
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:
uses: actions/setup-java@v1
with:
java-version: 1.8
- run: sed -i -e 's|^\( <version>\).*\(</version>\)$|\1${{ github.event.inputs.major }}.${{ github.event.inputs.minor }}.${{ github.event.inputs.patch }}\2|' pom.xml
- name: Release Maven package
uses: samuelmeuli/action-maven-publish@v1
with:
Expand Down
13 changes: 8 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
FROM adoptopenjdk/openjdk8-openj9:jre8u275-b01_openj9-0.23.0-ubuntu
FROM adoptopenjdk/openjdk8-openj9:jre8u282-b08_openj9-0.24.0-ubuntu

ARG revision=2.0.0
ARG revision=latest
ARG repository=ClickHouse/clickhouse-jdbc-bridge

# Maintainer
LABEL maintainer="[email protected]"

# Environment variables
ENV JDBC_BRIDGE_HOME=/app JDBC_BRIDGE_VERSION=${revision} \
JDBC_BRIDGE_REL_URL=https://github.com/${repository}/releases/download/v${revision}
JDBC_BRIDGE_REL_URL=https://github.com/${repository}/releases/download

# Labels
LABEL app_name="ClickHouse JDBC Bridge" app_version="$JDBC_BRIDGE_VERSION"
Expand All @@ -37,16 +37,19 @@ RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --allow-unauthenticated apache2-utils \
apt-transport-https curl htop iftop iptraf iputils-ping jq lsof net-tools tzdata wget \
&& apt-get clean \
&& if [ "$revision" = "latest" ] ; then export JDBC_BRIDGE_VERSION=$(curl -s https://repo1.maven.org/maven2/ru/yandex/clickhouse/clickhouse-jdbc-bridge/maven-metadata.xml | grep '<latest>' | sed -e 's|^.*>\(.*\)<.*$|\1|'); else export JDBC_BRIDGE_VERSION=${revision}; fi \
&& export JDBC_BRIDGE_REL_URL=$JDBC_BRIDGE_REL_URL/v$JDBC_BRIDGE_VERSION \
&& wget -q -P $JDBC_BRIDGE_HOME $JDBC_BRIDGE_REL_URL/LICENSE $JDBC_BRIDGE_REL_URL/NOTICE \
$JDBC_BRIDGE_REL_URL/clickhouse-jdbc-bridge-${revision}-shaded.jar \
$JDBC_BRIDGE_REL_URL/clickhouse-jdbc-bridge-${JDBC_BRIDGE_VERSION}-shaded.jar \
&& ln -s $JDBC_BRIDGE_HOME/clickhouse-jdbc-bridge-${JDBC_BRIDGE_VERSION}-shaded.jar $JDBC_BRIDGE_HOME/clickhouse-jdbc-bridge-shaded.jar \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

COPY --chown=root:root docker/ $JDBC_BRIDGE_HOME

RUN chmod +x $JDBC_BRIDGE_HOME/*.sh \
&& mkdir -p $JDBC_BRIDGE_HOME/logs /usr/local/lib/java \
&& ln -s $JDBC_BRIDGE_HOME/logs /var/log/clickhouse-jdbc-bridge \
&& ln -s $JDBC_BRIDGE_HOME/clickhouse-jdbc-bridge-${revision}-shaded.jar \
&& ln -s $JDBC_BRIDGE_HOME/clickhouse-jdbc-bridge-${JDBC_BRIDGE_VERSION}-shaded.jar \
/usr/local/lib/java/clickhouse-jdbc-bridge-shaded.jar \
&& ln -s $JDBC_BRIDGE_HOME /etc/clickhouse-jdbc-bridge

Expand Down
23 changes: 10 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,31 +96,28 @@ JDBC bridge for ClickHouse®. It acts as a stateless proxy passing queries from
Debian/Ubuntu
```bash
apt update && apt install -y procps wget
export JDBC_BRIDGE_VERSION=2.0.0
wget https://github.com/ClickHouse/clickhouse-jdbc-bridge/releases/download/v$JDBC_BRIDGE_VERSION/clickhouse-jdbc-bridge_$JDBC_BRIDGE_VERSION-1_all.deb
apt install --no-install-recommends -f ./clickhouse-jdbc-bridge_$JDBC_BRIDGE_VERSION-1_all.deb
wget https://github.com/ClickHouse/clickhouse-jdbc-bridge/releases/download/v2.0.1/clickhouse-jdbc-bridge_2.0.1-1_all.deb
apt install --no-install-recommends -f ./clickhouse-jdbc-bridge_2.0.1-1_all.deb
clickhouse-jdbc-bridge
```

CentOS/RHEL
```bash
yum install -y wget
export JDBC_BRIDGE_VERSION=2.0.0
wget https://github.com/ClickHouse/clickhouse-jdbc-bridge/releases/download/v$JDBC_BRIDGE_VERSION/clickhouse-jdbc-bridge-$JDBC_BRIDGE_VERSION-1.noarch.rpm
yum localinstall -y clickhouse-jdbc-bridge-$JDBC_BRIDGE_VERSION-1.noarch.rpm
wget https://github.com/ClickHouse/clickhouse-jdbc-bridge/releases/download/v2.0.1/clickhouse-jdbc-bridge-2.0.1-1.noarch.rpm
yum localinstall -y clickhouse-jdbc-bridge-2.0.1-1.noarch.rpm
clickhouse-jdbc-bridge
```

* Java CLI

```bash
export JDBC_BRIDGE_VERSION=2.0.0
wget https://github.com/ClickHouse/clickhouse-jdbc-bridge/releases/download/v$JDBC_BRIDGE_VERSION/clickhouse-jdbc-bridge-$JDBC_BRIDGE_VERSION-shaded.jar
wget https://github.com/ClickHouse/clickhouse-jdbc-bridge/releases/download/v2.0.1/clickhouse-jdbc-bridge-2.0.1-shaded.jar
# add named datasource
wget -P config/datasources https://raw.githubusercontent.com/ClickHouse/clickhouse-jdbc-bridge/master/misc/quick-start/jdbc-bridge/config/datasources/ch-server.json
# start jdbc bridge, and then issue below query in ClickHouse for testing
# select * from jdbc('ch-server', 'select 1')
java -jar clickhouse-jdbc-bridge-$JDBC_BRIDGE_VERSION-shaded.jar
java -jar clickhouse-jdbc-bridge-2.0.1-shaded.jar
```


Expand Down Expand Up @@ -267,7 +264,7 @@ Assuming you started a test environment using docker-compose, please refer to ex
"drivers/mariadb",
"D:\\drivers\\mariadb",
"/mnt/d/drivers/mariadb",
"https://repo1.maven.org/maven2/org/mariadb/jdbc/mariadb-java-client/2.7.0/mariadb-java-client-2.7.0.jar"
"https://repo1.maven.org/maven2/org/mariadb/jdbc/mariadb-java-client/2.7.2/mariadb-java-client-2.7.2.jar"
],
"driverClassName": "org.mariadb.jdbc.Driver",
...
Expand Down Expand Up @@ -330,16 +327,16 @@ cd clickhouse-jdbc-bridge
# compile and run unit tests
mvn -Prelease verify
# release shaded jar, rpm and debian packages
mvn -Prelease -Drevision=2.0.0 package
mvn -Prelease package
```
In order to build docker images:
```bash
git clone https://github.com/ClickHouse/clickhouse-jdbc-bridge.git
cd clickhouse-jdbc-bridge
docker build --squash --build-arg revision=2.0.0 -t my/clickhouse-jdbc-bridge .
docker build -t my/clickhouse-jdbc-bridge .
# or if you want to build the all-ine-one image
docker build --squash --build-arg revision=20.9.3 -f all-in-one.Dockerfile -t my/clickhouse-all-in-one .
docker build --build-arg revision=20.9.3 -f all-in-one.Dockerfile -t my/clickhouse-all-in-one .
```
## Develop
Expand Down
10 changes: 4 additions & 6 deletions all-in-one.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ WORKDIR /app

RUN apt-get update \
&& apt-get install -y --no-install-recommends dpkg fakeroot rpm \
&& mvn -Prelease -DskipTests -Drevision=${revision} package
&& mvn -Prelease -DskipTests package


#
Expand All @@ -58,15 +58,13 @@ RUN apt-get update \
&& apt-get clean \
&& rm -rf /*.deb /var/lib/apt/lists/* /tmp/* /var/tmp/* \
&& wget -q -P /etc/clickhouse-jdbc-bridge/drivers/clickhouse \
https://repo1.maven.org/maven2/net/jpountz/lz4/lz4/1.3.0/lz4-1.3.0.jar \
https://repo1.maven.org/maven2/org/slf4j/slf4j-api/1.7.30/slf4j-api-1.7.30.jar \
https://repo1.maven.org/maven2/ru/yandex/clickhouse/clickhouse-jdbc/0.2.4/clickhouse-jdbc-0.2.4-shaded.jar \
https://repo1.maven.org/maven2/ru/yandex/clickhouse/clickhouse-jdbc/0.2.5/clickhouse-jdbc-0.2.5-shaded.jar \
&& wget -q -P /etc/clickhouse-jdbc-bridge/drivers/mariadb \
https://repo1.maven.org/maven2/org/mariadb/jdbc/mariadb-java-client/2.7.1/mariadb-java-client-2.7.1.jar \
https://repo1.maven.org/maven2/org/mariadb/jdbc/mariadb-java-client/2.7.2/mariadb-java-client-2.7.2.jar \
&& wget -q -P /etc/clickhouse-jdbc-bridge/drivers/mysql5 \
https://repo1.maven.org/maven2/mysql/mysql-connector-java/5.1.49/mysql-connector-java-5.1.49.jar \
&& wget -q -P /etc/clickhouse-jdbc-bridge/drivers/mysql8 \
https://repo1.maven.org/maven2/mysql/mysql-connector-java/8.0.21/mysql-connector-java-8.0.21.jar \
https://repo1.maven.org/maven2/mysql/mysql-connector-java/8.0.23/mysql-connector-java-8.0.23.jar \
&& wget -q -P /etc/clickhouse-jdbc-bridge/drivers/postgres \
https://repo1.maven.org/maven2/org/postgresql/postgresql/42.2.18/postgresql-42.2.18.jar \
&& sed -i -e 's|\(^[[:space:]]*\)\(exec.*clickhouse-server.*$\)|\1exec -c clickhouse-jdbc-bridge >/dev/null \&\n\1\2|' /entrypoint.sh \
Expand Down
4 changes: 2 additions & 2 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ The latest tag points to the latest release from `master` branch. Branch tags li
```bash
docker run -d --name ch-jdbc-bridge -p9019:9019 \
-e MAVEN_REPO_URL="https://repo1.maven.org/maven2" \
-e JDBC_DRIVERS="org/mariadb/jdbc/mariadb-java-client/2.7.1/mariadb-java-client-2.7.1.jar,org/postgresql/postgresql/42.2.18/postgresql-42.2.18.jar" yandex/clickhouse-jdbc-bridge
-e JDBC_DRIVERS="org/mariadb/jdbc/mariadb-java-client/2.7.2/mariadb-java-client-2.7.2.jar,org/postgresql/postgresql/42.2.18/postgresql-42.2.18.jar" yandex/clickhouse-jdbc-bridge
```
If you prefer to use JDBC drivers and named datasources on host, you can use the following commands:
```bash
wget -P drivers \
https://repo1.maven.org/maven2/org/mariadb/jdbc/mariadb-java-client/2.7.1/mariadb-java-client-2.7.1.jar \
https://repo1.maven.org/maven2/org/mariadb/jdbc/mariadb-java-client/2.7.2/mariadb-java-client-2.7.2.jar \
https://repo1.maven.org/maven2/org/postgresql/postgresql/42.2.18/postgresql-42.2.18.jar
wget -P datasources \
https://raw.githubusercontent.com/ClickHouse/clickhouse-jdbc-bridge/master/misc/quick-start/jdbc-bridge/config/datasources/mariadb10.json \
Expand Down
3 changes: 1 addition & 2 deletions docker/config/datasources/datasource.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
"self"
],
"driverUrls": [
"https://repo1.maven.org/maven2/org/slf4j/slf4j-api/1.7.30/slf4j-api-1.7.30.jar",
"https://repo1.maven.org/maven2/ru/yandex/clickhouse/clickhouse-jdbc/0.2.4/clickhouse-jdbc-0.2.4-shaded.jar"
"https://repo1.maven.org/maven2/ru/yandex/clickhouse/clickhouse-jdbc/0.2.5/clickhouse-jdbc-0.2.5-shaded.jar"
],
"driverClassName": "ru.yandex.clickhouse.ClickHouseDriver",
"jdbcUrl": "jdbc:clickhouse://ch-server:8123/system?compress=false",
Expand Down
8 changes: 4 additions & 4 deletions docker/config/datasources/script.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"script": {
"type": "script",
"driverUrls": [
"/d/Tools/groovy-3.0.1/lib",
"!/d/Tools/groovy-3.0.1/lib/groovy-jaxb-3.0.1.jar",
"D:/Tools/groovy-3.0.1/lib",
"!D:/Tools/groovy-3.0.1/lib/groovy-jaxb-3.0.1.jar"
"/d/Tools/groovy-3.0.7/lib",
"!/d/Tools/groovy-3.0.7/lib/groovy-jaxb-3.0.7.jar",
"D:/Tools/groovy-3.0.7/lib",
"!D:/Tools/groovy-3.0.7/lib/groovy-jaxb-3.0.7.jar"
]
}
}
4 changes: 2 additions & 2 deletions docker/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ start_server() {
fi

if [ "$(echo ${CUSTOM_DRIVER_LOADER:="true"} | tr '[:upper:]' '[:lower:]')" != "true" ]; then
local classpath="./clickhouse-jdbc-bridge-$JDBC_BRIDGE_VERSION-shaded.jar:$(echo $(ls ${DRIVER_DIR:="drivers"}/*.jar) | tr ' ' ':'):."
local classpath="./clickhouse-jdbc-bridge-shaded.jar:$(echo $(ls ${DRIVER_DIR:="drivers"}/*.jar) | tr ' ' ':'):."
java -XX:+UseContainerSupport -XX:+IdleTuningCompactOnIdle -XX:+IdleTuningGcOnIdle \
-Xdump:none -Xdump:tool:events=systhrow+throw,filter=*OutOfMemoryError,exec="kill -9 %pid" \
-Dlog4j.configuration=file:///$JDBC_BRIDGE_HOME/log4j.properties -Dnashorn.args=--language=es6 \
Expand All @@ -30,7 +30,7 @@ start_server() {
java -XX:+UseContainerSupport -XX:+IdleTuningCompactOnIdle -XX:+IdleTuningGcOnIdle \
-Xdump:none -Xdump:tool:events=systhrow+throw,filter=*OutOfMemoryError,exec="kill -9 %pid" \
-Dlog4j.configuration=file:///$JDBC_BRIDGE_HOME/log4j.properties -Dnashorn.args=--language=es6 \
${JDBC_BRIDGE_JVM_OPTS:=""} -jar clickhouse-jdbc-bridge-$JDBC_BRIDGE_VERSION-shaded.jar
${JDBC_BRIDGE_JVM_OPTS:=""} -jar clickhouse-jdbc-bridge-shaded.jar
fi
}

Expand Down
2 changes: 1 addition & 1 deletion misc/perf-test/jdbc-bridge/config/datasources/mariadb.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "../../../../../docker/config/datasource.jschema",
"mariadb": {
"driverUrls": [
"https://repo1.maven.org/maven2/org/mariadb/jdbc/mariadb-java-client/2.7.0/mariadb-java-client-2.7.0.jar"
"https://repo1.maven.org/maven2/org/mariadb/jdbc/mariadb-java-client/2.7.2/mariadb-java-client-2.7.2.jar"
],
"driverClassName": "org.mariadb.jdbc.Driver",
"jdbcUrl": "jdbc:mariadb://mariadb:3306/test?useSSL=false&useCompression=false&rewriteBatchedStatements=true",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
"ch-server": {
"aliases": ["self"],
"driverUrls": [
"https://repo1.maven.org/maven2/org/slf4j/slf4j-api/1.7.30/slf4j-api-1.7.30.jar",
"https://repo1.maven.org/maven2/net/jpountz/lz4/lz4/1.3.0/lz4-1.3.0.jar",
"https://repo1.maven.org/maven2/ru/yandex/clickhouse/clickhouse-jdbc/0.2.4/clickhouse-jdbc-0.2.4-shaded.jar"
"https://repo1.maven.org/maven2/ru/yandex/clickhouse/clickhouse-jdbc/0.2.5/clickhouse-jdbc-0.2.5-shaded.jar"
],
"driverClassName": "ru.yandex.clickhouse.ClickHouseDriver",
"jdbcUrl": "jdbc:clickhouse://ch-server:8123/system",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "../../../../../docker/config/datasource.jschema",
"elasticsearch": {
"driverUrls": [
"https://repo1.maven.org/maven2/com/amazon/opendistroforelasticsearch/client/opendistro-sql-jdbc/1.11.0.0/opendistro-sql-jdbc-1.11.0.0.jar"
"https://repo1.maven.org/maven2/com/amazon/opendistroforelasticsearch/client/opendistro-sql-jdbc/1.12.0.0/opendistro-sql-jdbc-1.12.0.0.jar"
],
"readOnly": true,
"connectionTestQuery": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "../../../../../docker/config/datasource.jschema",
"mariadb10": {
"driverUrls": [
"https://repo1.maven.org/maven2/org/mariadb/jdbc/mariadb-java-client/2.7.1/mariadb-java-client-2.7.1.jar"
"https://repo1.maven.org/maven2/org/mariadb/jdbc/mariadb-java-client/2.7.2/mariadb-java-client-2.7.2.jar"
],
"driverClassName": "org.mariadb.jdbc.Driver",
"jdbcUrl": "jdbc:mariadb://db-mariadb10/test?useSSL=false&useCompression=false&useOldAliasMetadataBehavior=true&allowMultiQueries=true",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "../../../../../docker/config/datasource.jschema",
"mysql8": {
"driverUrls": [
"https://repo1.maven.org/maven2/mysql/mysql-connector-java/8.0.21/mysql-connector-java-8.0.21.jar"
"https://repo1.maven.org/maven2/mysql/mysql-connector-java/8.0.23/mysql-connector-java-8.0.23.jar"
],
"driverClassName": "com.mysql.cj.jdbc.Driver",
"jdbcUrl": "jdbc:mysql://db-mysql8/test?allowPublicKeyRetrieval=true&useSSL=false&useCompression=false&useOldAliasMetadataBehavior=true&allowMultiQueries=true",
Expand Down
3 changes: 1 addition & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
<groupId>ru.yandex.clickhouse</groupId>
<artifactId>clickhouse-jdbc-bridge</artifactId>
<packaging>jar</packaging>
<version>${revision}</version>
<version>2.0.1-SNAPSHOT</version>
<name>ClickHouse JDBC Bridge</name>
<url>https://github.com/ClickHouse/clickhouse-jdbc-bridge</url>
<description>JDBC bridge for ClickHouse.</description>
<inceptionYear>2019</inceptionYear>

<properties>
<revision>2.0.0-SNAPSHOT</revision>
<caffeine.version>2.8.6</caffeine.version>
<dnsjava.version>3.3.1</dnsjava.version>
<vertx.version>3.9.5</vertx.version>
Expand Down
34 changes: 11 additions & 23 deletions src/main/java/ru/yandex/clickhouse/jdbcbridge/core/ByteBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -318,17 +318,7 @@ public BigInteger readInt128() {
}

public ByteBuffer writeInt128(BigInteger value) {
byte empty = value.signum() == -1 ? (byte) 0xFF : 0x00;
byte[] bytes = value.toByteArray();
for (int i = bytes.length - 1; i >= 0; i--) {
writeByte(bytes[i]);
}

for (int i = 16 - bytes.length; i > 0; i--) {
writeByte(empty);
}

return this;
return writeBigInteger(value, DataType.Int128.getLength());
}

public BigInteger readInt256() {
Expand All @@ -341,17 +331,7 @@ public BigInteger readInt256() {
}

public ByteBuffer writeInt256(BigInteger value) {
byte empty = value.signum() == -1 ? (byte) 0xFF : 0x00;
byte[] bytes = value.toByteArray();
for (int i = bytes.length - 1; i >= 0; i--) {
writeByte(bytes[i]);
}

for (int i = 32 - bytes.length; i > 0; i--) {
writeByte(empty);
}

return this;
return writeBigInteger(value, DataType.Int256.getLength());
}

public BigInteger readUInt64() {
Expand Down Expand Up @@ -411,12 +391,20 @@ public java.util.UUID readUUID() {
}

public ByteBuffer writeBigInteger(BigInteger value) {
return writeBigInteger(value, 16);
}

public ByteBuffer writeBigInteger(BigInteger value, int length) {
byte empty = value.signum() == -1 ? (byte) 0xFF : 0x00;
byte[] bytes = value.toByteArray();
for (int i = bytes.length - 1; i >= 0; i--) {
writeByte(bytes[i]);
}

writeBytes(new byte[16 - bytes.length]);
// FIXME when the given (byte)length is less than bytes.length...
for (int i = length - bytes.length; i > 0; i--) {
writeByte(empty);
}

return this;
}
Expand Down
Loading

0 comments on commit c6b30b9

Please sign in to comment.