You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2023/07/08 05:42:57 UTC
[shardingsphere] branch master updated: Refactor YamlShardingRuleConfigurationSwapper (#26832)
This is an automated email from the ASF dual-hosted git repository.
zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 79e0cd9a0e7 Refactor YamlShardingRuleConfigurationSwapper (#26832)
79e0cd9a0e7 is described below
commit 79e0cd9a0e713f9dd23ab17527006108c991f6a7
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Sat Jul 8 13:42:51 2023 +0800
Refactor YamlShardingRuleConfigurationSwapper (#26832)
* Fix javadoc for RuleItemConfigurationChangedProcessor
* Refactor YamlShardingRuleConfigurationSwapper
---
.../swapper/NewYamlShardingRuleConfigurationSwapper.java | 12 ++++++------
.../yaml/swapper/YamlShardingRuleConfigurationSwapper.java | 12 ++++++------
2 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/yaml/swapper/NewYamlShardingRuleConfigurationSwapper.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/yaml/swapper/NewYamlShardingRuleConfigurationSwapper.java
index 13f16e2a510..8d3c07cf435 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/yaml/swapper/NewYamlShardingRuleConfigurationSwapper.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/yaml/swapper/NewYamlShardingRuleConfigurationSwapper.java
@@ -59,7 +59,7 @@ public final class NewYamlShardingRuleConfigurationSwapper implements NewYamlRul
private final YamlShardingTableRuleConfigurationSwapper tableSwapper = new YamlShardingTableRuleConfigurationSwapper();
- private final YamlShardingAutoTableRuleConfigurationSwapper autoTableYamlSwapper = new YamlShardingAutoTableRuleConfigurationSwapper();
+ private final YamlShardingAutoTableRuleConfigurationSwapper autoTableSwapper = new YamlShardingAutoTableRuleConfigurationSwapper();
private final YamlShardingStrategyConfigurationSwapper shardingStrategySwapper = new YamlShardingStrategyConfigurationSwapper();
@@ -69,7 +69,7 @@ public final class NewYamlShardingRuleConfigurationSwapper implements NewYamlRul
private final YamlAlgorithmConfigurationSwapper algorithmSwapper = new YamlAlgorithmConfigurationSwapper();
- private final YamlShardingCacheConfigurationSwapper shardingCacheYamlSwapper = new YamlShardingCacheConfigurationSwapper();
+ private final YamlShardingCacheConfigurationSwapper shardingCacheSwapper = new YamlShardingCacheConfigurationSwapper();
private final RuleNodePath shardingRuleNodePath = new ShardingRuleNodePathProvider().getRuleNodePath();
@@ -83,7 +83,7 @@ public final class NewYamlShardingRuleConfigurationSwapper implements NewYamlRul
}
if (null != data.getShardingCache()) {
result.add(new YamlDataNode(shardingRuleNodePath.getUniqueItem(ShardingRuleNodePathProvider.SHARDING_CACHE).getPath(),
- YamlEngine.marshal(shardingCacheYamlSwapper.swapToYamlConfiguration(data.getShardingCache()))));
+ YamlEngine.marshal(shardingCacheSwapper.swapToYamlConfiguration(data.getShardingCache()))));
}
swapTableRules(data, result);
return result;
@@ -130,7 +130,7 @@ public final class NewYamlShardingRuleConfigurationSwapper implements NewYamlRul
}
for (ShardingAutoTableRuleConfiguration each : data.getAutoTables()) {
result.add(new YamlDataNode(shardingRuleNodePath.getNamedItem(ShardingRuleNodePathProvider.AUTO_TABLES).getPath(each.getLogicTable()),
- YamlEngine.marshal(autoTableYamlSwapper.swapToYamlConfiguration(each))));
+ YamlEngine.marshal(autoTableSwapper.swapToYamlConfiguration(each))));
}
for (ShardingTableReferenceRuleConfiguration each : data.getBindingTableGroups()) {
result.add(new YamlDataNode(shardingRuleNodePath.getNamedItem(ShardingRuleNodePathProvider.BINDING_TABLES).getPath(each.getName()),
@@ -149,7 +149,7 @@ public final class NewYamlShardingRuleConfigurationSwapper implements NewYamlRul
shardingRuleNodePath.getNamedItem(ShardingRuleNodePathProvider.TABLES).getName(each.getKey())
.ifPresent(optional -> result.getTables().add(tableSwapper.swapToObject(YamlEngine.unmarshal(each.getValue(), YamlTableRuleConfiguration.class))));
shardingRuleNodePath.getNamedItem(ShardingRuleNodePathProvider.AUTO_TABLES).getName(each.getKey())
- .ifPresent(optional -> result.getAutoTables().add(autoTableYamlSwapper.swapToObject(YamlEngine.unmarshal(each.getValue(), YamlShardingAutoTableRuleConfiguration.class))));
+ .ifPresent(optional -> result.getAutoTables().add(autoTableSwapper.swapToObject(YamlEngine.unmarshal(each.getValue(), YamlShardingAutoTableRuleConfiguration.class))));
shardingRuleNodePath.getNamedItem(ShardingRuleNodePathProvider.BINDING_TABLES).getName(each.getKey())
.ifPresent(optional -> result.getBindingTableGroups().add(YamlShardingTableReferenceRuleConfigurationConverter.convertToObject(each.getValue())));
shardingRuleNodePath.getNamedItem(ShardingRuleNodePathProvider.ALGORITHMS).getName(each.getKey())
@@ -169,7 +169,7 @@ public final class NewYamlShardingRuleConfigurationSwapper implements NewYamlRul
} else if (shardingRuleNodePath.getUniqueItem(ShardingRuleNodePathProvider.DEFAULT_SHARDING_COLUMN).isValidatedPath(each.getKey())) {
result.setDefaultShardingColumn(each.getValue());
} else if (shardingRuleNodePath.getUniqueItem(ShardingRuleNodePathProvider.SHARDING_CACHE).isValidatedPath(each.getKey())) {
- result.setShardingCache(shardingCacheYamlSwapper.swapToObject(YamlEngine.unmarshal(each.getValue(), YamlShardingCacheConfiguration.class)));
+ result.setShardingCache(shardingCacheSwapper.swapToObject(YamlEngine.unmarshal(each.getValue(), YamlShardingCacheConfiguration.class)));
}
}
return Optional.of(result);
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/yaml/swapper/YamlShardingRuleConfigurationSwapper.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/yaml/swapper/YamlShardingRuleConfigurationSwapper.java
index 10695e0049d..d0be6cad5ec 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/yaml/swapper/YamlShardingRuleConfigurationSwapper.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/yaml/swapper/YamlShardingRuleConfigurationSwapper.java
@@ -50,21 +50,21 @@ public final class YamlShardingRuleConfigurationSwapper implements YamlRuleConfi
private final YamlShardingAuditStrategyConfigurationSwapper auditStrategySwapper = new YamlShardingAuditStrategyConfigurationSwapper();
- private final YamlShardingAutoTableRuleConfigurationSwapper autoTableYamlSwapper = new YamlShardingAutoTableRuleConfigurationSwapper();
+ private final YamlShardingAutoTableRuleConfigurationSwapper autoTableSwapper = new YamlShardingAutoTableRuleConfigurationSwapper();
- private final YamlShardingCacheConfigurationSwapper shardingCacheYamlSwapper = new YamlShardingCacheConfigurationSwapper();
+ private final YamlShardingCacheConfigurationSwapper shardingCacheSwapper = new YamlShardingCacheConfigurationSwapper();
@Override
public YamlShardingRuleConfiguration swapToYamlConfiguration(final ShardingRuleConfiguration data) {
YamlShardingRuleConfiguration result = new YamlShardingRuleConfiguration();
data.getTables().forEach(each -> result.getTables().put(each.getLogicTable(), tableSwapper.swapToYamlConfiguration(each)));
- data.getAutoTables().forEach(each -> result.getAutoTables().put(each.getLogicTable(), autoTableYamlSwapper.swapToYamlConfiguration(each)));
+ data.getAutoTables().forEach(each -> result.getAutoTables().put(each.getLogicTable(), autoTableSwapper.swapToYamlConfiguration(each)));
result.getBindingTables().addAll(data.getBindingTableGroups().stream().map(YamlShardingTableReferenceRuleConfigurationConverter::convertToYamlString).collect(Collectors.toList()));
setYamlStrategies(data, result);
setYamlAlgorithms(data, result);
result.setDefaultShardingColumn(data.getDefaultShardingColumn());
if (null != data.getShardingCache()) {
- result.setShardingCache(shardingCacheYamlSwapper.swapToYamlConfiguration(data.getShardingCache()));
+ result.setShardingCache(shardingCacheSwapper.swapToYamlConfiguration(data.getShardingCache()));
}
return result;
}
@@ -107,14 +107,14 @@ public final class YamlShardingRuleConfigurationSwapper implements YamlRuleConfi
for (Entry<String, YamlShardingAutoTableRuleConfiguration> entry : yamlConfig.getAutoTables().entrySet()) {
YamlShardingAutoTableRuleConfiguration tableRuleConfig = entry.getValue();
tableRuleConfig.setLogicTable(entry.getKey());
- result.getAutoTables().add(autoTableYamlSwapper.swapToObject(tableRuleConfig));
+ result.getAutoTables().add(autoTableSwapper.swapToObject(tableRuleConfig));
}
result.getBindingTableGroups().addAll(yamlConfig.getBindingTables().stream().map(YamlShardingTableReferenceRuleConfigurationConverter::convertToObject).collect(Collectors.toList()));
setStrategies(yamlConfig, result);
setAlgorithms(yamlConfig, result);
result.setDefaultShardingColumn(yamlConfig.getDefaultShardingColumn());
if (null != yamlConfig.getShardingCache()) {
- result.setShardingCache(shardingCacheYamlSwapper.swapToObject(yamlConfig.getShardingCache()));
+ result.setShardingCache(shardingCacheSwapper.swapToObject(yamlConfig.getShardingCache()));
}
return result;
}