Skip to content

Commit

Permalink
Refactor YamlRuleConfigurationUnmarshalIT
Browse files Browse the repository at this point in the history
  • Loading branch information
terrymanu committed Sep 27, 2024
1 parent 59a8017 commit 8da590a
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
class ShardingConfigurationRepositoryTupleSwapperEngineIT extends RepositoryTupleSwapperEngineIT {

ShardingConfigurationRepositoryTupleSwapperEngineIT() {
super("yaml/sharding-rule.yaml");
super("yaml/sharding-rule-for-tuple.yaml");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ private static ShardingRuleConfiguration getExpectedRuleConfiguration() {
ShardingTableRuleConfiguration orderItemTableRuleConfig = new ShardingTableRuleConfiguration("t_order_item", "ds_${0..1}.t_order_item_${0..1}");
orderItemTableRuleConfig.setTableShardingStrategy(new StandardShardingStrategyConfiguration("order_id", "core_standard_fixture"));
result.getTables().add(orderItemTableRuleConfig);
result.getBindingTableGroups().add(new ShardingTableReferenceRuleConfiguration(null, "t_order, t_order_item"));
result.getBindingTableGroups().add(new ShardingTableReferenceRuleConfiguration("foo", "t_order, t_order_item"));
result.setDefaultDatabaseShardingStrategy(new StandardShardingStrategyConfiguration("order_id", "database_inline"));
result.setDefaultTableShardingStrategy(new NoneShardingStrategyConfiguration());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
#
# 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.
#

rules:
- !SHARDING
tables:
t_user:
actualDataNodes: ds_${0..1}.t_user_${0..15}
databaseStrategy:
complex:
shardingColumns: region_id, user_id
shardingAlgorithmName: core_complex_fixture
tableStrategy:
complex:
shardingColumns: region_id, user_id
shardingAlgorithmName: core_complex_fixture
t_stock:
actualDataNodes: ds_${0..1}.t_stock{0..8}
databaseStrategy:
hint:
shardingAlgorithmName: core_hint_fixture
tableStrategy:
hint:
shardingAlgorithmName: core_hint_fixture
t_order:
actualDataNodes: ds_${0..1}.t_order_${0..1}
tableStrategy:
standard:
shardingColumn: order_id
shardingAlgorithmName: table_inline
keyGenerateStrategy:
column: order_id
keyGeneratorName: snowflake
t_order_item:
actualDataNodes: ds_${0..1}.t_order_item_${0..1}
tableStrategy:
standard:
shardingColumn: order_id
shardingAlgorithmName: core_standard_fixture
bindingTables:
- t_order, t_order_item
- foo:t_order, t_order_item
defaultDatabaseStrategy:
standard:
shardingColumn: order_id
shardingAlgorithmName: database_inline
defaultTableStrategy:
none:
defaultShardingColumn: order_id
defaultKeyGenerateStrategy:
column: id
keyGeneratorName: snowflake
defaultAuditStrategy:
auditorNames:
- sharding_key_required_auditor
allowHintDisable: true

shardingAlgorithms:
core_standard_fixture:
type: CORE.STANDARD.FIXTURE
core_complex_fixture:
type: CORE.COMPLEX.FIXTURE
core_hint_fixture:
type: CORE.HINT.FIXTURE
database_inline:
type: INLINE
props:
algorithm-expression: ds_${order_id % 2}
table_inline:
type: INLINE
props:
algorithm-expression: t_order_${order_id % 2}

keyGenerators:
snowflake:
type: SNOWFLAKE

auditors:
sharding_key_required_auditor:
type: DML_SHARDING_CONDITIONS

shardingCache:
allowedMaxSqlLength: 512
routeCache:
softValues: true
initialCapacity: 65536
maximumSize: 262144
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ rules:
shardingColumn: order_id
shardingAlgorithmName: core_standard_fixture
bindingTables:
- foo:t_order, t_order_item
- foo:t_order, t_order_item
defaultDatabaseStrategy:
standard:
shardingColumn: order_id
Expand Down

0 comments on commit 8da590a

Please sign in to comment.