You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by ji...@apache.org on 2023/07/07 15:28:37 UTC

[shardingsphere] branch master updated: Remove useless RuleChangedEventCreator (#26824)

This is an automated email from the ASF dual-hosted git repository.

jianglongtao 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 15bcecac146 Remove useless RuleChangedEventCreator (#26824)
15bcecac146 is described below

commit 15bcecac14666cc56a77d464de5d6e149cbfb38e
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Fri Jul 7 23:28:31 2023 +0800

    Remove useless RuleChangedEventCreator (#26824)
---
 .../mode/spi/RuleChangedEventCreator.java          | 58 ----------------------
 .../watcher/RuleConfigurationEventBuilder.java     |  8 +--
 2 files changed, 4 insertions(+), 62 deletions(-)

diff --git a/mode/api/src/main/java/org/apache/shardingsphere/mode/spi/RuleChangedEventCreator.java b/mode/api/src/main/java/org/apache/shardingsphere/mode/spi/RuleChangedEventCreator.java
deleted file mode 100644
index 69461f94d24..00000000000
--- a/mode/api/src/main/java/org/apache/shardingsphere/mode/spi/RuleChangedEventCreator.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.mode.spi;
-
-import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
-import org.apache.shardingsphere.mode.event.DataChangedEvent;
-import org.apache.shardingsphere.mode.event.NamedRuleItemChangedEventCreator;
-import org.apache.shardingsphere.mode.event.UniqueRuleItemChangedEventCreator;
-
-/**
- * Rule changed event creator.
- */
-public final class RuleChangedEventCreator {
-    
-    /**
-     * Create rule changed event.
-     * 
-     * @param databaseName database name
-     * @param event data changed event
-     * @param ruleType rule type
-     * @param itemType item type
-     * @param itemName item name
-     * @return rule configuration changed event
-     * @throws UnsupportedOperationException unsupported item type
-     */
-    public GovernanceEvent create(final String databaseName, final DataChangedEvent event, final String ruleType, final String itemType, final String itemName) {
-        return new NamedRuleItemChangedEventCreator().create(databaseName, itemName, event, ruleType + "." + itemType);
-    }
-    
-    /**
-     * Create rule changed event.
-     *
-     * @param databaseName database name
-     * @param event data changed event
-     * @param ruleType rule type
-     * @param itemType item type
-     * @return rule configuration changed event
-     * @throws UnsupportedOperationException unsupported item type
-     */
-    public GovernanceEvent create(final String databaseName, final DataChangedEvent event, final String ruleType, final String itemType) {
-        return new UniqueRuleItemChangedEventCreator().create(databaseName, event, ruleType + "." + itemType);
-    }
-}
diff --git a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/metadata/watcher/RuleConfigurationEventBuilder.java b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/metadata/watcher/RuleConfigurationEventBuilder.java
index 301a562b182..5f63a3622c2 100644
--- a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/metadata/watcher/RuleConfigurationEventBuilder.java
+++ b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/metadata/watcher/RuleConfigurationEventBuilder.java
@@ -24,7 +24,8 @@ import org.apache.shardingsphere.infra.metadata.nodepath.item.UniqueRuleItemNode
 import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
 import org.apache.shardingsphere.infra.util.spi.ShardingSphereServiceLoader;
 import org.apache.shardingsphere.mode.event.DataChangedEvent;
-import org.apache.shardingsphere.mode.spi.RuleChangedEventCreator;
+import org.apache.shardingsphere.mode.event.NamedRuleItemChangedEventCreator;
+import org.apache.shardingsphere.mode.event.UniqueRuleItemChangedEventCreator;
 import org.apache.shardingsphere.mode.spi.RuleNodePathProvider;
 
 import java.util.Map.Entry;
@@ -56,16 +57,15 @@ public final class RuleConfigurationEventBuilder {
         if (!ruleNodePath.getRoot().isValidatedPath(event.getKey()) || Strings.isNullOrEmpty(event.getValue())) {
             return Optional.empty();
         }
-        RuleChangedEventCreator eventCreator = new RuleChangedEventCreator();
         for (Entry<String, NamedRuleItemNodePath> entry : ruleNodePath.getNamedItems().entrySet()) {
             Optional<String> itemName = entry.getValue().getNameByActiveVersion(event.getKey());
             if (itemName.isPresent()) {
-                return Optional.of(eventCreator.create(databaseName, event, ruleNodePath.getRoot().getRuleType(), entry.getKey(), itemName.get()));
+                return Optional.of(new NamedRuleItemChangedEventCreator().create(databaseName, itemName.get(), event, ruleNodePath.getRoot().getRuleType() + "." + entry.getKey()));
             }
         }
         for (Entry<String, UniqueRuleItemNodePath> entry : ruleNodePath.getUniqueItems().entrySet()) {
             if (entry.getValue().isActiveVersionPath(event.getKey())) {
-                return Optional.of(eventCreator.create(databaseName, event, ruleNodePath.getRoot().getRuleType(), entry.getKey()));
+                return Optional.of(new UniqueRuleItemChangedEventCreator().create(databaseName, event, ruleNodePath.getRoot().getRuleType() + "." + entry.getKey()));
             }
         }
         return Optional.empty();