You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by du...@apache.org on 2022/04/11 02:07:32 UTC

[shardingsphere] branch master updated: Refactor RuleAlteredDetectorFactory (#16721)

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 36045ae5726 Refactor RuleAlteredDetectorFactory (#16721)
36045ae5726 is described below

commit 36045ae5726c035d443d05dd9e66b42a0a103b4e
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Mon Apr 11 10:07:25 2022 +0800

    Refactor RuleAlteredDetectorFactory (#16721)
---
 .../scenario/rulealtered/RuleAlteredJobWorker.java       |  6 +++---
 .../spi/rulealtered/RuleAlteredDetectorFactory.java      | 16 ++++++++--------
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/rulealtered/RuleAlteredJobWorker.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/rulealtered/RuleAlteredJobWorker.java
index 7987cef8d0f..5489e4763cc 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/rulealtered/RuleAlteredJobWorker.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/rulealtered/RuleAlteredJobWorker.java
@@ -99,7 +99,7 @@ public final class RuleAlteredJobWorker {
         if (null == ruleConfig) {
             return false;
         }
-        Optional<RuleAlteredDetector> detector = RuleAlteredDetectorFactory.findRuleAlteredDetector(ruleConfig);
+        Optional<RuleAlteredDetector> detector = RuleAlteredDetectorFactory.newInstance(ruleConfig);
         return detector.isPresent() && detector.get().getOnRuleAlteredActionConfig(ruleConfig).isPresent();
     }
     
@@ -142,7 +142,7 @@ public final class RuleAlteredJobWorker {
             throw new PipelineJobCreationException("could not find altered rule");
         }
         RuleConfiguration ruleConfig = SWAPPER_ENGINE.swapToRuleConfiguration(yamlRuleConfig);
-        Optional<RuleAlteredDetector> detector = RuleAlteredDetectorFactory.findRuleAlteredDetector(ruleConfig);
+        Optional<RuleAlteredDetector> detector = RuleAlteredDetectorFactory.newInstance(ruleConfig);
         Preconditions.checkState(detector.isPresent());
         Optional<OnRuleAlteredActionConfiguration> onRuleAlteredActionConfig = detector.get().getOnRuleAlteredActionConfig(ruleConfig);
         if (!onRuleAlteredActionConfig.isPresent()) {
@@ -197,7 +197,7 @@ public final class RuleAlteredJobWorker {
         Map<String, List<String>> alteredRuleYamlClassNameTablesMap = new HashMap<>();
         for (Pair<YamlRuleConfiguration, YamlRuleConfiguration> each : groupSourceTargetRuleConfigsByType(sourceRootConfig.getRules(), targetRootConfig.getRules())) {
             YamlRuleConfiguration yamlRuleConfig = null == each.getLeft() ? each.getRight() : each.getLeft();
-            Optional<RuleAlteredDetector> detector = RuleAlteredDetectorFactory.findRuleAlteredDetector(yamlRuleConfig);
+            Optional<RuleAlteredDetector> detector = RuleAlteredDetectorFactory.newInstance(yamlRuleConfig);
             if (!detector.isPresent()) {
                 continue;
             }
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-spi/src/main/java/org/apache/shardingsphere/data/pipeline/spi/rulealtered/RuleAlteredDetectorFactory.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-spi/src/main/java/org/apache/shardingsphere/data/pipeline/spi/rulealtered/RuleAlteredDetectorFactory.java
index f20da835739..f84b1c7fda9 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-spi/src/main/java/org/apache/shardingsphere/data/pipeline/spi/rulealtered/RuleAlteredDetectorFactory.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-spi/src/main/java/org/apache/shardingsphere/data/pipeline/spi/rulealtered/RuleAlteredDetectorFactory.java
@@ -36,23 +36,23 @@ public final class RuleAlteredDetectorFactory {
     }
     
     /**
-     * Find rule altered detector.
+     * Create new instance of rule altered detector.
      * 
-     * @param ruleConfig rule configuration to be found
-     * @return found rule altered detector
+     * @param ruleConfig rule configuration
+     * @return new instance of rule altered detector
      */
-    public static Optional<RuleAlteredDetector> findRuleAlteredDetector(final RuleConfiguration ruleConfig) {
+    public static Optional<RuleAlteredDetector> newInstance(final RuleConfiguration ruleConfig) {
         return ShardingSphereServiceLoader.getSingletonServiceInstances(RuleAlteredDetector.class).stream()
                 .filter(each -> each.getRuleConfigClassName().equals(ruleConfig.getClass().getName())).findFirst();
     }
     
     /**
-     * Find rule altered detector.
+     * Create new instance of rule altered detector.
      * 
-     * @param yamlRuleConfig YAML rule configuration to be found
-     * @return found rule altered detector
+     * @param yamlRuleConfig YAML rule configuration
+     * @return new instance of rule altered detector
      */
-    public static Optional<RuleAlteredDetector> findRuleAlteredDetector(final YamlRuleConfiguration yamlRuleConfig) {
+    public static Optional<RuleAlteredDetector> newInstance(final YamlRuleConfiguration yamlRuleConfig) {
         return ShardingSphereServiceLoader.getSingletonServiceInstances(RuleAlteredDetector.class).stream()
                 .filter(each -> each.getYamlRuleConfigClassName().equals(yamlRuleConfig.getClass().getName())).findFirst();
     }