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

menghaoran 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 bee796c  Rename PrimaryDataSourceEvent to 
PrimaryDataSourceChangedEvent (#12252)
bee796c is described below

commit bee796c7384643b9a3727b5874708b3e2fa52a3b
Author: Liang Zhang <[email protected]>
AuthorDate: Tue Sep 7 11:03:58 2021 +0800

    Rename PrimaryDataSourceEvent to PrimaryDataSourceChangedEvent (#12252)
---
 .../shardingsphere/dbdiscovery/rule/DatabaseDiscoveryRule.java    | 8 ++++----
 .../shardingsphere/dbdiscovery/mgr/MGRDatabaseDiscoveryType.java  | 4 ++--
 ...aryDataSourceEvent.java => PrimaryDataSourceChangedEvent.java} | 4 ++--
 .../mode/manager/cluster/ClusterContextManagerBuilder.java        | 4 ++--
 .../state/subscriber/DataSourceStatusRegistrySubscriber.java      | 4 ++--
 .../state/subscriber/DataSourceStatusRegistrySubscriberTest.java  | 6 +++---
 6 files changed, 15 insertions(+), 15 deletions(-)

diff --git 
a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/rule/DatabaseDiscoveryRule.java
 
b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/rule/DatabaseDiscoveryRule.java
index a5c135f..c8cab3a 100644
--- 
a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/rule/DatabaseDiscoveryRule.java
+++ 
b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/rule/DatabaseDiscoveryRule.java
@@ -30,7 +30,7 @@ import 
org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmF
 import org.apache.shardingsphere.infra.exception.ShardingSphereException;
 import org.apache.shardingsphere.infra.rule.event.DataSourceStatusChangedEvent;
 import 
org.apache.shardingsphere.infra.rule.event.impl.DataSourceNameDisabledEvent;
-import org.apache.shardingsphere.infra.rule.event.impl.PrimaryDataSourceEvent;
+import 
org.apache.shardingsphere.infra.rule.event.impl.PrimaryDataSourceChangedEvent;
 import org.apache.shardingsphere.infra.rule.identifier.scope.SchemaRule;
 import 
org.apache.shardingsphere.infra.rule.identifier.type.DataSourceContainedRule;
 import 
org.apache.shardingsphere.infra.rule.identifier.type.StatusContainedRule;
@@ -166,10 +166,10 @@ public final class DatabaseDiscoveryRule implements 
SchemaRule, DataSourceContai
                     
entry.getValue().enableDataSource(((DataSourceNameDisabledEvent) 
event).getDataSourceName());
                 }
             }
-        } else if (event instanceof PrimaryDataSourceEvent) {
+        } else if (event instanceof PrimaryDataSourceChangedEvent) {
             for (Entry<String, DatabaseDiscoveryDataSourceRule> entry : 
dataSourceRules.entrySet()) {
-                if 
(entry.getValue().getName().equals(((PrimaryDataSourceEvent) 
event).getGroupName())) {
-                    
entry.getValue().updatePrimaryDataSourceName(((PrimaryDataSourceEvent) 
event).getDataSourceName());
+                if 
(entry.getValue().getName().equals(((PrimaryDataSourceChangedEvent) 
event).getGroupName())) {
+                    
entry.getValue().updatePrimaryDataSourceName(((PrimaryDataSourceChangedEvent) 
event).getDataSourceName());
                 }
             }
         }
diff --git 
a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-mgr/src/main/java/org/apache/shardingsphere/dbdiscovery/mgr/MGRDatabaseDiscoveryType.java
 
b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-mgr/src/main/java/org/apache/shardingsphere/dbdiscovery/mgr/MGRDatabaseDiscoveryType.java
index 8e2f0bd..4c039b3 100644
--- 
a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-mgr/src/main/java/org/apache/shardingsphere/dbdiscovery/mgr/MGRDatabaseDiscoveryType.java
+++ 
b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-mgr/src/main/java/org/apache/shardingsphere/dbdiscovery/mgr/MGRDatabaseDiscoveryType.java
@@ -29,7 +29,7 @@ import 
org.apache.shardingsphere.elasticjob.reg.zookeeper.ZookeeperRegistryCente
 import 
org.apache.shardingsphere.infra.config.exception.ShardingSphereConfigurationException;
 import org.apache.shardingsphere.infra.eventbus.ShardingSphereEventBus;
 import org.apache.shardingsphere.infra.rule.event.impl.DataSourceDisabledEvent;
-import org.apache.shardingsphere.infra.rule.event.impl.PrimaryDataSourceEvent;
+import 
org.apache.shardingsphere.infra.rule.event.impl.PrimaryDataSourceChangedEvent;
 
 import javax.sql.DataSource;
 import java.sql.Connection;
@@ -137,7 +137,7 @@ public final class MGRDatabaseDiscoveryType implements 
DatabaseDiscoveryType {
             }
             if (!newPrimaryDataSource.equals(oldPrimaryDataSource)) {
                 oldPrimaryDataSource = newPrimaryDataSource;
-                ShardingSphereEventBus.getInstance().post(new 
PrimaryDataSourceEvent(schemaName, groupName, newPrimaryDataSource));
+                ShardingSphereEventBus.getInstance().post(new 
PrimaryDataSourceChangedEvent(schemaName, groupName, newPrimaryDataSource));
             }
         } else {
             oldPrimaryDataSource = primaryDataSourceName;
diff --git 
a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/event/impl/PrimaryDataSourceEvent.java
 
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/event/impl/PrimaryDataSourceChangedEvent.java
similarity index 90%
rename from 
shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/event/impl/PrimaryDataSourceEvent.java
rename to 
shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/event/impl/PrimaryDataSourceChangedEvent.java
index 3a4f7b5..ec3b00e 100644
--- 
a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/event/impl/PrimaryDataSourceEvent.java
+++ 
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/event/impl/PrimaryDataSourceChangedEvent.java
@@ -22,11 +22,11 @@ import lombok.RequiredArgsConstructor;
 import org.apache.shardingsphere.infra.rule.event.DataSourceStatusChangedEvent;
 
 /**
- * Primary data source event.
+ * Primary data source changed event.
  */
 @RequiredArgsConstructor
 @Getter
-public final class PrimaryDataSourceEvent implements 
DataSourceStatusChangedEvent {
+public final class PrimaryDataSourceChangedEvent implements 
DataSourceStatusChangedEvent {
     
     private final String schemaName;
     
diff --git 
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java
 
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java
index 68db820..97c0aa1 100644
--- 
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java
+++ 
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java
@@ -38,7 +38,7 @@ import 
org.apache.shardingsphere.infra.optimize.core.metadata.FederateSchemaMeta
 import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
 import org.apache.shardingsphere.infra.rule.builder.global.GlobalRulesBuilder;
 import 
org.apache.shardingsphere.infra.rule.event.impl.DataSourceNameDisabledEvent;
-import org.apache.shardingsphere.infra.rule.event.impl.PrimaryDataSourceEvent;
+import 
org.apache.shardingsphere.infra.rule.event.impl.PrimaryDataSourceChangedEvent;
 import 
org.apache.shardingsphere.infra.rule.identifier.type.StatusContainedRule;
 import org.apache.shardingsphere.mode.manager.ContextManager;
 import org.apache.shardingsphere.mode.manager.ContextManagerBuilder;
@@ -382,7 +382,7 @@ public final class ClusterContextManagerBuilder implements 
ContextManagerBuilder
         Collection<ShardingSphereRule> rules = 
contextManager.getMetaDataContexts().getMetaDataMap().get(governanceSchema.getSchemaName()).getRuleMetaData().getRules();
         for (ShardingSphereRule each : rules) {
             if (each instanceof StatusContainedRule) {
-                ((StatusContainedRule) each).updateStatus(new 
PrimaryDataSourceEvent(governanceSchema.getSchemaName(), 
governanceSchema.getDataSourceName(), event.getPrimaryDataSourceName()));
+                ((StatusContainedRule) each).updateStatus(new 
PrimaryDataSourceChangedEvent(governanceSchema.getSchemaName(), 
governanceSchema.getDataSourceName(), event.getPrimaryDataSourceName()));
             }
         }
     }
diff --git 
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/governance/registry/state/subscriber/DataSourceStatusRegistrySubscriber.java
 
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/governance/registry/state/subscriber/DataSourceStatusRegistrySubscr
 [...]
index cff34cf..a7667d1 100644
--- 
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/governance/registry/state/subscriber/DataSourceStatusRegistrySubscriber.java
+++ 
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/governance/registry/state/subscriber/DataSourceStatusRegistrySubscriber.java
@@ -23,7 +23,7 @@ import 
org.apache.shardingsphere.mode.manager.cluster.governance.registry.state.
 import 
org.apache.shardingsphere.mode.repository.cluster.ClusterPersistRepository;
 import org.apache.shardingsphere.infra.eventbus.ShardingSphereEventBus;
 import org.apache.shardingsphere.infra.rule.event.impl.DataSourceDisabledEvent;
-import org.apache.shardingsphere.infra.rule.event.impl.PrimaryDataSourceEvent;
+import 
org.apache.shardingsphere.infra.rule.event.impl.PrimaryDataSourceChangedEvent;
 
 /**
  * Data source status registry subscriber.
@@ -54,7 +54,7 @@ public final class DataSourceStatusRegistrySubscriber {
      * @param event primary data source event
      */
     @Subscribe
-    public void update(final PrimaryDataSourceEvent event) {
+    public void update(final PrimaryDataSourceChangedEvent event) {
         
repository.persist(StatesNode.getPrimaryDataSourcePath(event.getSchemaName(), 
event.getGroupName()), event.getDataSourceName());
     }
 }
diff --git 
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/governance/registry/state/subscriber/DataSourceStatusRegistrySubscriberTest.java
 
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/governance/registry/state/subscriber/DataSourceStatusRegistrySu
 [...]
index 54a011a..95b2f45 100644
--- 
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/governance/registry/state/subscriber/DataSourceStatusRegistrySubscriberTest.java
+++ 
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/governance/registry/state/subscriber/DataSourceStatusRegistrySubscriberTest.java
@@ -21,7 +21,7 @@ import 
org.apache.shardingsphere.mode.manager.cluster.governance.registry.state.
 import 
org.apache.shardingsphere.mode.manager.cluster.governance.registry.state.node.StatesNode;
 import 
org.apache.shardingsphere.mode.repository.cluster.ClusterPersistRepository;
 import org.apache.shardingsphere.infra.rule.event.impl.DataSourceDisabledEvent;
-import org.apache.shardingsphere.infra.rule.event.impl.PrimaryDataSourceEvent;
+import 
org.apache.shardingsphere.infra.rule.event.impl.PrimaryDataSourceChangedEvent;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
@@ -58,8 +58,8 @@ public final class DataSourceStatusRegistrySubscriberTest {
         String schemaName = "replica_query_db";
         String groupName = "group1";
         String dataSourceName = "replica_ds_0";
-        PrimaryDataSourceEvent primaryDataSourceEvent = new 
PrimaryDataSourceEvent(schemaName, groupName, dataSourceName);
-        new 
DataSourceStatusRegistrySubscriber(repository).update(primaryDataSourceEvent);
+        PrimaryDataSourceChangedEvent event = new 
PrimaryDataSourceChangedEvent(schemaName, groupName, dataSourceName);
+        new DataSourceStatusRegistrySubscriber(repository).update(event);
         
verify(repository).persist(StatesNode.getPrimaryDataSourcePath(schemaName, 
groupName), dataSourceName);
     }
 }

Reply via email to