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 55ad2df7007 Remove redundant event and subscribe for global rule 
(#26764)
55ad2df7007 is described below

commit 55ad2df7007c9d3ca7c36af194c1899035e5f9ce
Author: zhaojinchao <[email protected]>
AuthorDate: Thu Jul 6 11:48:45 2023 +0800

    Remove redundant event and subscribe for global rule (#26764)
---
 .../core/exception/GlobalClockSQLException.java    | 35 ----------------------
 .../global/DeleteGlobalRuleConfigurationEvent.java | 32 --------------------
 .../watcher/NewGlobalRuleChangedWatcher.java       | 16 ++--------
 .../NewConfigurationChangedSubscriber.java         | 11 -------
 4 files changed, 2 insertions(+), 92 deletions(-)

diff --git 
a/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/core/exception/GlobalClockSQLException.java
 
b/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/core/exception/GlobalClockSQLException.java
deleted file mode 100644
index 94f47dc6852..00000000000
--- 
a/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/core/exception/GlobalClockSQLException.java
+++ /dev/null
@@ -1,35 +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.globalclock.core.exception;
-
-import 
org.apache.shardingsphere.infra.util.exception.external.sql.sqlstate.SQLState;
-import 
org.apache.shardingsphere.infra.util.exception.external.sql.type.kernel.KernelSQLException;
-
-/**
- * Global clock SQL exception.
- */
-public abstract class GlobalClockSQLException extends KernelSQLException {
-    
-    private static final long serialVersionUID = -2262893200471389177L;
-    
-    private static final int KERNEL_CODE = 10;
-    
-    protected GlobalClockSQLException(final SQLState sqlState, final int 
errorCode, final String reason, final Object... messageArgs) {
-        super(sqlState, KERNEL_CODE, errorCode, reason, messageArgs);
-    }
-}
diff --git 
a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/config/global/DeleteGlobalRuleConfigurationEvent.java
 
b/mode/core/src/main/java/org/apache/shardingsphere/mode/event/config/global/DeleteGlobalRuleConfigurationEvent.java
deleted file mode 100644
index d3a415f9d31..00000000000
--- 
a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/config/global/DeleteGlobalRuleConfigurationEvent.java
+++ /dev/null
@@ -1,32 +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.event.config.global;
-
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
-
-/**
- * Delete global rule configuration event.
- */
-@RequiredArgsConstructor
-@Getter
-public final class DeleteGlobalRuleConfigurationEvent implements 
GovernanceEvent {
-    
-    private final String ruleSimpleName;
-}
diff --git 
a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/config/watcher/NewGlobalRuleChangedWatcher.java
 
b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/config/watcher/NewGlobalRuleChangedWatcher.java
index bd8a870e1d4..c90fea39c8f 100644
--- 
a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/config/watcher/NewGlobalRuleChangedWatcher.java
+++ 
b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/config/watcher/NewGlobalRuleChangedWatcher.java
@@ -23,7 +23,6 @@ import 
org.apache.shardingsphere.metadata.persist.node.GlobalNode;
 import org.apache.shardingsphere.mode.event.DataChangedEvent;
 import org.apache.shardingsphere.mode.event.DataChangedEvent.Type;
 import 
org.apache.shardingsphere.mode.event.config.global.AlterGlobalRuleConfigurationEvent;
-import 
org.apache.shardingsphere.mode.event.config.global.DeleteGlobalRuleConfigurationEvent;
 import 
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.NewGovernanceWatcher;
 
 import java.util.Arrays;
@@ -44,24 +43,13 @@ public final class NewGlobalRuleChangedWatcher implements 
NewGovernanceWatcher<G
     
     @Override
     public Collection<Type> getWatchingTypes() {
-        return Arrays.asList(Type.ADDED, Type.UPDATED, Type.DELETED);
+        return Arrays.asList(Type.ADDED, Type.UPDATED);
     }
     
     @Override
     public Optional<GovernanceEvent> createGovernanceEvent(final 
DataChangedEvent event) {
-        return createGlobalRuleEvent(event);
-    }
-    
-    private Optional<GovernanceEvent> createGlobalRuleEvent(final 
DataChangedEvent event) {
         if (GlobalNodePath.isRuleActiveVersionPath(event.getKey())) {
-            Optional<String> ruleName = 
GlobalNodePath.getRuleName(event.getKey());
-            if (!ruleName.isPresent()) {
-                return Optional.empty();
-            }
-            if (Type.ADDED == event.getType() || Type.UPDATED == 
event.getType()) {
-                return Optional.of(new 
AlterGlobalRuleConfigurationEvent(ruleName.get(), event.getKey(), 
event.getValue()));
-            }
-            return Optional.of(new 
DeleteGlobalRuleConfigurationEvent(ruleName.get()));
+            return GlobalNodePath.getRuleName(event.getKey()).map(optional -> 
new AlterGlobalRuleConfigurationEvent(optional, event.getKey(), 
event.getValue()));
         }
         return Optional.empty();
     }
diff --git 
a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/subscriber/NewConfigurationChangedSubscriber.java
 
b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/subscriber/NewConfigurationChangedSubscriber.java
index 06d8a9be088..c0b519965ef 100644
--- 
a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/subscriber/NewConfigurationChangedSubscriber.java
+++ 
b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/subscriber/NewConfigurationChangedSubscriber.java
@@ -21,7 +21,6 @@ import com.google.common.eventbus.Subscribe;
 import 
org.apache.shardingsphere.mode.event.config.DatabaseRuleConfigurationChangedEvent;
 import 
org.apache.shardingsphere.mode.event.config.global.AlterGlobalRuleConfigurationEvent;
 import org.apache.shardingsphere.mode.event.config.global.AlterPropertiesEvent;
-import 
org.apache.shardingsphere.mode.event.config.global.DeleteGlobalRuleConfigurationEvent;
 import org.apache.shardingsphere.mode.event.datasource.AlterStorageUnitEvent;
 import 
org.apache.shardingsphere.mode.event.datasource.RegisterStorageUnitEvent;
 import 
org.apache.shardingsphere.mode.event.datasource.UnregisterStorageUnitEvent;
@@ -108,16 +107,6 @@ public final class NewConfigurationChangedSubscriber {
         
contextManager.alterGlobalRuleConfiguration(contextManager.getMetaDataContexts().getPersistService().getGlobalRuleService().load(event.getRuleSimpleName()));
     }
     
-    /**
-     * Renew for global rule configuration.
-     *
-     * @param event global rule delete event
-     */
-    @Subscribe
-    public synchronized void renew(final DeleteGlobalRuleConfigurationEvent 
event) {
-        contextManager.dropGlobalRuleConfiguration(event.getRuleSimpleName());
-    }
-    
     /**
      * Renew for global properties.
      *

Reply via email to