Skip to content

Commit

Permalink
Merge branch 'master' into 17196
Browse files Browse the repository at this point in the history
* master: (90 commits)
  Remove usage of com.google.common.collect.Collections2 (apache#17721)
  Refactor execute RAL  statement reload metaData (apache#17720)
  Use caffeine instead of guava cache (apache#17712)
  Minor changes for test cases and code format (apache#17718)
  Add test case for RuleBasedSchemaMetaDataBuilderFactory . (apache#17709)
  Update Mockito and ByteBuddy to help with GraalVM integration (apache#17665)
  fix CI error (apache#17713)
  Add unit for MetaDataPersistService.persistTransactionRule(final Properties props, final boolean isOverwrit)  apache#16091 (apache#17714)
  Remove useless DatabaseMetaDataContextsBuilder (apache#17717)
  private MetaDataContextsBuilder.addDatabase and addSystemDatabases (apache#17716)
  Add unit test for ModShardingAlgorithm  (apache#17710)
  Refactor distribute database lock (apache#17711)
  Add unit test for Bootstrap use proxy default port from props (apache#17707)
  Scaling IT optimization (apache#17702)
  Add test cases for SQLRewriteContextDecoratorFactory and ExecutionPrepareDecoratorFactory . (apache#17701)
  Use ConfigurationProperties in ContextManager (apache#17706)
  Use ConfigurationProperties in MetaDataContextsBuilder (apache#17705)
  Refactor create schema statement parse logic (apache#17703)
  Revise apache#17695 (apache#17700)
  add test for DataNodeBuilderFactory (apache#17695)
  ...
  • Loading branch information
zhaoguhong committed May 17, 2022
2 parents 78b9b92 + 436b495 commit 46f0565
Show file tree
Hide file tree
Showing 567 changed files with 7,659 additions and 4,215 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -186,3 +186,25 @@ jobs:
run: ./mvnw -B clean install -Dmaven.javadoc.skip=true -Drat.skip=true -Dcheckstyle.skip=true -DskipITs -DskipTests -Dspotless.apply.skip=true
- name: Run Example generator
run: echo y | ./mvnw -B test -f examples/shardingsphere-example-generator/pom.xml -Pexample-generator

test-coverage-report:
runs-on: ubuntu-latest
name: shardingsphere test-coverage report
steps:
- uses: actions/checkout@v2
- name: Cache Maven Repos
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Set up JDK 8
uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: 8
- name: Test with Maven
run: ./mvnw -B --no-transfer-progress clean install cobertura:cobertura -Dmaven.javadoc.skip=true
- name: Upload to Codecov
run: bash <(curl -s https://codecov.io/bash)
28 changes: 14 additions & 14 deletions .github/workflows/it-scaling.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ on:
branches: [ master, dev ]
paths:
- '.github/workflows/it-scaling.yml'
- 'shardingsphere-infra/shardingsphere-infra-common/src/main/**/datasource/**'
- 'shardingsphere-kernel/shardingsphere-data-pipeline/**'
- 'shardingsphere-kernel/shardingsphere-data-pipeline/**/src/test/**'
- 'shardingsphere-infra/shardingsphere-infra-common/src/main/**'
- 'shardingsphere-mode/**/src/main/**'
- 'shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/**'
- '**/*-distsql*/**/src/main/**'
- 'shardingsphere-kernel/shardingsphere-data-pipeline/**/src/main/**'
- 'shardingsphere-features/**/src/main/**/scaling/**'
- 'shardingsphere-features/**/src/main/**/sharding/schedule/**'
- 'shardingsphere-features/**/src/main/resources/META-INF/services/*.data.pipeline.*'
- 'shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/**/*Pipeline*.java'
- 'shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/resources/META-INF/services/*.data.pipeline.*'
- '**/src/main/**/data/pipeline/**'
- '**/src/main/resources/META-INF/services/*.data.pipeline.*'
- '!shardingsphere-test/**'
- 'shardingsphere-test/shardingsphere-integration-test/**'
- '!shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/**'
Expand All @@ -38,14 +38,14 @@ on:
branches: [ master ]
paths:
- '.github/workflows/it-scaling.yml'
- 'shardingsphere-infra/shardingsphere-infra-common/src/main/**/datasource/**'
- 'shardingsphere-kernel/shardingsphere-data-pipeline/**'
- 'shardingsphere-kernel/shardingsphere-data-pipeline/**/src/test/**'
- 'shardingsphere-infra/shardingsphere-infra-common/src/main/**'
- 'shardingsphere-mode/**/src/main/**'
- 'shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/**'
- '**/*-distsql*/**/src/main/**'
- 'shardingsphere-kernel/shardingsphere-data-pipeline/**/src/main/**'
- 'shardingsphere-features/**/src/main/**/scaling/**'
- 'shardingsphere-features/**/src/main/**/sharding/schedule/**'
- 'shardingsphere-features/**/src/main/resources/META-INF/services/*.data.pipeline.*'
- 'shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/**/*Pipeline*.java'
- 'shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/resources/META-INF/services/*.data.pipeline.*'
- '**/src/main/**/data/pipeline/**'
- '**/src/main/resources/META-INF/services/*.data.pipeline.*'
- '!shardingsphere-test/**'
- 'shardingsphere-test/shardingsphere-integration-test/**'
- '!shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/**'
Expand Down
50 changes: 0 additions & 50 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion docs/document/content/overview/_index.cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ Apache ShardingSphere 由 JDBC、Proxy 和 Sidecar(规划中)这 3 款既能

### ShardingSphere-Proxy

[![Nightly-Download](https://img.shields.io/static/v1?label=nightly-builds&message=download&color=orange)](https://nightlies.apache.org/shardingsphere/)
[![Nightly-Download](https://img.shields.io/badge/nightly--builds-download-orange.svg)](https://nightlies.apache.org/shardingsphere/)
[![Download](https://img.shields.io/badge/release-download-orange.svg)](/cn/downloads/)
[![Docker Pulls](https://img.shields.io/docker/pulls/apache/shardingsphere-proxy.svg)](https://hub.docker.com/r/apache/shardingsphere-proxy)

Expand Down
2 changes: 1 addition & 1 deletion docs/document/content/overview/_index.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ It can be considered as an enhanced JDBC driver, which is fully compatible with

### ShardingSphere-Proxy

[![Nightly-Download](https://img.shields.io/static/v1?label=nightly-builds&message=download&color=orange)](https://nightlies.apache.org/shardingsphere/)
[![Nightly-Download](https://img.shields.io/badge/nightly--builds-download-orange.svg)](https://nightlies.apache.org/shardingsphere/)
[![Download](https://img.shields.io/badge/release-download-orange.svg)](/en/downloads/)
[![Docker Pulls](https://img.shields.io/docker/pulls/apache/shardingsphere-proxy.svg)](https://hub.docker.com/r/apache/shardingsphere-proxy)

Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,12 @@ it.cluster.databases=H2,MySQL,Oracle,SQLServer,PostgreSQL
```bash
./mvnw -B clean install -f shardingsphere-test/shardingsphere-integration-test/pom.xml -Pit.env.docker -Dit.cluster.adapters=proxy,jdbc -Dit.scenarios=${scenario_name_1,scenario_name_1,scenario_name_n} -Dit.cluster.databases=MySQL
```
运行以上命令会构建出一个用于集成测试的 Docker 镜像 `apache/shardingsphere-proxy-test:latest`
如果仅修改了测试代码,可以复用已有的测试镜像,无须重新构建。使用以下命令可以跳过镜像构建,直接运行集成测试:

```bash
./mvnw -B clean install -f shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/pom.xml -Pit.env.docker -Dit.cluster.adapters=proxy,jdbc -Dit.scenarios=${scenario_name_1,scenario_name_1,scenario_name_n} -Dit.cluster.databases=MySQL
```

#### 注意事项

Expand Down
15 changes: 15 additions & 0 deletions docs/document/content/reference/test/integration-test/_index.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,21 @@ This file is very like the dataset.xml mentioned before, and the difference is t
Util now, all config files are ready, just launch the corresponding test case is fine.With no need to modify any Java code, only set up some config files.
This will reduce the difficulty for ShardingSphere testing.

### Running Integration Tests

#### Run with Docker

```bash
./mvnw -B clean install -f shardingsphere-test/shardingsphere-integration-test/pom.xml -Pit.env.docker -Dit.cluster.adapters=proxy,jdbc -Dit.scenarios=${scenario_name_1,scenario_name_1,scenario_name_n} -Dit.cluster.databases=MySQL
```
Running the above command will build a Docker image `apache/shardingsphere-proxy-test:latest` for integration testing.
The existing test Docker image can be reused without rebuilding if only the test code is modified.
Use the following command to skip the image building and run the integration tests directly:

```bash
./mvnw -B clean install -f shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/pom.xml -Pit.env.docker -Dit.cluster.adapters=proxy,jdbc -Dit.scenarios=${scenario_name_1,scenario_name_1,scenario_name_n} -Dit.cluster.databases=MySQL
```

## Notice

1. If Oracle needs to be tested, please add Oracle driver dependencies to the pom.xml.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
+++
title = "内置算法"
weight = 6
weight = 7
chapter = true
+++

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
+++
title = "Builtin Algorithm"
weight = 6
weight = 7
chapter = true
+++

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ShardingSphere-JDBC 支持所有的数据库 JDBC 驱动和连接池。

## 配置示例

示例的数据库驱动为 MySQL,连接池为 HikariCP,可以更换为其他数据库驱动和连接池。
示例的数据库驱动为 MySQL,连接池为 HikariCP,可以更换为其他数据库驱动和连接池。当使用 ShardingSphere JDBC 时,JDBC 池的属性名取决于各自 JDBC 池自己的定义,并不由 ShardingSphere 硬定义,相关的处理可以参考类`org.apache.shardingsphere.infra.datasource.pool.creator.DataSourcePoolCreator`

```java
Map<String, DataSource> dataSourceMap = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ShardingSphere-JDBC Supports all JDBC drivers and database connection pools.

## Example

In this example, the database driver is MySQL, and connection pool is HikariCP, which can be replaced with other database drivers and connection pools.
In this example, the database driver is MySQL, and connection pool is HikariCP, which can be replaced with other database drivers and connection pools. When using ShardingSphere JDBC, the property name of the JDBC pool depends on the definition of the respective JDBC pool, and is not defined by ShardingSphere. For related processing, please refer to the class `org.apache.shardingsphere.infra.datasource.pool.creator.DataSourcePoolCreator`.

```java
Map<String, DataSource> dataSourceMap = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
+++
title = "JDBC 驱动"
weight = 3
chapter = true
+++

## 简介

ShardingSphere-JDBC 提供了 JDBC 驱动,可以仅通过配置变更即可使用,无需改写代码。

## 使用步骤

### 引入 Maven 依赖

```xml
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-jdbc-core</artifactId>
<version>${shardingsphere.version}</version>
</dependency>
```

### 使用驱动

#### 使用原生驱动

```java
Class.forName("org.apache.shardingsphere.driver.ShardingSphereDriver"); // 或者使用标准 SPI 注册数据库驱动
String jdbcUrl = "jdbc:shardingsphere:classpath:config.yaml";

String sql = "SELECT i.* FROM t_order o JOIN t_order_item i ON o.order_id=i.order_id WHERE o.user_id=? AND o.order_id=?";
try (
Connection conn = DriverManager.getConnection(jdbcUrl);
PreparedStatement ps = conn.prepareStatement(sql)) {
ps.setInt(1, 10);
ps.setInt(2, 1000);
try (ResultSet rs = preparedStatement.executeQuery()) {
while(rs.next()) {
// ...
}
}
}
```

#### 使用数据库连接池

```java
String driverClassName = "org.apache.shardingsphere.driver.ShardingSphereDriver";
String jdbcUrl = "jdbc:shardingsphere:classpath:config.yaml";

// 以 HikariCP 为例
HikariDataSource dataSource = new HikariDataSource();
dataSource.setDriverClassName(driverClassName);
dataSource.setJdbcUrl(jdbcUrl);

String sql = "SELECT i.* FROM t_order o JOIN t_order_item i ON o.order_id=i.order_id WHERE o.user_id=? AND o.order_id=?";
try (
Connection conn = dataSource.getConnection();
PreparedStatement ps = conn.prepareStatement(sql)) {
ps.setInt(1, 10);
ps.setInt(2, 1000);
try (ResultSet rs = preparedStatement.executeQuery()) {
while(rs.next()) {
// ...
}
}
}
```

### 配置说明

#### 驱动类名称

`org.apache.shardingsphere.driver.ShardingSphereDriver`

#### URL 配置说明

-`jdbc:shardingsphere:` 为前缀
- 配置文件:`xxx.yaml`,配置文件格式与 [YAML 配置](/cn/user-manual/yaml-config/)一致
- 配置文件加载规则:
- 无前缀表示从绝对路径加载配置文件
- `classpath:` 前缀表示从类路径中加载配置文件
Loading

0 comments on commit 46f0565

Please sign in to comment.