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/06/14 03:12:08 UTC
[shardingsphere] branch master updated: Fix single rule persist by new metadata (#26335)
This is an automated email from the ASF dual-hosted git repository.
zhaojinchao 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 caf19bd9ddd Fix single rule persist by new metadata (#26335)
caf19bd9ddd is described below
commit caf19bd9ddd53685af87cc53026602754414cb99
Author: ChenJiaHao <Pa...@163.com>
AuthorDate: Wed Jun 14 11:12:00 2023 +0800
Fix single rule persist by new metadata (#26335)
---
.../config/swapper/NewYamlSingleRuleConfigurationSwapper.java | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/yaml/config/swapper/NewYamlSingleRuleConfigurationSwapper.java b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/yaml/config/swapper/NewYamlSingleRuleConfigurationSwapper.java
index 83f60b3fd18..dd49edf9b84 100644
--- a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/yaml/config/swapper/NewYamlSingleRuleConfigurationSwapper.java
+++ b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/yaml/config/swapper/NewYamlSingleRuleConfigurationSwapper.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.single.yaml.config.swapper;
-import org.apache.shardingsphere.infra.config.rule.global.converter.GlobalRuleNodeConverter;
+import com.google.common.base.Strings;
import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
import org.apache.shardingsphere.infra.util.yaml.datanode.YamlDataNode;
import org.apache.shardingsphere.infra.yaml.config.swapper.rule.NewYamlRuleConfigurationSwapper;
@@ -27,7 +27,6 @@ import org.apache.shardingsphere.single.yaml.config.pojo.YamlSingleRuleConfigura
import java.util.Collection;
import java.util.Collections;
-import java.util.Optional;
/**
* TODO Rename YamlSingleRuleConfigurationSwapper when metadata structure adjustment completed. #25485
@@ -35,9 +34,12 @@ import java.util.Optional;
*/
public final class NewYamlSingleRuleConfigurationSwapper implements NewYamlRuleConfigurationSwapper<SingleRuleConfiguration> {
+ private static final String ROOT_NODE = "tables";
+
@Override
public Collection<YamlDataNode> swapToDataNodes(final SingleRuleConfiguration data) {
- return Collections.singletonList(new YamlDataNode(GlobalRuleNodeConverter.getRootNode(getRuleTagName().toLowerCase()), YamlEngine.marshal(swapToYamlConfiguration(data))));
+ // TODO Consider whether to split tables and defaultDataSource
+ return Collections.singletonList(new YamlDataNode(ROOT_NODE, YamlEngine.marshal(swapToYamlConfiguration(data))));
}
private YamlSingleRuleConfiguration swapToYamlConfiguration(final SingleRuleConfiguration data) {
@@ -50,8 +52,7 @@ public final class NewYamlSingleRuleConfigurationSwapper implements NewYamlRuleC
@Override
public SingleRuleConfiguration swapToObject(final Collection<YamlDataNode> dataNodes) {
for (YamlDataNode each : dataNodes) {
- Optional<String> version = GlobalRuleNodeConverter.getVersion(getRuleTagName().toLowerCase(), each.getKey());
- if (!version.isPresent()) {
+ if (Strings.isNullOrEmpty(each.getValue())) {
continue;
}
return swapToObject(YamlEngine.unmarshal(each.getValue(), YamlSingleRuleConfiguration.class));