diff --git a/features/readwrite-splitting/distsql/handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/AlterReadwriteSplittingStorageUnitStatusExecutor.java b/features/readwrite-splitting/distsql/handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/AlterReadwriteSplittingStorageUnitStatusExecutor.java index a3d4a755b541a..9ba188fd2c32b 100644 --- a/features/readwrite-splitting/distsql/handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/AlterReadwriteSplittingStorageUnitStatusExecutor.java +++ b/features/readwrite-splitting/distsql/handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/AlterReadwriteSplittingStorageUnitStatusExecutor.java @@ -78,7 +78,7 @@ private void checkBeforeUpdate(final AlterReadwriteSplittingStorageUnitStatusSta private void updateStatus(final ContextManager contextManager, final AlterReadwriteSplittingStorageUnitStatusStatement sqlStatement) { DataSourceState status = sqlStatement.isEnable() ? DataSourceState.ENABLED : DataSourceState.DISABLED; new QualifiedDataSourceStatusService(contextManager.getMetaDataContexts().getPersistService().getRepository()) - .changeMemberQualifiedDataSourceStatus(database.getName(), sqlStatement.getRuleName(), sqlStatement.getStorageUnitName(), status); + .changeStatus(database.getName(), sqlStatement.getRuleName(), sqlStatement.getStorageUnitName(), status); } @Override diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/storage/service/QualifiedDataSourceStatusService.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/storage/service/QualifiedDataSourceStatusService.java index a8e899da0fbf0..c1399b6face40 100644 --- a/mode/core/src/main/java/org/apache/shardingsphere/mode/storage/service/QualifiedDataSourceStatusService.java +++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/storage/service/QualifiedDataSourceStatusService.java @@ -45,7 +45,7 @@ public final class QualifiedDataSourceStatusService { * * @return qualified data source status */ - public Map loadQualifiedDataSourceStatus() { + public Map loadStatus() { Collection qualifiedDataSourceNodes = repository.getChildrenKeys(QualifiedDataSourceNode.getRootPath()); Map result = new HashMap<>(qualifiedDataSourceNodes.size(), 1F); qualifiedDataSourceNodes.forEach(each -> { @@ -58,16 +58,16 @@ public Map loadQualifiedDataSourceStatus() { } /** - * Change member qualified data source status. + * Change qualified data source status. * * @param databaseName database name * @param groupName group name * @param storageUnitName storage unit name * @param dataSourceState data source state */ - public void changeMemberQualifiedDataSourceStatus(final String databaseName, final String groupName, final String storageUnitName, final DataSourceState dataSourceState) { + public void changeStatus(final String databaseName, final String groupName, final String storageUnitName, final DataSourceState dataSourceState) { QualifiedDataSourceStatus status = new QualifiedDataSourceStatus(dataSourceState); - repository.persist(QualifiedDataSourceNode.getQualifiedDataSourceNodePath(new QualifiedDataSource(databaseName, groupName, storageUnitName)), - YamlEngine.marshal(new YamlQualifiedDataSourceStatusSwapper().swapToYamlConfiguration(status))); + repository.persist(QualifiedDataSourceNode.getQualifiedDataSourceNodePath( + new QualifiedDataSource(databaseName, groupName, storageUnitName)), YamlEngine.marshal(new YamlQualifiedDataSourceStatusSwapper().swapToYamlConfiguration(status))); } } diff --git a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java index 16ed52f69da05..9fd2ab75d5884 100644 --- a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java +++ b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java @@ -55,7 +55,7 @@ public ContextManager build(final ContextManagerBuilderParameter param) throws S } MetaDataPersistService persistService = new MetaDataPersistService(repository); MetaDataContexts metaDataContexts = MetaDataContextsFactory.create( - persistService, param, instanceContext, registryCenter.getQualifiedDataSourceStatusService().loadQualifiedDataSourceStatus()); + persistService, param, instanceContext, registryCenter.getQualifiedDataSourceStatusService().loadStatus()); ContextManager result = new ContextManager(metaDataContexts, instanceContext); setContextManagerAware(result); registerOnline(registryCenter, param, result); diff --git a/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/storage/service/QualifiedDataSourceStatusServiceTest.java b/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/storage/service/QualifiedDataSourceStatusServiceTest.java index fee16f70bd01f..e91e6771e40a4 100644 --- a/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/storage/service/QualifiedDataSourceStatusServiceTest.java +++ b/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/storage/service/QualifiedDataSourceStatusServiceTest.java @@ -38,9 +38,9 @@ class QualifiedDataSourceStatusServiceTest { private ClusterPersistRepository repository; @Test - void assertLoadDisabledDataSources() { + void assertLoadStatus() { List disabledDataSources = Arrays.asList("replica_query_db.readwrite_ds.replica_ds_0", "other_schema.other_ds.other_ds0"); when(repository.getChildrenKeys(anyString())).thenReturn(disabledDataSources); - assertDoesNotThrow(() -> new QualifiedDataSourceStatusService(repository).loadQualifiedDataSourceStatus()); + assertDoesNotThrow(() -> new QualifiedDataSourceStatusService(repository).loadStatus()); } }