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

totalo 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 f8f6dd4ba19 Rename MetaDataVersionPersistService (#19300)
f8f6dd4ba19 is described below

commit f8f6dd4ba194a25a8ece226db748bf6da83cc191
Author: Liang Zhang <[email protected]>
AuthorDate: Sun Jul 17 23:58:40 2022 +0800

    Rename MetaDataVersionPersistService (#19300)
---
 .../mode/metadata/persist/MetaDataPersistService.java      |  6 +++---
 ...sistService.java => MetaDataVersionPersistService.java} |  4 ++--
 .../coordinator/ClusterContextManagerCoordinator.java      |  4 ++--
 .../cache/subscriber/ScalingRegistrySubscriber.java        | 14 +++++++-------
 .../coordinator/ClusterContextManagerCoordinatorTest.java  |  4 ++--
 .../cache/subscriber/ScalingRegistrySubscriberTest.java    | 12 +++++-------
 .../distsql/rdl/rule/RuleDefinitionBackendHandler.java     |  2 +-
 7 files changed, 22 insertions(+), 24 deletions(-)

diff --git 
a/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/MetaDataPersistService.java
 
b/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/MetaDataPersistService.java
index 8817d39575f..f85c7c7fc8f 100644
--- 
a/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/MetaDataPersistService.java
+++ 
b/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/MetaDataPersistService.java
@@ -24,7 +24,7 @@ import 
org.apache.shardingsphere.infra.datasource.pool.creator.DataSourcePoolCre
 import 
org.apache.shardingsphere.infra.datasource.pool.destroyer.DataSourcePoolDestroyer;
 import org.apache.shardingsphere.infra.datasource.props.DataSourceProperties;
 import 
org.apache.shardingsphere.infra.datasource.props.DataSourcePropertiesCreator;
-import 
org.apache.shardingsphere.mode.metadata.persist.service.DatabaseVersionPersistService;
+import 
org.apache.shardingsphere.mode.metadata.persist.service.MetaDataVersionPersistService;
 import 
org.apache.shardingsphere.mode.metadata.persist.service.DatabaseMetaDataPersistService;
 import 
org.apache.shardingsphere.mode.metadata.persist.service.config.database.DataSourcePersistService;
 import 
org.apache.shardingsphere.mode.metadata.persist.service.config.database.DatabaseRulePersistService;
@@ -57,7 +57,7 @@ public final class MetaDataPersistService {
     
     private final PropertiesPersistService propsService;
     
-    private final DatabaseVersionPersistService databaseVersionPersistService;
+    private final MetaDataVersionPersistService metaDataVersionPersistService;
     
     public MetaDataPersistService(final PersistRepository repository) {
         this.repository = repository;
@@ -66,7 +66,7 @@ public final class MetaDataPersistService {
         databaseRulePersistService = new 
DatabaseRulePersistService(repository);
         globalRuleService = new GlobalRulePersistService(repository);
         propsService = new PropertiesPersistService(repository);
-        databaseVersionPersistService = new 
DatabaseVersionPersistService(repository);
+        metaDataVersionPersistService = new 
MetaDataVersionPersistService(repository);
     }
     
     /**
diff --git 
a/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/service/DatabaseVersionPersistService.java
 
b/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/service/MetaDataVersionPersistService.java
similarity index 97%
rename from 
shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/service/DatabaseVersionPersistService.java
rename to 
shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/service/MetaDataVersionPersistService.java
index b60e9dd2c13..4a507f7112e 100644
--- 
a/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/service/DatabaseVersionPersistService.java
+++ 
b/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/service/MetaDataVersionPersistService.java
@@ -25,10 +25,10 @@ import java.util.Optional;
 import java.util.concurrent.atomic.AtomicLong;
 
 /**
- * Database version persist service.
+ * Meta data version persist service.
  */
 @RequiredArgsConstructor
-public final class DatabaseVersionPersistService {
+public final class MetaDataVersionPersistService {
     
     private final PersistRepository repository;
     
diff --git 
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/ClusterContextManagerCoordinator.java
 
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/ClusterContextManagerCoordinator.java
index 7965ac0d394..cdae485c1c4 100644
--- 
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/ClusterContextManagerCoordinator.java
+++ 
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/ClusterContextManagerCoordinator.java
@@ -142,7 +142,7 @@ public final class ClusterContextManagerCoordinator {
      */
     @Subscribe
     public synchronized void renew(final RuleConfigurationsChangedEvent event) 
{
-        if 
(persistService.getDatabaseVersionPersistService().isActiveVersion(event.getDatabaseName(),
 event.getDatabaseVersion())) {
+        if 
(persistService.getMetaDataVersionPersistService().isActiveVersion(event.getDatabaseName(),
 event.getDatabaseVersion())) {
             contextManager.alterRuleConfiguration(event.getDatabaseName(), 
event.getRuleConfigurations());
             disableDataSources();
         }
@@ -155,7 +155,7 @@ public final class ClusterContextManagerCoordinator {
      */
     @Subscribe
     public synchronized void renew(final DataSourceChangedEvent event) {
-        if 
(persistService.getDatabaseVersionPersistService().isActiveVersion(event.getDatabaseName(),
 event.getDatabaseVersion())) {
+        if 
(persistService.getMetaDataVersionPersistService().isActiveVersion(event.getDatabaseName(),
 event.getDatabaseVersion())) {
             
contextManager.alterDataSourceConfiguration(event.getDatabaseName(), 
event.getDataSourcePropertiesMap());
             disableDataSources();
         }
diff --git 
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/cache/subscriber/ScalingRegistrySubscriber.java
 
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/cache/subscriber/ScalingRegistrySubscriber.java
index e2980765dc4..9612cf7afd6 100644
--- 
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/cache/subscriber/ScalingRegistrySubscriber.java
+++ 
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/cache/subscriber/ScalingRegistrySubscriber.java
@@ -24,7 +24,7 @@ import 
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.cache
 import 
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.config.event.rule.ScalingTaskFinishedEvent;
 import 
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.config.event.version.MetadataVersionPreparedEvent;
 import 
org.apache.shardingsphere.mode.metadata.persist.node.DatabaseMetaDataNode;
-import 
org.apache.shardingsphere.mode.metadata.persist.service.DatabaseVersionPersistService;
+import 
org.apache.shardingsphere.mode.metadata.persist.service.MetaDataVersionPersistService;
 import 
org.apache.shardingsphere.mode.repository.cluster.ClusterPersistRepository;
 
 import java.util.Optional;
@@ -39,14 +39,14 @@ public final class ScalingRegistrySubscriber {
     
     private final ClusterPersistRepository repository;
     
-    private final DatabaseVersionPersistService databaseVersionPersistService;
+    private final MetaDataVersionPersistService metaDataVersionPersistService;
     
     private final EventBusContext eventBusContext;
     
     public ScalingRegistrySubscriber(final ClusterPersistRepository 
repository, final EventBusContext eventBusContext) {
         this.repository = repository;
         this.eventBusContext = eventBusContext;
-        databaseVersionPersistService = new 
DatabaseVersionPersistService(repository);
+        metaDataVersionPersistService = new 
MetaDataVersionPersistService(repository);
         eventBusContext.register(this);
     }
     
@@ -58,7 +58,7 @@ public final class ScalingRegistrySubscriber {
     @Subscribe
     public void startScaling(final MetadataVersionPreparedEvent event) {
         String databaseName = event.getDatabaseName();
-        String activeVersion = 
databaseVersionPersistService.getActiveVersion(databaseName).get();
+        String activeVersion = 
metaDataVersionPersistService.getActiveVersion(databaseName).get();
         String sourceDataSource = 
repository.get(DatabaseMetaDataNode.getMetaDataDataSourcePath(databaseName, 
activeVersion));
         String targetDataSource = 
repository.get(DatabaseMetaDataNode.getMetaDataDataSourcePath(databaseName, 
event.getVersion()));
         String sourceRule = 
repository.get(DatabaseMetaDataNode.getRulePath(databaseName, activeVersion));
@@ -78,10 +78,10 @@ public final class ScalingRegistrySubscriber {
     public void scalingTaskFinished(final ScalingTaskFinishedEvent event) {
         log.info("scalingTaskFinished, event={}", event);
         int targetActiveVersion = event.getTargetActiveVersion();
-        Optional<String> activeVersion = 
databaseVersionPersistService.getActiveVersion(event.getTargetSchemaName());
+        Optional<String> activeVersion = 
metaDataVersionPersistService.getActiveVersion(event.getTargetSchemaName());
         if (activeVersion.isPresent() && targetActiveVersion == 
Integer.parseInt(activeVersion.get())) {
-            
databaseVersionPersistService.persistActiveVersion(event.getTargetSchemaName(), 
event.getTargetNewVersion() + "");
-            
databaseVersionPersistService.deleteVersion(event.getTargetSchemaName(), 
targetActiveVersion + "");
+            
metaDataVersionPersistService.persistActiveVersion(event.getTargetSchemaName(), 
event.getTargetNewVersion() + "");
+            
metaDataVersionPersistService.deleteVersion(event.getTargetSchemaName(), 
targetActiveVersion + "");
         } else {
             log.error("targetActiveVersion does not match current 
activeVersion, targetActiveVersion={}, activeVersion={}", targetActiveVersion, 
activeVersion.orElse(null));
         }
diff --git 
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/ClusterContextManagerCoordinatorTest.java
 
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/ClusterContextManagerCoordinatorTest.java
index de1155d1e74..d826c162ad3 100644
--- 
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/ClusterContextManagerCoordinatorTest.java
+++ 
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/ClusterContextManagerCoordinatorTest.java
@@ -215,7 +215,7 @@ public final class ClusterContextManagerCoordinatorTest {
     
     @Test
     public void assertRenewForRuleConfigurationsChanged() {
-        
when(persistService.getDatabaseVersionPersistService().isActiveVersion("db", 
"0")).thenReturn(true);
+        
when(persistService.getMetaDataVersionPersistService().isActiveVersion("db", 
"0")).thenReturn(true);
         
assertThat(contextManager.getMetaDataContexts().getMetaData().getDatabases().get("db"),
 is(database));
         coordinator.renew(new RuleConfigurationsChangedEvent("db", "0", 
Collections.emptyList()));
         
assertThat(contextManager.getMetaDataContexts().getMetaData().getDatabases().get("db"),
 not(database));
@@ -234,7 +234,7 @@ public final class ClusterContextManagerCoordinatorTest {
     
     @Test
     public void assertRenewForDataSourceChanged() {
-        
when(persistService.getDatabaseVersionPersistService().isActiveVersion("db", 
"0")).thenReturn(true);
+        
when(persistService.getMetaDataVersionPersistService().isActiveVersion("db", 
"0")).thenReturn(true);
         coordinator.renew(new DataSourceChangedEvent("db", "0", 
createChangedDataSourcePropertiesMap()));
         
assertTrue(contextManager.getMetaDataContexts().getMetaData().getDatabases().get("db").getResource().getDataSources().containsKey("ds_2"));
     }
diff --git 
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/cache/subscriber/ScalingRegistrySubscriberTest.java
 
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/cache/subscriber/ScalingRegistrySubscriberTest.java
index 55f89aacfb5..61302352360 100644
--- 
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/cache/subscriber/ScalingRegistrySubscriberTest.java
+++ 
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/cache/subscriber/ScalingRegistrySubscriberTest.java
@@ -18,7 +18,7 @@
 package 
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.cache.subscriber;
 
 import org.apache.shardingsphere.infra.eventbus.EventBusContext;
-import 
org.apache.shardingsphere.mode.metadata.persist.service.DatabaseVersionPersistService;
+import 
org.apache.shardingsphere.mode.metadata.persist.service.MetaDataVersionPersistService;
 import 
org.apache.shardingsphere.mode.repository.cluster.ClusterPersistRepository;
 import org.junit.Before;
 import org.junit.Test;
@@ -35,16 +35,14 @@ public final class ScalingRegistrySubscriberTest {
     private ClusterPersistRepository repository;
     
     @Mock
-    private DatabaseVersionPersistService databaseVersionPersistService;
-    
-    private ScalingRegistrySubscriber scalingRegistrySubscriber;
+    private MetaDataVersionPersistService metaDataVersionPersistService;
     
     @Before
     public void setUp() throws ReflectiveOperationException {
-        scalingRegistrySubscriber = new ScalingRegistrySubscriber(repository, 
new EventBusContext());
-        Field persistServiceField = 
ScalingRegistrySubscriber.class.getDeclaredField("databaseVersionPersistService");
+        ScalingRegistrySubscriber scalingRegistrySubscriber = new 
ScalingRegistrySubscriber(repository, new EventBusContext());
+        Field persistServiceField = 
ScalingRegistrySubscriber.class.getDeclaredField("metaDataVersionPersistService");
         persistServiceField.setAccessible(true);
-        persistServiceField.set(scalingRegistrySubscriber, 
databaseVersionPersistService);
+        persistServiceField.set(scalingRegistrySubscriber, 
metaDataVersionPersistService);
     }
     
     @Test
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/rule/RuleDefinitionBackendHandler.java
 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/rule/RuleDefinitionBackendHandler.java
index 798545b0db4..1933a4a1510 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/rule/RuleDefinitionBackendHandler.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/rule/RuleDefinitionBackendHandler.java
@@ -151,7 +151,7 @@ public final class RuleDefinitionBackendHandler<T extends 
RuleDefinitionStatemen
     private void prepareScaling(final ShardingSphereDatabase database, final T 
sqlStatement, final RuleDefinitionAlterUpdater<?, ?> updater, final 
RuleConfiguration currentRuleConfig,
                                 final RuleDefinitionAlterPreprocessor<?> 
preprocessor) {
         MetaDataPersistService persistService = 
ProxyContext.getInstance().getContextManager().getMetaDataContexts().getPersistService();
-        Optional<String> newVersion = 
persistService.getDatabaseVersionPersistService().createNewVersion(database.getName());
+        Optional<String> newVersion = 
persistService.getMetaDataVersionPersistService().createNewVersion(database.getName());
         if (!newVersion.isPresent()) {
             throw new RuntimeException(String.format("Unable to get a new 
version for database: %s", database.getName()));
         }

Reply via email to