diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/MetaDataContextManager.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/MetaDataContextManager.java index 119d40b1098a6..911d72cad7947 100644 --- a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/MetaDataContextManager.java +++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/MetaDataContextManager.java @@ -29,6 +29,7 @@ import org.apache.shardingsphere.infra.metadata.database.schema.manager.GenericSchemaManager; import org.apache.shardingsphere.infra.metadata.statistics.builder.ShardingSphereStatisticsFactory; import org.apache.shardingsphere.infra.rule.builder.global.GlobalRulesBuilder; +import org.apache.shardingsphere.mode.metadata.factory.MetaDataContextsFactory; import org.apache.shardingsphere.mode.metadata.manager.DatabaseRuleConfigurationManager; import org.apache.shardingsphere.mode.metadata.manager.GlobalConfigurationManager; import org.apache.shardingsphere.mode.metadata.manager.ResourceSwitchManager; diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/MetaDataContextsFactory.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/factory/MetaDataContextsFactory.java similarity index 61% rename from mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/MetaDataContextsFactory.java rename to mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/factory/MetaDataContextsFactory.java index 681608c445f65..9ada96c58eb21 100644 --- a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/MetaDataContextsFactory.java +++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/factory/MetaDataContextsFactory.java @@ -15,36 +15,29 @@ * limitations under the License. */ -package org.apache.shardingsphere.mode.metadata; +package org.apache.shardingsphere.mode.metadata.factory; import lombok.RequiredArgsConstructor; import org.apache.shardingsphere.infra.config.database.DatabaseConfiguration; -import org.apache.shardingsphere.infra.config.database.impl.DataSourceGeneratedDatabaseConfiguration; import org.apache.shardingsphere.infra.config.database.impl.DataSourceProvidedDatabaseConfiguration; import org.apache.shardingsphere.infra.config.props.ConfigurationProperties; import org.apache.shardingsphere.infra.config.rule.RuleConfiguration; import org.apache.shardingsphere.infra.database.DatabaseTypeEngine; import org.apache.shardingsphere.infra.database.core.type.DatabaseType; -import org.apache.shardingsphere.infra.datasource.pool.config.DataSourceConfiguration; -import org.apache.shardingsphere.infra.datasource.pool.destroyer.DataSourcePoolDestroyer; import org.apache.shardingsphere.infra.datasource.pool.props.domain.DataSourcePoolProperties; import org.apache.shardingsphere.infra.instance.ComputeNodeInstanceContext; -import org.apache.shardingsphere.infra.instance.metadata.jdbc.JDBCInstanceMetaData; import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData; import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase; -import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabasesFactory; import org.apache.shardingsphere.infra.metadata.database.resource.ResourceMetaData; import org.apache.shardingsphere.infra.metadata.database.resource.node.StorageNode; import org.apache.shardingsphere.infra.metadata.database.resource.unit.StorageUnit; import org.apache.shardingsphere.infra.metadata.database.rule.RuleMetaData; -import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema; -import org.apache.shardingsphere.infra.metadata.statistics.ShardingSphereDatabaseData; -import org.apache.shardingsphere.infra.metadata.statistics.ShardingSphereSchemaData; -import org.apache.shardingsphere.infra.metadata.statistics.ShardingSphereStatistics; import org.apache.shardingsphere.infra.metadata.statistics.builder.ShardingSphereStatisticsFactory; -import org.apache.shardingsphere.infra.rule.ShardingSphereRule; import org.apache.shardingsphere.infra.rule.builder.global.GlobalRulesBuilder; import org.apache.shardingsphere.mode.manager.ContextManagerBuilderParameter; +import org.apache.shardingsphere.mode.metadata.MetaDataContexts; +import org.apache.shardingsphere.mode.metadata.factory.type.LocalConfigurationMetaDataContextsFactory; +import org.apache.shardingsphere.mode.metadata.factory.type.RegisterCenterMetaDataContextsFactory; import org.apache.shardingsphere.mode.metadata.manager.SwitchingResource; import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService; @@ -74,95 +67,15 @@ public final class MetaDataContextsFactory { * @throws SQLException SQL exception */ public MetaDataContexts create(final ContextManagerBuilderParameter param) throws SQLException { - return containsRegisteredDatabases() ? createFromRegisterCenter(param) : createFromLocalConfiguration(param); + return containsRegisteredDatabases() + ? new RegisterCenterMetaDataContextsFactory(persistService, instanceContext).create(param) + : new LocalConfigurationMetaDataContextsFactory(persistService, instanceContext).create(param); } private boolean containsRegisteredDatabases() { return !persistService.getDatabaseMetaDataFacade().getDatabase().loadAllDatabaseNames().isEmpty(); } - private MetaDataContexts createFromRegisterCenter(final ContextManagerBuilderParameter param) { - Map effectiveDatabaseConfigs = createEffectiveDatabaseConfigurations(getDatabaseNames(param.getDatabaseConfigs()), param.getDatabaseConfigs()); - Collection globalRuleConfigs = persistService.getGlobalRuleService().load(); - // TODO load global data sources from persist service - Map globalDataSources = param.getGlobalDataSources(); - ConfigurationProperties props = new ConfigurationProperties(persistService.getPropsService().load()); - Collection databases = ShardingSphereDatabasesFactory.create( - effectiveDatabaseConfigs, loadSchemas(effectiveDatabaseConfigs.keySet()), props, instanceContext); - return createMetaDataContexts(globalRuleConfigs, globalDataSources, databases, props); - } - - private MetaDataContexts createFromLocalConfiguration(final ContextManagerBuilderParameter param) throws SQLException { - ConfigurationProperties props = new ConfigurationProperties(param.getProps()); - Collection databases = ShardingSphereDatabasesFactory.create(param.getDatabaseConfigs(), props, instanceContext); - MetaDataContexts result = createMetaDataContexts(param.getGlobalRuleConfigs(), param.getGlobalDataSources(), databases, props); - persistDatabaseConfigurations(result, param); - persistMetaData(result); - return result; - } - - private MetaDataContexts createMetaDataContexts(final Collection globalRuleConfigs, final Map globalDataSources, - final Collection databases, final ConfigurationProperties props) { - Collection globalRules = GlobalRulesBuilder.buildRules(globalRuleConfigs, databases, props); - ShardingSphereMetaData metaData = new ShardingSphereMetaData(databases, new ResourceMetaData(globalDataSources), new RuleMetaData(globalRules), props); - ShardingSphereStatistics statistics = ShardingSphereStatisticsFactory.create(metaData, persistService.getShardingSphereDataPersistService().load(metaData)); - return new MetaDataContexts(metaData, statistics); - } - - private void persistDatabaseConfigurations(final MetaDataContexts metadataContexts, final ContextManagerBuilderParameter param) { - Collection globalRuleConfigs = metadataContexts.getMetaData().getGlobalRuleMetaData().getConfigurations(); - persistService.persistGlobalRuleConfiguration(globalRuleConfigs, param.getProps()); - for (Entry entry : param.getDatabaseConfigs().entrySet()) { - String databaseName = entry.getKey(); - persistService.persistConfigurations(entry.getKey(), entry.getValue(), - metadataContexts.getMetaData().getDatabase(databaseName).getResourceMetaData().getStorageUnits().entrySet().stream() - .collect(Collectors.toMap(Entry::getKey, each -> each.getValue().getDataSource(), (oldValue, currentValue) -> oldValue, LinkedHashMap::new)), - metadataContexts.getMetaData().getDatabase(databaseName).getRuleMetaData().getRules()); - } - } - - private void persistMetaData(final MetaDataContexts metaDataContexts) { - metaDataContexts.getMetaData().getAllDatabases().forEach(each -> each.getAllSchemas().forEach(schema -> { - if (schema.isEmpty()) { - persistService.getDatabaseMetaDataFacade().getSchema().add(each.getName(), schema.getName()); - } - persistService.getDatabaseMetaDataFacade().getTable().persist(each.getName(), schema.getName(), schema.getAllTables()); - })); - for (Entry databaseDataEntry : metaDataContexts.getStatistics().getDatabaseData().entrySet()) { - for (Entry schemaDataEntry : databaseDataEntry.getValue().getSchemaData().entrySet()) { - persistService.getShardingSphereDataPersistService().persist( - metaDataContexts.getMetaData().getDatabase(databaseDataEntry.getKey()), schemaDataEntry.getKey(), schemaDataEntry.getValue()); - } - } - } - - private Collection getDatabaseNames(final Map databaseConfigs) { - return instanceContext.getInstance().getMetaData() instanceof JDBCInstanceMetaData - ? databaseConfigs.keySet() - : persistService.getDatabaseMetaDataFacade().getDatabase().loadAllDatabaseNames(); - } - - private Map createEffectiveDatabaseConfigurations(final Collection databaseNames, final Map databaseConfigs) { - return databaseNames.stream().collect(Collectors.toMap(each -> each, each -> createEffectiveDatabaseConfiguration(each, databaseConfigs))); - } - - private DatabaseConfiguration createEffectiveDatabaseConfiguration(final String databaseName, final Map databaseConfigs) { - closeGeneratedDataSources(databaseName, databaseConfigs); - Map dataSources = persistService.loadDataSourceConfigurations(databaseName); - Collection databaseRuleConfigs = persistService.getDatabaseRulePersistService().load(databaseName); - return new DataSourceGeneratedDatabaseConfiguration(dataSources, databaseRuleConfigs); - } - - private void closeGeneratedDataSources(final String databaseName, final Map databaseConfigs) { - if (databaseConfigs.containsKey(databaseName) && !databaseConfigs.get(databaseName).getStorageUnits().isEmpty()) { - databaseConfigs.get(databaseName).getDataSources().values().forEach(each -> new DataSourcePoolDestroyer(each).asyncDestroy()); - } - } - - private Map> loadSchemas(final Collection databaseNames) { - return databaseNames.stream().collect(Collectors.toMap(each -> each, each -> persistService.getDatabaseMetaDataFacade().getSchema().load(each))); - } - /** * Create meta data contexts by switch resource. * diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/factory/type/LocalConfigurationMetaDataContextsFactory.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/factory/type/LocalConfigurationMetaDataContextsFactory.java new file mode 100644 index 0000000000000..23b3aaa444015 --- /dev/null +++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/factory/type/LocalConfigurationMetaDataContextsFactory.java @@ -0,0 +1,107 @@ +/* + * 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.metadata.factory.type; + +import lombok.RequiredArgsConstructor; +import org.apache.shardingsphere.infra.config.database.DatabaseConfiguration; +import org.apache.shardingsphere.infra.config.props.ConfigurationProperties; +import org.apache.shardingsphere.infra.config.rule.RuleConfiguration; +import org.apache.shardingsphere.infra.instance.ComputeNodeInstanceContext; +import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData; +import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase; +import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabasesFactory; +import org.apache.shardingsphere.infra.metadata.database.resource.ResourceMetaData; +import org.apache.shardingsphere.infra.metadata.database.rule.RuleMetaData; +import org.apache.shardingsphere.infra.metadata.statistics.ShardingSphereDatabaseData; +import org.apache.shardingsphere.infra.metadata.statistics.ShardingSphereSchemaData; +import org.apache.shardingsphere.infra.metadata.statistics.ShardingSphereStatistics; +import org.apache.shardingsphere.infra.metadata.statistics.builder.ShardingSphereStatisticsFactory; +import org.apache.shardingsphere.infra.rule.ShardingSphereRule; +import org.apache.shardingsphere.infra.rule.builder.global.GlobalRulesBuilder; +import org.apache.shardingsphere.mode.manager.ContextManagerBuilderParameter; +import org.apache.shardingsphere.mode.metadata.MetaDataContexts; +import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService; + +import javax.sql.DataSource; +import java.sql.SQLException; +import java.util.Collection; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Map.Entry; +import java.util.stream.Collectors; + +/** + * Local configuration meta data contexts factory. + */ +@RequiredArgsConstructor +public final class LocalConfigurationMetaDataContextsFactory { + + private final MetaDataPersistService persistService; + + private final ComputeNodeInstanceContext instanceContext; + + /** + * Create meta data contexts. + * + * @param param context manager builder parameter + * @return meta data contexts + * @throws SQLException SQL exception + */ + public MetaDataContexts create(final ContextManagerBuilderParameter param) throws SQLException { + ConfigurationProperties props = new ConfigurationProperties(param.getProps()); + Collection databases = ShardingSphereDatabasesFactory.create(param.getDatabaseConfigs(), props, instanceContext); + MetaDataContexts result = createMetaDataContexts(param.getGlobalRuleConfigs(), param.getGlobalDataSources(), databases, props); + persistDatabaseConfigurations(result, param); + persistMetaData(result); + return result; + } + + private MetaDataContexts createMetaDataContexts(final Collection globalRuleConfigs, final Map globalDataSources, + final Collection databases, final ConfigurationProperties props) { + Collection globalRules = GlobalRulesBuilder.buildRules(globalRuleConfigs, databases, props); + ShardingSphereMetaData metaData = new ShardingSphereMetaData(databases, new ResourceMetaData(globalDataSources), new RuleMetaData(globalRules), props); + ShardingSphereStatistics statistics = ShardingSphereStatisticsFactory.create(metaData, persistService.getShardingSphereDataPersistService().load(metaData)); + return new MetaDataContexts(metaData, statistics); + } + + private void persistDatabaseConfigurations(final MetaDataContexts metadataContexts, final ContextManagerBuilderParameter param) { + Collection globalRuleConfigs = metadataContexts.getMetaData().getGlobalRuleMetaData().getConfigurations(); + persistService.persistGlobalRuleConfiguration(globalRuleConfigs, param.getProps()); + for (Entry entry : param.getDatabaseConfigs().entrySet()) { + ShardingSphereDatabase database = metadataContexts.getMetaData().getDatabase(entry.getKey()); + Map dataSources = database.getResourceMetaData().getStorageUnits().entrySet().stream() + .collect(Collectors.toMap(Entry::getKey, each -> each.getValue().getDataSource(), (oldValue, currentValue) -> oldValue, LinkedHashMap::new)); + persistService.persistConfigurations(entry.getKey(), entry.getValue(), dataSources, database.getRuleMetaData().getRules()); + } + } + + private void persistMetaData(final MetaDataContexts metaDataContexts) { + metaDataContexts.getMetaData().getAllDatabases().forEach(each -> each.getAllSchemas().forEach(schema -> { + if (schema.isEmpty()) { + persistService.getDatabaseMetaDataFacade().getSchema().add(each.getName(), schema.getName()); + } + persistService.getDatabaseMetaDataFacade().getTable().persist(each.getName(), schema.getName(), schema.getAllTables()); + })); + for (Entry databaseDataEntry : metaDataContexts.getStatistics().getDatabaseData().entrySet()) { + for (Entry schemaDataEntry : databaseDataEntry.getValue().getSchemaData().entrySet()) { + persistService.getShardingSphereDataPersistService().persist( + metaDataContexts.getMetaData().getDatabase(databaseDataEntry.getKey()), schemaDataEntry.getKey(), schemaDataEntry.getValue()); + } + } + } +} diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/factory/type/RegisterCenterMetaDataContextsFactory.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/factory/type/RegisterCenterMetaDataContextsFactory.java new file mode 100644 index 0000000000000..42461ec3d148b --- /dev/null +++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/factory/type/RegisterCenterMetaDataContextsFactory.java @@ -0,0 +1,110 @@ +/* + * 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.metadata.factory.type; + +import lombok.RequiredArgsConstructor; +import org.apache.shardingsphere.infra.config.database.DatabaseConfiguration; +import org.apache.shardingsphere.infra.config.database.impl.DataSourceGeneratedDatabaseConfiguration; +import org.apache.shardingsphere.infra.config.props.ConfigurationProperties; +import org.apache.shardingsphere.infra.config.rule.RuleConfiguration; +import org.apache.shardingsphere.infra.datasource.pool.config.DataSourceConfiguration; +import org.apache.shardingsphere.infra.datasource.pool.destroyer.DataSourcePoolDestroyer; +import org.apache.shardingsphere.infra.instance.ComputeNodeInstanceContext; +import org.apache.shardingsphere.infra.instance.metadata.jdbc.JDBCInstanceMetaData; +import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData; +import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase; +import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabasesFactory; +import org.apache.shardingsphere.infra.metadata.database.resource.ResourceMetaData; +import org.apache.shardingsphere.infra.metadata.database.rule.RuleMetaData; +import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema; +import org.apache.shardingsphere.infra.metadata.statistics.ShardingSphereStatistics; +import org.apache.shardingsphere.infra.metadata.statistics.builder.ShardingSphereStatisticsFactory; +import org.apache.shardingsphere.infra.rule.ShardingSphereRule; +import org.apache.shardingsphere.infra.rule.builder.global.GlobalRulesBuilder; +import org.apache.shardingsphere.mode.manager.ContextManagerBuilderParameter; +import org.apache.shardingsphere.mode.metadata.MetaDataContexts; +import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService; + +import javax.sql.DataSource; +import java.sql.SQLException; +import java.util.Collection; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * Register center meta data contexts factory. + */ +@RequiredArgsConstructor +public final class RegisterCenterMetaDataContextsFactory { + + private final MetaDataPersistService persistService; + + private final ComputeNodeInstanceContext instanceContext; + + /** + * Create meta data contexts. + * + * @param param context manager builder parameter + * @return meta data contexts + * @throws SQLException SQL exception + */ + public MetaDataContexts create(final ContextManagerBuilderParameter param) throws SQLException { + Map effectiveDatabaseConfigs = createEffectiveDatabaseConfigurations(getDatabaseNames(param.getDatabaseConfigs()), param.getDatabaseConfigs()); + Collection globalRuleConfigs = persistService.getGlobalRuleService().load(); + // TODO load global data sources from persist service + Map globalDataSources = param.getGlobalDataSources(); + ConfigurationProperties props = new ConfigurationProperties(persistService.getPropsService().load()); + Collection databases = ShardingSphereDatabasesFactory.create(effectiveDatabaseConfigs, loadSchemas(effectiveDatabaseConfigs.keySet()), props, instanceContext); + return createMetaDataContexts(globalRuleConfigs, globalDataSources, databases, props); + } + + private Collection getDatabaseNames(final Map databaseConfigs) { + return instanceContext.getInstance().getMetaData() instanceof JDBCInstanceMetaData + ? databaseConfigs.keySet() + : persistService.getDatabaseMetaDataFacade().getDatabase().loadAllDatabaseNames(); + } + + private Map createEffectiveDatabaseConfigurations(final Collection databaseNames, final Map databaseConfigs) { + return databaseNames.stream().collect(Collectors.toMap(each -> each, each -> createEffectiveDatabaseConfiguration(each, databaseConfigs))); + } + + private DatabaseConfiguration createEffectiveDatabaseConfiguration(final String databaseName, final Map databaseConfigs) { + closeGeneratedDataSources(databaseName, databaseConfigs); + Map dataSources = persistService.loadDataSourceConfigurations(databaseName); + Collection databaseRuleConfigs = persistService.getDatabaseRulePersistService().load(databaseName); + return new DataSourceGeneratedDatabaseConfiguration(dataSources, databaseRuleConfigs); + } + + private void closeGeneratedDataSources(final String databaseName, final Map databaseConfigs) { + if (databaseConfigs.containsKey(databaseName) && !databaseConfigs.get(databaseName).getStorageUnits().isEmpty()) { + databaseConfigs.get(databaseName).getDataSources().values().forEach(each -> new DataSourcePoolDestroyer(each).asyncDestroy()); + } + } + + private Map> loadSchemas(final Collection databaseNames) { + return databaseNames.stream().collect(Collectors.toMap(each -> each, each -> persistService.getDatabaseMetaDataFacade().getSchema().load(each))); + } + + private MetaDataContexts createMetaDataContexts(final Collection globalRuleConfigs, final Map globalDataSources, + final Collection databases, final ConfigurationProperties props) { + Collection globalRules = GlobalRulesBuilder.buildRules(globalRuleConfigs, databases, props); + ShardingSphereMetaData metaData = new ShardingSphereMetaData(databases, new ResourceMetaData(globalDataSources), new RuleMetaData(globalRules), props); + ShardingSphereStatistics statistics = ShardingSphereStatisticsFactory.create(metaData, persistService.getShardingSphereDataPersistService().load(metaData)); + return new MetaDataContexts(metaData, statistics); + } +} diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/manager/DatabaseRuleConfigurationManager.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/manager/DatabaseRuleConfigurationManager.java index 996b7a7f16d96..530a92899c67c 100644 --- a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/manager/DatabaseRuleConfigurationManager.java +++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/manager/DatabaseRuleConfigurationManager.java @@ -27,7 +27,7 @@ import org.apache.shardingsphere.infra.rule.builder.database.DatabaseRulesBuilder; import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader; import org.apache.shardingsphere.mode.metadata.MetaDataContexts; -import org.apache.shardingsphere.mode.metadata.MetaDataContextsFactory; +import org.apache.shardingsphere.mode.metadata.factory.MetaDataContextsFactory; import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService; import org.apache.shardingsphere.mode.spi.repository.PersistRepository; diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/manager/StorageUnitManager.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/manager/StorageUnitManager.java index 66539df3e15d9..4f7ef1d2467bb 100644 --- a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/manager/StorageUnitManager.java +++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/manager/StorageUnitManager.java @@ -25,7 +25,7 @@ import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema; import org.apache.shardingsphere.infra.rule.ShardingSphereRule; import org.apache.shardingsphere.mode.metadata.MetaDataContexts; -import org.apache.shardingsphere.mode.metadata.MetaDataContextsFactory; +import org.apache.shardingsphere.mode.metadata.factory.MetaDataContextsFactory; import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService; import org.apache.shardingsphere.mode.spi.repository.PersistRepository; diff --git a/mode/core/src/test/java/org/apache/shardingsphere/mode/metadata/MetaDataContextsFactoryTest.java b/mode/core/src/test/java/org/apache/shardingsphere/mode/metadata/factory/MetaDataContextsFactoryTest.java similarity index 98% rename from mode/core/src/test/java/org/apache/shardingsphere/mode/metadata/MetaDataContextsFactoryTest.java rename to mode/core/src/test/java/org/apache/shardingsphere/mode/metadata/factory/MetaDataContextsFactoryTest.java index 79f8feeebcfe0..deca0c65f2811 100644 --- a/mode/core/src/test/java/org/apache/shardingsphere/mode/metadata/MetaDataContextsFactoryTest.java +++ b/mode/core/src/test/java/org/apache/shardingsphere/mode/metadata/factory/MetaDataContextsFactoryTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.shardingsphere.mode.metadata; +package org.apache.shardingsphere.mode.metadata.factory; import org.apache.shardingsphere.infra.config.database.DatabaseConfiguration; import org.apache.shardingsphere.infra.config.database.impl.DataSourceProvidedDatabaseConfiguration; @@ -28,6 +28,7 @@ import org.apache.shardingsphere.infra.rule.builder.global.GlobalRulesBuilder; import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader; import org.apache.shardingsphere.mode.manager.ContextManagerBuilderParameter; +import org.apache.shardingsphere.mode.metadata.MetaDataContexts; import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService; import org.apache.shardingsphere.mode.metadata.persist.service.config.database.DatabaseRulePersistService; import org.apache.shardingsphere.mode.metadata.persist.service.config.global.GlobalRulePersistService; diff --git a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java index d3288bfad095d..4dd8330d1f9bd 100644 --- a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java +++ b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java @@ -38,7 +38,7 @@ import org.apache.shardingsphere.mode.deliver.DeliverEventSubscriberRegistry; import org.apache.shardingsphere.mode.manager.cluster.workerid.ClusterWorkerIdGenerator; import org.apache.shardingsphere.mode.metadata.MetaDataContexts; -import org.apache.shardingsphere.mode.metadata.MetaDataContextsFactory; +import org.apache.shardingsphere.mode.metadata.factory.MetaDataContextsFactory; import org.apache.shardingsphere.mode.repository.cluster.ClusterPersistRepository; import org.apache.shardingsphere.mode.repository.cluster.ClusterPersistRepositoryConfiguration; import org.apache.shardingsphere.mode.spi.repository.PersistRepository; diff --git a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/persist/service/ClusterMetaDataManagerPersistService.java b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/persist/service/ClusterMetaDataManagerPersistService.java index bccb6da4eaad7..99025d945c3de 100644 --- a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/persist/service/ClusterMetaDataManagerPersistService.java +++ b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/persist/service/ClusterMetaDataManagerPersistService.java @@ -34,7 +34,7 @@ import org.apache.shardingsphere.mode.metadata.persist.service.metadata.DatabaseMetaDataPersistFacade; import org.apache.shardingsphere.mode.metadata.MetaDataContextManager; import org.apache.shardingsphere.mode.metadata.MetaDataContexts; -import org.apache.shardingsphere.mode.metadata.MetaDataContextsFactory; +import org.apache.shardingsphere.mode.metadata.factory.MetaDataContextsFactory; import org.apache.shardingsphere.mode.metadata.manager.SwitchingResource; import org.apache.shardingsphere.mode.persist.service.unified.ListenerAssistedType; import org.apache.shardingsphere.mode.persist.service.unified.ListenerAssistedPersistService; diff --git a/mode/type/standalone/core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneContextManagerBuilder.java b/mode/type/standalone/core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneContextManagerBuilder.java index 38737a3222dad..be131af666340 100644 --- a/mode/type/standalone/core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneContextManagerBuilder.java +++ b/mode/type/standalone/core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneContextManagerBuilder.java @@ -28,7 +28,7 @@ import org.apache.shardingsphere.mode.manager.standalone.lock.StandaloneLockContext; import org.apache.shardingsphere.mode.manager.standalone.workerid.StandaloneWorkerIdGenerator; import org.apache.shardingsphere.mode.metadata.MetaDataContexts; -import org.apache.shardingsphere.mode.metadata.MetaDataContextsFactory; +import org.apache.shardingsphere.mode.metadata.factory.MetaDataContextsFactory; import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService; import org.apache.shardingsphere.mode.repository.standalone.StandalonePersistRepository; diff --git a/mode/type/standalone/core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/persist/service/StandaloneMetaDataManagerPersistService.java b/mode/type/standalone/core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/persist/service/StandaloneMetaDataManagerPersistService.java index 45018548fc6d6..dffa6d67eb36c 100644 --- a/mode/type/standalone/core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/persist/service/StandaloneMetaDataManagerPersistService.java +++ b/mode/type/standalone/core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/persist/service/StandaloneMetaDataManagerPersistService.java @@ -37,7 +37,7 @@ import org.apache.shardingsphere.mode.event.DataChangedEvent.Type; import org.apache.shardingsphere.mode.metadata.MetaDataContextManager; import org.apache.shardingsphere.mode.metadata.MetaDataContexts; -import org.apache.shardingsphere.mode.metadata.MetaDataContextsFactory; +import org.apache.shardingsphere.mode.metadata.factory.MetaDataContextsFactory; import org.apache.shardingsphere.mode.metadata.manager.RuleItemChangedBuilder; import org.apache.shardingsphere.mode.metadata.manager.SwitchingResource; import org.apache.shardingsphere.mode.metadata.refresher.util.TableRefreshUtils;