This is an automated email from the ASF dual-hosted git repository.
sunnianjun 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 97604eb25af Remove RuleConfiguration generic type on
RepositoryTupleSwapper (#31084)
97604eb25af is described below
commit 97604eb25afa75d95717184b7f521b4b9cc3c3c7
Author: Liang Zhang <[email protected]>
AuthorDate: Wed May 1 00:17:19 2024 +0800
Remove RuleConfiguration generic type on RepositoryTupleSwapper (#31084)
---
...adcastRuleConfigurationRepositoryTupleSwapper.java | 7 +++----
...ncryptRuleConfigurationRepositoryTupleSwapper.java | 7 +++----
.../MaskRuleConfigurationRepositoryTupleSwapper.java | 7 +++----
...ittingRuleConfigurationRepositoryTupleSwapper.java | 7 +++----
...ShadowRuleConfigurationRepositoryTupleSwapper.java | 7 +++----
...ardingRuleConfigurationRepositoryTupleSwapper.java | 7 +++----
.../database/type/DropDatabaseRuleOperator.java | 5 ++++-
...horityRuleConfigurationRepositoryTupleSwapper.java | 7 +++----
...lClockRuleConfigurationRepositoryTupleSwapper.java | 7 +++----
...oggingRuleConfigurationRepositoryTupleSwapper.java | 7 +++----
.../database/rule/DatabaseRulePersistService.java | 19 ++++++++++---------
.../config/global/GlobalRulePersistService.java | 7 ++++---
...SingleRuleConfigurationRepositoryTupleSwapper.java | 9 ++++-----
...rationRuleConfigurationRepositoryTupleSwapper.java | 7 +++----
...ParserRuleConfigurationRepositoryTupleSwapper.java | 7 +++----
...slatorRuleConfigurationRepositoryTupleSwapper.java | 7 +++----
...rafficRuleConfigurationRepositoryTupleSwapper.java | 7 +++----
...actionRuleConfigurationRepositoryTupleSwapper.java | 7 +++----
.../mode/spi/RepositoryTupleSwapper.java | 10 ++++------
.../manager/context/ConfigurationContextManager.java | 19 ++++++++++---------
20 files changed, 78 insertions(+), 89 deletions(-)
diff --git
a/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/yaml/swapper/BroadcastRuleConfigurationRepositoryTupleSwapper.java
b/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/yaml/swapper/BroadcastRuleConfigurationRepositoryTupleSwapper.java
index 10e4167edfd..2750c57c3d9 100644
---
a/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/yaml/swapper/BroadcastRuleConfigurationRepositoryTupleSwapper.java
+++
b/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/yaml/swapper/BroadcastRuleConfigurationRepositoryTupleSwapper.java
@@ -17,7 +17,6 @@
package org.apache.shardingsphere.broadcast.yaml.swapper;
-import
org.apache.shardingsphere.broadcast.api.config.BroadcastRuleConfiguration;
import org.apache.shardingsphere.broadcast.constant.BroadcastOrder;
import
org.apache.shardingsphere.broadcast.metadata.nodepath.BroadcastRuleNodePathProvider;
import
org.apache.shardingsphere.broadcast.yaml.config.YamlBroadcastRuleConfiguration;
@@ -35,7 +34,7 @@ import java.util.stream.Collectors;
/**
* Broadcast rule configuration repository tuple swapper.
*/
-public final class BroadcastRuleConfigurationRepositoryTupleSwapper implements
RepositoryTupleSwapper<BroadcastRuleConfiguration,
YamlBroadcastRuleConfiguration> {
+public final class BroadcastRuleConfigurationRepositoryTupleSwapper implements
RepositoryTupleSwapper<YamlBroadcastRuleConfiguration> {
private final RuleNodePath ruleNodePath = new
BroadcastRuleNodePathProvider().getRuleNodePath();
@@ -58,8 +57,8 @@ public final class
BroadcastRuleConfigurationRepositoryTupleSwapper implements R
}
@Override
- public Class<BroadcastRuleConfiguration> getTypeClass() {
- return BroadcastRuleConfiguration.class;
+ public Class<YamlBroadcastRuleConfiguration> getTypeClass() {
+ return YamlBroadcastRuleConfiguration.class;
}
@Override
diff --git
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/yaml/swapper/EncryptRuleConfigurationRepositoryTupleSwapper.java
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/yaml/swapper/EncryptRuleConfigurationRepositoryTupleSwapper.java
index f831d2b5c57..01463fbb4bb 100644
---
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/yaml/swapper/EncryptRuleConfigurationRepositoryTupleSwapper.java
+++
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/yaml/swapper/EncryptRuleConfigurationRepositoryTupleSwapper.java
@@ -17,7 +17,6 @@
package org.apache.shardingsphere.encrypt.yaml.swapper;
-import org.apache.shardingsphere.encrypt.api.config.EncryptRuleConfiguration;
import org.apache.shardingsphere.encrypt.constant.EncryptOrder;
import
org.apache.shardingsphere.encrypt.metadata.nodepath.EncryptRuleNodePathProvider;
import
org.apache.shardingsphere.encrypt.yaml.config.YamlEncryptRuleConfiguration;
@@ -40,7 +39,7 @@ import java.util.stream.Collectors;
/**
* Encrypt rule configuration repository tuple swapper.
*/
-public final class EncryptRuleConfigurationRepositoryTupleSwapper implements
RepositoryTupleSwapper<EncryptRuleConfiguration, YamlEncryptRuleConfiguration> {
+public final class EncryptRuleConfigurationRepositoryTupleSwapper implements
RepositoryTupleSwapper<YamlEncryptRuleConfiguration> {
private final RuleNodePath ruleNodePath = new
EncryptRuleNodePathProvider().getRuleNodePath();
@@ -77,8 +76,8 @@ public final class
EncryptRuleConfigurationRepositoryTupleSwapper implements Rep
}
@Override
- public Class<EncryptRuleConfiguration> getTypeClass() {
- return EncryptRuleConfiguration.class;
+ public Class<YamlEncryptRuleConfiguration> getTypeClass() {
+ return YamlEncryptRuleConfiguration.class;
}
@Override
diff --git
a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/yaml/swapper/MaskRuleConfigurationRepositoryTupleSwapper.java
b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/yaml/swapper/MaskRuleConfigurationRepositoryTupleSwapper.java
index 1cb299e5231..51a4e6c3ebb 100644
---
a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/yaml/swapper/MaskRuleConfigurationRepositoryTupleSwapper.java
+++
b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/yaml/swapper/MaskRuleConfigurationRepositoryTupleSwapper.java
@@ -20,7 +20,6 @@ package org.apache.shardingsphere.mask.yaml.swapper;
import
org.apache.shardingsphere.infra.algorithm.core.yaml.YamlAlgorithmConfiguration;
import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
import org.apache.shardingsphere.infra.util.yaml.datanode.RepositoryTuple;
-import org.apache.shardingsphere.mask.api.config.MaskRuleConfiguration;
import org.apache.shardingsphere.mask.constant.MaskOrder;
import
org.apache.shardingsphere.mask.metadata.nodepath.MaskRuleNodePathProvider;
import org.apache.shardingsphere.mask.yaml.config.YamlMaskRuleConfiguration;
@@ -39,7 +38,7 @@ import java.util.stream.Collectors;
/**
* Mask rule configuration repository tuple swapper.
*/
-public final class MaskRuleConfigurationRepositoryTupleSwapper implements
RepositoryTupleSwapper<MaskRuleConfiguration, YamlMaskRuleConfiguration> {
+public final class MaskRuleConfigurationRepositoryTupleSwapper implements
RepositoryTupleSwapper<YamlMaskRuleConfiguration> {
private final RuleNodePath ruleNodePath = new
MaskRuleNodePathProvider().getRuleNodePath();
@@ -76,8 +75,8 @@ public final class
MaskRuleConfigurationRepositoryTupleSwapper implements Reposi
}
@Override
- public Class<MaskRuleConfiguration> getTypeClass() {
- return MaskRuleConfiguration.class;
+ public Class<YamlMaskRuleConfiguration> getTypeClass() {
+ return YamlMaskRuleConfiguration.class;
}
@Override
diff --git
a/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/yaml/swapper/ReadwriteSplittingRuleConfigurationRepositoryTupleSwapper.java
b/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/yaml/swapper/ReadwriteSplittingRuleConfigurationRepositoryTupleSwapper.java
index 63b5dd855c8..fc2ddd63211 100644
---
a/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/yaml/swapper/ReadwriteSplittingRuleConfigurationRepositoryTupleSwapper.java
+++
b/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/yaml/swapper/ReadwriteSplittingRuleConfigurationRepositoryTupleSwapper.java
@@ -22,7 +22,6 @@ import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
import org.apache.shardingsphere.infra.util.yaml.datanode.RepositoryTuple;
import org.apache.shardingsphere.mode.path.RuleNodePath;
import org.apache.shardingsphere.mode.spi.RepositoryTupleSwapper;
-import
org.apache.shardingsphere.readwritesplitting.api.ReadwriteSplittingRuleConfiguration;
import
org.apache.shardingsphere.readwritesplitting.constant.ReadwriteSplittingOrder;
import
org.apache.shardingsphere.readwritesplitting.metadata.nodepath.ReadwriteSplittingRuleNodePathProvider;
import
org.apache.shardingsphere.readwritesplitting.yaml.config.YamlReadwriteSplittingRuleConfiguration;
@@ -40,7 +39,7 @@ import java.util.stream.Collectors;
/**
* Readwrite-splitting rule configuration repository tuple swapper.
*/
-public final class ReadwriteSplittingRuleConfigurationRepositoryTupleSwapper
implements RepositoryTupleSwapper<ReadwriteSplittingRuleConfiguration,
YamlReadwriteSplittingRuleConfiguration> {
+public final class ReadwriteSplittingRuleConfigurationRepositoryTupleSwapper
implements RepositoryTupleSwapper<YamlReadwriteSplittingRuleConfiguration> {
private final RuleNodePath ruleNodePath = new
ReadwriteSplittingRuleNodePathProvider().getRuleNodePath();
@@ -77,8 +76,8 @@ public final class
ReadwriteSplittingRuleConfigurationRepositoryTupleSwapper imp
}
@Override
- public Class<ReadwriteSplittingRuleConfiguration> getTypeClass() {
- return ReadwriteSplittingRuleConfiguration.class;
+ public Class<YamlReadwriteSplittingRuleConfiguration> getTypeClass() {
+ return YamlReadwriteSplittingRuleConfiguration.class;
}
@Override
diff --git
a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/yaml/swapper/ShadowRuleConfigurationRepositoryTupleSwapper.java
b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/yaml/swapper/ShadowRuleConfigurationRepositoryTupleSwapper.java
index c4bea542a26..52cf20e349e 100644
---
a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/yaml/swapper/ShadowRuleConfigurationRepositoryTupleSwapper.java
+++
b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/yaml/swapper/ShadowRuleConfigurationRepositoryTupleSwapper.java
@@ -23,7 +23,6 @@ import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
import org.apache.shardingsphere.infra.util.yaml.datanode.RepositoryTuple;
import org.apache.shardingsphere.mode.path.RuleNodePath;
import org.apache.shardingsphere.mode.spi.RepositoryTupleSwapper;
-import org.apache.shardingsphere.shadow.api.config.ShadowRuleConfiguration;
import org.apache.shardingsphere.shadow.constant.ShadowOrder;
import
org.apache.shardingsphere.shadow.metadata.nodepath.ShadowRuleNodePathProvider;
import
org.apache.shardingsphere.shadow.yaml.config.YamlShadowRuleConfiguration;
@@ -42,7 +41,7 @@ import java.util.stream.Collectors;
/**
* Shadow rule configuration repository tuple swapper.
*/
-public final class ShadowRuleConfigurationRepositoryTupleSwapper implements
RepositoryTupleSwapper<ShadowRuleConfiguration, YamlShadowRuleConfiguration> {
+public final class ShadowRuleConfigurationRepositoryTupleSwapper implements
RepositoryTupleSwapper<YamlShadowRuleConfiguration> {
private final RuleNodePath ruleNodePath = new
ShadowRuleNodePathProvider().getRuleNodePath();
@@ -92,8 +91,8 @@ public final class
ShadowRuleConfigurationRepositoryTupleSwapper implements Repo
}
@Override
- public Class<ShadowRuleConfiguration> getTypeClass() {
- return ShadowRuleConfiguration.class;
+ public Class<YamlShadowRuleConfiguration> getTypeClass() {
+ return YamlShadowRuleConfiguration.class;
}
@Override
diff --git
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/yaml/swapper/ShardingRuleConfigurationRepositoryTupleSwapper.java
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/yaml/swapper/ShardingRuleConfigurationRepositoryTupleSwapper.java
index 756e0b0ac80..49bf5044020 100644
---
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/yaml/swapper/ShardingRuleConfigurationRepositoryTupleSwapper.java
+++
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/yaml/swapper/ShardingRuleConfigurationRepositoryTupleSwapper.java
@@ -22,7 +22,6 @@ import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
import org.apache.shardingsphere.infra.util.yaml.datanode.RepositoryTuple;
import org.apache.shardingsphere.mode.path.RuleNodePath;
import org.apache.shardingsphere.mode.spi.RepositoryTupleSwapper;
-import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.constant.ShardingOrder;
import
org.apache.shardingsphere.sharding.metadata.nodepath.ShardingRuleNodePathProvider;
import
org.apache.shardingsphere.sharding.yaml.config.YamlShardingRuleConfiguration;
@@ -44,7 +43,7 @@ import java.util.stream.Collectors;
/**
* Sharding rule configuration repository tuple swapper.
*/
-public final class ShardingRuleConfigurationRepositoryTupleSwapper implements
RepositoryTupleSwapper<ShardingRuleConfiguration,
YamlShardingRuleConfiguration> {
+public final class ShardingRuleConfigurationRepositoryTupleSwapper implements
RepositoryTupleSwapper<YamlShardingRuleConfiguration> {
private final RuleNodePath ruleNodePath = new
ShardingRuleNodePathProvider().getRuleNodePath();
@@ -159,8 +158,8 @@ public final class
ShardingRuleConfigurationRepositoryTupleSwapper implements Re
}
@Override
- public Class<ShardingRuleConfiguration> getTypeClass() {
- return ShardingRuleConfiguration.class;
+ public Class<YamlShardingRuleConfiguration> getTypeClass() {
+ return YamlShardingRuleConfiguration.class;
}
@Override
diff --git
a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/engine/update/rdl/rule/engine/database/type/DropDatabaseRuleOperator.java
b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/engine/update/rdl/rule/engine/database/type/DropDatabaseRuleOperator.java
index cf053ab9298..9f2eb7d8a4b 100644
---
a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/engine/update/rdl/rule/engine/database/type/DropDatabaseRuleOperator.java
+++
b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/engine/update/rdl/rule/engine/database/type/DropDatabaseRuleOperator.java
@@ -29,6 +29,8 @@ import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.metadata.version.MetaDataVersion;
import
org.apache.shardingsphere.infra.rule.attribute.datasource.StaticDataSourceRuleAttribute;
import org.apache.shardingsphere.infra.spi.type.ordered.OrderedSPILoader;
+import
org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfiguration;
+import
org.apache.shardingsphere.infra.yaml.config.swapper.rule.YamlRuleConfigurationSwapperEngine;
import org.apache.shardingsphere.mode.spi.RepositoryTupleSwapper;
import org.apache.shardingsphere.mode.manager.ContextManager;
@@ -63,7 +65,8 @@ public final class DropDatabaseRuleOperator implements
DatabaseRuleOperator {
modeContextManager.removeRuleConfigurationItem(database.getName(),
toBeDroppedRuleConfig);
RuleConfiguration toBeAlteredRuleConfig =
executor.buildToBeAlteredRuleConfiguration(sqlStatement);
if (null != toBeAlteredRuleConfig && ((DatabaseRuleConfiguration)
toBeAlteredRuleConfig).isEmpty()) {
- OrderedSPILoader.getServices(RepositoryTupleSwapper.class,
Collections.singleton(currentRuleConfig)).values().stream().findFirst()
+ YamlRuleConfiguration yamlRuleConfig = new
YamlRuleConfigurationSwapperEngine().swapToYamlRuleConfiguration(currentRuleConfig);
+ OrderedSPILoader.getServices(RepositoryTupleSwapper.class,
Collections.singleton(yamlRuleConfig)).values().stream().findFirst()
.ifPresent(optional ->
modeContextManager.removeRuleConfiguration(database.getName(),
optional.getRuleTypeName()));
return Collections.emptyList();
}
diff --git
a/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/yaml/swapper/AuthorityRuleConfigurationRepositoryTupleSwapper.java
b/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/yaml/swapper/AuthorityRuleConfigurationRepositoryTupleSwapper.java
index 21cd74953be..c6218f365eb 100644
---
a/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/yaml/swapper/AuthorityRuleConfigurationRepositoryTupleSwapper.java
+++
b/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/yaml/swapper/AuthorityRuleConfigurationRepositoryTupleSwapper.java
@@ -17,7 +17,6 @@
package org.apache.shardingsphere.authority.yaml.swapper;
-import org.apache.shardingsphere.authority.config.AuthorityRuleConfiguration;
import org.apache.shardingsphere.authority.constant.AuthorityOrder;
import
org.apache.shardingsphere.authority.yaml.config.YamlAuthorityRuleConfiguration;
import org.apache.shardingsphere.infra.config.nodepath.GlobalNodePath;
@@ -32,7 +31,7 @@ import java.util.Optional;
/**
* Authority rule configuration repository tuple swapper.
*/
-public final class AuthorityRuleConfigurationRepositoryTupleSwapper implements
RepositoryTupleSwapper<AuthorityRuleConfiguration,
YamlAuthorityRuleConfiguration> {
+public final class AuthorityRuleConfigurationRepositoryTupleSwapper implements
RepositoryTupleSwapper<YamlAuthorityRuleConfiguration> {
@Override
public Collection<RepositoryTuple> swapToRepositoryTuples(final
YamlAuthorityRuleConfiguration yamlRuleConfig) {
@@ -50,8 +49,8 @@ public final class
AuthorityRuleConfigurationRepositoryTupleSwapper implements R
}
@Override
- public Class<AuthorityRuleConfiguration> getTypeClass() {
- return AuthorityRuleConfiguration.class;
+ public Class<YamlAuthorityRuleConfiguration> getTypeClass() {
+ return YamlAuthorityRuleConfiguration.class;
}
@Override
diff --git
a/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/core/yaml/swapper/GlobalClockRuleConfigurationRepositoryTupleSwapper.java
b/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/core/yaml/swapper/GlobalClockRuleConfigurationRepositoryTupleSwapper.java
index ffa3bfaae56..2e8ab63472c 100644
---
a/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/core/yaml/swapper/GlobalClockRuleConfigurationRepositoryTupleSwapper.java
+++
b/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/core/yaml/swapper/GlobalClockRuleConfigurationRepositoryTupleSwapper.java
@@ -17,7 +17,6 @@
package org.apache.shardingsphere.globalclock.core.yaml.swapper;
-import
org.apache.shardingsphere.globalclock.api.config.GlobalClockRuleConfiguration;
import
org.apache.shardingsphere.globalclock.core.rule.constant.GlobalClockOrder;
import
org.apache.shardingsphere.globalclock.core.yaml.config.YamlGlobalClockRuleConfiguration;
import org.apache.shardingsphere.infra.config.nodepath.GlobalNodePath;
@@ -32,7 +31,7 @@ import java.util.Optional;
/**
* Global clock rule configuration repository tuple swapper.
*/
-public final class GlobalClockRuleConfigurationRepositoryTupleSwapper
implements RepositoryTupleSwapper<GlobalClockRuleConfiguration,
YamlGlobalClockRuleConfiguration> {
+public final class GlobalClockRuleConfigurationRepositoryTupleSwapper
implements RepositoryTupleSwapper<YamlGlobalClockRuleConfiguration> {
@Override
public Collection<RepositoryTuple> swapToRepositoryTuples(final
YamlGlobalClockRuleConfiguration yamlRuleConfig) {
@@ -60,7 +59,7 @@ public final class
GlobalClockRuleConfigurationRepositoryTupleSwapper implements
}
@Override
- public Class<GlobalClockRuleConfiguration> getTypeClass() {
- return GlobalClockRuleConfiguration.class;
+ public Class<YamlGlobalClockRuleConfiguration> getTypeClass() {
+ return YamlGlobalClockRuleConfiguration.class;
}
}
diff --git
a/kernel/logging/core/src/main/java/org/apache/shardingsphere/logging/yaml/swapper/LoggingRuleConfigurationRepositoryTupleSwapper.java
b/kernel/logging/core/src/main/java/org/apache/shardingsphere/logging/yaml/swapper/LoggingRuleConfigurationRepositoryTupleSwapper.java
index 6b249899983..a80370f1d7e 100644
---
a/kernel/logging/core/src/main/java/org/apache/shardingsphere/logging/yaml/swapper/LoggingRuleConfigurationRepositoryTupleSwapper.java
+++
b/kernel/logging/core/src/main/java/org/apache/shardingsphere/logging/yaml/swapper/LoggingRuleConfigurationRepositoryTupleSwapper.java
@@ -20,7 +20,6 @@ package org.apache.shardingsphere.logging.yaml.swapper;
import org.apache.shardingsphere.infra.config.nodepath.GlobalNodePath;
import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
import org.apache.shardingsphere.infra.util.yaml.datanode.RepositoryTuple;
-import org.apache.shardingsphere.logging.config.LoggingRuleConfiguration;
import org.apache.shardingsphere.logging.constant.LoggingOrder;
import
org.apache.shardingsphere.logging.yaml.config.YamlLoggingRuleConfiguration;
import org.apache.shardingsphere.mode.spi.RepositoryTupleSwapper;
@@ -32,7 +31,7 @@ import java.util.Optional;
/**
* Logging rule configuration repository tuple swapper.
*/
-public final class LoggingRuleConfigurationRepositoryTupleSwapper implements
RepositoryTupleSwapper<LoggingRuleConfiguration, YamlLoggingRuleConfiguration> {
+public final class LoggingRuleConfigurationRepositoryTupleSwapper implements
RepositoryTupleSwapper<YamlLoggingRuleConfiguration> {
@Override
public Collection<RepositoryTuple> swapToRepositoryTuples(final
YamlLoggingRuleConfiguration yamlRuleConfig) {
@@ -50,8 +49,8 @@ public final class
LoggingRuleConfigurationRepositoryTupleSwapper implements Rep
}
@Override
- public Class<LoggingRuleConfiguration> getTypeClass() {
- return LoggingRuleConfiguration.class;
+ public Class<YamlLoggingRuleConfiguration> getTypeClass() {
+ return YamlLoggingRuleConfiguration.class;
}
@Override
diff --git
a/kernel/metadata/core/src/main/java/org/apache/shardingsphere/metadata/persist/service/config/database/rule/DatabaseRulePersistService.java
b/kernel/metadata/core/src/main/java/org/apache/shardingsphere/metadata/persist/service/config/database/rule/DatabaseRulePersistService.java
index 5cd0ef22603..63e527b1938 100644
---
a/kernel/metadata/core/src/main/java/org/apache/shardingsphere/metadata/persist/service/config/database/rule/DatabaseRulePersistService.java
+++
b/kernel/metadata/core/src/main/java/org/apache/shardingsphere/metadata/persist/service/config/database/rule/DatabaseRulePersistService.java
@@ -22,6 +22,7 @@ import
org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
import org.apache.shardingsphere.infra.metadata.version.MetaDataVersion;
import org.apache.shardingsphere.infra.spi.type.ordered.OrderedSPILoader;
import org.apache.shardingsphere.infra.util.yaml.datanode.RepositoryTuple;
+import
org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfiguration;
import
org.apache.shardingsphere.infra.yaml.config.swapper.rule.YamlRuleConfigurationSwapperEngine;
import
org.apache.shardingsphere.metadata.persist.node.metadata.DatabaseRuleMetaDataNode;
import
org.apache.shardingsphere.metadata.persist.service.config.RepositoryTuplePersistService;
@@ -55,9 +56,9 @@ public final class DatabaseRulePersistService implements
DatabaseBasedPersistSer
@SuppressWarnings({"unchecked", "rawtypes"})
@Override
public void persist(final String databaseName, final
Collection<RuleConfiguration> configs) {
- YamlRuleConfigurationSwapperEngine yamlSwapperEngine = new
YamlRuleConfigurationSwapperEngine();
- for (Entry<RuleConfiguration, RepositoryTupleSwapper> entry :
OrderedSPILoader.getServices(RepositoryTupleSwapper.class, configs).entrySet())
{
- Collection<RepositoryTuple> repositoryTuples =
entry.getValue().swapToRepositoryTuples(yamlSwapperEngine.swapToYamlRuleConfiguration(entry.getKey()));
+ Collection<YamlRuleConfiguration> yamlRuleConfigs = new
YamlRuleConfigurationSwapperEngine().swapToYamlRuleConfigurations(configs);
+ for (Entry<YamlRuleConfiguration, RepositoryTupleSwapper> entry :
OrderedSPILoader.getServices(RepositoryTupleSwapper.class,
yamlRuleConfigs).entrySet()) {
+ Collection<RepositoryTuple> repositoryTuples =
entry.getValue().swapToRepositoryTuples(entry.getKey());
if (!repositoryTuples.isEmpty()) {
persistDataNodes(databaseName,
entry.getValue().getRuleTypeName(), repositoryTuples);
}
@@ -78,9 +79,9 @@ public final class DatabaseRulePersistService implements
DatabaseBasedPersistSer
@Override
public Collection<MetaDataVersion> persistConfigurations(final String
databaseName, final Collection<RuleConfiguration> configs) {
Collection<MetaDataVersion> result = new LinkedList<>();
- YamlRuleConfigurationSwapperEngine yamlSwapperEngine = new
YamlRuleConfigurationSwapperEngine();
- for (Entry<RuleConfiguration, RepositoryTupleSwapper> entry :
OrderedSPILoader.getServices(RepositoryTupleSwapper.class, configs).entrySet())
{
- Collection<RepositoryTuple> repositoryTuples =
entry.getValue().swapToRepositoryTuples(yamlSwapperEngine.swapToYamlRuleConfiguration(entry.getKey()));
+ Collection<YamlRuleConfiguration> yamlRuleConfigs = new
YamlRuleConfigurationSwapperEngine().swapToYamlRuleConfigurations(configs);
+ for (Entry<YamlRuleConfiguration, RepositoryTupleSwapper> entry :
OrderedSPILoader.getServices(RepositoryTupleSwapper.class,
yamlRuleConfigs).entrySet()) {
+ Collection<RepositoryTuple> repositoryTuples =
entry.getValue().swapToRepositoryTuples(entry.getKey());
if (!repositoryTuples.isEmpty()) {
result.addAll(persistDataNodes(databaseName,
entry.getValue().getRuleTypeName(), repositoryTuples));
}
@@ -106,9 +107,9 @@ public final class DatabaseRulePersistService implements
DatabaseBasedPersistSer
@Override
public Collection<MetaDataVersion> deleteConfigurations(final String
databaseName, final Collection<RuleConfiguration> configs) {
Collection<MetaDataVersion> result = new LinkedList<>();
- YamlRuleConfigurationSwapperEngine yamlSwapperEngine = new
YamlRuleConfigurationSwapperEngine();
- for (Entry<RuleConfiguration, RepositoryTupleSwapper> entry :
OrderedSPILoader.getServices(RepositoryTupleSwapper.class, configs).entrySet())
{
- Collection<RepositoryTuple> repositoryTuples =
entry.getValue().swapToRepositoryTuples(yamlSwapperEngine.swapToYamlRuleConfiguration(entry.getKey()));
+ Collection<YamlRuleConfiguration> yamlRuleConfigs = new
YamlRuleConfigurationSwapperEngine().swapToYamlRuleConfigurations(configs);
+ for (Entry<YamlRuleConfiguration, RepositoryTupleSwapper> entry :
OrderedSPILoader.getServices(RepositoryTupleSwapper.class,
yamlRuleConfigs).entrySet()) {
+ Collection<RepositoryTuple> repositoryTuples =
entry.getValue().swapToRepositoryTuples(entry.getKey());
if (repositoryTuples.isEmpty()) {
continue;
}
diff --git
a/kernel/metadata/core/src/main/java/org/apache/shardingsphere/metadata/persist/service/config/global/GlobalRulePersistService.java
b/kernel/metadata/core/src/main/java/org/apache/shardingsphere/metadata/persist/service/config/global/GlobalRulePersistService.java
index 402b416e7e9..92dbc1229b0 100644
---
a/kernel/metadata/core/src/main/java/org/apache/shardingsphere/metadata/persist/service/config/global/GlobalRulePersistService.java
+++
b/kernel/metadata/core/src/main/java/org/apache/shardingsphere/metadata/persist/service/config/global/GlobalRulePersistService.java
@@ -22,6 +22,7 @@ import
org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
import org.apache.shardingsphere.infra.metadata.version.MetaDataVersion;
import org.apache.shardingsphere.infra.spi.type.ordered.OrderedSPILoader;
import org.apache.shardingsphere.infra.util.yaml.datanode.RepositoryTuple;
+import
org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfiguration;
import
org.apache.shardingsphere.infra.yaml.config.swapper.rule.YamlRuleConfigurationSwapperEngine;
import org.apache.shardingsphere.mode.spi.RepositoryTupleSwapper;
import
org.apache.shardingsphere.metadata.persist.service.config.RepositoryTupleSwapperEngine;
@@ -59,9 +60,9 @@ public final class GlobalRulePersistService implements
GlobalPersistService<Coll
@Override
public void persist(final Collection<RuleConfiguration> globalRuleConfigs)
{
Collection<MetaDataVersion> metaDataVersions = new LinkedList<>();
- YamlRuleConfigurationSwapperEngine yamlSwapperEngine = new
YamlRuleConfigurationSwapperEngine();
- for (Entry<RuleConfiguration, RepositoryTupleSwapper> entry :
OrderedSPILoader.getServices(RepositoryTupleSwapper.class,
globalRuleConfigs).entrySet()) {
- Collection<RepositoryTuple> repositoryTuples =
entry.getValue().swapToRepositoryTuples(yamlSwapperEngine.swapToYamlRuleConfiguration(entry.getKey()));
+ Collection<YamlRuleConfiguration> yamlGlobalRuleConfigs = new
YamlRuleConfigurationSwapperEngine().swapToYamlRuleConfigurations(globalRuleConfigs);
+ for (Entry<YamlRuleConfiguration, RepositoryTupleSwapper> entry :
OrderedSPILoader.getServices(RepositoryTupleSwapper.class,
yamlGlobalRuleConfigs).entrySet()) {
+ Collection<RepositoryTuple> repositoryTuples =
entry.getValue().swapToRepositoryTuples(entry.getKey());
if (!repositoryTuples.isEmpty()) {
metaDataVersions.addAll(persistTuples(repositoryTuples));
}
diff --git
a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/yaml/config/swapper/SingleRuleConfigurationRepositoryTupleSwapper.java
b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/yaml/config/swapper/SingleRuleConfigurationRepositoryTupleSwapper.java
index 85d73568e8d..5bc7014a417 100644
---
a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/yaml/config/swapper/SingleRuleConfigurationRepositoryTupleSwapper.java
+++
b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/yaml/config/swapper/SingleRuleConfigurationRepositoryTupleSwapper.java
@@ -19,9 +19,8 @@ package org.apache.shardingsphere.single.yaml.config.swapper;
import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
import org.apache.shardingsphere.infra.util.yaml.datanode.RepositoryTuple;
-import org.apache.shardingsphere.mode.spi.RepositoryTupleSwapper;
import org.apache.shardingsphere.mode.path.RuleNodePath;
-import org.apache.shardingsphere.single.api.config.SingleRuleConfiguration;
+import org.apache.shardingsphere.mode.spi.RepositoryTupleSwapper;
import org.apache.shardingsphere.single.constant.SingleOrder;
import
org.apache.shardingsphere.single.metadata.nodepath.SingleRuleNodePathProvider;
import
org.apache.shardingsphere.single.yaml.config.pojo.YamlSingleRuleConfiguration;
@@ -34,7 +33,7 @@ import java.util.stream.Collectors;
/**
* Single rule configuration repository tuple swapper.
*/
-public final class SingleRuleConfigurationRepositoryTupleSwapper implements
RepositoryTupleSwapper<SingleRuleConfiguration, YamlSingleRuleConfiguration> {
+public final class SingleRuleConfigurationRepositoryTupleSwapper implements
RepositoryTupleSwapper<YamlSingleRuleConfiguration> {
private final RuleNodePath ruleNodePath = new
SingleRuleNodePathProvider().getRuleNodePath();
@@ -54,8 +53,8 @@ public final class
SingleRuleConfigurationRepositoryTupleSwapper implements Repo
}
@Override
- public Class<SingleRuleConfiguration> getTypeClass() {
- return SingleRuleConfiguration.class;
+ public Class<YamlSingleRuleConfiguration> getTypeClass() {
+ return YamlSingleRuleConfiguration.class;
}
@Override
diff --git
a/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/yaml/swapper/SQLFederationRuleConfigurationRepositoryTupleSwapper.java
b/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/yaml/swapper/SQLFederationRuleConfigurationRepositoryTupleSwapper.java
index 512b029cd3b..05c254b4cdd 100644
---
a/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/yaml/swapper/SQLFederationRuleConfigurationRepositoryTupleSwapper.java
+++
b/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/yaml/swapper/SQLFederationRuleConfigurationRepositoryTupleSwapper.java
@@ -21,7 +21,6 @@ import
org.apache.shardingsphere.infra.config.nodepath.GlobalNodePath;
import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
import org.apache.shardingsphere.infra.util.yaml.datanode.RepositoryTuple;
import org.apache.shardingsphere.mode.spi.RepositoryTupleSwapper;
-import
org.apache.shardingsphere.sqlfederation.api.config.SQLFederationRuleConfiguration;
import org.apache.shardingsphere.sqlfederation.constant.SQLFederationOrder;
import
org.apache.shardingsphere.sqlfederation.yaml.config.YamlSQLFederationRuleConfiguration;
@@ -32,7 +31,7 @@ import java.util.Optional;
/**
* SQL federation rule configuration repository tuple swapper.
*/
-public final class SQLFederationRuleConfigurationRepositoryTupleSwapper
implements RepositoryTupleSwapper<SQLFederationRuleConfiguration,
YamlSQLFederationRuleConfiguration> {
+public final class SQLFederationRuleConfigurationRepositoryTupleSwapper
implements RepositoryTupleSwapper<YamlSQLFederationRuleConfiguration> {
@Override
public Collection<RepositoryTuple> swapToRepositoryTuples(final
YamlSQLFederationRuleConfiguration yamlRuleConfig) {
@@ -50,8 +49,8 @@ public final class
SQLFederationRuleConfigurationRepositoryTupleSwapper implemen
}
@Override
- public Class<SQLFederationRuleConfiguration> getTypeClass() {
- return SQLFederationRuleConfiguration.class;
+ public Class<YamlSQLFederationRuleConfiguration> getTypeClass() {
+ return YamlSQLFederationRuleConfiguration.class;
}
@Override
diff --git
a/kernel/sql-parser/core/src/main/java/org/apache/shardingsphere/parser/yaml/swapper/SQLParserRuleConfigurationRepositoryTupleSwapper.java
b/kernel/sql-parser/core/src/main/java/org/apache/shardingsphere/parser/yaml/swapper/SQLParserRuleConfigurationRepositoryTupleSwapper.java
index f4f7cd06f7b..84a2b768543 100644
---
a/kernel/sql-parser/core/src/main/java/org/apache/shardingsphere/parser/yaml/swapper/SQLParserRuleConfigurationRepositoryTupleSwapper.java
+++
b/kernel/sql-parser/core/src/main/java/org/apache/shardingsphere/parser/yaml/swapper/SQLParserRuleConfigurationRepositoryTupleSwapper.java
@@ -21,7 +21,6 @@ import
org.apache.shardingsphere.infra.config.nodepath.GlobalNodePath;
import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
import org.apache.shardingsphere.infra.util.yaml.datanode.RepositoryTuple;
import org.apache.shardingsphere.mode.spi.RepositoryTupleSwapper;
-import org.apache.shardingsphere.parser.config.SQLParserRuleConfiguration;
import org.apache.shardingsphere.parser.constant.SQLParserOrder;
import
org.apache.shardingsphere.parser.yaml.config.YamlSQLParserRuleConfiguration;
@@ -32,7 +31,7 @@ import java.util.Optional;
/**
* SQL parser rule configuration repository tuple swapper.
*/
-public final class SQLParserRuleConfigurationRepositoryTupleSwapper implements
RepositoryTupleSwapper<SQLParserRuleConfiguration,
YamlSQLParserRuleConfiguration> {
+public final class SQLParserRuleConfigurationRepositoryTupleSwapper implements
RepositoryTupleSwapper<YamlSQLParserRuleConfiguration> {
@Override
public Collection<RepositoryTuple> swapToRepositoryTuples(final
YamlSQLParserRuleConfiguration yamlRuleConfig) {
@@ -50,8 +49,8 @@ public final class
SQLParserRuleConfigurationRepositoryTupleSwapper implements R
}
@Override
- public Class<SQLParserRuleConfiguration> getTypeClass() {
- return SQLParserRuleConfiguration.class;
+ public Class<YamlSQLParserRuleConfiguration> getTypeClass() {
+ return YamlSQLParserRuleConfiguration.class;
}
@Override
diff --git
a/kernel/sql-translator/core/src/main/java/org/apache/shardingsphere/sqltranslator/yaml/swapper/SQLTranslatorRuleConfigurationRepositoryTupleSwapper.java
b/kernel/sql-translator/core/src/main/java/org/apache/shardingsphere/sqltranslator/yaml/swapper/SQLTranslatorRuleConfigurationRepositoryTupleSwapper.java
index b337f62148f..6ee9bc13932 100644
---
a/kernel/sql-translator/core/src/main/java/org/apache/shardingsphere/sqltranslator/yaml/swapper/SQLTranslatorRuleConfigurationRepositoryTupleSwapper.java
+++
b/kernel/sql-translator/core/src/main/java/org/apache/shardingsphere/sqltranslator/yaml/swapper/SQLTranslatorRuleConfigurationRepositoryTupleSwapper.java
@@ -21,7 +21,6 @@ import
org.apache.shardingsphere.infra.config.nodepath.GlobalNodePath;
import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
import org.apache.shardingsphere.infra.util.yaml.datanode.RepositoryTuple;
import org.apache.shardingsphere.mode.spi.RepositoryTupleSwapper;
-import
org.apache.shardingsphere.sqltranslator.api.config.SQLTranslatorRuleConfiguration;
import org.apache.shardingsphere.sqltranslator.constant.SQLTranslatorOrder;
import
org.apache.shardingsphere.sqltranslator.yaml.config.YamlSQLTranslatorRuleConfiguration;
@@ -32,7 +31,7 @@ import java.util.Optional;
/**
* SQL translator rule configuration repository tuple swapper.
*/
-public final class SQLTranslatorRuleConfigurationRepositoryTupleSwapper
implements RepositoryTupleSwapper<SQLTranslatorRuleConfiguration,
YamlSQLTranslatorRuleConfiguration> {
+public final class SQLTranslatorRuleConfigurationRepositoryTupleSwapper
implements RepositoryTupleSwapper<YamlSQLTranslatorRuleConfiguration> {
@Override
public Collection<RepositoryTuple> swapToRepositoryTuples(final
YamlSQLTranslatorRuleConfiguration yamlRuleConfig) {
@@ -50,8 +49,8 @@ public final class
SQLTranslatorRuleConfigurationRepositoryTupleSwapper implemen
}
@Override
- public Class<SQLTranslatorRuleConfiguration> getTypeClass() {
- return SQLTranslatorRuleConfiguration.class;
+ public Class<YamlSQLTranslatorRuleConfiguration> getTypeClass() {
+ return YamlSQLTranslatorRuleConfiguration.class;
}
@Override
diff --git
a/kernel/traffic/core/src/main/java/org/apache/shardingsphere/traffic/yaml/swapper/TrafficRuleConfigurationRepositoryTupleSwapper.java
b/kernel/traffic/core/src/main/java/org/apache/shardingsphere/traffic/yaml/swapper/TrafficRuleConfigurationRepositoryTupleSwapper.java
index 33d69e9686c..0b6b594a29d 100644
---
a/kernel/traffic/core/src/main/java/org/apache/shardingsphere/traffic/yaml/swapper/TrafficRuleConfigurationRepositoryTupleSwapper.java
+++
b/kernel/traffic/core/src/main/java/org/apache/shardingsphere/traffic/yaml/swapper/TrafficRuleConfigurationRepositoryTupleSwapper.java
@@ -21,7 +21,6 @@ import
org.apache.shardingsphere.infra.config.nodepath.GlobalNodePath;
import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
import org.apache.shardingsphere.infra.util.yaml.datanode.RepositoryTuple;
import org.apache.shardingsphere.mode.spi.RepositoryTupleSwapper;
-import org.apache.shardingsphere.traffic.api.config.TrafficRuleConfiguration;
import org.apache.shardingsphere.traffic.constant.TrafficOrder;
import
org.apache.shardingsphere.traffic.yaml.config.YamlTrafficRuleConfiguration;
@@ -32,7 +31,7 @@ import java.util.Optional;
/**
* Traffic rule configuration repository tuple swapper.
*/
-public final class TrafficRuleConfigurationRepositoryTupleSwapper implements
RepositoryTupleSwapper<TrafficRuleConfiguration, YamlTrafficRuleConfiguration> {
+public final class TrafficRuleConfigurationRepositoryTupleSwapper implements
RepositoryTupleSwapper<YamlTrafficRuleConfiguration> {
@Override
public Collection<RepositoryTuple> swapToRepositoryTuples(final
YamlTrafficRuleConfiguration yamlRuleConfig) {
@@ -50,8 +49,8 @@ public final class
TrafficRuleConfigurationRepositoryTupleSwapper implements Rep
}
@Override
- public Class<TrafficRuleConfiguration> getTypeClass() {
- return TrafficRuleConfiguration.class;
+ public Class<YamlTrafficRuleConfiguration> getTypeClass() {
+ return YamlTrafficRuleConfiguration.class;
}
@Override
diff --git
a/kernel/transaction/core/src/main/java/org/apache/shardingsphere/transaction/yaml/swapper/TransactionRuleConfigurationRepositoryTupleSwapper.java
b/kernel/transaction/core/src/main/java/org/apache/shardingsphere/transaction/yaml/swapper/TransactionRuleConfigurationRepositoryTupleSwapper.java
index 073e0cff4a4..6391b52dff0 100644
---
a/kernel/transaction/core/src/main/java/org/apache/shardingsphere/transaction/yaml/swapper/TransactionRuleConfigurationRepositoryTupleSwapper.java
+++
b/kernel/transaction/core/src/main/java/org/apache/shardingsphere/transaction/yaml/swapper/TransactionRuleConfigurationRepositoryTupleSwapper.java
@@ -21,7 +21,6 @@ import
org.apache.shardingsphere.infra.config.nodepath.GlobalNodePath;
import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
import org.apache.shardingsphere.infra.util.yaml.datanode.RepositoryTuple;
import org.apache.shardingsphere.mode.spi.RepositoryTupleSwapper;
-import
org.apache.shardingsphere.transaction.config.TransactionRuleConfiguration;
import org.apache.shardingsphere.transaction.constant.TransactionOrder;
import
org.apache.shardingsphere.transaction.yaml.config.YamlTransactionRuleConfiguration;
@@ -32,7 +31,7 @@ import java.util.Optional;
/**
* Transaction rule configuration repository tuple swapper.
*/
-public final class TransactionRuleConfigurationRepositoryTupleSwapper
implements RepositoryTupleSwapper<TransactionRuleConfiguration,
YamlTransactionRuleConfiguration> {
+public final class TransactionRuleConfigurationRepositoryTupleSwapper
implements RepositoryTupleSwapper<YamlTransactionRuleConfiguration> {
@Override
public Collection<RepositoryTuple> swapToRepositoryTuples(final
YamlTransactionRuleConfiguration yamlRuleConfig) {
@@ -50,8 +49,8 @@ public final class
TransactionRuleConfigurationRepositoryTupleSwapper implements
}
@Override
- public Class<TransactionRuleConfiguration> getTypeClass() {
- return TransactionRuleConfiguration.class;
+ public Class<YamlTransactionRuleConfiguration> getTypeClass() {
+ return YamlTransactionRuleConfiguration.class;
}
@Override
diff --git
a/mode/api/src/main/java/org/apache/shardingsphere/mode/spi/RepositoryTupleSwapper.java
b/mode/api/src/main/java/org/apache/shardingsphere/mode/spi/RepositoryTupleSwapper.java
index 134770808c3..43ce6ffa9dd 100644
---
a/mode/api/src/main/java/org/apache/shardingsphere/mode/spi/RepositoryTupleSwapper.java
+++
b/mode/api/src/main/java/org/apache/shardingsphere/mode/spi/RepositoryTupleSwapper.java
@@ -17,7 +17,6 @@
package org.apache.shardingsphere.mode.spi;
-import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
import org.apache.shardingsphere.infra.spi.annotation.SingletonSPI;
import org.apache.shardingsphere.infra.spi.type.ordered.OrderedSPI;
import org.apache.shardingsphere.infra.util.yaml.datanode.RepositoryTuple;
@@ -29,11 +28,10 @@ import java.util.Optional;
/**
* Repository tuple swapper.
*
- * @param <T> type of swapped object
- * @param <Y> type of swapped YAML rule configuration
+ * @param <T> type of swapped YAML rule configuration
*/
@SingletonSPI
-public interface RepositoryTupleSwapper<T extends RuleConfiguration, Y extends
YamlRuleConfiguration> extends OrderedSPI<T> {
+public interface RepositoryTupleSwapper<T extends YamlRuleConfiguration>
extends OrderedSPI<T> {
/**
* Swap to repository tuples.
@@ -41,7 +39,7 @@ public interface RepositoryTupleSwapper<T extends
RuleConfiguration, Y extends Y
* @param yamlRuleConfig YAML rule configuration to be swapped
* @return repository tuples
*/
- Collection<RepositoryTuple> swapToRepositoryTuples(Y yamlRuleConfig);
+ Collection<RepositoryTuple> swapToRepositoryTuples(T yamlRuleConfig);
/**
* Swap from repository tuple to YAML rule configurations.
@@ -49,7 +47,7 @@ public interface RepositoryTupleSwapper<T extends
RuleConfiguration, Y extends Y
* @param repositoryTuples repository tuples
* @return swapped YAML rule configurations
*/
- Optional<Y> swapToObject(Collection<RepositoryTuple> repositoryTuples);
+ Optional<T> swapToObject(Collection<RepositoryTuple> repositoryTuples);
/**
* Get rule type name.
diff --git
a/mode/core/src/main/java/org/apache/shardingsphere/mode/manager/context/ConfigurationContextManager.java
b/mode/core/src/main/java/org/apache/shardingsphere/mode/manager/context/ConfigurationContextManager.java
index 8544193461c..a5f9aafb6c8 100644
---
a/mode/core/src/main/java/org/apache/shardingsphere/mode/manager/context/ConfigurationContextManager.java
+++
b/mode/core/src/main/java/org/apache/shardingsphere/mode/manager/context/ConfigurationContextManager.java
@@ -39,6 +39,8 @@ import
org.apache.shardingsphere.infra.rule.ShardingSphereRule;
import
org.apache.shardingsphere.infra.rule.builder.database.DatabaseRulesBuilder;
import org.apache.shardingsphere.infra.rule.builder.global.GlobalRulesBuilder;
import org.apache.shardingsphere.infra.spi.type.ordered.OrderedSPILoader;
+import
org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfiguration;
+import
org.apache.shardingsphere.infra.yaml.config.swapper.rule.YamlRuleConfigurationSwapperEngine;
import org.apache.shardingsphere.mode.spi.RepositoryTupleSwapper;
import org.apache.shardingsphere.metadata.factory.ExternalMetaDataFactory;
import org.apache.shardingsphere.metadata.factory.InternalMetaDataFactory;
@@ -376,15 +378,14 @@ public final class ConfigurationContextManager {
@SuppressWarnings("rawtypes")
@SneakyThrows(Exception.class)
private void closeStaleTransactionRule(final RuleConfiguration ruleConfig)
{
- for (Entry<RuleConfiguration, RepositoryTupleSwapper> entry :
OrderedSPILoader.getServices(
- RepositoryTupleSwapper.class,
Collections.singleton(ruleConfig)).entrySet()) {
- if
("transaction".equalsIgnoreCase(entry.getValue().getRuleTypeName())) {
- Optional<TransactionRule> transactionRule =
metaDataContexts.get().getMetaData().getGlobalRuleMetaData().findSingleRule(TransactionRule.class);
- if (!transactionRule.isPresent()) {
- return;
- }
- ((AutoCloseable) transactionRule.get()).close();
- }
+ YamlRuleConfiguration yamlRuleConfig = new
YamlRuleConfigurationSwapperEngine().swapToYamlRuleConfiguration(ruleConfig);
+ RepositoryTupleSwapper repositoryTupleSwapper =
OrderedSPILoader.getServices(RepositoryTupleSwapper.class,
Collections.singleton(yamlRuleConfig)).get(yamlRuleConfig);
+ if (!"transaction".equals(repositoryTupleSwapper.getRuleTypeName())) {
+ return;
+ }
+ Optional<TransactionRule> transactionRule =
metaDataContexts.get().getMetaData().getGlobalRuleMetaData().findSingleRule(TransactionRule.class);
+ if (transactionRule.isPresent()) {
+ ((AutoCloseable) transactionRule.get()).close();
}
}