Skip to content

Commit

Permalink
Removes support for jdbcURL prefix of `jdbc:tc:shardingsphere0clickho…
Browse files Browse the repository at this point in the history
…use:`
  • Loading branch information
linghengqian committed Nov 18, 2024
1 parent 5a85a20 commit b575220
Show file tree
Hide file tree
Showing 19 changed files with 193 additions and 188 deletions.
2 changes: 2 additions & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

### API Changes

1. Infra: Removes support for jdbcURL prefix of `jdbc:tc:shardingsphere0clickhouse:` - [#33707](https://github.com/apache/shardingsphere/pull/33707)

### New Features

### Enhancements
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ Truffle 与 JDK 的向后兼容性矩阵位于 https://medium.com/graalvm/40027a
考虑一个简单的 SPI 实现类,

```java
package org.example;
import org.apache.shardingsphere.infra.expr.spi.InlineExpressionParser;
import java.util.Arrays;
import java.util.List;
Expand All @@ -146,6 +147,12 @@ public final class CustomInlineExpressionParserFixture implements InlineExpressi
}
```

并在项目的 classpath 添加 `META-INF/services/org.apache.shardingsphere.infra.expr.spi.InlineExpressionParser`文件,

```
org.example.CustomInlineExpressionParserFixture
```

此时对于 ShardingSphere 配置文件中的 `actualDataNodes`
1. 若配置为 `<CUSTOM.FIXTURE>spring`,将被转化为 `t_order_2024_01, t_order_2024_02`
2. 若配置为 `<CUSTOM.FIXTURE>summer`,将被转化为 `t_order_2024_03, t_order_2024_04`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,12 @@ public final class CustomInlineExpressionParserFixture implements InlineExpressi
}
```

And add the file `META-INF/services/org.apache.shardingsphere.infra.expr.spi.InlineExpressionParser` to the project classpath,

```
org.example.CustomInlineExpressionParserFixture
```

At this time, for `actualDataNodes` in the ShardingSphere configuration file,
1. If configured as `<CUSTOM.FIXTURE>spring`, it will be converted to `t_order_2024_01, t_order_2024_02`.
2. If configured as `<CUSTOM.FIXTURE>summer`, it will be converted to `t_order_2024_03, t_order_2024_04`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,14 @@ Apache ShardingSphere 内置的标准分片算法实现类包括:

可配置属性:

| *属性名称* | *数据类型* | *说明* | *默认值* |
|------------------------------|--------|--------------------------------------------------------------------------------------------------------------------------------------------|-------|
| datetime-pattern | String | 分片键的时间戳格式,必须遵循 Java DateTimeFormatter 的格式。例如:yyyy-MM-dd HH:mm:ss,yyyy-MM-dd 或 HH:mm:ss 等。但不支持与 `java.time.chrono.JapaneseDate` 相关的 Gy-MM 等 | |
| datetime-lower | String | 时间分片下界值,格式与 `datetime-pattern` 定义的时间戳格式一致 | |
| datetime-upper (?) | String | 时间分片上界值,格式与 `datetime-pattern` 定义的时间戳格式一致 | 当前时间 |
| sharding-suffix-pattern | String | 分片数据源或真实表的后缀格式,必须遵循 Java DateTimeFormatter 的格式,必须和 `datetime-interval-unit` 保持一致。例如:yyyyMM | |
| datetime-interval-amount (?) | int | 分片键时间间隔,超过该时间间隔将进入下一分片 | 1 |
| datetime-interval-unit (?) | String | 分片键时间间隔单位,必须遵循 Java ChronoUnit 的枚举值。例如:MONTHS | DAYS |
| *属性名称* | *数据类型* | *说明* | *默认值* |
|------------------------------|--------|-----------------------------------------------------------------------------------------------------------------------------------------------|-------|
| datetime-pattern | String | 分片键的时间戳格式,必须遵循 Java DateTimeFormatter 的格式。例如:yyyy-MM-dd HH:mm:ss,yyyy-MM-dd 或 HH:mm:ss 等。但不支持与 `java.time.chrono.JapaneseDate` 相关的 GGGGy-MM 等 | |
| datetime-lower | String | 时间分片下界值,格式与 `datetime-pattern` 定义的时间戳格式一致 | |
| datetime-upper (?) | String | 时间分片上界值,格式与 `datetime-pattern` 定义的时间戳格式一致 | 当前时间 |
| sharding-suffix-pattern | String | 分片数据源或真实表的后缀格式,必须遵循 Java DateTimeFormatter 的格式,必须和 `datetime-interval-unit` 保持一致。例如:yyyyMM | |
| datetime-interval-amount (?) | int | 分片键时间间隔,超过该时间间隔将进入下一分片 | 1 |
| datetime-interval-unit (?) | String | 分片键时间间隔单位,必须遵循 Java ChronoUnit 的枚举值。例如:MONTHS | DAYS |

### 复合分片算法

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,14 @@ Type: INTERVAL

Attributes:

| *Name* | *DataType* | *Description* | *Default Value* |
|------------------------------|------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------|
| datetime-pattern | String | Timestamp pattern of sharding value, must can be transformed to Java LocalDateTime. For example: yyyy-MM-dd HH:mm:ss, yyyy-MM-dd or HH:mm:ss etc. But Gy-MM etc. related to `java.time.chrono.JapaneseDate` are not supported | - |
| datetime-lower | String | Datetime sharding lower boundary, pattern is defined `datetime-pattern` | - |
| datetime-upper (?) | String | Datetime sharding upper boundary, pattern is defined `datetime-pattern` | Now |
| sharding-suffix-pattern | String | Suffix pattern of sharding data sources or tables, must can be transformed to Java LocalDateTime, must be consistent with `datetime-interval-unit`. For example: yyyyMM | - |
| datetime-interval-amount (?) | int | Interval of sharding value, after which the next shard will be entered | 1 |
| datetime-interval-unit (?) | String | Unit of sharding value interval, must can be transformed to Java ChronoUnit's Enum value. For example: MONTHS | DAYS |
| *Name* | *DataType* | *Description* | *Default Value* |
|------------------------------|------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------|
| datetime-pattern | String | Timestamp pattern of sharding value, must can be transformed to Java LocalDateTime. For example: yyyy-MM-dd HH:mm:ss, yyyy-MM-dd or HH:mm:ss etc. But GGGGy-MM etc. related to `java.time.chrono.JapaneseDate` are not supported | - |
| datetime-lower | String | Datetime sharding lower boundary, pattern is defined `datetime-pattern` | - |
| datetime-upper (?) | String | Datetime sharding upper boundary, pattern is defined `datetime-pattern` | Now |
| sharding-suffix-pattern | String | Suffix pattern of sharding data sources or tables, must can be transformed to Java LocalDateTime, must be consistent with `datetime-interval-unit`. For example: yyyyMM | - |
| datetime-interval-amount (?) | int | Interval of sharding value, after which the next shard will be entered | 1 |
| datetime-interval-unit (?) | String | Unit of sharding value interval, must can be transformed to Java ChronoUnit's Enum value. For example: MONTHS | DAYS |

### Complex Sharding Algorithm

Expand Down
2 changes: 1 addition & 1 deletion examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@

<profiles>
<profile>
<id>jdk11-22</id>
<id>jdk11+</id>
<activation>
<jdk>[11,)</jdk>
</activation>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,18 @@
import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;

import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Optional;

/**
* Database type of ClickHouse in testcontainers-java.
*/
public final class TcClickHouseDatabaseType implements TestcontainersDatabaseType {

/**
* TODO See the JavaDoc for `org.apache.shardingsphere.test.natived.jdbc.commons.testcontainers.ClickHouseProvider`.
*
* @return prefixes of JDBC URL
*/
@Override
public Collection<String> getJdbcUrlPrefixes() {
return Arrays.asList("jdbc:tc:clickhouse:", "jdbc:tc:shardingsphere0clickhouse:");
return Collections.singletonList("jdbc:tc:clickhouse:");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.junit.jupiter.api.Test;

import java.util.Arrays;
import java.util.Collections;

import static org.hamcrest.CoreMatchers.is;
Expand All @@ -31,7 +30,7 @@ class TestcontainersDatabaseTypeTest {

@Test
void assertGetJdbcUrlPrefixes() {
assertThat(TypedSPILoader.getService(DatabaseType.class, "TC-ClickHouse").getJdbcUrlPrefixes(), is(Arrays.asList("jdbc:tc:clickhouse:", "jdbc:tc:shardingsphere0clickhouse:")));
assertThat(TypedSPILoader.getService(DatabaseType.class, "TC-ClickHouse").getJdbcUrlPrefixes(), is(Collections.singletonList("jdbc:tc:clickhouse:")));
assertThat(TypedSPILoader.getService(DatabaseType.class, "TC-MariaDB").getJdbcUrlPrefixes(), is(Collections.singleton("jdbc:tc:mariadb:")));
assertThat(TypedSPILoader.getService(DatabaseType.class, "TC-MySQL").getJdbcUrlPrefixes(), is(Collections.singleton("jdbc:tc:mysql:")));
assertThat(TypedSPILoader.getService(DatabaseType.class, "TC-Oracle").getJdbcUrlPrefixes(), is(Collections.singleton("jdbc:tc:oracle:")));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@
"includes":[{
"condition":{"typeReachable":"com.clickhouse.logging.LoggerFactory"},
"pattern":"\\QMETA-INF/services/com.clickhouse.logging.LoggerFactory\\E"
}, {
"condition":{"typeReachable":"com.clickhouse.client.ClickHouseRequestManager"},
"pattern":"\\QMETA-INF/services/com.clickhouse.client.ClickHouseRequestManager\\E"
}, {
"condition":{"typeReachable":"com.clickhouse.data.ClickHouseDataStreamFactory"},
"pattern":"\\QMETA-INF/services/com.clickhouse.data.ClickHouseDataStreamFactory\\E"
}, {
"condition":{"typeReachable":"com.clickhouse.jdbc.JdbcTypeMapping"},
"pattern":"\\QMETA-INF/services/com.clickhouse.jdbc.JdbcTypeMapping\\E"
}, {
"condition":{"typeReachable":"com.clickhouse.client.internal.jpountz.lz4.LZ4JNI"},
"pattern":"\\Qcom/clickhouse/client/internal/jpountz/util/linux/amd64/liblz4-java.so\\E"
}]},
"bundles":[]
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"name":"[Lcom.zaxxer.hikari.util.ConcurrentBag$IConcurrentBagEntry;"
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.mode.manager.standalone.persist.StandaloneMetaDataManagerPersistService"},
"condition":{"typeReachable":"org.apache.shardingsphere.metadata.persist.service.version.MetaDataVersionPersistService"},
"name":"[Lcom.zaxxer.hikari.util.ConcurrentBag$IConcurrentBagEntry;"
},
{
Expand Down Expand Up @@ -176,6 +176,11 @@
"queryAllDeclaredMethods":true,
"methods":[{"name":"close","parameterTypes":[] }, {"name":"read","parameterTypes":["java.nio.CharBuffer"] }]
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.driver.jdbc.core.datasource.ShardingSphereDataSource"},
"name":"java.io.Serializable",
"queryAllDeclaredMethods":true
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.infra.expr.groovy.GroovyInlineExpressionParser"},
"name":"java.io.Serializable",
Expand Down Expand Up @@ -468,11 +473,6 @@
"condition":{"typeReachable":"org.apache.shardingsphere.infra.expr.groovy.GroovyInlineExpressionParser"},
"name":"java.net.Socket"
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.driver.jdbc.core.datasource.ShardingSphereDataSource"},
"name":"java.net.SocketException",
"methods":[{"name":"<init>","parameterTypes":["java.lang.String"] }]
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.infra.expr.groovy.GroovyInlineExpressionParser"},
"name":"java.net.URI"
Expand Down Expand Up @@ -1103,7 +1103,7 @@
"methods":[{"name":"<init>","parameterTypes":[] }]
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.proxy.backend.connector.DatabaseConnector"},
"condition":{"typeReachable":"org.apache.shardingsphere.proxy.backend.connector.StandardDatabaseConnector"},
"name":"org.apache.shardingsphere.encrypt.checker.sql.EncryptSupportedSQLCheckersBuilder",
"methods":[{"name":"<init>","parameterTypes":[] }]
},
Expand Down Expand Up @@ -2070,7 +2070,7 @@
"queryAllDeclaredMethods":true
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.mode.manager.cluster.listener.DatabaseMetaDataChangedListener$$Lambda/0x00007f490fb226e0"},
"condition":{"typeReachable":"org.apache.shardingsphere.mode.manager.cluster.listener.DatabaseMetaDataChangedListener$$Lambda/0x00007ffa47b22d00"},
"name":"org.apache.shardingsphere.mode.manager.cluster.event.subscriber.dispatch.MetaDataChangedSubscriber"
},
{
Expand Down Expand Up @@ -2417,10 +2417,6 @@
"condition":{"typeReachable":"org.apache.shardingsphere.infra.spi.type.ordered.OrderedSPILoader"},
"name":"org.apache.shardingsphere.readwritesplitting.checker.ReadwriteSplittingRuleConfigurationChecker"
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.infra.datanode.DataNodes"},
"name":"org.apache.shardingsphere.readwritesplitting.datanode.ReadwriteSplittingDataNodeBuilder"
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.proxy.frontend.mysql.command.query.text.query.MySQLComQueryPacketExecutor"},
"name":"org.apache.shardingsphere.readwritesplitting.distsql.handler.update.AlterReadwriteSplittingRuleExecutor"
Expand Down Expand Up @@ -2548,10 +2544,6 @@
"condition":{"typeReachable":"org.apache.shardingsphere.infra.spi.type.ordered.OrderedSPILoader"},
"name":"org.apache.shardingsphere.shadow.checker.ShadowRuleConfigurationChecker"
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.infra.datanode.DataNodes"},
"name":"org.apache.shardingsphere.shadow.datanode.ShadowDataNodeBuilder"
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.proxy.frontend.mysql.command.query.text.query.MySQLComQueryPacketExecutor"},
"name":"org.apache.shardingsphere.shadow.distsql.handler.update.AlterDefaultShadowAlgorithmExecutor"
Expand Down Expand Up @@ -3602,5 +3594,10 @@
{
"condition":{"typeReachable":"org.apache.shardingsphere.proxy.initializer.BootstrapInitializer"},
"name":"org.apache.shardingsphere.transaction.yaml.config.YamlTransactionRuleConfigurationCustomizer"
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.infra.executor.kernel.ExecutorEngine"},
"name":"sun.security.provider.SecureRandom",
"methods":[{"name":"<init>","parameterTypes":[] }, {"name":"<init>","parameterTypes":["java.security.SecureRandomParameters"] }]
}
]
Loading

0 comments on commit b575220

Please sign in to comment.