This is an automated email from the ASF dual-hosted git repository.
duanzhengqiang 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 55c91ce7dd4 Refactor RulePersistDecorator (#32362)
55c91ce7dd4 is described below
commit 55c91ce7dd408c25119550aa452f8ac377ddc663
Author: Liang Zhang <[email protected]>
AuthorDate: Thu Aug 1 21:23:37 2024 +0800
Refactor RulePersistDecorator (#32362)
* Refactor RulePersistDecorator
* Refactor RulePersistDecorator
---
.../apache/shardingsphere/mode/spi/RulePersistDecorator.java | 10 ++++++----
.../shardingsphere/mode/metadata/MetaDataContextsFactory.java | 2 ++
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git
a/mode/api/src/main/java/org/apache/shardingsphere/mode/spi/RulePersistDecorator.java
b/mode/api/src/main/java/org/apache/shardingsphere/mode/spi/RulePersistDecorator.java
index edcf200a6ae..9acc7497f0b 100644
---
a/mode/api/src/main/java/org/apache/shardingsphere/mode/spi/RulePersistDecorator.java
+++
b/mode/api/src/main/java/org/apache/shardingsphere/mode/spi/RulePersistDecorator.java
@@ -24,9 +24,11 @@ import
org.apache.shardingsphere.infra.spi.type.typed.TypedSPI;
/**
* Rule persist decorator.
+ *
+ * @param <T> type of rule configuration
*/
@SingletonSPI
-public interface RulePersistDecorator extends TypedSPI {
+public interface RulePersistDecorator<T extends RuleConfiguration> extends
TypedSPI {
/**
* Check whether the rule configuration can be restored.
@@ -34,7 +36,7 @@ public interface RulePersistDecorator extends TypedSPI {
* @param ruleConfig rule configuration to be checked
* @return can be restored or not
*/
- boolean canBeRestored(RuleConfiguration ruleConfig);
+ boolean canBeRestored(T ruleConfig);
/**
* Restore rule configuration.
@@ -42,7 +44,7 @@ public interface RulePersistDecorator extends TypedSPI {
* @param ruleConfig rule configuration to be restored
* @return restored rule configuration
*/
- RuleConfiguration restore(RuleConfiguration ruleConfig);
+ RuleConfiguration restore(T ruleConfig);
/**
* Get rule type.
@@ -52,5 +54,5 @@ public interface RulePersistDecorator extends TypedSPI {
Class<? extends ShardingSphereRule> getRuleType();
@Override
- Class<? extends RuleConfiguration> getType();
+ Class<T> getType();
}
diff --git
a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/MetaDataContextsFactory.java
b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/MetaDataContextsFactory.java
index 62f66c290d6..5a1958b8b55 100644
---
a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/MetaDataContextsFactory.java
+++
b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/MetaDataContextsFactory.java
@@ -153,6 +153,7 @@ public final class MetaDataContextsFactory {
}
}
+ @SuppressWarnings({"unchecked", "rawtypes"})
private static Collection<RuleConfiguration>
getGlobalRuleConfigurations(final Collection<RuleConfiguration>
globalRuleConfigs) {
Collection<RuleConfiguration> result = new LinkedList<>();
for (RuleConfiguration each : globalRuleConfigs) {
@@ -204,6 +205,7 @@ public final class MetaDataContextsFactory {
}
}
+ @SuppressWarnings({"unchecked", "rawtypes"})
private static void restoreRules(final MetaDataContexts metaDataContexts,
final ComputeNodeInstanceContext computeNodeInstanceContext) {
if (!computeNodeInstanceContext.isCluster()) {
return;