Skip to content

Commit

Permalink
Merge pull request ClickHouse#79 from zhicwu/develop
Browse files Browse the repository at this point in the history
Prepare 2.0 release
  • Loading branch information
zhicwu authored Dec 16, 2020
2 parents 15f6251 + 4e52149 commit 7e7bc4e
Show file tree
Hide file tree
Showing 75 changed files with 2,506 additions and 1,394 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Build

on:
push:
branches:
- master
- develop
paths-ignore:
- "**.md"
- "misc/**"

pull_request:
types:
- opened
- synchronize
- reopened
paths-ignore:
- "**.md"
- "misc/**"

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Setup Dependencies
env:
DEBIAN_FRONTEND: noninteractive
CH_REPO: deb [trusted=yes] https://repo.clickhouse.tech/deb/stable/ main/
CH_CONF_DIR: /etc/clickhouse-server/config.d
run: |
sudo apt-get update -y -qq
sudo apt-get install -y -qq --no-install-recommends ca-certificates dpkg fakeroot rpm
echo $CH_REPO | sudo tee -a /etc/apt/sources.list
sudo apt-get update -y -qq
sudo apt-get install -y -qq clickhouse-server
sudo mkdir -p $CH_CONF_DIR
sudo touch $CH_CONF_DIR/test.xml
echo "<yandex><jdbc_bridge><host>127.0.0.1</host><port>9019</port></jdbc_bridge></yandex>" | sudo tee -a $CH_CONF_DIR/test.xml
sudo /usr/sbin/clickhouse-server --config=/etc/clickhouse-server/config.xml &
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Build with Maven
run: mvn --batch-mode --update-snapshots -Prelease verify
78 changes: 78 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Release

on:
workflow_dispatch:
inputs:
major:
description: "Major version"
required: true
default: "2"
minor:
description: "Minor version"
required: false
default: "0"
patch:
description: "Patch"
required: false
default: "0"
organization:
description: "DockerHub organization"
required: false
default: "yandex"

jobs:
pre-release:
name: "Pre Release"
runs-on: "ubuntu-latest"

steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Build with Maven
run: mvn -Dmaven.test.skip=true -Drevision=${{ github.event.inputs.major }}.${{ github.event.inputs.minor }}.${{ github.event.inputs.patch }} --batch-mode -Prelease package
- uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "v${{ github.event.inputs.major }}.${{ github.event.inputs.minor }}.${{ github.event.inputs.patch }}"
prerelease: true
title: "Release v${{ github.event.inputs.major }}.${{ github.event.inputs.minor }}.${{ github.event.inputs.patch }}"
files: |
LICENSE
NOTICE
target/clickhouse*.jar
target/*.deb
target/**/*.rpm
publish:
name: "Build and Publish Docker Image"
runs-on: ubuntu-latest
needs: pre-release
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: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USER }}
password: ${{ secrets.DOCKER_HUB_PASSWD }}
- name: Build and Push Docker Image
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
push: true
build-args: |
revision=${{ github.event.inputs.major }}.${{ github.event.inputs.minor }}.${{ github.event.inputs.patch }}
repository=${{ github.repository }}
tags: |
${{ github.event.inputs.organization }}/clickhouse-jdbc-bridge:latest
${{ github.event.inputs.organization }}/clickhouse-jdbc-bridge:${{ github.event.inputs.major }}
${{ github.event.inputs.organization }}/clickhouse-jdbc-bridge:${{ github.event.inputs.major }}.${{ github.event.inputs.minor }}
${{ github.event.inputs.organization }}/clickhouse-jdbc-bridge:${{ github.event.inputs.major }}.${{ github.event.inputs.minor }}.${{ github.event.inputs.patch }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ dependency-reduced-pom.xml
.vscode/
demo/
target/
test.sh
36 changes: 7 additions & 29 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,39 +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

# docker build --squash --build-arg revision=2.0.0 -t yandex/clickhouse-jdbc-bridge .
ARG revision=2.0.0-SNAPSHOT

#
# Stage 1/2: Build
#
FROM maven:3-openjdk-8 as builder

ARG revision

COPY LICENSE NOTICE pom.xml /app/
COPY docker /app/docker/
COPY misc /app/misc/
COPY src /app/src/

WORKDIR /app

RUN mvn -Drevision=${revision} package


#
# Stage 2/2: Pack
#
FROM adoptopenjdk/openjdk8-openj9:jre8u265-b01_openj9-0.21.0-ubuntu

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

# Maintainer
LABEL maintainer="[email protected]"

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

# Labels
LABEL app_name="ClickHouse JDBC Bridge" app_version="$JDBC_BRIDGE_VERSION"
Expand All @@ -59,10 +37,10 @@ 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 \
&& wget -q -P $JDBC_BRIDGE_HOME $JDBC_BRIDGE_REL_URL/LICENSE $JDBC_BRIDGE_REL_URL/NOTICE \
$JDBC_BRIDGE_REL_URL/clickhouse-jdbc-bridge-${revision}.jar \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

COPY --from=builder /app/LICENSE /app/NOTICE \
/app/target/clickhouse-jdbc-bridge-$JDBC_BRIDGE_VERSION.jar $JDBC_BRIDGE_HOME/
COPY --chown=root:root docker/ $JDBC_BRIDGE_HOME

RUN chmod +x $JDBC_BRIDGE_HOME/*.sh \
Expand Down
35 changes: 25 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ JDBC bridge for ClickHouse. It acts as a stateless proxy passing queries to exte

## Known Issues / Limitation

**Caution: this is not ready for production use, as it's still under development and lack of testing.**

* ClickHouse server should be patched or you may run into issues like `JDBC bridge is not running` and `Timeout: connect timed out`
* Pushdown is not supported
* Use the most recent LTS/stable version of ClickHouse
Note: you may need to patch ClickHouse if you're using older version release before July, 2020. Please refer to [this](https://github.com/ClickHouse/ClickHouse/pull/11690) for details.
* Pushdown is not supported by design
* Query may execute twice because of type inferring
* Complex data types like Array and Tuple are not supported
* Mutation is not fully supported - only insertion in simple cases
* Complex data types like Array and Tuple are not supported - they'll be treated as String
* Mutation is not fully supported by deisgn - only insertion in simple cases
* Scripting is experimental


Expand All @@ -32,9 +31,24 @@ Below is a rough performance comparison to help you understand overhead caused b
* Java CLI

```bash
# 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 you can issue below query in ClickHouse for testing
# select * from jdbc('ch-server', 'select 1')
java -jar clickhouse-jdbc-bridge-<version>.jar
```

If you need adhoc datasource, which is disabled by default for security reason, you may try below:
```bash
# download jdbc drivers and required libs if any
wget -P drivers https://repo1.maven.org/maven2/org/mariadb/jdbc/mariadb-java-client/2.7.1/mariadb-java-client-2.7.1.jar
# start jdbc bridge, and you'll be able to run query like below in ClickHouse:
# select * from jdbc('jdbc:mariadb://localhost:3306/test?user=root&password=root', 'select 1')
java -Djdbc-bridge.driver.loader=false \
-cp `pwd`/drivers/mariadb-java-client-2.7.1.jar:`pwd`/clickhouse-jdbc-bridge-<version>.jar:. \
ru.yandex.clickhouse.jdbcbridge.JdbcBridgeVerticle
```

* Docker CLI

It's simple to get started using all-in-one docker image:
Expand Down Expand Up @@ -212,7 +226,7 @@ Below is a rough performance comparison to help you understand overhead caused b
* Monitoring
You can use [Prometheus](https://prometheus.io/) to monitor metrics exposed by JDBC brige.
You can use [Prometheus](https://prometheus.io/) to monitor metrics exposed by JDBC bridge.
```bash
curl -v http://jdbc-bridge:9019/metrics
```
Expand Down Expand Up @@ -256,11 +270,11 @@ Below is a rough performance comparison to help you understand overhead caused b
* Vert.x
If you're familiar with [Vert.x](https://vertx.io/). You can customize its configuration by changing `config/httpd.json` and `config/vertx.json`.
If you're familiar with [Vert.x](https://vertx.io/), you can customize its configuration by changing `config/httpd.json` and `config/vertx.json`.
* Query Parameters
All supported query parameters can be found at [here](src/main/java/ru/yandex/clickhouse/jdbcbridge/core/QueryPamraters.java). `datasource_column=true` can be simplied as `datasource_column`, for example:
All supported query parameters can be found at [here](src/main/java/ru/yandex/clickhouse/jdbcbridge/core/QueryParameters.java). `datasource_column=true` can be simplied as `datasource_column`, for example:
```sql
select * from jdbc('ch-server?datasource_column=true', 'select 1')
Expand All @@ -270,7 +284,7 @@ Below is a rough performance comparison to help you understand overhead caused b
* Timeout
Couple of timeout settings you should be aware of:
1. datasource timeout, for example: `max_execution_time` in MySQL and ClickHouse
1. datasource timeout, for example: `max_execution_time` in MySQL
2. JDBC driver timeout, for example: `connectTimeout` and `socketTimeout` in [MySQL Connector/J](https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-reference-configuration-properties.html)
3. Vertx timeout - see `config/server.json` and `config/vertx.json`
4. Client(ClickHouse JDBC driver) timeout - see timeout settings in ClickHouse JDBC driver
Expand Down Expand Up @@ -327,6 +341,7 @@ An extension for JDBC bridge is basically a Java class with 3 optional parts:
```
3. Instantiation Method
In order to create instance of your extension, in general you should define a static method like below so that JDBC bridge knows how(besides walking through all possible constructors):
```java
public static MyExtension newInstance(Object... args) {
Expand Down
4 changes: 2 additions & 2 deletions all-in-one.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
# specific language governing permissions and limitations
# under the License.

# docker build --squash --build-arg revision=20.9.3 -f all-in-one.Dockerfile -t yandex/clickhouse-all-in-one:20.9.3 .
ARG revision=20.9.3
# docker build --squash --build-arg revision=20.8 -f all-in-one.Dockerfile -t yandex/clickhouse-all-in-one:20.8 .
ARG revision=20.8

#
# Stage 1/2: Build
Expand Down
Loading

0 comments on commit 7e7bc4e

Please sign in to comment.