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 30c92492b22a5..76ee61a239150 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 @@ -42,9 +42,9 @@ 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.MetaDataContextManager; import org.apache.shardingsphere.mode.service.PersistServiceFacade; -import org.apache.shardingsphere.mode.service.manager.ConfigurationManagerService; +import org.apache.shardingsphere.mode.service.manager.ConfigurationManager; import org.apache.shardingsphere.mode.spi.PersistRepository; import org.apache.shardingsphere.mode.state.StateContext; @@ -71,7 +71,7 @@ public final class ContextManager implements AutoCloseable { private final PersistServiceFacade persistServiceFacade; - private final ManagerServiceFacade managerServiceFacade; + private final MetaDataContextManager metaDataContextManager; private final PersistRepository repository; @@ -80,7 +80,7 @@ public ContextManager(final MetaDataContexts metaDataContexts, final ComputeNode this.computeNodeInstanceContext = computeNodeInstanceContext; this.repository = repository; persistServiceFacade = new PersistServiceFacade(repository, computeNodeInstanceContext.getModeConfiguration(), this); - managerServiceFacade = new ManagerServiceFacade(this.metaDataContexts, computeNodeInstanceContext, persistServiceFacade); + metaDataContextManager = new MetaDataContextManager(this.metaDataContexts, computeNodeInstanceContext, persistServiceFacade); executorEngine = ExecutorEngine.createExecutorEngineWithSize(metaDataContexts.getMetaData().getProps().getValue(ConfigurationPropertyKey.KERNEL_EXECUTOR_SIZE)); stateContext = new StateContext(); } @@ -170,12 +170,12 @@ public void refreshTableMetaData(final ShardingSphereDatabase database) { private MetaDataContexts createMetaDataContexts(final ShardingSphereDatabase database) throws SQLException { MetaDataPersistService metaDataPersistService = persistServiceFacade.getMetaDataPersistService(); - ConfigurationManagerService configurationManagerService = managerServiceFacade.getConfigurationManagerService(); + ConfigurationManager configurationManager = metaDataContextManager.getConfigurationManager(); Map dataSourcePoolPropsFromRegCenter = metaDataPersistService.getDataSourceUnitService().load(database.getName()); SwitchingResource switchingResource = new ResourceSwitchManager().alterStorageUnit(database.getResourceMetaData(), dataSourcePoolPropsFromRegCenter); - metaDataContexts.get().getMetaData().getDatabases().putAll(configurationManagerService.renewDatabase(database, switchingResource)); + metaDataContexts.get().getMetaData().getDatabases().putAll(configurationManager.renewDatabase(database, switchingResource)); Collection ruleConfigs = metaDataPersistService.getDatabaseRulePersistService().load(database.getName()); - Map changedDatabases = configurationManagerService.createChangedDatabases(database.getName(), false, switchingResource, ruleConfigs); + Map changedDatabases = configurationManager.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/service/ManagerServiceFacade.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/service/MetaDataContextManager.java similarity index 57% rename from mode/core/src/main/java/org/apache/shardingsphere/mode/service/ManagerServiceFacade.java rename to mode/core/src/main/java/org/apache/shardingsphere/mode/service/MetaDataContextManager.java index 381342fb7f2c4..9eef46a590039 100644 --- a/mode/core/src/main/java/org/apache/shardingsphere/mode/service/ManagerServiceFacade.java +++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/service/MetaDataContextManager.java @@ -20,28 +20,28 @@ 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 org.apache.shardingsphere.mode.service.manager.ConfigurationManager; +import org.apache.shardingsphere.mode.service.manager.ResourceMetaDataManager; +import org.apache.shardingsphere.mode.service.manager.ShardingSphereDatabaseManager; import java.util.concurrent.atomic.AtomicReference; /** - * Context manager service facade. + * Meta data context manager.. */ @Getter -public class ManagerServiceFacade { +public class MetaDataContextManager { - private final ShardingSphereDatabaseManagerService databaseManagerService; + private final ShardingSphereDatabaseManager databaseManager; - private final ConfigurationManagerService configurationManagerService; + private final ConfigurationManager configurationManager; - private final ResourceMetaDataManagerService resourceMetaDataManagerService; + private final ResourceMetaDataManager resourceMetaDataManager; - 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); + public MetaDataContextManager(final AtomicReference metaDataContexts, final ComputeNodeInstanceContext computeNodeInstanceContext, + final PersistServiceFacade persistServiceFacade) { + databaseManager = new ShardingSphereDatabaseManager(metaDataContexts); + configurationManager = new ConfigurationManager(metaDataContexts, computeNodeInstanceContext, persistServiceFacade); + resourceMetaDataManager = new ResourceMetaDataManager(metaDataContexts, persistServiceFacade); } } diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/service/manager/ConfigurationManagerService.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/service/manager/ConfigurationManager.java similarity index 99% rename from mode/core/src/main/java/org/apache/shardingsphere/mode/service/manager/ConfigurationManagerService.java rename to mode/core/src/main/java/org/apache/shardingsphere/mode/service/manager/ConfigurationManager.java index 6aa234e7f495e..5fb6face9553b 100644 --- a/mode/core/src/main/java/org/apache/shardingsphere/mode/service/manager/ConfigurationManagerService.java +++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/service/manager/ConfigurationManager.java @@ -71,7 +71,7 @@ */ @RequiredArgsConstructor @Slf4j -public final class ConfigurationManagerService { +public final class ConfigurationManager { private final AtomicReference metaDataContexts; diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/service/manager/ResourceMetaDataManagerService.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/service/manager/ResourceMetaDataManager.java similarity index 99% rename from mode/core/src/main/java/org/apache/shardingsphere/mode/service/manager/ResourceMetaDataManagerService.java rename to mode/core/src/main/java/org/apache/shardingsphere/mode/service/manager/ResourceMetaDataManager.java index 0e0dcdc9dfb39..5cd635ec582bc 100644 --- a/mode/core/src/main/java/org/apache/shardingsphere/mode/service/manager/ResourceMetaDataManagerService.java +++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/service/manager/ResourceMetaDataManager.java @@ -39,10 +39,10 @@ import java.util.concurrent.atomic.AtomicReference; /** - * Resource meta data context manager. + * Resource meta data manager. */ @RequiredArgsConstructor -public final class ResourceMetaDataManagerService { +public final class ResourceMetaDataManager { private final AtomicReference metaDataContexts; diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/service/manager/ShardingSphereDatabaseManagerService.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/service/manager/ShardingSphereDatabaseManager.java similarity index 99% rename from mode/core/src/main/java/org/apache/shardingsphere/mode/service/manager/ShardingSphereDatabaseManagerService.java rename to mode/core/src/main/java/org/apache/shardingsphere/mode/service/manager/ShardingSphereDatabaseManager.java index 039053e4bfc1e..88839913a5753 100644 --- a/mode/core/src/main/java/org/apache/shardingsphere/mode/service/manager/ShardingSphereDatabaseManagerService.java +++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/service/manager/ShardingSphereDatabaseManager.java @@ -34,7 +34,7 @@ * ShardingSphere database context manager. */ @RequiredArgsConstructor -public final class ShardingSphereDatabaseManagerService { +public final class ShardingSphereDatabaseManager { private final AtomicReference metaDataContexts; 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 95152f219ea53..61566f762b4f7 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.getManagerServiceFacade().getConfigurationManagerService().alterRuleConfiguration(databaseName, currentRuleConfig); + contextManager.getMetaDataContextManager().getConfigurationManager().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.getManagerServiceFacade().getConfigurationManagerService().dropRuleConfiguration(databaseName, currentRuleConfig); + contextManager.getMetaDataContextManager().getConfigurationManager().dropRuleConfiguration(databaseName, currentRuleConfig); } } } 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 cbb0a0aa324fb..d689b9de3bb6f 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.getManagerServiceFacade().getResourceMetaDataManagerService().addDatabase("new_db"); + contextManager.getMetaDataContextManager().getResourceMetaDataManager().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.getManagerServiceFacade().getResourceMetaDataManagerService().addDatabase("foo_db"); + contextManager.getMetaDataContextManager().getResourceMetaDataManager().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.getManagerServiceFacade().getResourceMetaDataManagerService().dropDatabase("foo_db"); + contextManager.getMetaDataContextManager().getResourceMetaDataManager().dropDatabase("foo_db"); verify(metaDataContexts.getMetaData()).dropDatabase("foo_db"); } @Test void assertDropNotExistedDatabase() { - contextManager.getManagerServiceFacade().getResourceMetaDataManagerService().dropDatabase("not_existed_db"); + contextManager.getMetaDataContextManager().getResourceMetaDataManager().dropDatabase("not_existed_db"); verify(metaDataContexts.getMetaData(), times(0)).dropDatabase("not_existed_db"); } @Test void assertAddSchema() { - contextManager.getManagerServiceFacade().getResourceMetaDataManagerService().addSchema("foo_db", "bar_schema"); + contextManager.getMetaDataContextManager().getResourceMetaDataManager().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.getManagerServiceFacade().getResourceMetaDataManagerService().addSchema("foo_db", "foo_schema"); + contextManager.getMetaDataContextManager().getResourceMetaDataManager().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.getManagerServiceFacade().getResourceMetaDataManagerService().alterSchema("foo_db", "foo_schema", toBeChangedTable, null); + contextManager.getMetaDataContextManager().getResourceMetaDataManager().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.getManagerServiceFacade().getResourceMetaDataManagerService().alterSchema("foo_db", "foo_schema", null, toBeChangedView); + contextManager.getMetaDataContextManager().getResourceMetaDataManager().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.getManagerServiceFacade().getResourceMetaDataManagerService().alterSchema("foo_db", "foo_schema", "foo_tbl", null); + contextManager.getMetaDataContextManager().getResourceMetaDataManager().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.getManagerServiceFacade().getResourceMetaDataManagerService().alterSchema("foo_db", "foo_schema", "foo_view", null); + contextManager.getMetaDataContextManager().getResourceMetaDataManager().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.getManagerServiceFacade().getConfigurationManagerService().alterProperties(PropertiesBuilder.build(new Property("foo", "foo_value"))); + contextManager.getMetaDataContextManager().getConfigurationManager().alterProperties(PropertiesBuilder.build(new Property("foo", "foo_value"))); assertThat(contextManager.getMetaDataContexts().getMetaData().getProps().getProps().getProperty("foo"), is("foo_value")); } 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 00180aa76dedc..e44a512b38db1 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.getManagerServiceFacade().getConfigurationManagerService().registerStorageUnit(event.getDatabaseName(), + contextManager.getMetaDataContextManager().getConfigurationManager().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.getManagerServiceFacade().getConfigurationManagerService().alterStorageUnit( + contextManager.getMetaDataContextManager().getConfigurationManager().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.getManagerServiceFacade().getConfigurationManagerService().unregisterStorageUnit(event.getDatabaseName(), event.getStorageUnitName()); + contextManager.getMetaDataContextManager().getConfigurationManager().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.getManagerServiceFacade().getConfigurationManagerService().alterGlobalRuleConfiguration(optional)); + .ifPresent(optional -> contextManager.getMetaDataContextManager().getConfigurationManager().alterGlobalRuleConfiguration(optional)); } @@ -106,6 +106,6 @@ public synchronized void renew(final AlterPropertiesEvent event) { .getActiveVersionByFullPath(event.getActiveVersionKey()))) { return; } - contextManager.getManagerServiceFacade().getConfigurationManagerService().alterProperties(contextManager.getPersistServiceFacade().getMetaDataPersistService().getPropsService().load()); + contextManager.getMetaDataContextManager().getConfigurationManager().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 42c065fb6792b..bf2be2dfeb532 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.getManagerServiceFacade().getDatabaseManagerService().addShardingSphereDatabaseData(event.getDatabaseName()); + contextManager.getMetaDataContextManager().getDatabaseManager().addShardingSphereDatabaseData(event.getDatabaseName()); } /** @@ -55,7 +55,7 @@ public synchronized void renew(final DatabaseDataAddedEvent event) { */ @Subscribe public synchronized void renew(final DatabaseDataDeletedEvent event) { - contextManager.getManagerServiceFacade().getDatabaseManagerService().dropShardingSphereDatabaseData(event.getDatabaseName()); + contextManager.getMetaDataContextManager().getDatabaseManager().dropShardingSphereDatabaseData(event.getDatabaseName()); } /** @@ -65,7 +65,7 @@ public synchronized void renew(final DatabaseDataDeletedEvent event) { */ @Subscribe public synchronized void renew(final SchemaDataAddedEvent event) { - contextManager.getManagerServiceFacade().getDatabaseManagerService().addShardingSphereSchemaData(event.getDatabaseName(), event.getSchemaName()); + contextManager.getMetaDataContextManager().getDatabaseManager().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.getManagerServiceFacade().getDatabaseManagerService().dropShardingSphereSchemaData(event.getDatabaseName(), event.getSchemaName()); + contextManager.getMetaDataContextManager().getDatabaseManager().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.getManagerServiceFacade().getDatabaseManagerService().addShardingSphereTableData(event.getDatabaseName(), event.getSchemaName(), event.getAddedTable()); + contextManager.getMetaDataContextManager().getDatabaseManager().addShardingSphereTableData(event.getDatabaseName(), event.getSchemaName(), event.getAddedTable()); } if (null != event.getDeletedTable()) { - contextManager.getManagerServiceFacade().getDatabaseManagerService().dropShardingSphereTableData(event.getDatabaseName(), event.getSchemaName(), event.getDeletedTable()); + contextManager.getMetaDataContextManager().getDatabaseManager().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.getManagerServiceFacade().getDatabaseManagerService().alterShardingSphereRowData(event.getDatabaseName(), event.getSchemaName(), event.getTableName(), event.getYamlRowData()); + contextManager.getMetaDataContextManager().getDatabaseManager().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.getManagerServiceFacade().getDatabaseManagerService().deleteShardingSphereRowData(event.getDatabaseName(), event.getSchemaName(), event.getTableName(), event.getUniqueKey()); + contextManager.getMetaDataContextManager().getDatabaseManager().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 2dbd28c9b19ad..2f6d58befb68f 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.getManagerServiceFacade().getResourceMetaDataManagerService().addDatabase(event.getDatabaseName()); + contextManager.getMetaDataContextManager().getResourceMetaDataManager().addDatabase(event.getDatabaseName()); } /** @@ -60,7 +60,7 @@ public synchronized void renew(final DatabaseAddedEvent event) { */ @Subscribe public synchronized void renew(final DatabaseDeletedEvent event) { - contextManager.getManagerServiceFacade().getResourceMetaDataManagerService().dropDatabase(event.getDatabaseName()); + contextManager.getMetaDataContextManager().getResourceMetaDataManager().dropDatabase(event.getDatabaseName()); } /** @@ -70,7 +70,7 @@ public synchronized void renew(final DatabaseDeletedEvent event) { */ @Subscribe public synchronized void renew(final SchemaAddedEvent event) { - contextManager.getManagerServiceFacade().getResourceMetaDataManagerService().addSchema(event.getDatabaseName(), event.getSchemaName()); + contextManager.getMetaDataContextManager().getResourceMetaDataManager().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.getManagerServiceFacade().getResourceMetaDataManagerService().dropSchema(event.getDatabaseName(), event.getSchemaName()); + contextManager.getMetaDataContextManager().getResourceMetaDataManager().dropSchema(event.getDatabaseName(), event.getSchemaName()); } /** @@ -96,7 +96,7 @@ public synchronized void renew(final CreateOrAlterTableEvent event) { } Map tables = contextManager.getPersistServiceFacade().getMetaDataPersistService().getDatabaseMetaDataService() .getTableMetaDataPersistService().load(event.getDatabaseName(), event.getSchemaName(), event.getTableName()); - contextManager.getManagerServiceFacade().getResourceMetaDataManagerService().alterSchema(event.getDatabaseName(), event.getSchemaName(), + contextManager.getMetaDataContextManager().getResourceMetaDataManager().alterSchema(event.getDatabaseName(), event.getSchemaName(), tables.values().iterator().next(), null); } @@ -107,7 +107,7 @@ public synchronized void renew(final CreateOrAlterTableEvent event) { */ @Subscribe public synchronized void renew(final DropTableEvent event) { - contextManager.getManagerServiceFacade().getResourceMetaDataManagerService().alterSchema(event.getDatabaseName(), event.getSchemaName(), event.getTableName(), null); + contextManager.getMetaDataContextManager().getResourceMetaDataManager().alterSchema(event.getDatabaseName(), event.getSchemaName(), event.getTableName(), null); } /** @@ -123,7 +123,7 @@ public synchronized void renew(final CreateOrAlterViewEvent event) { } Map views = contextManager.getPersistServiceFacade().getMetaDataPersistService().getDatabaseMetaDataService() .getViewMetaDataPersistService().load(event.getDatabaseName(), event.getSchemaName(), event.getViewName()); - contextManager.getManagerServiceFacade().getResourceMetaDataManagerService().alterSchema(event.getDatabaseName(), event.getSchemaName(), + contextManager.getMetaDataContextManager().getResourceMetaDataManager().alterSchema(event.getDatabaseName(), event.getSchemaName(), null, views.values().iterator().next()); } @@ -134,6 +134,6 @@ public synchronized void renew(final CreateOrAlterViewEvent event) { */ @Subscribe public synchronized void renew(final DropViewEvent event) { - contextManager.getManagerServiceFacade().getResourceMetaDataManagerService().alterSchema(event.getDatabaseName(), event.getSchemaName(), null, event.getViewName()); + contextManager.getMetaDataContextManager().getResourceMetaDataManager().alterSchema(event.getDatabaseName(), event.getSchemaName(), null, event.getViewName()); } } 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 ea31aaac2668c..b526e0a0a0c4e 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,7 @@ 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.manager.ConfigurationManagerService; +import org.apache.shardingsphere.mode.service.manager.ConfigurationManager; import org.apache.shardingsphere.mode.service.persist.MetaDataManagerPersistService; import org.apache.shardingsphere.single.api.config.SingleRuleConfiguration; @@ -72,14 +72,14 @@ public StandaloneMetaDataManagerPersistService(final ContextManager contextManag @Override public void createDatabase(final String databaseName) { - contextManager.getManagerServiceFacade().getResourceMetaDataManagerService().addDatabase(databaseName); + contextManager.getMetaDataContextManager().getResourceMetaDataManager().addDatabase(databaseName); contextManager.getPersistServiceFacade().getMetaDataPersistService().getDatabaseMetaDataService().addDatabase(databaseName); clearServiceCache(); } @Override public void dropDatabase(final String databaseName) { - contextManager.getManagerServiceFacade().getResourceMetaDataManagerService().dropDatabase(databaseName); + contextManager.getMetaDataContextManager().getResourceMetaDataManager().dropDatabase(databaseName); contextManager.getPersistServiceFacade().getMetaDataPersistService().getDatabaseMetaDataService().dropDatabase(databaseName); clearServiceCache(); } @@ -217,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.getManagerServiceFacade().getConfigurationManagerService() + contextManager.getMetaDataContexts().getMetaData().getDatabases().putAll(contextManager.getMetaDataContextManager().getConfigurationManager() .createChangedDatabases(databaseName, false, switchingResource, null)); contextManager.getMetaDataContexts().getMetaData().getGlobalRuleMetaData().getRules() .forEach(each -> ((GlobalRule) each).refresh(contextManager.getMetaDataContexts().getMetaData().getDatabases(), GlobalRuleChangedType.DATABASE_CHANGED)); @@ -234,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.getManagerServiceFacade().getConfigurationManagerService() + contextManager.getMetaDataContexts().getMetaData().getDatabases().putAll(contextManager.getMetaDataContextManager().getConfigurationManager() .createChangedDatabases(databaseName, true, switchingResource, null)); contextManager.getMetaDataContexts().getMetaData().getGlobalRuleMetaData().getRules() .forEach(each -> ((GlobalRule) each).refresh(contextManager.getMetaDataContexts().getMetaData().getDatabases(), GlobalRuleChangedType.DATABASE_CHANGED)); @@ -249,11 +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(); + ConfigurationManager configurationManager = contextManager.getMetaDataContextManager().getConfigurationManager(); contextManager.getMetaDataContexts().getMetaData().getDatabases() - .putAll(configurationManagerService.renewDatabase(contextManager.getMetaDataContexts().getMetaData().getDatabase(databaseName), switchingResource)); - MetaDataContexts reloadMetaDataContexts = configurationManagerService.createMetaDataContexts(databaseName, false, switchingResource, null); - configurationManagerService.alterSchemaMetaData(databaseName, reloadMetaDataContexts.getMetaData().getDatabase(databaseName), + .putAll(configurationManager.renewDatabase(contextManager.getMetaDataContexts().getMetaData().getDatabase(databaseName), switchingResource)); + MetaDataContexts reloadMetaDataContexts = configurationManager.createMetaDataContexts(databaseName, false, switchingResource, null); + configurationManager.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); @@ -267,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.getManagerServiceFacade().getConfigurationManagerService().alterRuleConfiguration(databaseName, ruleConfigs.iterator().next()); + contextManager.getMetaDataContextManager().getConfigurationManager().alterRuleConfiguration(databaseName, ruleConfigs.iterator().next()); clearServiceCache(); } @@ -312,14 +312,14 @@ public void removeRuleConfiguration(final String databaseName, final String rule @Override public void alterGlobalRuleConfiguration(final RuleConfiguration toBeAlteredRuleConfig) { - contextManager.getManagerServiceFacade().getConfigurationManagerService().alterGlobalRuleConfiguration(toBeAlteredRuleConfig); + contextManager.getMetaDataContextManager().getConfigurationManager().alterGlobalRuleConfiguration(toBeAlteredRuleConfig); contextManager.getPersistServiceFacade().getMetaDataPersistService().getGlobalRuleService().persist(Collections.singleton(toBeAlteredRuleConfig)); clearServiceCache(); } @Override public void alterProperties(final Properties props) { - contextManager.getManagerServiceFacade().getConfigurationManagerService().alterProperties(props); + contextManager.getMetaDataContextManager().getConfigurationManager().alterProperties(props); contextManager.getPersistServiceFacade().getMetaDataPersistService().getPropsService().persist(props); clearServiceCache(); }