From a3b9039f04b50f4d9b558ab51ec507325bd53349 Mon Sep 17 00:00:00 2001 From: "Juan Pan(Trista)" Date: Wed, 15 Apr 2020 18:13:14 +0800 Subject: [PATCH] Provide inline implement for standard algorithm (#5195) * Provide inline implement for standard algorithm * fix --- .../sharding/conf/config-sharding.yaml | 14 +++- .../sharding/InlineShardingAlgorithm.java | 78 +++++++++++++++++++ ...dingsphere.spi.algorithm.ShardingAlgorithm | 18 +++++ ...EngineShadowShardingConfigurationTest.java | 5 +- .../YamlEngineShardingConfigurationTest.java | 5 +- .../resources/yaml/shadow-sharding-rule.yaml | 14 +++- .../test/resources/yaml/sharding-rule.yaml | 14 +++- .../resources/yaml/mix/query-with-cipher.yaml | 21 +++-- .../resources/yaml/mix/query-with-plain.yaml | 21 +++-- .../yaml/sharding/sharding-rule.yaml | 14 +++- .../integrate/env/shadow/sharding-rule.yaml | 14 +++- .../configWithDataSourceWithProps.yaml | 14 +++- .../configWithDataSourceWithoutProps.yaml | 16 ++-- .../configWithoutDataSourceWithProps.yaml | 14 +++- .../configWithoutDataSourceWithoutProps.yaml | 14 +++- .../configWithDataSourceWithProps.yaml | 14 +++- .../configWithDataSourceWithoutProps.yaml | 14 +++- .../configWithoutDataSourceWithoutProps.yaml | 14 +++- .../test/resources/yaml/unit/sharding.yaml | 28 +++++-- 19 files changed, 273 insertions(+), 73 deletions(-) create mode 100644 sharding-core/sharding-core-common/src/main/java/org/apache/shardingsphere/core/strategy/sharding/InlineShardingAlgorithm.java create mode 100644 sharding-core/sharding-core-common/src/main/resources/META-INF/services/org.apache.shardingsphere.spi.algorithm.ShardingAlgorithm diff --git a/examples/docker/sharding-proxy/sharding/conf/config-sharding.yaml b/examples/docker/sharding-proxy/sharding/conf/config-sharding.yaml index 99f963c3ac..2353983d4c 100644 --- a/examples/docker/sharding-proxy/sharding/conf/config-sharding.yaml +++ b/examples/docker/sharding-proxy/sharding/conf/config-sharding.yaml @@ -50,16 +50,22 @@ shardingRule: t_order: actualDataNodes: ds_${0..1}.t_order_${0..1} tableStrategy: - inline: + standard: shardingColumn: order_id - algorithmExpression: t_order_${order_id % 2} + shardingAlgorithm: + type: INLINE + props: + algorithm.expression: t_order_${order_id % 2} keyGeneratorColumnName: order_id t_order_item: actualDataNodes: ds_${0..1}.t_order_item_${0..1} tableStrategy: - inline: + standard: shardingColumn: order_id - algorithmExpression: t_order_item_${order_id % 2} + shardingAlgorithm: + type: INLINE + props: + algorithm.expression: t_order_item_${order_id % 2} keyGeneratorColumnName: order_item_id bindingTables: - t_order,t_order_item diff --git a/sharding-core/sharding-core-common/src/main/java/org/apache/shardingsphere/core/strategy/sharding/InlineShardingAlgorithm.java b/sharding-core/sharding-core-common/src/main/java/org/apache/shardingsphere/core/strategy/sharding/InlineShardingAlgorithm.java new file mode 100644 index 0000000000..d9aee1a871 --- /dev/null +++ b/sharding-core/sharding-core-common/src/main/java/org/apache/shardingsphere/core/strategy/sharding/InlineShardingAlgorithm.java @@ -0,0 +1,78 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.shardingsphere.core.strategy.sharding; + +import com.google.common.base.Preconditions; +import groovy.lang.Closure; +import groovy.util.Expando; +import org.apache.shardingsphere.api.sharding.standard.PreciseShardingValue; +import org.apache.shardingsphere.api.sharding.standard.RangeShardingValue; +import org.apache.shardingsphere.api.sharding.standard.StandardShardingAlgorithm; +import org.apache.shardingsphere.underlying.common.config.inline.InlineExpressionParser; + +import java.util.Collection; +import java.util.Properties; + +/** + * Inline sharding algorithm. + */ +public final class InlineShardingAlgorithm implements StandardShardingAlgorithm> { + + private static final String ALLOW_RANGE_QUERY = "allow.range.query.with.inline.sharding"; + + private static final String ALGORITHM_EXPRESSION = "algorithm.expression"; + + private Properties properties = new Properties(); + + @Override + public String doSharding(final Collection availableTargetNames, final PreciseShardingValue> shardingValue) { + Preconditions.checkNotNull(properties.get(ALGORITHM_EXPRESSION), "Inline sharding algorithm expression cannot be null."); + Closure closure = new InlineExpressionParser(properties.get(ALGORITHM_EXPRESSION).toString()).evaluateClosure(); + Closure result = closure.rehydrate(new Expando(), null, null); + result.setResolveStrategy(Closure.DELEGATE_ONLY); + result.setProperty(shardingValue.getColumnName(), shardingValue.getValue()); + return result.call().toString(); + } + + @Override + public Collection doSharding(final Collection availableTargetNames, final RangeShardingValue> shardingValue) { + if (isAllowRangeQuery()) { + return availableTargetNames; + } + throw new UnsupportedOperationException("Since the property of `allow.range.query.with.inline.sharding` is false, inline sharding algorithm can not tackle with range query."); + } + + private boolean isAllowRangeQuery() { + return null != properties.get(ALLOW_RANGE_QUERY) && Boolean.parseBoolean(properties.get(ALLOW_RANGE_QUERY).toString()); + } + + @Override + public String getType() { + return "INLINE"; + } + + @Override + public Properties getProperties() { + return properties; + } + + @Override + public void setProperties(final Properties properties) { + this.properties = properties; + } +} diff --git a/sharding-core/sharding-core-common/src/main/resources/META-INF/services/org.apache.shardingsphere.spi.algorithm.ShardingAlgorithm b/sharding-core/sharding-core-common/src/main/resources/META-INF/services/org.apache.shardingsphere.spi.algorithm.ShardingAlgorithm new file mode 100644 index 0000000000..3e372c3c1b --- /dev/null +++ b/sharding-core/sharding-core-common/src/main/resources/META-INF/services/org.apache.shardingsphere.spi.algorithm.ShardingAlgorithm @@ -0,0 +1,18 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +org.apache.shardingsphere.core.strategy.sharding.InlineShardingAlgorithm diff --git a/sharding-core/sharding-core-common/src/test/java/org/apache/shardingsphere/core/yaml/engine/YamlEngineShadowShardingConfigurationTest.java b/sharding-core/sharding-core-common/src/test/java/org/apache/shardingsphere/core/yaml/engine/YamlEngineShadowShardingConfigurationTest.java index 1d4b1bf45a..ce1bd01651 100644 --- a/sharding-core/sharding-core-common/src/test/java/org/apache/shardingsphere/core/yaml/engine/YamlEngineShadowShardingConfigurationTest.java +++ b/sharding-core/sharding-core-common/src/test/java/org/apache/shardingsphere/core/yaml/engine/YamlEngineShadowShardingConfigurationTest.java @@ -100,8 +100,9 @@ public final class YamlEngineShadowShardingConfigurationTest { private void assertTOrder(final YamlRootShadowConfiguration actual) { assertThat(actual.getShadowRule().getShardingRule().getTables().get("t_order").getActualDataNodes(), is("ds_${0..1}.t_order_${0..1}")); - assertThat(actual.getShadowRule().getShardingRule().getTables().get("t_order").getTableStrategy().getInline().getShardingColumn(), is("order_id")); - assertThat(actual.getShadowRule().getShardingRule().getTables().get("t_order").getTableStrategy().getInline().getAlgorithmExpression(), is("t_order_${order_id % 2}")); + assertThat(actual.getShadowRule().getShardingRule().getTables().get("t_order").getTableStrategy().getStandard().getShardingColumn(), is("order_id")); + assertThat(actual.getShadowRule().getShardingRule().getTables().get("t_order").getTableStrategy().getStandard().getShardingAlgorithm().getProps().getProperty("algorithm.expression"), + is("t_order_${order_id % 2}")); assertThat(actual.getShadowRule().getShardingRule().getTables().get("t_order").getKeyGenerator().getColumn(), is("order_id")); assertThat(actual.getShadowRule().getShardingRule().getTables().get("t_order").getKeyGenerator().getType(), is("SNOWFLAKE")); } diff --git a/sharding-core/sharding-core-common/src/test/java/org/apache/shardingsphere/core/yaml/engine/YamlEngineShardingConfigurationTest.java b/sharding-core/sharding-core-common/src/test/java/org/apache/shardingsphere/core/yaml/engine/YamlEngineShardingConfigurationTest.java index 4bbafe77b5..4bac10822c 100644 --- a/sharding-core/sharding-core-common/src/test/java/org/apache/shardingsphere/core/yaml/engine/YamlEngineShardingConfigurationTest.java +++ b/sharding-core/sharding-core-common/src/test/java/org/apache/shardingsphere/core/yaml/engine/YamlEngineShardingConfigurationTest.java @@ -99,8 +99,9 @@ public final class YamlEngineShardingConfigurationTest { private void assertTOrder(final YamlRootShardingConfiguration actual) { assertThat(actual.getShardingRule().getTables().get("t_order").getActualDataNodes(), is("ds_${0..1}.t_order_${0..1}")); - assertThat(actual.getShardingRule().getTables().get("t_order").getTableStrategy().getInline().getShardingColumn(), is("order_id")); - assertThat(actual.getShardingRule().getTables().get("t_order").getTableStrategy().getInline().getAlgorithmExpression(), is("t_order_${order_id % 2}")); + assertThat(actual.getShardingRule().getTables().get("t_order").getTableStrategy().getStandard().getShardingColumn(), is("order_id")); + assertThat(actual.getShardingRule().getTables().get("t_order").getTableStrategy().getStandard().getShardingAlgorithm().getProps().getProperty("algorithm.expression"), + is("t_order_${order_id % 2}")); assertThat(actual.getShardingRule().getTables().get("t_order").getKeyGenerator().getColumn(), is("order_id")); assertThat(actual.getShardingRule().getTables().get("t_order").getKeyGenerator().getType(), is("SNOWFLAKE")); } diff --git a/sharding-core/sharding-core-common/src/test/resources/yaml/shadow-sharding-rule.yaml b/sharding-core/sharding-core-common/src/test/resources/yaml/shadow-sharding-rule.yaml index f0bdecded9..270433194b 100644 --- a/sharding-core/sharding-core-common/src/test/resources/yaml/shadow-sharding-rule.yaml +++ b/sharding-core/sharding-core-common/src/test/resources/yaml/shadow-sharding-rule.yaml @@ -92,9 +92,12 @@ shadowRule: t_order: actualDataNodes: ds_${0..1}.t_order_${0..1} tableStrategy: - inline: + standard: shardingColumn: order_id - algorithmExpression: t_order_${order_id % 2} + shardingAlgorithm: + type: INLINE + props: + algorithm.expression: t_order_${order_id % 2} keyGenerator: type: SNOWFLAKE column: order_id @@ -112,9 +115,12 @@ shadowRule: broadcastTables: - t_config defaultDatabaseStrategy: - inline: + standard: shardingColumn: order_id - algorithmExpression: ds_${order_id % 2} + shardingAlgorithm: + type: INLINE + props: + algorithm.expression: ds_${order_id % 2} defaultTableStrategy: none: masterSlaveRules: diff --git a/sharding-core/sharding-core-common/src/test/resources/yaml/sharding-rule.yaml b/sharding-core/sharding-core-common/src/test/resources/yaml/sharding-rule.yaml index 2acfd56a55..e4ab3bf879 100644 --- a/sharding-core/sharding-core-common/src/test/resources/yaml/sharding-rule.yaml +++ b/sharding-core/sharding-core-common/src/test/resources/yaml/sharding-rule.yaml @@ -79,9 +79,12 @@ shardingRule: t_order: actualDataNodes: ds_${0..1}.t_order_${0..1} tableStrategy: - inline: + standard: shardingColumn: order_id - algorithmExpression: t_order_${order_id % 2} + shardingAlgorithm: + type: INLINE + props: + algorithm.expression: t_order_${order_id % 2} keyGenerator: type: SNOWFLAKE column: order_id @@ -99,9 +102,12 @@ shardingRule: broadcastTables: - t_config defaultDatabaseStrategy: - inline: + standard: shardingColumn: order_id - algorithmExpression: ds_${order_id % 2} + shardingAlgorithm: + type: INLINE + props: + algorithm.expression: ds_${order_id % 2} defaultTableStrategy: none: masterSlaveRules: diff --git a/sharding-core/sharding-core-rewrite/src/test/resources/yaml/mix/query-with-cipher.yaml b/sharding-core/sharding-core-rewrite/src/test/resources/yaml/mix/query-with-cipher.yaml index 3decc2ed62..34c2a5de75 100644 --- a/sharding-core/sharding-core-rewrite/src/test/resources/yaml/mix/query-with-cipher.yaml +++ b/sharding-core/sharding-core-rewrite/src/test/resources/yaml/mix/query-with-cipher.yaml @@ -27,27 +27,36 @@ shardingRule: t_account: actualDataNodes: db.t_account_${0..1} tableStrategy: - inline: + standard: shardingColumn: account_id - algorithmExpression: t_account_${account_id % 2} + shardingAlgorithm: + type: INLINE + props: + algorithm.expression: t_account_${account_id % 2} keyGenerator: type: TEST column: account_id t_account_bak: actualDataNodes: db.t_account_bak_${0..1} tableStrategy: - inline: + standard: shardingColumn: account_id - algorithmExpression: t_account_bak_${account_id % 2} + shardingAlgorithm: + type: INLINE + props: + algorithm.expression: t_account_bak_${account_id % 2} keyGenerator: type: TEST column: account_id t_account_detail: actualDataNodes: db.t_account_detail_${0..1} tableStrategy: - inline: + standard: shardingColumn: account_id - algorithmExpression: t_account_${account_id % 2} + shardingAlgorithm: + type: INLINE + props: + algorithm.expression: t_account_${account_id % 2} bindingTables: - t_account, t_account_detail diff --git a/sharding-core/sharding-core-rewrite/src/test/resources/yaml/mix/query-with-plain.yaml b/sharding-core/sharding-core-rewrite/src/test/resources/yaml/mix/query-with-plain.yaml index ec94bc1288..3e544a51c0 100644 --- a/sharding-core/sharding-core-rewrite/src/test/resources/yaml/mix/query-with-plain.yaml +++ b/sharding-core/sharding-core-rewrite/src/test/resources/yaml/mix/query-with-plain.yaml @@ -27,27 +27,36 @@ shardingRule: t_account: actualDataNodes: db.t_account_${0..1} tableStrategy: - inline: + standard: shardingColumn: account_id - algorithmExpression: t_account_${account_id % 2} + shardingAlgorithm: + type: INLINE + props: + algorithm.expression: t_account_${account_id % 2} keyGenerator: type: TEST column: account_id t_account_bak: actualDataNodes: db.t_account_bak_${0..1} tableStrategy: - inline: + standard: shardingColumn: account_id - algorithmExpression: t_account_bak_${account_id % 2} + shardingAlgorithm: + type: INLINE + props: + algorithm.expression: t_account_bak_${account_id % 2} keyGenerator: type: TEST column: account_id t_account_detail: actualDataNodes: db.t_account_detail_${0..1} tableStrategy: - inline: + standard: shardingColumn: account_id - algorithmExpression: t_account_${account_id % 2} + shardingAlgorithm: + type: INLINE + props: + algorithm.expression: t_account_${account_id % 2} bindingTables: - t_account, t_account_detail diff --git a/sharding-core/sharding-core-rewrite/src/test/resources/yaml/sharding/sharding-rule.yaml b/sharding-core/sharding-core-rewrite/src/test/resources/yaml/sharding/sharding-rule.yaml index 3f191b9004..82be7229a8 100644 --- a/sharding-core/sharding-core-rewrite/src/test/resources/yaml/sharding/sharding-rule.yaml +++ b/sharding-core/sharding-core-rewrite/src/test/resources/yaml/sharding/sharding-rule.yaml @@ -27,17 +27,23 @@ shardingRule: t_account: actualDataNodes: db.t_account_${0..1} tableStrategy: - inline: + standard: shardingColumn: account_id - algorithmExpression: t_account_${account_id % 2} + shardingAlgorithm: + type: INLINE + props: + algorithm.expression: t_account_${account_id % 2} keyGenerator: type: TEST column: account_id t_account_detail: actualDataNodes: db.t_account_detail_${0..1} tableStrategy: - inline: + standard: shardingColumn: account_id - algorithmExpression: t_account_detail_${account_id % 2} + shardingAlgorithm: + type: INLINE + props: + algorithm.expression: t_account_detail_${account_id % 2} bindingTables: - t_account, t_account_detail diff --git a/sharding-integration-test/sharding-jdbc-test/src/test/resources/integrate/env/shadow/sharding-rule.yaml b/sharding-integration-test/sharding-jdbc-test/src/test/resources/integrate/env/shadow/sharding-rule.yaml index 28f71bf659..89cad5997d 100644 --- a/sharding-integration-test/sharding-jdbc-test/src/test/resources/integrate/env/shadow/sharding-rule.yaml +++ b/sharding-integration-test/sharding-jdbc-test/src/test/resources/integrate/env/shadow/sharding-rule.yaml @@ -24,13 +24,19 @@ shadowRule: t_order_item: actualDataNodes: db.t_order_item databaseStrategy: - inline: + standard: shardingColumn: item_id - algorithmExpression: db + shardingAlgorithm: + type: INLINE + props: + algorithm.expression: db tableStrategy: - inline: + standard: shardingColumn: item_id - algorithmExpression: t_order_item + shardingAlgorithm: + type: INLINE + props: + algorithm.expression: t_order_item keyGenerator: type: Constant column: item_id diff --git a/sharding-jdbc/sharding-jdbc-orchestration/src/test/resources/yaml/integrate/sharding/configWithDataSourceWithProps.yaml b/sharding-jdbc/sharding-jdbc-orchestration/src/test/resources/yaml/integrate/sharding/configWithDataSourceWithProps.yaml index 6f3f628df2..052d394cab 100644 --- a/sharding-jdbc/sharding-jdbc-orchestration/src/test/resources/yaml/integrate/sharding/configWithDataSourceWithProps.yaml +++ b/sharding-jdbc/sharding-jdbc-orchestration/src/test/resources/yaml/integrate/sharding/configWithDataSourceWithProps.yaml @@ -42,9 +42,12 @@ shardingRule: shardingAlgorithm: type: STANDARD_TEST tableStrategy: - inline: + standard: shardingColumn: order_id - algorithmExpression: t_order_${order_id % 2} + shardingAlgorithm: + type: INLINE + props: + algorithm.expression: t_order_${order_id % 2} keyGenerator: type: INCREMENT column: order_id @@ -56,9 +59,12 @@ shardingRule: shardingAlgorithm: type: STANDARD_TEST tableStrategy: - inline: + standard: shardingColumn: order_id - algorithmExpression: t_order_item_${order_id % 2} + shardingAlgorithm: + type: INLINE + props: + algorithm.expression: t_order_item_${order_id % 2} bindingTables: - t_order,t_order_item diff --git a/sharding-jdbc/sharding-jdbc-orchestration/src/test/resources/yaml/integrate/sharding/configWithDataSourceWithoutProps.yaml b/sharding-jdbc/sharding-jdbc-orchestration/src/test/resources/yaml/integrate/sharding/configWithDataSourceWithoutProps.yaml index ab9376bf1c..6b94421513 100644 --- a/sharding-jdbc/sharding-jdbc-orchestration/src/test/resources/yaml/integrate/sharding/configWithDataSourceWithoutProps.yaml +++ b/sharding-jdbc/sharding-jdbc-orchestration/src/test/resources/yaml/integrate/sharding/configWithDataSourceWithoutProps.yaml @@ -41,10 +41,13 @@ shardingRule: shardingColumn: user_id shardingAlgorithm: type: STANDARD_TEST - tableStrategy: - inline: + tableStrategy: + standard: shardingColumn: order_id - algorithmExpression: t_order_${order_id % 2} + shardingAlgorithm: + type: INLINE + props: + algorithm.expression: t_order_${order_id % 2} keyGenerator: type: INCREMENT column: order_id @@ -56,9 +59,12 @@ shardingRule: shardingAlgorithm: type: STANDARD_TEST tableStrategy: - inline: + standard: shardingColumn: order_id - algorithmExpression: t_order_item_${order_id % 2} + shardingAlgorithm: + type: INLINE + props: + algorithm.expression: t_order_${order_id % 2} bindingTables: - t_order,t_order_item diff --git a/sharding-jdbc/sharding-jdbc-orchestration/src/test/resources/yaml/integrate/sharding/configWithoutDataSourceWithProps.yaml b/sharding-jdbc/sharding-jdbc-orchestration/src/test/resources/yaml/integrate/sharding/configWithoutDataSourceWithProps.yaml index d2185b78af..0156acffda 100644 --- a/sharding-jdbc/sharding-jdbc-orchestration/src/test/resources/yaml/integrate/sharding/configWithoutDataSourceWithProps.yaml +++ b/sharding-jdbc/sharding-jdbc-orchestration/src/test/resources/yaml/integrate/sharding/configWithoutDataSourceWithProps.yaml @@ -28,9 +28,12 @@ shardingRule: shardingAlgorithm: type: STANDARD_TEST tableStrategy: - inline: + standard: shardingColumn: order_id - algorithmExpression: t_order_${order_id % 2} + shardingAlgorithm: + type: INLINE + props: + algorithm.expression: t_order_${order_id % 2} keyGenerator: type: INCREMENT column: order_id @@ -42,9 +45,12 @@ shardingRule: shardingAlgorithm: type: STANDARD_TEST tableStrategy: - inline: + standard: shardingColumn: order_id - algorithmExpression: t_order_item_${order_id % 2} + shardingAlgorithm: + type: INLINE + props: + algorithm.expression: t_order_item_${order_id % 2} bindingTables: - t_order,t_order_item diff --git a/sharding-jdbc/sharding-jdbc-orchestration/src/test/resources/yaml/integrate/sharding/configWithoutDataSourceWithoutProps.yaml b/sharding-jdbc/sharding-jdbc-orchestration/src/test/resources/yaml/integrate/sharding/configWithoutDataSourceWithoutProps.yaml index fcc138ccae..ef5999c529 100644 --- a/sharding-jdbc/sharding-jdbc-orchestration/src/test/resources/yaml/integrate/sharding/configWithoutDataSourceWithoutProps.yaml +++ b/sharding-jdbc/sharding-jdbc-orchestration/src/test/resources/yaml/integrate/sharding/configWithoutDataSourceWithoutProps.yaml @@ -27,9 +27,12 @@ shardingRule: shardingAlgorithm: type: STANDARD_TEST tableStrategy: - inline: + standard: shardingColumn: order_id - algorithmExpression: t_order_${order_id % 2} + shardingAlgorithm: + type: INLINE + props: + algorithm.expression: t_order_${order_id % 2} keyGenerator: type: INCREMENT column: order_id @@ -41,9 +44,12 @@ shardingRule: shardingAlgorithm: type: STANDARD_TEST tableStrategy: - inline: + standard: shardingColumn: order_id - algorithmExpression: t_order_item_${order_id % 2} + shardingAlgorithm: + type: INLINE + props: + algorithm.expression: t_order_item_${order_id % 2} bindingTables: - t_order,t_order_item defaultDatabaseStrategy: diff --git a/sharding-jdbc/sharding-jdbc-orchestration/src/test/resources/yaml/integrate/sharding_ms/configWithDataSourceWithProps.yaml b/sharding-jdbc/sharding-jdbc-orchestration/src/test/resources/yaml/integrate/sharding_ms/configWithDataSourceWithProps.yaml index 523617fe4e..97f79d9ea1 100644 --- a/sharding-jdbc/sharding-jdbc-orchestration/src/test/resources/yaml/integrate/sharding_ms/configWithDataSourceWithProps.yaml +++ b/sharding-jdbc/sharding-jdbc-orchestration/src/test/resources/yaml/integrate/sharding_ms/configWithDataSourceWithProps.yaml @@ -54,9 +54,12 @@ shardingRule: shardingAlgorithm: type: STANDARD_TEST tableStrategy: - inline: + standard: shardingColumn: order_id - algorithmExpression: t_order_${order_id % 2} + shardingAlgorithm: + type: INLINE + props: + algorithm.expression: t_order_${order_id % 2} keyGenerator: type: INCREMENT column: order_id @@ -68,9 +71,12 @@ shardingRule: shardingAlgorithm: type: STANDARD_TEST tableStrategy: - inline: + standard: shardingColumn: id - algorithmExpression: t_order_item_${id % 2} + shardingAlgorithm: + type: INLINE + props: + algorithm.expression: t_order_item_${id % 2} bindingTables: - t_order,t_order_item diff --git a/sharding-jdbc/sharding-jdbc-orchestration/src/test/resources/yaml/integrate/sharding_ms/configWithDataSourceWithoutProps.yaml b/sharding-jdbc/sharding-jdbc-orchestration/src/test/resources/yaml/integrate/sharding_ms/configWithDataSourceWithoutProps.yaml index 3bb0a73e67..a0c4bc959b 100644 --- a/sharding-jdbc/sharding-jdbc-orchestration/src/test/resources/yaml/integrate/sharding_ms/configWithDataSourceWithoutProps.yaml +++ b/sharding-jdbc/sharding-jdbc-orchestration/src/test/resources/yaml/integrate/sharding_ms/configWithDataSourceWithoutProps.yaml @@ -54,9 +54,12 @@ shardingRule: shardingAlgorithm: type: STANDARD_TEST tableStrategy: - inline: + standard: shardingColumn: order_id - algorithmExpression: t_order_${order_id % 2} + shardingAlgorithm: + type: INLINE + props: + algorithm.expression: t_order_${order_id % 2} keyGenerator: type: INCREMENT column: order_id @@ -68,9 +71,12 @@ shardingRule: shardingAlgorithm: type: STANDARD_TEST tableStrategy: - inline: + standard: shardingColumn: order_id - algorithmExpression: t_order_item_${order_id % 2} + shardingAlgorithm: + type: INLINE + props: + algorithm.expression: t_order_item_${order_id % 2} bindingTables: - t_order,t_order_item diff --git a/sharding-jdbc/sharding-jdbc-orchestration/src/test/resources/yaml/integrate/sharding_ms/configWithoutDataSourceWithoutProps.yaml b/sharding-jdbc/sharding-jdbc-orchestration/src/test/resources/yaml/integrate/sharding_ms/configWithoutDataSourceWithoutProps.yaml index 74dc8578f0..051887b4d0 100644 --- a/sharding-jdbc/sharding-jdbc-orchestration/src/test/resources/yaml/integrate/sharding_ms/configWithoutDataSourceWithoutProps.yaml +++ b/sharding-jdbc/sharding-jdbc-orchestration/src/test/resources/yaml/integrate/sharding_ms/configWithoutDataSourceWithoutProps.yaml @@ -28,9 +28,12 @@ shardingRule: shardingAlgorithm: type: STANDARD_TEST tableStrategy: - inline: + standard: shardingColumn: order_id - algorithmExpression: t_order_${order_id % 2} + shardingAlgorithm: + type: INLINE + props: + algorithm.expression: t_order_${order_id % 2} keyGenerator: type: INCREMENT column: order_id @@ -42,9 +45,12 @@ shardingRule: shardingAlgorithm: type: STANDARD_TEST tableStrategy: - inline: + standard: shardingColumn: order_id - algorithmExpression: t_order_item_${order_id % 2} + shardingAlgorithm: + type: INLINE + props: + algorithm.expression: t_order_item_${order_id % 2} bindingTables: - t_order,t_order_item diff --git a/sharding-jdbc/sharding-jdbc-orchestration/src/test/resources/yaml/unit/sharding.yaml b/sharding-jdbc/sharding-jdbc-orchestration/src/test/resources/yaml/unit/sharding.yaml index f2bd814334..1ba3b5642e 100644 --- a/sharding-jdbc/sharding-jdbc-orchestration/src/test/resources/yaml/unit/sharding.yaml +++ b/sharding-jdbc/sharding-jdbc-orchestration/src/test/resources/yaml/unit/sharding.yaml @@ -32,13 +32,19 @@ shardingRule: t_order: actualDataNodes: ds_ms.t_order_${0..1} databaseStrategy: - inline: + standard: shardingColumn: user_id - algorithmExpression: t_order_${user_id % 2} + shardingAlgorithm: + type: INLINE + props: + algorithm.expression: t_order_${user_id % 2} tableStrategy: - inline: + standard: shardingColumn: order_id - algorithmExpression: t_order_${order_id % 2} + shardingAlgorithm: + type: INLINE + props: + algorithm.expression: t_order_${order_id % 2} keyGenerator: type: SNOWFLAKE column: order_id @@ -47,9 +53,12 @@ shardingRule: t_order_item: actualDataNodes: ds_ms.t_order_item_${0..1} tableStrategy: - inline: + standard: shardingColumn: order_id - algorithmExpression: t_order_item_${order_id % 2} + shardingAlgorithm: + type: INLINE + props: + algorithm.expression: t_order_item_${order_id % 2} keyGenerator: type: SNOWFLAKE column: order_item_id @@ -63,9 +72,12 @@ shardingRule: slaveDataSourceNames: - ds_s defaultDatabaseStrategy: - inline: + standard: shardingColumn: user_id - algorithmExpression: ds_ms_${user_id % 2} + shardingAlgorithm: + type: INLINE + props: + algorithm.expression: ds_ms_${user_id % 2} defaultTableStrategy: none: props: -- GitLab