From 56c9cdb472e8e1e1de2f60c697241b4c81409258 Mon Sep 17 00:00:00 2001 From: Haoran Meng Date: Mon, 27 May 2024 17:35:53 +0800 Subject: [PATCH] Add ManagerServiceFacade for context manager services --- .../type/AlterDatabaseRuleOperator.java | 2 +- .../type/CreateDatabaseRuleOperator.java | 2 +- .../type/DropDatabaseRuleOperator.java | 2 +- .../UnregisterStorageUnitExecutorTest.java | 2 +- .../driver/executor/DriverJDBCExecutor.java | 2 +- .../mode/manager/ContextManager.java | 22 ++++----- .../refresher/MetaDataRefreshEngine.java | 2 +- .../metadata/refresher/MetaDataRefresher.java | 2 +- .../AlterIndexStatementSchemaRefresher.java | 2 +- .../CreateIndexStatementSchemaRefresher.java | 2 +- .../DropIndexStatementSchemaRefresher.java | 2 +- .../AlterSchemaStatementSchemaRefresher.java | 2 +- .../CreateSchemaStatementSchemaRefresher.java | 2 +- .../DropSchemaStatementSchemaRefresher.java | 2 +- .../AlterTableStatementSchemaRefresher.java | 2 +- .../CreateTableStatementSchemaRefresher.java | 2 +- .../DropTableStatementSchemaRefresher.java | 2 +- .../RenameTableStatementSchemaRefresher.java | 2 +- .../AlterViewStatementSchemaRefresher.java | 2 +- .../CreateViewStatementSchemaRefresher.java | 2 +- .../DropViewStatementSchemaRefresher.java | 2 +- .../mode/service/ManagerServiceFacade.java | 47 +++++++++++++++++++ .../mode/service/PersistServiceFacade.java | 4 ++ .../manager/ConfigurationManagerService.java} | 4 +- .../ResourceMetaDataManagerService.java} | 4 +- ...ShardingSphereDatabaseManagerService.java} | 7 +-- .../ComputeNodePersistService.java | 2 +- .../MetaDataManagerPersistService.java | 2 +- .../{ => persist}/PersistServiceBuilder.java | 2 +- .../{ => persist}/ProcessPersistService.java | 2 +- .../subsciber/RuleItemChangedSubscriber.java | 4 +- .../fixture/PersistServiceBuilderFixture.java | 6 +-- .../mode/manager/ContextManagerTest.java | 22 ++++----- .../ComputeNodePersistServiceTest.java | 1 + ...ode.service.persist.PersistServiceBuilder} | 0 .../generator/ClusterWorkerIdGenerator.java | 2 +- .../ConfigurationChangedSubscriber.java | 10 ++-- .../subscriber/DatabaseChangedSubscriber.java | 16 +++---- .../ResourceMetaDataChangedSubscriber.java | 18 +++---- .../ClusterMetaDataManagerPersistService.java | 2 +- .../service/ClusterPersistServiceBuilder.java | 6 +-- .../service/ClusterProcessPersistService.java | 2 +- ...ode.service.persist.PersistServiceBuilder} | 0 .../SessionConnectionReconnectListener.java | 2 +- ...andaloneMetaDataManagerPersistService.java | 24 +++++----- .../StandalonePersistServiceBuilder.java | 6 +-- .../StandaloneProcessPersistService.java | 2 +- ...ode.service.persist.PersistServiceBuilder} | 0 .../DistSQLBackendHandlerFactoryTest.java | 2 +- 49 files changed, 154 insertions(+), 107 deletions(-) create mode 100644 mode/core/src/main/java/org/apache/shardingsphere/mode/service/ManagerServiceFacade.java rename mode/core/src/main/java/org/apache/shardingsphere/mode/{manager/context/ConfigurationContextManager.java => service/manager/ConfigurationManagerService.java} (99%) rename mode/core/src/main/java/org/apache/shardingsphere/mode/{manager/context/ResourceMetaDataContextManager.java => service/manager/ResourceMetaDataManagerService.java} (98%) rename mode/core/src/main/java/org/apache/shardingsphere/mode/{manager/context/ShardingSphereDatabaseContextManager.java => service/manager/ShardingSphereDatabaseManagerService.java} (96%) rename mode/core/src/main/java/org/apache/shardingsphere/mode/service/{ => persist}/ComputeNodePersistService.java (99%) rename mode/core/src/main/java/org/apache/shardingsphere/mode/service/{ => persist}/MetaDataManagerPersistService.java (98%) rename mode/core/src/main/java/org/apache/shardingsphere/mode/service/{ => persist}/PersistServiceBuilder.java (96%) rename mode/core/src/main/java/org/apache/shardingsphere/mode/service/{ => persist}/ProcessPersistService.java (95%) rename mode/core/src/test/resources/META-INF/services/{org.apache.shardingsphere.mode.service.PersistServiceBuilder => org.apache.shardingsphere.mode.service.persist.PersistServiceBuilder} (100%) rename mode/type/cluster/core/src/main/resources/META-INF/services/{org.apache.shardingsphere.mode.service.PersistServiceBuilder => org.apache.shardingsphere.mode.service.persist.PersistServiceBuilder} (100%) rename mode/type/standalone/core/src/main/resources/META-INF/services/{org.apache.shardingsphere.mode.service.PersistServiceBuilder => org.apache.shardingsphere.mode.service.persist.PersistServiceBuilder} (100%) diff --git a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/engine/update/rdl/rule/engine/database/type/AlterDatabaseRuleOperator.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/engine/update/rdl/rule/engine/database/type/AlterDatabaseRuleOperator.java index 61f43a35f7b32..4ff05507f9e09 100644 --- a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/engine/update/rdl/rule/engine/database/type/AlterDatabaseRuleOperator.java +++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/engine/update/rdl/rule/engine/database/type/AlterDatabaseRuleOperator.java @@ -27,7 +27,7 @@ import org.apache.shardingsphere.infra.metadata.version.MetaDataVersion; import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader; import org.apache.shardingsphere.mode.manager.ContextManager; -import org.apache.shardingsphere.mode.service.MetaDataManagerPersistService; +import org.apache.shardingsphere.mode.service.persist.MetaDataManagerPersistService; import java.util.Collection; import java.util.LinkedHashMap; diff --git a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/engine/update/rdl/rule/engine/database/type/CreateDatabaseRuleOperator.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/engine/update/rdl/rule/engine/database/type/CreateDatabaseRuleOperator.java index faf4dd6fc8e99..0bb6a715fdec2 100644 --- a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/engine/update/rdl/rule/engine/database/type/CreateDatabaseRuleOperator.java +++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/engine/update/rdl/rule/engine/database/type/CreateDatabaseRuleOperator.java @@ -27,7 +27,7 @@ import org.apache.shardingsphere.infra.metadata.version.MetaDataVersion; import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader; import org.apache.shardingsphere.mode.manager.ContextManager; -import org.apache.shardingsphere.mode.service.MetaDataManagerPersistService; +import org.apache.shardingsphere.mode.service.persist.MetaDataManagerPersistService; import java.util.Collection; import java.util.LinkedHashMap; diff --git a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/engine/update/rdl/rule/engine/database/type/DropDatabaseRuleOperator.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/engine/update/rdl/rule/engine/database/type/DropDatabaseRuleOperator.java index 7177d9e99245c..0b2d1ccb5a45a 100644 --- a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/engine/update/rdl/rule/engine/database/type/DropDatabaseRuleOperator.java +++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/engine/update/rdl/rule/engine/database/type/DropDatabaseRuleOperator.java @@ -28,7 +28,7 @@ import org.apache.shardingsphere.infra.metadata.version.MetaDataVersion; import org.apache.shardingsphere.infra.rule.attribute.datasource.StaticDataSourceRuleAttribute; import org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfiguration; -import org.apache.shardingsphere.mode.service.MetaDataManagerPersistService; +import org.apache.shardingsphere.mode.service.persist.MetaDataManagerPersistService; import org.apache.shardingsphere.mode.tuple.annotation.RepositoryTupleEntity; import org.apache.shardingsphere.infra.yaml.config.swapper.rule.YamlRuleConfigurationSwapperEngine; import org.apache.shardingsphere.mode.manager.ContextManager; diff --git a/infra/distsql-handler/src/test/java/org/apache/shardingsphere/distsql/handler/executor/rdl/resource/UnregisterStorageUnitExecutorTest.java b/infra/distsql-handler/src/test/java/org/apache/shardingsphere/distsql/handler/executor/rdl/resource/UnregisterStorageUnitExecutorTest.java index 5dcfc1f4f1d5d..0ef4f195647ed 100644 --- a/infra/distsql-handler/src/test/java/org/apache/shardingsphere/distsql/handler/executor/rdl/resource/UnregisterStorageUnitExecutorTest.java +++ b/infra/distsql-handler/src/test/java/org/apache/shardingsphere/distsql/handler/executor/rdl/resource/UnregisterStorageUnitExecutorTest.java @@ -31,7 +31,7 @@ import org.apache.shardingsphere.infra.rule.attribute.datasource.DataSourceMapperRuleAttribute; import org.apache.shardingsphere.mode.manager.ContextManager; import org.apache.shardingsphere.mode.metadata.MetaDataContexts; -import org.apache.shardingsphere.mode.service.MetaDataManagerPersistService; +import org.apache.shardingsphere.mode.service.persist.MetaDataManagerPersistService; import org.apache.shardingsphere.test.fixture.jdbc.MockedDataSource; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/jdbc/src/main/java/org/apache/shardingsphere/driver/executor/DriverJDBCExecutor.java b/jdbc/src/main/java/org/apache/shardingsphere/driver/executor/DriverJDBCExecutor.java index 90c09bf88164f..766ac35c1813f 100644 --- a/jdbc/src/main/java/org/apache/shardingsphere/driver/executor/DriverJDBCExecutor.java +++ b/jdbc/src/main/java/org/apache/shardingsphere/driver/executor/DriverJDBCExecutor.java @@ -32,7 +32,7 @@ import org.apache.shardingsphere.mode.manager.ContextManager; import org.apache.shardingsphere.mode.metadata.MetaDataContexts; import org.apache.shardingsphere.mode.metadata.refresher.MetaDataRefreshEngine; -import org.apache.shardingsphere.mode.service.MetaDataManagerPersistService; +import org.apache.shardingsphere.mode.service.persist.MetaDataManagerPersistService; import java.sql.SQLException; import java.util.Collection; diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/manager/ContextManager.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/manager/ContextManager.java index 159240a79501e..30c92492b22a5 100644 --- a/mode/core/src/main/java/org/apache/shardingsphere/mode/manager/ContextManager.java +++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/manager/ContextManager.java @@ -38,14 +38,13 @@ import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema; import org.apache.shardingsphere.infra.rule.builder.global.GlobalRulesBuilder; import org.apache.shardingsphere.metadata.persist.MetaDataPersistService; -import org.apache.shardingsphere.mode.manager.context.ConfigurationContextManager; -import org.apache.shardingsphere.mode.manager.context.ResourceMetaDataContextManager; -import org.apache.shardingsphere.mode.manager.context.ShardingSphereDatabaseContextManager; import org.apache.shardingsphere.mode.manager.switcher.ResourceSwitchManager; import org.apache.shardingsphere.mode.manager.switcher.SwitchingResource; import org.apache.shardingsphere.mode.metadata.MetaDataContexts; import org.apache.shardingsphere.mode.metadata.MetaDataContextsFactory; +import org.apache.shardingsphere.mode.service.ManagerServiceFacade; import org.apache.shardingsphere.mode.service.PersistServiceFacade; +import org.apache.shardingsphere.mode.service.manager.ConfigurationManagerService; import org.apache.shardingsphere.mode.spi.PersistRepository; import org.apache.shardingsphere.mode.state.StateContext; @@ -66,18 +65,14 @@ public final class ContextManager implements AutoCloseable { private final ComputeNodeInstanceContext computeNodeInstanceContext; - private final ShardingSphereDatabaseContextManager shardingSphereDatabaseContextManager; - - private final ConfigurationContextManager configurationContextManager; - - private final ResourceMetaDataContextManager resourceMetaDataContextManager; - private final ExecutorEngine executorEngine; private final StateContext stateContext; private final PersistServiceFacade persistServiceFacade; + private final ManagerServiceFacade managerServiceFacade; + private final PersistRepository repository; public ContextManager(final MetaDataContexts metaDataContexts, final ComputeNodeInstanceContext computeNodeInstanceContext, final PersistRepository repository) { @@ -85,9 +80,7 @@ public ContextManager(final MetaDataContexts metaDataContexts, final ComputeNode this.computeNodeInstanceContext = computeNodeInstanceContext; this.repository = repository; persistServiceFacade = new PersistServiceFacade(repository, computeNodeInstanceContext.getModeConfiguration(), this); - shardingSphereDatabaseContextManager = new ShardingSphereDatabaseContextManager(this.metaDataContexts, persistServiceFacade); - configurationContextManager = new ConfigurationContextManager(this.metaDataContexts, computeNodeInstanceContext, persistServiceFacade); - resourceMetaDataContextManager = new ResourceMetaDataContextManager(this.metaDataContexts, persistServiceFacade); + managerServiceFacade = new ManagerServiceFacade(this.metaDataContexts, computeNodeInstanceContext, persistServiceFacade); executorEngine = ExecutorEngine.createExecutorEngineWithSize(metaDataContexts.getMetaData().getProps().getValue(ConfigurationPropertyKey.KERNEL_EXECUTOR_SIZE)); stateContext = new StateContext(); } @@ -177,11 +170,12 @@ public void refreshTableMetaData(final ShardingSphereDatabase database) { private MetaDataContexts createMetaDataContexts(final ShardingSphereDatabase database) throws SQLException { MetaDataPersistService metaDataPersistService = persistServiceFacade.getMetaDataPersistService(); + ConfigurationManagerService configurationManagerService = managerServiceFacade.getConfigurationManagerService(); Map dataSourcePoolPropsFromRegCenter = metaDataPersistService.getDataSourceUnitService().load(database.getName()); SwitchingResource switchingResource = new ResourceSwitchManager().alterStorageUnit(database.getResourceMetaData(), dataSourcePoolPropsFromRegCenter); - metaDataContexts.get().getMetaData().getDatabases().putAll(configurationContextManager.renewDatabase(database, switchingResource)); + metaDataContexts.get().getMetaData().getDatabases().putAll(configurationManagerService.renewDatabase(database, switchingResource)); Collection ruleConfigs = metaDataPersistService.getDatabaseRulePersistService().load(database.getName()); - Map changedDatabases = configurationContextManager.createChangedDatabases(database.getName(), false, switchingResource, ruleConfigs); + Map changedDatabases = configurationManagerService.createChangedDatabases(database.getName(), false, switchingResource, ruleConfigs); ConfigurationProperties props = new ConfigurationProperties(metaDataPersistService.getPropsService().load()); Collection globalRuleConfigs = metaDataPersistService.getGlobalRuleService().load(); RuleMetaData changedGlobalMetaData = new RuleMetaData(GlobalRulesBuilder.buildRules(globalRuleConfigs, changedDatabases, props)); diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/MetaDataRefreshEngine.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/MetaDataRefreshEngine.java index a284974cb4e0e..dba42c4d8e888 100644 --- a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/MetaDataRefreshEngine.java +++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/MetaDataRefreshEngine.java @@ -24,7 +24,7 @@ import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase; import org.apache.shardingsphere.infra.route.context.RouteUnit; import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader; -import org.apache.shardingsphere.mode.service.MetaDataManagerPersistService; +import org.apache.shardingsphere.mode.service.persist.MetaDataManagerPersistService; import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement; import java.sql.SQLException; diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/MetaDataRefresher.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/MetaDataRefresher.java index b22ff921cdbd2..1cfc8580961e9 100644 --- a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/MetaDataRefresher.java +++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/MetaDataRefresher.java @@ -22,7 +22,7 @@ import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase; import org.apache.shardingsphere.infra.spi.annotation.SingletonSPI; import org.apache.shardingsphere.infra.spi.type.typed.TypedSPI; -import org.apache.shardingsphere.mode.service.MetaDataManagerPersistService; +import org.apache.shardingsphere.mode.service.persist.MetaDataManagerPersistService; import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement; import java.sql.SQLException; diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/index/AlterIndexStatementSchemaRefresher.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/index/AlterIndexStatementSchemaRefresher.java index 75e1da79c0030..33c8e92b7dc92 100644 --- a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/index/AlterIndexStatementSchemaRefresher.java +++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/index/AlterIndexStatementSchemaRefresher.java @@ -26,7 +26,7 @@ import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereTable; import org.apache.shardingsphere.infra.metadata.database.schema.pojo.AlterSchemaMetaDataPOJO; import org.apache.shardingsphere.mode.metadata.refresher.MetaDataRefresher; -import org.apache.shardingsphere.mode.service.MetaDataManagerPersistService; +import org.apache.shardingsphere.mode.service.persist.MetaDataManagerPersistService; import org.apache.shardingsphere.sql.parser.sql.common.segment.ddl.index.IndexSegment; import org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.AlterIndexStatement; import org.apache.shardingsphere.sql.parser.sql.dialect.handler.ddl.AlterIndexStatementHandler; diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/index/CreateIndexStatementSchemaRefresher.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/index/CreateIndexStatementSchemaRefresher.java index a0ebfa87ec2ba..b9f5e089503ea 100644 --- a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/index/CreateIndexStatementSchemaRefresher.java +++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/index/CreateIndexStatementSchemaRefresher.java @@ -26,7 +26,7 @@ import org.apache.shardingsphere.infra.metadata.database.schema.pojo.AlterSchemaMetaDataPOJO; import org.apache.shardingsphere.infra.metadata.database.schema.util.IndexMetaDataUtils; import org.apache.shardingsphere.mode.metadata.refresher.MetaDataRefresher; -import org.apache.shardingsphere.mode.service.MetaDataManagerPersistService; +import org.apache.shardingsphere.mode.service.persist.MetaDataManagerPersistService; import org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.CreateIndexStatement; import java.util.Collection; diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/index/DropIndexStatementSchemaRefresher.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/index/DropIndexStatementSchemaRefresher.java index ddfde302a248a..14a3dbbca51aa 100644 --- a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/index/DropIndexStatementSchemaRefresher.java +++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/index/DropIndexStatementSchemaRefresher.java @@ -25,7 +25,7 @@ import org.apache.shardingsphere.infra.metadata.database.schema.pojo.AlterSchemaMetaDataPOJO; import org.apache.shardingsphere.infra.metadata.database.schema.util.IndexMetaDataUtils; import org.apache.shardingsphere.mode.metadata.refresher.MetaDataRefresher; -import org.apache.shardingsphere.mode.service.MetaDataManagerPersistService; +import org.apache.shardingsphere.mode.service.persist.MetaDataManagerPersistService; import org.apache.shardingsphere.sql.parser.sql.common.segment.ddl.index.IndexSegment; import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.SimpleTableSegment; import org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.DropIndexStatement; diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/schema/AlterSchemaStatementSchemaRefresher.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/schema/AlterSchemaStatementSchemaRefresher.java index 27093ae1989a5..2c1514d6040f0 100644 --- a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/schema/AlterSchemaStatementSchemaRefresher.java +++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/schema/AlterSchemaStatementSchemaRefresher.java @@ -22,7 +22,7 @@ import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase; import org.apache.shardingsphere.infra.metadata.database.schema.pojo.AlterSchemaPOJO; import org.apache.shardingsphere.mode.metadata.refresher.MetaDataRefresher; -import org.apache.shardingsphere.mode.service.MetaDataManagerPersistService; +import org.apache.shardingsphere.mode.service.persist.MetaDataManagerPersistService; import org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.AlterSchemaStatement; import org.apache.shardingsphere.sql.parser.sql.dialect.handler.ddl.AlterSchemaStatementHandler; diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/schema/CreateSchemaStatementSchemaRefresher.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/schema/CreateSchemaStatementSchemaRefresher.java index 1bbcafb1a4624..475b642c46f8f 100644 --- a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/schema/CreateSchemaStatementSchemaRefresher.java +++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/schema/CreateSchemaStatementSchemaRefresher.java @@ -21,7 +21,7 @@ import org.apache.shardingsphere.infra.database.core.type.DatabaseType; import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase; import org.apache.shardingsphere.mode.metadata.refresher.MetaDataRefresher; -import org.apache.shardingsphere.mode.service.MetaDataManagerPersistService; +import org.apache.shardingsphere.mode.service.persist.MetaDataManagerPersistService; import org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.CreateSchemaStatement; import org.apache.shardingsphere.sql.parser.sql.dialect.handler.ddl.CreateSchemaStatementHandler; diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/schema/DropSchemaStatementSchemaRefresher.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/schema/DropSchemaStatementSchemaRefresher.java index f897111d8ea86..77a487c81cdaa 100644 --- a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/schema/DropSchemaStatementSchemaRefresher.java +++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/schema/DropSchemaStatementSchemaRefresher.java @@ -21,7 +21,7 @@ import org.apache.shardingsphere.infra.database.core.type.DatabaseType; import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase; import org.apache.shardingsphere.mode.metadata.refresher.MetaDataRefresher; -import org.apache.shardingsphere.mode.service.MetaDataManagerPersistService; +import org.apache.shardingsphere.mode.service.persist.MetaDataManagerPersistService; import org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.DropSchemaStatement; import org.apache.shardingsphere.sql.parser.sql.common.value.identifier.IdentifierValue; diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/table/AlterTableStatementSchemaRefresher.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/table/AlterTableStatementSchemaRefresher.java index 49eb76aba8c88..47e9d03ae2c56 100644 --- a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/table/AlterTableStatementSchemaRefresher.java +++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/table/AlterTableStatementSchemaRefresher.java @@ -29,7 +29,7 @@ import org.apache.shardingsphere.infra.rule.attribute.datanode.MutableDataNodeRuleAttribute; import org.apache.shardingsphere.mode.metadata.refresher.MetaDataRefresher; import org.apache.shardingsphere.mode.metadata.refresher.util.TableRefreshUtils; -import org.apache.shardingsphere.mode.service.MetaDataManagerPersistService; +import org.apache.shardingsphere.mode.service.persist.MetaDataManagerPersistService; import org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.AlterTableStatement; import java.sql.SQLException; diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/table/CreateTableStatementSchemaRefresher.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/table/CreateTableStatementSchemaRefresher.java index 0a5bf53c5342d..f10a560fa5c71 100644 --- a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/table/CreateTableStatementSchemaRefresher.java +++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/table/CreateTableStatementSchemaRefresher.java @@ -29,7 +29,7 @@ import org.apache.shardingsphere.infra.rule.attribute.datanode.MutableDataNodeRuleAttribute; import org.apache.shardingsphere.mode.metadata.refresher.MetaDataRefresher; import org.apache.shardingsphere.mode.metadata.refresher.util.TableRefreshUtils; -import org.apache.shardingsphere.mode.service.MetaDataManagerPersistService; +import org.apache.shardingsphere.mode.service.persist.MetaDataManagerPersistService; import org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.CreateTableStatement; import java.sql.SQLException; diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/table/DropTableStatementSchemaRefresher.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/table/DropTableStatementSchemaRefresher.java index 6fc169d87b341..789558f1741f2 100644 --- a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/table/DropTableStatementSchemaRefresher.java +++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/table/DropTableStatementSchemaRefresher.java @@ -23,7 +23,7 @@ import org.apache.shardingsphere.infra.metadata.database.schema.pojo.AlterSchemaMetaDataPOJO; import org.apache.shardingsphere.mode.metadata.refresher.MetaDataRefresher; import org.apache.shardingsphere.mode.metadata.refresher.util.TableRefreshUtils; -import org.apache.shardingsphere.mode.service.MetaDataManagerPersistService; +import org.apache.shardingsphere.mode.service.persist.MetaDataManagerPersistService; import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.SimpleTableSegment; import org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.DropTableStatement; diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/table/RenameTableStatementSchemaRefresher.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/table/RenameTableStatementSchemaRefresher.java index 10420dad26f23..4a5f2154ff88d 100644 --- a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/table/RenameTableStatementSchemaRefresher.java +++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/table/RenameTableStatementSchemaRefresher.java @@ -29,7 +29,7 @@ import org.apache.shardingsphere.infra.rule.attribute.datanode.MutableDataNodeRuleAttribute; import org.apache.shardingsphere.mode.metadata.refresher.MetaDataRefresher; import org.apache.shardingsphere.mode.metadata.refresher.util.TableRefreshUtils; -import org.apache.shardingsphere.mode.service.MetaDataManagerPersistService; +import org.apache.shardingsphere.mode.service.persist.MetaDataManagerPersistService; import org.apache.shardingsphere.sql.parser.sql.common.segment.ddl.table.RenameTableDefinitionSegment; import org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.RenameTableStatement; diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/view/AlterViewStatementSchemaRefresher.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/view/AlterViewStatementSchemaRefresher.java index 6a3c5e623e671..36fd9d274924f 100644 --- a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/view/AlterViewStatementSchemaRefresher.java +++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/view/AlterViewStatementSchemaRefresher.java @@ -30,7 +30,7 @@ import org.apache.shardingsphere.infra.rule.attribute.datanode.MutableDataNodeRuleAttribute; import org.apache.shardingsphere.mode.metadata.refresher.MetaDataRefresher; import org.apache.shardingsphere.mode.metadata.refresher.util.TableRefreshUtils; -import org.apache.shardingsphere.mode.service.MetaDataManagerPersistService; +import org.apache.shardingsphere.mode.service.persist.MetaDataManagerPersistService; import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.SimpleTableSegment; import org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.AlterViewStatement; import org.apache.shardingsphere.sql.parser.sql.dialect.handler.ddl.AlterViewStatementHandler; diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/view/CreateViewStatementSchemaRefresher.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/view/CreateViewStatementSchemaRefresher.java index ccd8df5702454..e26e91857b332 100644 --- a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/view/CreateViewStatementSchemaRefresher.java +++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/view/CreateViewStatementSchemaRefresher.java @@ -30,7 +30,7 @@ import org.apache.shardingsphere.infra.rule.attribute.datanode.MutableDataNodeRuleAttribute; import org.apache.shardingsphere.mode.metadata.refresher.MetaDataRefresher; import org.apache.shardingsphere.mode.metadata.refresher.util.TableRefreshUtils; -import org.apache.shardingsphere.mode.service.MetaDataManagerPersistService; +import org.apache.shardingsphere.mode.service.persist.MetaDataManagerPersistService; import org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.CreateViewStatement; import java.sql.SQLException; diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/view/DropViewStatementSchemaRefresher.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/view/DropViewStatementSchemaRefresher.java index 4e847ea9eb977..421ea7a825e8e 100644 --- a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/view/DropViewStatementSchemaRefresher.java +++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/view/DropViewStatementSchemaRefresher.java @@ -22,7 +22,7 @@ import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase; import org.apache.shardingsphere.infra.metadata.database.schema.pojo.AlterSchemaMetaDataPOJO; import org.apache.shardingsphere.mode.metadata.refresher.MetaDataRefresher; -import org.apache.shardingsphere.mode.service.MetaDataManagerPersistService; +import org.apache.shardingsphere.mode.service.persist.MetaDataManagerPersistService; import org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.DropViewStatement; import java.util.Collection; diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/service/ManagerServiceFacade.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/service/ManagerServiceFacade.java new file mode 100644 index 0000000000000..381342fb7f2c4 --- /dev/null +++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/service/ManagerServiceFacade.java @@ -0,0 +1,47 @@ +/* + * 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.service; + +import lombok.Getter; +import org.apache.shardingsphere.infra.instance.ComputeNodeInstanceContext; +import org.apache.shardingsphere.mode.metadata.MetaDataContexts; +import org.apache.shardingsphere.mode.service.manager.ConfigurationManagerService; +import org.apache.shardingsphere.mode.service.manager.ResourceMetaDataManagerService; +import org.apache.shardingsphere.mode.service.manager.ShardingSphereDatabaseManagerService; + +import java.util.concurrent.atomic.AtomicReference; + +/** + * Context manager service facade. + */ +@Getter +public class ManagerServiceFacade { + + private final ShardingSphereDatabaseManagerService databaseManagerService; + + private final ConfigurationManagerService configurationManagerService; + + private final ResourceMetaDataManagerService resourceMetaDataManagerService; + + public ManagerServiceFacade(final AtomicReference metaDataContexts, final ComputeNodeInstanceContext computeNodeInstanceContext, + final PersistServiceFacade persistServiceFacade) { + databaseManagerService = new ShardingSphereDatabaseManagerService(metaDataContexts); + configurationManagerService = new ConfigurationManagerService(metaDataContexts, computeNodeInstanceContext, persistServiceFacade); + resourceMetaDataManagerService = new ResourceMetaDataManagerService(metaDataContexts, persistServiceFacade); + } +} diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/service/PersistServiceFacade.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/service/PersistServiceFacade.java index ab52d3f0239b3..d83359fc7bd20 100644 --- a/mode/core/src/main/java/org/apache/shardingsphere/mode/service/PersistServiceFacade.java +++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/service/PersistServiceFacade.java @@ -22,6 +22,10 @@ import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader; import org.apache.shardingsphere.metadata.persist.MetaDataPersistService; import org.apache.shardingsphere.mode.manager.ContextManager; +import org.apache.shardingsphere.mode.service.persist.ComputeNodePersistService; +import org.apache.shardingsphere.mode.service.persist.MetaDataManagerPersistService; +import org.apache.shardingsphere.mode.service.persist.PersistServiceBuilder; +import org.apache.shardingsphere.mode.service.persist.ProcessPersistService; import org.apache.shardingsphere.mode.service.pojo.ShardingSphereSchemaDataAlteredPOJO; import org.apache.shardingsphere.mode.spi.PersistRepository; import org.apache.shardingsphere.mode.state.StatePersistService; diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/manager/context/ConfigurationContextManager.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/service/manager/ConfigurationManagerService.java similarity index 99% rename from mode/core/src/main/java/org/apache/shardingsphere/mode/manager/context/ConfigurationContextManager.java rename to mode/core/src/main/java/org/apache/shardingsphere/mode/service/manager/ConfigurationManagerService.java index 4684a182c355c..6aa234e7f495e 100644 --- a/mode/core/src/main/java/org/apache/shardingsphere/mode/manager/context/ConfigurationContextManager.java +++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/service/manager/ConfigurationManagerService.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.shardingsphere.mode.manager.context; +package org.apache.shardingsphere.mode.service.manager; import lombok.RequiredArgsConstructor; import lombok.SneakyThrows; @@ -71,7 +71,7 @@ */ @RequiredArgsConstructor @Slf4j -public final class ConfigurationContextManager { +public final class ConfigurationManagerService { private final AtomicReference metaDataContexts; diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/manager/context/ResourceMetaDataContextManager.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/service/manager/ResourceMetaDataManagerService.java similarity index 98% rename from mode/core/src/main/java/org/apache/shardingsphere/mode/manager/context/ResourceMetaDataContextManager.java rename to mode/core/src/main/java/org/apache/shardingsphere/mode/service/manager/ResourceMetaDataManagerService.java index 3463544e13db4..0e0dcdc9dfb39 100644 --- a/mode/core/src/main/java/org/apache/shardingsphere/mode/manager/context/ResourceMetaDataContextManager.java +++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/service/manager/ResourceMetaDataManagerService.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.shardingsphere.mode.manager.context; +package org.apache.shardingsphere.mode.service.manager; import com.google.common.base.Strings; import lombok.RequiredArgsConstructor; @@ -42,7 +42,7 @@ * Resource meta data context manager. */ @RequiredArgsConstructor -public final class ResourceMetaDataContextManager { +public final class ResourceMetaDataManagerService { private final AtomicReference metaDataContexts; diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/manager/context/ShardingSphereDatabaseContextManager.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/service/manager/ShardingSphereDatabaseManagerService.java similarity index 96% rename from mode/core/src/main/java/org/apache/shardingsphere/mode/manager/context/ShardingSphereDatabaseContextManager.java rename to mode/core/src/main/java/org/apache/shardingsphere/mode/service/manager/ShardingSphereDatabaseManagerService.java index ccf49cbc12f3a..039053e4bfc1e 100644 --- a/mode/core/src/main/java/org/apache/shardingsphere/mode/manager/context/ShardingSphereDatabaseContextManager.java +++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/service/manager/ShardingSphereDatabaseManagerService.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.shardingsphere.mode.manager.context; +package org.apache.shardingsphere.mode.service.manager; import lombok.RequiredArgsConstructor; import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereColumn; @@ -25,7 +25,6 @@ import org.apache.shardingsphere.infra.yaml.data.pojo.YamlShardingSphereRowData; import org.apache.shardingsphere.infra.yaml.data.swapper.YamlShardingSphereRowDataSwapper; import org.apache.shardingsphere.mode.metadata.MetaDataContexts; -import org.apache.shardingsphere.mode.service.PersistServiceFacade; import java.util.ArrayList; import java.util.List; @@ -35,12 +34,10 @@ * ShardingSphere database context manager. */ @RequiredArgsConstructor -public final class ShardingSphereDatabaseContextManager { +public final class ShardingSphereDatabaseManagerService { private final AtomicReference metaDataContexts; - private final PersistServiceFacade persistServiceFacade; - /** * Add ShardingSphere database data. * diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/service/ComputeNodePersistService.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/service/persist/ComputeNodePersistService.java similarity index 99% rename from mode/core/src/main/java/org/apache/shardingsphere/mode/service/ComputeNodePersistService.java rename to mode/core/src/main/java/org/apache/shardingsphere/mode/service/persist/ComputeNodePersistService.java index 5fdeb7323b781..6487bb09eb111 100644 --- a/mode/core/src/main/java/org/apache/shardingsphere/mode/service/ComputeNodePersistService.java +++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/service/persist/ComputeNodePersistService.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.shardingsphere.mode.service; +package org.apache.shardingsphere.mode.service.persist; import com.google.common.base.Strings; import lombok.RequiredArgsConstructor; diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/service/MetaDataManagerPersistService.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/service/persist/MetaDataManagerPersistService.java similarity index 98% rename from mode/core/src/main/java/org/apache/shardingsphere/mode/service/MetaDataManagerPersistService.java rename to mode/core/src/main/java/org/apache/shardingsphere/mode/service/persist/MetaDataManagerPersistService.java index 8b1d9a91ae327..a4ca7d660af28 100644 --- a/mode/core/src/main/java/org/apache/shardingsphere/mode/service/MetaDataManagerPersistService.java +++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/service/persist/MetaDataManagerPersistService.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.shardingsphere.mode.service; +package org.apache.shardingsphere.mode.service.persist; import org.apache.shardingsphere.infra.config.rule.RuleConfiguration; import org.apache.shardingsphere.infra.datasource.pool.props.domain.DataSourcePoolProperties; diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/service/PersistServiceBuilder.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/service/persist/PersistServiceBuilder.java similarity index 96% rename from mode/core/src/main/java/org/apache/shardingsphere/mode/service/PersistServiceBuilder.java rename to mode/core/src/main/java/org/apache/shardingsphere/mode/service/persist/PersistServiceBuilder.java index 88452b9400833..b7a69d47da57b 100644 --- a/mode/core/src/main/java/org/apache/shardingsphere/mode/service/PersistServiceBuilder.java +++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/service/persist/PersistServiceBuilder.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.shardingsphere.mode.service; +package org.apache.shardingsphere.mode.service.persist; import org.apache.shardingsphere.infra.spi.type.typed.TypedSPI; import org.apache.shardingsphere.mode.manager.ContextManager; diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/service/ProcessPersistService.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/service/persist/ProcessPersistService.java similarity index 95% rename from mode/core/src/main/java/org/apache/shardingsphere/mode/service/ProcessPersistService.java rename to mode/core/src/main/java/org/apache/shardingsphere/mode/service/persist/ProcessPersistService.java index bb86a970db543..91641fe18ac0f 100644 --- a/mode/core/src/main/java/org/apache/shardingsphere/mode/service/ProcessPersistService.java +++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/service/persist/ProcessPersistService.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.shardingsphere.mode.service; +package org.apache.shardingsphere.mode.service.persist; import org.apache.shardingsphere.infra.executor.sql.process.Process; 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 3643dca1dff5f..95152f219ea53 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 @@ -55,7 +55,7 @@ public void renew(final AlterRuleItemEvent event) { RuleConfiguration currentRuleConfig = processor.findRuleConfiguration(contextManager.getMetaDataContexts().getMetaData().getDatabase(databaseName)); synchronized (this) { processor.changeRuleItemConfiguration(event, currentRuleConfig, processor.swapRuleItemConfiguration(event, yamlContent)); - contextManager.getConfigurationContextManager().alterRuleConfiguration(databaseName, currentRuleConfig); + contextManager.getManagerServiceFacade().getConfigurationManagerService().alterRuleConfiguration(databaseName, currentRuleConfig); } } @@ -75,7 +75,7 @@ public void renew(final DropRuleItemEvent event) { RuleConfiguration currentRuleConfig = processor.findRuleConfiguration(contextManager.getMetaDataContexts().getMetaData().getDatabase(databaseName)); synchronized (this) { processor.dropRuleItemConfiguration(event, currentRuleConfig); - contextManager.getConfigurationContextManager().dropRuleConfiguration(databaseName, currentRuleConfig); + contextManager.getManagerServiceFacade().getConfigurationManagerService().dropRuleConfiguration(databaseName, currentRuleConfig); } } } diff --git a/mode/core/src/test/java/org/apache/shardingsphere/mode/fixture/PersistServiceBuilderFixture.java b/mode/core/src/test/java/org/apache/shardingsphere/mode/fixture/PersistServiceBuilderFixture.java index 52e2e312b2b69..b944de70f5f66 100644 --- a/mode/core/src/test/java/org/apache/shardingsphere/mode/fixture/PersistServiceBuilderFixture.java +++ b/mode/core/src/test/java/org/apache/shardingsphere/mode/fixture/PersistServiceBuilderFixture.java @@ -18,9 +18,9 @@ package org.apache.shardingsphere.mode.fixture; import org.apache.shardingsphere.mode.manager.ContextManager; -import org.apache.shardingsphere.mode.service.MetaDataManagerPersistService; -import org.apache.shardingsphere.mode.service.PersistServiceBuilder; -import org.apache.shardingsphere.mode.service.ProcessPersistService; +import org.apache.shardingsphere.mode.service.persist.MetaDataManagerPersistService; +import org.apache.shardingsphere.mode.service.persist.PersistServiceBuilder; +import org.apache.shardingsphere.mode.service.persist.ProcessPersistService; public final class PersistServiceBuilderFixture implements PersistServiceBuilder { diff --git a/mode/core/src/test/java/org/apache/shardingsphere/mode/manager/ContextManagerTest.java b/mode/core/src/test/java/org/apache/shardingsphere/mode/manager/ContextManagerTest.java index 95e5ce0c18838..cbb0a0aa324fb 100644 --- a/mode/core/src/test/java/org/apache/shardingsphere/mode/manager/ContextManagerTest.java +++ b/mode/core/src/test/java/org/apache/shardingsphere/mode/manager/ContextManagerTest.java @@ -131,14 +131,14 @@ void assertRenewMetaDataContexts() { @Test void assertAddDatabase() { - contextManager.getResourceMetaDataContextManager().addDatabase("new_db"); + contextManager.getManagerServiceFacade().getResourceMetaDataManagerService().addDatabase("new_db"); verify(metaDataContexts.getMetaData()).addDatabase(eq("new_db"), any(DatabaseType.class), any(ConfigurationProperties.class)); } @Test void assertAddExistedDatabase() { when(metaDataContexts.getMetaData().containsDatabase("foo_db")).thenReturn(true); - contextManager.getResourceMetaDataContextManager().addDatabase("foo_db"); + contextManager.getManagerServiceFacade().getResourceMetaDataManagerService().addDatabase("foo_db"); verify(metaDataContexts.getMetaData(), times(0)).addDatabase(eq("foo_db"), any(DatabaseType.class), any(ConfigurationProperties.class)); } @@ -146,26 +146,26 @@ void assertAddExistedDatabase() { void assertDropDatabase() { when(metaDataContexts.getMetaData().getDatabase("foo_db").getName()).thenReturn("foo_db"); when(metaDataContexts.getMetaData().containsDatabase("foo_db")).thenReturn(true); - contextManager.getResourceMetaDataContextManager().dropDatabase("foo_db"); + contextManager.getManagerServiceFacade().getResourceMetaDataManagerService().dropDatabase("foo_db"); verify(metaDataContexts.getMetaData()).dropDatabase("foo_db"); } @Test void assertDropNotExistedDatabase() { - contextManager.getResourceMetaDataContextManager().dropDatabase("not_existed_db"); + contextManager.getManagerServiceFacade().getResourceMetaDataManagerService().dropDatabase("not_existed_db"); verify(metaDataContexts.getMetaData(), times(0)).dropDatabase("not_existed_db"); } @Test void assertAddSchema() { - contextManager.getResourceMetaDataContextManager().addSchema("foo_db", "bar_schema"); + contextManager.getManagerServiceFacade().getResourceMetaDataManagerService().addSchema("foo_db", "bar_schema"); verify(metaDataContexts.getMetaData().getDatabase("foo_db")).addSchema(anyString(), any(ShardingSphereSchema.class)); } @Test void assertAddExistedSchema() { when(contextManager.getMetaDataContexts().getMetaData().getDatabase("foo_db").containsSchema("foo_schema")).thenReturn(true); - contextManager.getResourceMetaDataContextManager().addSchema("foo_db", "foo_schema"); + contextManager.getManagerServiceFacade().getResourceMetaDataManagerService().addSchema("foo_db", "foo_schema"); verify(metaDataContexts.getMetaData().getDatabase("foo_db"), times(0)).addSchema(anyString(), any(ShardingSphereSchema.class)); } @@ -176,7 +176,7 @@ void assertAlterSchemaForTableAltered() { when(metaDataContexts.getMetaData().getDatabase("foo_db").getSchema("foo_schema")).thenReturn(toBeAlteredSchema); ShardingSphereColumn toBeChangedColumn = new ShardingSphereColumn("foo_col", Types.VARCHAR, false, false, false, true, false, false); ShardingSphereTable toBeChangedTable = new ShardingSphereTable("foo_tbl", Collections.singleton(toBeChangedColumn), Collections.emptyList(), Collections.emptyList()); - contextManager.getResourceMetaDataContextManager().alterSchema("foo_db", "foo_schema", toBeChangedTable, null); + contextManager.getManagerServiceFacade().getResourceMetaDataManagerService().alterSchema("foo_db", "foo_schema", toBeChangedTable, null); ShardingSphereTable table = contextManager.getMetaDataContexts().getMetaData().getDatabase("foo_db").getSchema("foo_schema").getTables().get("foo_tbl"); assertThat(table.getColumnValues().size(), is(1)); assertTrue(table.containsColumn("foo_col")); @@ -188,7 +188,7 @@ void assertAlterSchemaForViewAltered() { when(metaDataContexts.getMetaData().getDatabase("foo_db").getSchemas()).thenReturn(Collections.singletonMap("foo_schema", toBeAlteredSchema)); when(metaDataContexts.getMetaData().getDatabase("foo_db").getSchema("foo_schema")).thenReturn(toBeAlteredSchema); ShardingSphereView toBeChangedView = new ShardingSphereView("foo_view", "select `foo_view`.`foo_view`.`id` AS `id` from `foo_view`.`foo_view`"); - contextManager.getResourceMetaDataContextManager().alterSchema("foo_db", "foo_schema", null, toBeChangedView); + contextManager.getManagerServiceFacade().getResourceMetaDataManagerService().alterSchema("foo_db", "foo_schema", null, toBeChangedView); ShardingSphereView view = contextManager.getMetaDataContexts().getMetaData().getDatabase("foo_db").getSchema("foo_schema").getView("foo_view"); assertThat(view.getName(), is("foo_view")); assertThat(view.getViewDefinition(), is("select `foo_view`.`foo_view`.`id` AS `id` from `foo_view`.`foo_view`")); @@ -197,14 +197,14 @@ void assertAlterSchemaForViewAltered() { @Test void assertAlterSchemaForTableDropped() { when(metaDataContexts.getMetaData().getDatabase("foo_db").getSchemas()).thenReturn(Collections.singletonMap("foo_schema", createToBeAlteredSchema())); - contextManager.getResourceMetaDataContextManager().alterSchema("foo_db", "foo_schema", "foo_tbl", null); + contextManager.getManagerServiceFacade().getResourceMetaDataManagerService().alterSchema("foo_db", "foo_schema", "foo_tbl", null); assertFalse(contextManager.getMetaDataContexts().getMetaData().getDatabase("foo_db").getSchema("foo_schema").getTables().containsKey("foo_tbl")); } @Test void assertAlterSchemaForViewDropped() { when(metaDataContexts.getMetaData().getDatabase("foo_db").getSchemas()).thenReturn(Collections.singletonMap("foo_schema", createToBeAlteredSchema())); - contextManager.getResourceMetaDataContextManager().alterSchema("foo_db", "foo_schema", "foo_view", null); + contextManager.getManagerServiceFacade().getResourceMetaDataManagerService().alterSchema("foo_db", "foo_schema", "foo_view", null); assertFalse(contextManager.getMetaDataContexts().getMetaData().getDatabase("foo_db").getSchema("foo_schema").getViews().containsKey("foo_view")); } @@ -236,7 +236,7 @@ void assertGetDatabase() { @Test void assertAlterProperties() { - contextManager.getConfigurationContextManager().alterProperties(PropertiesBuilder.build(new Property("foo", "foo_value"))); + contextManager.getManagerServiceFacade().getConfigurationManagerService().alterProperties(PropertiesBuilder.build(new Property("foo", "foo_value"))); assertThat(contextManager.getMetaDataContexts().getMetaData().getProps().getProps().getProperty("foo"), is("foo_value")); } diff --git a/mode/core/src/test/java/org/apache/shardingsphere/mode/service/ComputeNodePersistServiceTest.java b/mode/core/src/test/java/org/apache/shardingsphere/mode/service/ComputeNodePersistServiceTest.java index 1184caecea7de..19265284fdca8 100644 --- a/mode/core/src/test/java/org/apache/shardingsphere/mode/service/ComputeNodePersistServiceTest.java +++ b/mode/core/src/test/java/org/apache/shardingsphere/mode/service/ComputeNodePersistServiceTest.java @@ -26,6 +26,7 @@ import org.apache.shardingsphere.infra.state.instance.InstanceState; import org.apache.shardingsphere.infra.util.yaml.YamlEngine; import org.apache.shardingsphere.metadata.persist.node.ComputeNode; +import org.apache.shardingsphere.mode.service.persist.ComputeNodePersistService; import org.apache.shardingsphere.mode.spi.PersistRepository; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/mode/core/src/test/resources/META-INF/services/org.apache.shardingsphere.mode.service.PersistServiceBuilder b/mode/core/src/test/resources/META-INF/services/org.apache.shardingsphere.mode.service.persist.PersistServiceBuilder similarity index 100% rename from mode/core/src/test/resources/META-INF/services/org.apache.shardingsphere.mode.service.PersistServiceBuilder rename to mode/core/src/test/resources/META-INF/services/org.apache.shardingsphere.mode.service.persist.PersistServiceBuilder diff --git a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/workerid/generator/ClusterWorkerIdGenerator.java b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/workerid/generator/ClusterWorkerIdGenerator.java index ff033d6d14bcf..87dfeefa38a09 100644 --- a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/workerid/generator/ClusterWorkerIdGenerator.java +++ b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/workerid/generator/ClusterWorkerIdGenerator.java @@ -25,7 +25,7 @@ import org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.workerid.node.WorkerIdReservationNode; import org.apache.shardingsphere.mode.repository.cluster.ClusterPersistRepository; import org.apache.shardingsphere.mode.repository.cluster.exception.ClusterPersistRepositoryException; -import org.apache.shardingsphere.mode.service.ComputeNodePersistService; +import org.apache.shardingsphere.mode.service.persist.ComputeNodePersistService; import java.util.Collection; import java.util.Optional; 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 0da5fe1907009..00180aa76dedc 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 @@ -47,7 +47,7 @@ public void renew(final RegisterStorageUnitEvent event) { .getActiveVersionByFullPath(event.getActiveVersionKey()))) { return; } - contextManager.getConfigurationContextManager().registerStorageUnit(event.getDatabaseName(), + contextManager.getManagerServiceFacade().getConfigurationManagerService().registerStorageUnit(event.getDatabaseName(), contextManager.getPersistServiceFacade().getMetaDataPersistService().getDataSourceUnitService().load(event.getDatabaseName(), event.getStorageUnitName())); } @@ -62,7 +62,7 @@ public void renew(final AlterStorageUnitEvent event) { .getActiveVersionByFullPath(event.getActiveVersionKey()))) { return; } - contextManager.getConfigurationContextManager().alterStorageUnit( + contextManager.getManagerServiceFacade().getConfigurationManagerService().alterStorageUnit( event.getDatabaseName(), contextManager.getPersistServiceFacade().getMetaDataPersistService().getDataSourceUnitService().load(event.getDatabaseName(), event.getStorageUnitName())); } @@ -76,7 +76,7 @@ public void renew(final UnregisterStorageUnitEvent event) { if (!contextManager.getMetaDataContexts().getMetaData().containsDatabase(event.getDatabaseName())) { return; } - contextManager.getConfigurationContextManager().unregisterStorageUnit(event.getDatabaseName(), event.getStorageUnitName()); + contextManager.getManagerServiceFacade().getConfigurationManagerService().unregisterStorageUnit(event.getDatabaseName(), event.getStorageUnitName()); } /** @@ -91,7 +91,7 @@ public synchronized void renew(final AlterGlobalRuleConfigurationEvent event) { return; } contextManager.getPersistServiceFacade().getMetaDataPersistService().getGlobalRuleService().load(event.getRuleSimpleName()) - .ifPresent(optional -> contextManager.getConfigurationContextManager().alterGlobalRuleConfiguration(optional)); + .ifPresent(optional -> contextManager.getManagerServiceFacade().getConfigurationManagerService().alterGlobalRuleConfiguration(optional)); } @@ -106,6 +106,6 @@ public synchronized void renew(final AlterPropertiesEvent event) { .getActiveVersionByFullPath(event.getActiveVersionKey()))) { return; } - contextManager.getConfigurationContextManager().alterProperties(contextManager.getPersistServiceFacade().getMetaDataPersistService().getPropsService().load()); + contextManager.getManagerServiceFacade().getConfigurationManagerService().alterProperties(contextManager.getPersistServiceFacade().getMetaDataPersistService().getPropsService().load()); } } diff --git a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/subscriber/DatabaseChangedSubscriber.java b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/subscriber/DatabaseChangedSubscriber.java index f6c0224d1fe3c..42c065fb6792b 100644 --- a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/subscriber/DatabaseChangedSubscriber.java +++ b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/subscriber/DatabaseChangedSubscriber.java @@ -45,7 +45,7 @@ public final class DatabaseChangedSubscriber implements EventSubscriber { */ @Subscribe public synchronized void renew(final DatabaseDataAddedEvent event) { - contextManager.getShardingSphereDatabaseContextManager().addShardingSphereDatabaseData(event.getDatabaseName()); + contextManager.getManagerServiceFacade().getDatabaseManagerService().addShardingSphereDatabaseData(event.getDatabaseName()); } /** @@ -55,7 +55,7 @@ public synchronized void renew(final DatabaseDataAddedEvent event) { */ @Subscribe public synchronized void renew(final DatabaseDataDeletedEvent event) { - contextManager.getShardingSphereDatabaseContextManager().dropShardingSphereDatabaseData(event.getDatabaseName()); + contextManager.getManagerServiceFacade().getDatabaseManagerService().dropShardingSphereDatabaseData(event.getDatabaseName()); } /** @@ -65,7 +65,7 @@ public synchronized void renew(final DatabaseDataDeletedEvent event) { */ @Subscribe public synchronized void renew(final SchemaDataAddedEvent event) { - contextManager.getShardingSphereDatabaseContextManager().addShardingSphereSchemaData(event.getDatabaseName(), event.getSchemaName()); + contextManager.getManagerServiceFacade().getDatabaseManagerService().addShardingSphereSchemaData(event.getDatabaseName(), event.getSchemaName()); } /** @@ -75,7 +75,7 @@ public synchronized void renew(final SchemaDataAddedEvent event) { */ @Subscribe public synchronized void renew(final SchemaDataDeletedEvent event) { - contextManager.getShardingSphereDatabaseContextManager().dropShardingSphereSchemaData(event.getDatabaseName(), event.getSchemaName()); + contextManager.getManagerServiceFacade().getDatabaseManagerService().dropShardingSphereSchemaData(event.getDatabaseName(), event.getSchemaName()); } /** @@ -86,10 +86,10 @@ public synchronized void renew(final SchemaDataDeletedEvent event) { @Subscribe public synchronized void renew(final TableDataChangedEvent event) { if (null != event.getAddedTable()) { - contextManager.getShardingSphereDatabaseContextManager().addShardingSphereTableData(event.getDatabaseName(), event.getSchemaName(), event.getAddedTable()); + contextManager.getManagerServiceFacade().getDatabaseManagerService().addShardingSphereTableData(event.getDatabaseName(), event.getSchemaName(), event.getAddedTable()); } if (null != event.getDeletedTable()) { - contextManager.getShardingSphereDatabaseContextManager().dropShardingSphereTableData(event.getDatabaseName(), event.getSchemaName(), event.getDeletedTable()); + contextManager.getManagerServiceFacade().getDatabaseManagerService().dropShardingSphereTableData(event.getDatabaseName(), event.getSchemaName(), event.getDeletedTable()); } } @@ -100,7 +100,7 @@ public synchronized void renew(final TableDataChangedEvent event) { */ @Subscribe public synchronized void renew(final ShardingSphereRowDataChangedEvent event) { - contextManager.getShardingSphereDatabaseContextManager().alterShardingSphereRowData(event.getDatabaseName(), event.getSchemaName(), event.getTableName(), event.getYamlRowData()); + contextManager.getManagerServiceFacade().getDatabaseManagerService().alterShardingSphereRowData(event.getDatabaseName(), event.getSchemaName(), event.getTableName(), event.getYamlRowData()); } /** @@ -110,6 +110,6 @@ public synchronized void renew(final ShardingSphereRowDataChangedEvent event) { */ @Subscribe public synchronized void renew(final ShardingSphereRowDataDeletedEvent event) { - contextManager.getShardingSphereDatabaseContextManager().deleteShardingSphereRowData(event.getDatabaseName(), event.getSchemaName(), event.getTableName(), event.getUniqueKey()); + contextManager.getManagerServiceFacade().getDatabaseManagerService().deleteShardingSphereRowData(event.getDatabaseName(), event.getSchemaName(), event.getTableName(), event.getUniqueKey()); } } diff --git a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/subscriber/ResourceMetaDataChangedSubscriber.java b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/subscriber/ResourceMetaDataChangedSubscriber.java index e8e234deba865..2dbd28c9b19ad 100644 --- a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/subscriber/ResourceMetaDataChangedSubscriber.java +++ b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/subscriber/ResourceMetaDataChangedSubscriber.java @@ -50,7 +50,7 @@ public final class ResourceMetaDataChangedSubscriber implements EventSubscriber */ @Subscribe public synchronized void renew(final DatabaseAddedEvent event) { - contextManager.getResourceMetaDataContextManager().addDatabase(event.getDatabaseName()); + contextManager.getManagerServiceFacade().getResourceMetaDataManagerService().addDatabase(event.getDatabaseName()); } /** @@ -60,7 +60,7 @@ public synchronized void renew(final DatabaseAddedEvent event) { */ @Subscribe public synchronized void renew(final DatabaseDeletedEvent event) { - contextManager.getResourceMetaDataContextManager().dropDatabase(event.getDatabaseName()); + contextManager.getManagerServiceFacade().getResourceMetaDataManagerService().dropDatabase(event.getDatabaseName()); } /** @@ -70,7 +70,7 @@ public synchronized void renew(final DatabaseDeletedEvent event) { */ @Subscribe public synchronized void renew(final SchemaAddedEvent event) { - contextManager.getResourceMetaDataContextManager().addSchema(event.getDatabaseName(), event.getSchemaName()); + contextManager.getManagerServiceFacade().getResourceMetaDataManagerService().addSchema(event.getDatabaseName(), event.getSchemaName()); } /** @@ -80,7 +80,7 @@ public synchronized void renew(final SchemaAddedEvent event) { */ @Subscribe public synchronized void renew(final SchemaDeletedEvent event) { - contextManager.getResourceMetaDataContextManager().dropSchema(event.getDatabaseName(), event.getSchemaName()); + contextManager.getManagerServiceFacade().getResourceMetaDataManagerService().dropSchema(event.getDatabaseName(), event.getSchemaName()); } /** @@ -96,7 +96,8 @@ public synchronized void renew(final CreateOrAlterTableEvent event) { } Map tables = contextManager.getPersistServiceFacade().getMetaDataPersistService().getDatabaseMetaDataService() .getTableMetaDataPersistService().load(event.getDatabaseName(), event.getSchemaName(), event.getTableName()); - contextManager.getResourceMetaDataContextManager().alterSchema(event.getDatabaseName(), event.getSchemaName(), tables.values().iterator().next(), null); + contextManager.getManagerServiceFacade().getResourceMetaDataManagerService().alterSchema(event.getDatabaseName(), event.getSchemaName(), + tables.values().iterator().next(), null); } /** @@ -106,7 +107,7 @@ public synchronized void renew(final CreateOrAlterTableEvent event) { */ @Subscribe public synchronized void renew(final DropTableEvent event) { - contextManager.getResourceMetaDataContextManager().alterSchema(event.getDatabaseName(), event.getSchemaName(), event.getTableName(), null); + contextManager.getManagerServiceFacade().getResourceMetaDataManagerService().alterSchema(event.getDatabaseName(), event.getSchemaName(), event.getTableName(), null); } /** @@ -122,7 +123,8 @@ public synchronized void renew(final CreateOrAlterViewEvent event) { } Map views = contextManager.getPersistServiceFacade().getMetaDataPersistService().getDatabaseMetaDataService() .getViewMetaDataPersistService().load(event.getDatabaseName(), event.getSchemaName(), event.getViewName()); - contextManager.getResourceMetaDataContextManager().alterSchema(event.getDatabaseName(), event.getSchemaName(), null, views.values().iterator().next()); + contextManager.getManagerServiceFacade().getResourceMetaDataManagerService().alterSchema(event.getDatabaseName(), event.getSchemaName(), + null, views.values().iterator().next()); } /** @@ -132,6 +134,6 @@ public synchronized void renew(final CreateOrAlterViewEvent event) { */ @Subscribe public synchronized void renew(final DropViewEvent event) { - contextManager.getResourceMetaDataContextManager().alterSchema(event.getDatabaseName(), event.getSchemaName(), null, event.getViewName()); + contextManager.getManagerServiceFacade().getResourceMetaDataManagerService().alterSchema(event.getDatabaseName(), event.getSchemaName(), null, event.getViewName()); } } diff --git a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/service/ClusterMetaDataManagerPersistService.java b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/service/ClusterMetaDataManagerPersistService.java index 71a0a21ce06ee..d95b48e3682f2 100644 --- a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/service/ClusterMetaDataManagerPersistService.java +++ b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/service/ClusterMetaDataManagerPersistService.java @@ -29,7 +29,7 @@ import org.apache.shardingsphere.metadata.persist.service.config.database.DataSourceUnitPersistService; import org.apache.shardingsphere.metadata.persist.service.database.DatabaseMetaDataPersistService; import org.apache.shardingsphere.mode.manager.ContextManager; -import org.apache.shardingsphere.mode.service.MetaDataManagerPersistService; +import org.apache.shardingsphere.mode.service.persist.MetaDataManagerPersistService; import org.apache.shardingsphere.single.api.config.SingleRuleConfiguration; import java.util.Collection; diff --git a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/service/ClusterPersistServiceBuilder.java b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/service/ClusterPersistServiceBuilder.java index af5403bb86f26..1a27f072b9ef1 100644 --- a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/service/ClusterPersistServiceBuilder.java +++ b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/service/ClusterPersistServiceBuilder.java @@ -18,9 +18,9 @@ package org.apache.shardingsphere.mode.manager.cluster.service; import org.apache.shardingsphere.mode.manager.ContextManager; -import org.apache.shardingsphere.mode.service.MetaDataManagerPersistService; -import org.apache.shardingsphere.mode.service.PersistServiceBuilder; -import org.apache.shardingsphere.mode.service.ProcessPersistService; +import org.apache.shardingsphere.mode.service.persist.MetaDataManagerPersistService; +import org.apache.shardingsphere.mode.service.persist.PersistServiceBuilder; +import org.apache.shardingsphere.mode.service.persist.ProcessPersistService; /** * Cluster persist service builder. diff --git a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/service/ClusterProcessPersistService.java b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/service/ClusterProcessPersistService.java index 634dea0fda469..45d588d269219 100644 --- a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/service/ClusterProcessPersistService.java +++ b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/service/ClusterProcessPersistService.java @@ -26,7 +26,7 @@ import org.apache.shardingsphere.infra.util.yaml.YamlEngine; import org.apache.shardingsphere.metadata.persist.node.ComputeNode; import org.apache.shardingsphere.metadata.persist.node.ProcessNode; -import org.apache.shardingsphere.mode.service.ProcessPersistService; +import org.apache.shardingsphere.mode.service.persist.ProcessPersistService; import org.apache.shardingsphere.mode.spi.PersistRepository; import java.util.Collection; diff --git a/mode/type/cluster/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.service.PersistServiceBuilder b/mode/type/cluster/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.service.persist.PersistServiceBuilder similarity index 100% rename from mode/type/cluster/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.service.PersistServiceBuilder rename to mode/type/cluster/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.service.persist.PersistServiceBuilder diff --git a/mode/type/cluster/repository/provider/zookeeper/src/main/java/org/apache/shardingsphere/mode/repository/cluster/zookeeper/listener/SessionConnectionReconnectListener.java b/mode/type/cluster/repository/provider/zookeeper/src/main/java/org/apache/shardingsphere/mode/repository/cluster/zookeeper/listener/SessionConnectionReconnectListener.java index 09b286d66f123..a68819b9c8c9c 100644 --- a/mode/type/cluster/repository/provider/zookeeper/src/main/java/org/apache/shardingsphere/mode/repository/cluster/zookeeper/listener/SessionConnectionReconnectListener.java +++ b/mode/type/cluster/repository/provider/zookeeper/src/main/java/org/apache/shardingsphere/mode/repository/cluster/zookeeper/listener/SessionConnectionReconnectListener.java @@ -24,7 +24,7 @@ import org.apache.curator.framework.state.ConnectionStateListener; import org.apache.shardingsphere.infra.instance.ComputeNodeInstanceContext; import org.apache.shardingsphere.mode.repository.cluster.ClusterPersistRepository; -import org.apache.shardingsphere.mode.service.ComputeNodePersistService; +import org.apache.shardingsphere.mode.service.persist.ComputeNodePersistService; import java.util.Properties; diff --git a/mode/type/standalone/core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/service/StandaloneMetaDataManagerPersistService.java b/mode/type/standalone/core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/service/StandaloneMetaDataManagerPersistService.java index af9f91637689f..ea31aaac2668c 100644 --- a/mode/type/standalone/core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/service/StandaloneMetaDataManagerPersistService.java +++ b/mode/type/standalone/core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/service/StandaloneMetaDataManagerPersistService.java @@ -42,7 +42,8 @@ import org.apache.shardingsphere.mode.metadata.MetaDataContexts; import org.apache.shardingsphere.mode.metadata.builder.RuleConfigurationEventBuilder; import org.apache.shardingsphere.mode.metadata.refresher.util.TableRefreshUtils; -import org.apache.shardingsphere.mode.service.MetaDataManagerPersistService; +import org.apache.shardingsphere.mode.service.manager.ConfigurationManagerService; +import org.apache.shardingsphere.mode.service.persist.MetaDataManagerPersistService; import org.apache.shardingsphere.single.api.config.SingleRuleConfiguration; import java.sql.SQLException; @@ -71,14 +72,14 @@ public StandaloneMetaDataManagerPersistService(final ContextManager contextManag @Override public void createDatabase(final String databaseName) { - contextManager.getResourceMetaDataContextManager().addDatabase(databaseName); + contextManager.getManagerServiceFacade().getResourceMetaDataManagerService().addDatabase(databaseName); contextManager.getPersistServiceFacade().getMetaDataPersistService().getDatabaseMetaDataService().addDatabase(databaseName); clearServiceCache(); } @Override public void dropDatabase(final String databaseName) { - contextManager.getResourceMetaDataContextManager().dropDatabase(databaseName); + contextManager.getManagerServiceFacade().getResourceMetaDataManagerService().dropDatabase(databaseName); contextManager.getPersistServiceFacade().getMetaDataPersistService().getDatabaseMetaDataService().dropDatabase(databaseName); clearServiceCache(); } @@ -216,7 +217,7 @@ public void alterSchemaMetaData(final AlterSchemaMetaDataPOJO alterSchemaMetaDat public void registerStorageUnits(final String databaseName, final Map toBeRegisteredProps) throws SQLException { SwitchingResource switchingResource = new ResourceSwitchManager().registerStorageUnit(contextManager.getMetaDataContexts().getMetaData().getDatabase(databaseName).getResourceMetaData(), toBeRegisteredProps); - contextManager.getMetaDataContexts().getMetaData().getDatabases().putAll(contextManager.getConfigurationContextManager() + contextManager.getMetaDataContexts().getMetaData().getDatabases().putAll(contextManager.getManagerServiceFacade().getConfigurationManagerService() .createChangedDatabases(databaseName, false, switchingResource, null)); contextManager.getMetaDataContexts().getMetaData().getGlobalRuleMetaData().getRules() .forEach(each -> ((GlobalRule) each).refresh(contextManager.getMetaDataContexts().getMetaData().getDatabases(), GlobalRuleChangedType.DATABASE_CHANGED)); @@ -233,7 +234,7 @@ public void registerStorageUnits(final String databaseName, final Map toBeUpdatedProps) throws SQLException { SwitchingResource switchingResource = new ResourceSwitchManager().alterStorageUnit(contextManager.getMetaDataContexts().getMetaData().getDatabase(databaseName).getResourceMetaData(), toBeUpdatedProps); - contextManager.getMetaDataContexts().getMetaData().getDatabases().putAll(contextManager.getConfigurationContextManager() + contextManager.getMetaDataContexts().getMetaData().getDatabases().putAll(contextManager.getManagerServiceFacade().getConfigurationManagerService() .createChangedDatabases(databaseName, true, switchingResource, null)); contextManager.getMetaDataContexts().getMetaData().getGlobalRuleMetaData().getRules() .forEach(each -> ((GlobalRule) each).refresh(contextManager.getMetaDataContexts().getMetaData().getDatabases(), GlobalRuleChangedType.DATABASE_CHANGED)); @@ -248,10 +249,11 @@ public void alterStorageUnits(final String databaseName, final Map toBeDroppedStorageUnitNames) throws SQLException { SwitchingResource switchingResource = new ResourceSwitchManager().unregisterStorageUnit(contextManager.getMetaDataContexts().getMetaData().getDatabase(databaseName).getResourceMetaData(), toBeDroppedStorageUnitNames); + ConfigurationManagerService configurationManagerService = contextManager.getManagerServiceFacade().getConfigurationManagerService(); contextManager.getMetaDataContexts().getMetaData().getDatabases() - .putAll(contextManager.getConfigurationContextManager().renewDatabase(contextManager.getMetaDataContexts().getMetaData().getDatabase(databaseName), switchingResource)); - MetaDataContexts reloadMetaDataContexts = contextManager.getConfigurationContextManager().createMetaDataContexts(databaseName, false, switchingResource, null); - contextManager.getConfigurationContextManager().alterSchemaMetaData(databaseName, reloadMetaDataContexts.getMetaData().getDatabase(databaseName), + .putAll(configurationManagerService.renewDatabase(contextManager.getMetaDataContexts().getMetaData().getDatabase(databaseName), switchingResource)); + MetaDataContexts reloadMetaDataContexts = configurationManagerService.createMetaDataContexts(databaseName, false, switchingResource, null); + configurationManagerService.alterSchemaMetaData(databaseName, reloadMetaDataContexts.getMetaData().getDatabase(databaseName), contextManager.getMetaDataContexts().getMetaData().getDatabase(databaseName), true); contextManager.deletedSchemaNames(databaseName, reloadMetaDataContexts.getMetaData().getDatabase(databaseName), contextManager.getMetaDataContexts().getMetaData().getDatabase(databaseName)); contextManager.renewMetaDataContexts(reloadMetaDataContexts); @@ -265,7 +267,7 @@ public void alterSingleRuleConfiguration(final String databaseName, final Collec Collection metaDataVersions = contextManager.getPersistServiceFacade().getMetaDataPersistService().getDatabaseRulePersistService() .persistConfigurations(contextManager.getMetaDataContexts().getMetaData().getDatabase(databaseName).getName(), ruleConfigs); contextManager.getPersistServiceFacade().getMetaDataPersistService().getMetaDataVersionPersistService().switchActiveVersion(metaDataVersions); - contextManager.getConfigurationContextManager().alterRuleConfiguration(databaseName, ruleConfigs.iterator().next()); + contextManager.getManagerServiceFacade().getConfigurationManagerService().alterRuleConfiguration(databaseName, ruleConfigs.iterator().next()); clearServiceCache(); } @@ -310,14 +312,14 @@ public void removeRuleConfiguration(final String databaseName, final String rule @Override public void alterGlobalRuleConfiguration(final RuleConfiguration toBeAlteredRuleConfig) { - contextManager.getConfigurationContextManager().alterGlobalRuleConfiguration(toBeAlteredRuleConfig); + contextManager.getManagerServiceFacade().getConfigurationManagerService().alterGlobalRuleConfiguration(toBeAlteredRuleConfig); contextManager.getPersistServiceFacade().getMetaDataPersistService().getGlobalRuleService().persist(Collections.singleton(toBeAlteredRuleConfig)); clearServiceCache(); } @Override public void alterProperties(final Properties props) { - contextManager.getConfigurationContextManager().alterProperties(props); + contextManager.getManagerServiceFacade().getConfigurationManagerService().alterProperties(props); contextManager.getPersistServiceFacade().getMetaDataPersistService().getPropsService().persist(props); clearServiceCache(); } diff --git a/mode/type/standalone/core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/service/StandalonePersistServiceBuilder.java b/mode/type/standalone/core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/service/StandalonePersistServiceBuilder.java index 1297944ddef5b..b77fbe2f49f55 100644 --- a/mode/type/standalone/core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/service/StandalonePersistServiceBuilder.java +++ b/mode/type/standalone/core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/service/StandalonePersistServiceBuilder.java @@ -18,9 +18,9 @@ package org.apache.shardingsphere.mode.manager.standalone.service; import org.apache.shardingsphere.mode.manager.ContextManager; -import org.apache.shardingsphere.mode.service.MetaDataManagerPersistService; -import org.apache.shardingsphere.mode.service.PersistServiceBuilder; -import org.apache.shardingsphere.mode.service.ProcessPersistService; +import org.apache.shardingsphere.mode.service.persist.MetaDataManagerPersistService; +import org.apache.shardingsphere.mode.service.persist.PersistServiceBuilder; +import org.apache.shardingsphere.mode.service.persist.ProcessPersistService; /** * Standalone meta data manager persist service builder. diff --git a/mode/type/standalone/core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/service/StandaloneProcessPersistService.java b/mode/type/standalone/core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/service/StandaloneProcessPersistService.java index 4f09169f4d7bf..428bb9003f3b3 100644 --- a/mode/type/standalone/core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/service/StandaloneProcessPersistService.java +++ b/mode/type/standalone/core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/service/StandaloneProcessPersistService.java @@ -20,7 +20,7 @@ import lombok.RequiredArgsConstructor; import org.apache.shardingsphere.infra.executor.sql.process.Process; import org.apache.shardingsphere.infra.executor.sql.process.ProcessRegistry; -import org.apache.shardingsphere.mode.service.ProcessPersistService; +import org.apache.shardingsphere.mode.service.persist.ProcessPersistService; import java.sql.SQLException; import java.sql.Statement; diff --git a/mode/type/standalone/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.service.PersistServiceBuilder b/mode/type/standalone/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.service.persist.PersistServiceBuilder similarity index 100% rename from mode/type/standalone/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.service.PersistServiceBuilder rename to mode/type/standalone/core/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.service.persist.PersistServiceBuilder diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/DistSQLBackendHandlerFactoryTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/DistSQLBackendHandlerFactoryTest.java index 2e517c5a4fb09..e015bc0a88d99 100644 --- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/DistSQLBackendHandlerFactoryTest.java +++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/DistSQLBackendHandlerFactoryTest.java @@ -28,7 +28,7 @@ import org.apache.shardingsphere.infra.metadata.database.rule.RuleMetaData; import org.apache.shardingsphere.mode.manager.ContextManager; import org.apache.shardingsphere.mode.metadata.MetaDataContexts; -import org.apache.shardingsphere.mode.service.MetaDataManagerPersistService; +import org.apache.shardingsphere.mode.service.persist.MetaDataManagerPersistService; import org.apache.shardingsphere.proxy.backend.context.ProxyContext; import org.apache.shardingsphere.proxy.backend.response.header.query.QueryResponseHeader; import org.apache.shardingsphere.proxy.backend.response.header.update.UpdateResponseHeader;