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 3f23afb6888 Remove AlterDatabaseRuleConfigurationEvent and
DropDatabaseRuleConfigurationEvent (#31194)
3f23afb6888 is described below
commit 3f23afb68886f485111edf913afe32bef98d189f
Author: Liang Zhang <[email protected]>
AuthorDate: Fri May 10 12:57:34 2024 +0800
Remove AlterDatabaseRuleConfigurationEvent and
DropDatabaseRuleConfigurationEvent (#31194)
---
.../mysql/ingest/binlog/event/QueryEvent.java | 2 +-
.../AlterGlobalRuleConfigurationEvent.java | 2 +-
.../config/{global => }/AlterPropertiesEvent.java | 2 +-
.../AlterDatabaseRuleConfigurationEvent.java | 34 ----------------------
.../DropDatabaseRuleConfigurationEvent.java | 34 ----------------------
.../mode/subsciber/RuleItemChangedSubscriber.java | 29 +++++++++---------
.../registry/watcher/GlobalRuleChangedWatcher.java | 2 +-
.../registry/watcher/PropertiesChangedWatcher.java | 2 +-
.../subscriber/ConfigurationChangedSubscriber.java | 32 ++------------------
9 files changed, 22 insertions(+), 117 deletions(-)
diff --git
a/kernel/data-pipeline/dialect/mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/binlog/event/QueryEvent.java
b/kernel/data-pipeline/dialect/mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/binlog/event/QueryEvent.java
index e006c61d7d6..ee75debf9bf 100644
---
a/kernel/data-pipeline/dialect/mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/binlog/event/QueryEvent.java
+++
b/kernel/data-pipeline/dialect/mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/binlog/event/QueryEvent.java
@@ -28,8 +28,8 @@ import lombok.RequiredArgsConstructor;
*
* @see <a
href="https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_replication_binlog_event.html#sect_protocol_replication_event_query">QUERY_EVENT</a>
*/
-@Getter
@RequiredArgsConstructor
+@Getter
public final class QueryEvent extends AbstractBinlogEvent {
private final long threadId;
diff --git
a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/config/global/AlterGlobalRuleConfigurationEvent.java
b/mode/core/src/main/java/org/apache/shardingsphere/mode/event/config/AlterGlobalRuleConfigurationEvent.java
similarity index 95%
rename from
mode/core/src/main/java/org/apache/shardingsphere/mode/event/config/global/AlterGlobalRuleConfigurationEvent.java
rename to
mode/core/src/main/java/org/apache/shardingsphere/mode/event/config/AlterGlobalRuleConfigurationEvent.java
index e93bac00163..5cc7b5cb6db 100644
---
a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/config/global/AlterGlobalRuleConfigurationEvent.java
+++
b/mode/core/src/main/java/org/apache/shardingsphere/mode/event/config/AlterGlobalRuleConfigurationEvent.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.mode.event.config.global;
+package org.apache.shardingsphere.mode.event.config;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
diff --git
a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/config/global/AlterPropertiesEvent.java
b/mode/core/src/main/java/org/apache/shardingsphere/mode/event/config/AlterPropertiesEvent.java
similarity index 95%
rename from
mode/core/src/main/java/org/apache/shardingsphere/mode/event/config/global/AlterPropertiesEvent.java
rename to
mode/core/src/main/java/org/apache/shardingsphere/mode/event/config/AlterPropertiesEvent.java
index 26fdc54d0ee..f2b1313a262 100644
---
a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/config/global/AlterPropertiesEvent.java
+++
b/mode/core/src/main/java/org/apache/shardingsphere/mode/event/config/AlterPropertiesEvent.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.mode.event.config.global;
+package org.apache.shardingsphere.mode.event.config;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
diff --git
a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/config/database/AlterDatabaseRuleConfigurationEvent.java
b/mode/core/src/main/java/org/apache/shardingsphere/mode/event/config/database/AlterDatabaseRuleConfigurationEvent.java
deleted file mode 100644
index d9749c726d1..00000000000
---
a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/config/database/AlterDatabaseRuleConfigurationEvent.java
+++ /dev/null
@@ -1,34 +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.database;
-
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
-
-/**
- * Alter database rule configuration changed event.
- */
-@RequiredArgsConstructor
-@Getter
-public final class AlterDatabaseRuleConfigurationEvent {
-
- private final String databaseName;
-
- private final RuleConfiguration ruleConfig;
-}
diff --git
a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/config/database/DropDatabaseRuleConfigurationEvent.java
b/mode/core/src/main/java/org/apache/shardingsphere/mode/event/config/database/DropDatabaseRuleConfigurationEvent.java
deleted file mode 100644
index de22d167370..00000000000
---
a/mode/core/src/main/java/org/apache/shardingsphere/mode/event/config/database/DropDatabaseRuleConfigurationEvent.java
+++ /dev/null
@@ -1,34 +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.database;
-
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
-
-/**
- * Drop database rule configuration changed event.
- */
-@RequiredArgsConstructor
-@Getter
-public final class DropDatabaseRuleConfigurationEvent {
-
- private final String databaseName;
-
- private final RuleConfiguration ruleConfig;
-}
diff --git
a/mode/core/src/main/java/org/apache/shardingsphere/mode/subsciber/RuleItemChangedSubscriber.java
b/mode/core/src/main/java/org/apache/shardingsphere/mode/subsciber/RuleItemChangedSubscriber.java
index 4dbb37ca367..e16b8d7eeb1 100644
---
a/mode/core/src/main/java/org/apache/shardingsphere/mode/subsciber/RuleItemChangedSubscriber.java
+++
b/mode/core/src/main/java/org/apache/shardingsphere/mode/subsciber/RuleItemChangedSubscriber.java
@@ -20,12 +20,9 @@ package org.apache.shardingsphere.mode.subsciber;
import com.google.common.eventbus.Subscribe;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
-import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import
org.apache.shardingsphere.infra.rule.event.rule.alter.AlterRuleItemEvent;
import org.apache.shardingsphere.infra.rule.event.rule.drop.DropRuleItemEvent;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
-import
org.apache.shardingsphere.mode.event.config.database.AlterDatabaseRuleConfigurationEvent;
-import
org.apache.shardingsphere.mode.event.config.database.DropDatabaseRuleConfigurationEvent;
import org.apache.shardingsphere.mode.manager.ContextManager;
import
org.apache.shardingsphere.mode.spi.RuleItemConfigurationChangedProcessor;
@@ -51,16 +48,18 @@ public final class RuleItemChangedSubscriber {
RuleItemConfigurationChangedProcessor processor =
TypedSPILoader.getService(RuleItemConfigurationChangedProcessor.class,
event.getType());
String yamlContent =
contextManager.getMetaDataContexts().getPersistService().getMetaDataVersionPersistService().getVersionPathByActiveVersion(event.getActiveVersionKey(),
event.getActiveVersion());
- ShardingSphereDatabase database =
contextManager.getMetaDataContexts().getMetaData().getDatabase(event.getDatabaseName());
- RuleConfiguration currentRuleConfig =
processor.findRuleConfiguration(database);
+ String databaseName = event.getDatabaseName();
+ RuleConfiguration currentRuleConfig =
processor.findRuleConfiguration(contextManager.getMetaDataContexts().getMetaData().getDatabase(databaseName));
synchronized (this) {
processor.changeRuleItemConfiguration(event, currentRuleConfig,
processor.swapRuleItemConfiguration(event, yamlContent));
// TODO Remove isCluster judgment
if (contextManager.getInstanceContext().isCluster()) {
-
contextManager.getInstanceContext().getEventBusContext().post(new
AlterDatabaseRuleConfigurationEvent(event.getDatabaseName(),
currentRuleConfig));
- return;
+ if
(contextManager.getMetaDataContexts().getMetaData().containsDatabase(databaseName))
{
+
contextManager.getConfigurationContextManager().alterRuleConfiguration(databaseName,
currentRuleConfig);
+ }
+ } else {
+
contextManager.getConfigurationContextManager().alterRuleConfiguration(databaseName,
currentRuleConfig);
}
-
contextManager.getConfigurationContextManager().alterRuleConfiguration(event.getDatabaseName(),
currentRuleConfig);
}
}
@@ -72,20 +71,22 @@ public final class RuleItemChangedSubscriber {
@SuppressWarnings({"rawtypes", "unchecked", "unused"})
@Subscribe
public void renew(final DropRuleItemEvent event) {
- if
(!contextManager.getMetaDataContexts().getMetaData().containsDatabase(event.getDatabaseName()))
{
+ String databaseName = event.getDatabaseName();
+ if
(!contextManager.getMetaDataContexts().getMetaData().containsDatabase(databaseName))
{
return;
}
RuleItemConfigurationChangedProcessor processor =
TypedSPILoader.getService(RuleItemConfigurationChangedProcessor.class,
event.getType());
- ShardingSphereDatabase database =
contextManager.getMetaDataContexts().getMetaData().getDatabase(event.getDatabaseName());
- RuleConfiguration currentRuleConfig =
processor.findRuleConfiguration(database);
+ RuleConfiguration currentRuleConfig =
processor.findRuleConfiguration(contextManager.getMetaDataContexts().getMetaData().getDatabase(databaseName));
synchronized (this) {
processor.dropRuleItemConfiguration(event, currentRuleConfig);
// TODO Remove isCluster judgment
if (contextManager.getInstanceContext().isCluster()) {
-
contextManager.getInstanceContext().getEventBusContext().post(new
DropDatabaseRuleConfigurationEvent(event.getDatabaseName(), currentRuleConfig));
- return;
+ if
(contextManager.getMetaDataContexts().getMetaData().containsDatabase(databaseName))
{
+
contextManager.getConfigurationContextManager().dropRuleConfiguration(databaseName,
currentRuleConfig);
+ }
+ } else {
+
contextManager.getConfigurationContextManager().dropRuleConfiguration(databaseName,
currentRuleConfig);
}
-
contextManager.getConfigurationContextManager().dropRuleConfiguration(event.getDatabaseName(),
currentRuleConfig);
}
}
}
diff --git
a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/watcher/GlobalRuleChangedWatcher.java
b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/watcher/GlobalRuleChangedWatcher.java
index 0c29a51588b..783c89bd926 100644
---
a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/watcher/GlobalRuleChangedWatcher.java
+++
b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/watcher/GlobalRuleChangedWatcher.java
@@ -22,7 +22,7 @@ import org.apache.shardingsphere.mode.path.GlobalNodePath;
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.AlterGlobalRuleConfigurationEvent;
import
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.GovernanceWatcher;
import java.util.Arrays;
diff --git
a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/watcher/PropertiesChangedWatcher.java
b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/watcher/PropertiesChangedWatcher.java
index b70cd305b40..a86dd0d9fc0 100644
---
a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/watcher/PropertiesChangedWatcher.java
+++
b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/watcher/PropertiesChangedWatcher.java
@@ -21,7 +21,7 @@ import org.apache.shardingsphere.mode.path.GlobalNodePath;
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.AlterPropertiesEvent;
+import org.apache.shardingsphere.mode.event.config.AlterPropertiesEvent;
import
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.GovernanceWatcher;
import java.util.Arrays;
diff --git
a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/subscriber/ConfigurationChangedSubscriber.java
b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/subscriber/ConfigurationChangedSubscriber.java
index 5747e854b15..2c8c283da49 100644
---
a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/subscriber/ConfigurationChangedSubscriber.java
+++
b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/subscriber/ConfigurationChangedSubscriber.java
@@ -18,10 +18,8 @@
package org.apache.shardingsphere.mode.manager.cluster.coordinator.subscriber;
import com.google.common.eventbus.Subscribe;
-import
org.apache.shardingsphere.mode.event.config.database.AlterDatabaseRuleConfigurationEvent;
-import
org.apache.shardingsphere.mode.event.config.database.DropDatabaseRuleConfigurationEvent;
-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.AlterGlobalRuleConfigurationEvent;
+import org.apache.shardingsphere.mode.event.config.AlterPropertiesEvent;
import
org.apache.shardingsphere.mode.event.datasource.unit.AlterStorageUnitEvent;
import
org.apache.shardingsphere.mode.event.datasource.unit.RegisterStorageUnitEvent;
import
org.apache.shardingsphere.mode.event.datasource.unit.UnregisterStorageUnitEvent;
@@ -81,32 +79,6 @@ public final class ConfigurationChangedSubscriber {
contextManager.getConfigurationContextManager().unregisterStorageUnit(event.getDatabaseName(),
event.getStorageUnitName());
}
- /**
- * Renew for database rule configuration.
- *
- * @param event database rule changed event
- */
- @Subscribe
- public synchronized void renew(final AlterDatabaseRuleConfigurationEvent
event) {
- if
(!contextManager.getMetaDataContexts().getMetaData().containsDatabase(event.getDatabaseName()))
{
- return;
- }
-
contextManager.getConfigurationContextManager().alterRuleConfiguration(event.getDatabaseName(),
event.getRuleConfig());
- }
-
- /**
- * Renew for database rule configuration.
- *
- * @param event database rule changed event
- */
- @Subscribe
- public synchronized void renew(final DropDatabaseRuleConfigurationEvent
event) {
- if
(!contextManager.getMetaDataContexts().getMetaData().containsDatabase(event.getDatabaseName()))
{
- return;
- }
-
contextManager.getConfigurationContextManager().dropRuleConfiguration(event.getDatabaseName(),
event.getRuleConfig());
- }
-
/**
* Renew for global rule configuration.
*