1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.shardingsphere.sharding.yaml.config;
19
20 import lombok.Getter;
21 import lombok.Setter;
22 import org.apache.shardingsphere.infra.algorithm.core.yaml.YamlAlgorithmConfiguration;
23 import org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfiguration;
24 import org.apache.shardingsphere.mode.tuple.annotation.RepositoryTupleField;
25 import org.apache.shardingsphere.mode.tuple.annotation.RepositoryTupleEntity;
26 import org.apache.shardingsphere.mode.tuple.annotation.RepositoryTupleField.Type;
27 import org.apache.shardingsphere.mode.tuple.annotation.RepositoryTupleKeyListNameGenerator;
28 import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
29 import org.apache.shardingsphere.sharding.yaml.config.cache.YamlShardingCacheConfiguration;
30 import org.apache.shardingsphere.sharding.yaml.config.rule.YamlShardingAutoTableRuleConfiguration;
31 import org.apache.shardingsphere.sharding.yaml.config.rule.YamlTableRuleConfiguration;
32 import org.apache.shardingsphere.sharding.yaml.config.strategy.audit.YamlShardingAuditStrategyConfiguration;
33 import org.apache.shardingsphere.sharding.yaml.config.strategy.keygen.YamlKeyGenerateStrategyConfiguration;
34 import org.apache.shardingsphere.sharding.yaml.config.strategy.sharding.YamlShardingStrategyConfiguration;
35 import org.apache.shardingsphere.sharding.yaml.swapper.ShardingBindingTableRepositoryTupleKeyListNameGenerator;
36
37 import java.util.Collection;
38 import java.util.LinkedHashMap;
39 import java.util.LinkedList;
40 import java.util.Map;
41
42
43
44
45 @RepositoryTupleEntity("sharding")
46 @Getter
47 @Setter
48 public final class YamlShardingRuleConfiguration implements YamlRuleConfiguration {
49
50 @RepositoryTupleField(type = Type.TABLE)
51 private Map<String, YamlTableRuleConfiguration> tables = new LinkedHashMap<>();
52
53 @RepositoryTupleField(type = Type.TABLE)
54 private Map<String, YamlShardingAutoTableRuleConfiguration> autoTables = new LinkedHashMap<>();
55
56 @RepositoryTupleField(type = Type.TABLE)
57 @RepositoryTupleKeyListNameGenerator(ShardingBindingTableRepositoryTupleKeyListNameGenerator.class)
58 private Collection<String> bindingTables = new LinkedList<>();
59
60 @RepositoryTupleField(type = Type.DEFAULT_STRATEGY)
61 private YamlShardingStrategyConfiguration defaultDatabaseStrategy;
62
63 @RepositoryTupleField(type = Type.DEFAULT_STRATEGY)
64 private YamlShardingStrategyConfiguration defaultTableStrategy;
65
66 @RepositoryTupleField(type = Type.DEFAULT_STRATEGY)
67 private YamlKeyGenerateStrategyConfiguration defaultKeyGenerateStrategy;
68
69 @RepositoryTupleField(type = Type.DEFAULT_STRATEGY)
70 private YamlShardingAuditStrategyConfiguration defaultAuditStrategy;
71
72 @RepositoryTupleField(type = Type.ALGORITHM)
73 private Map<String, YamlAlgorithmConfiguration> shardingAlgorithms = new LinkedHashMap<>();
74
75 @RepositoryTupleField(type = Type.ALGORITHM)
76 private Map<String, YamlAlgorithmConfiguration> keyGenerators = new LinkedHashMap<>();
77
78 @RepositoryTupleField(type = Type.ALGORITHM)
79 private Map<String, YamlAlgorithmConfiguration> auditors = new LinkedHashMap<>();
80
81 @RepositoryTupleField(type = Type.OTHER)
82 private String defaultShardingColumn;
83
84 @RepositoryTupleField(type = Type.OTHER)
85 private YamlShardingCacheConfiguration shardingCache;
86
87 @Override
88 public Class<ShardingRuleConfiguration> getRuleConfigurationType() {
89 return ShardingRuleConfiguration.class;
90 }
91 }