diff --git a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/resource/ResourceMetaData.java b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/resource/ResourceMetaData.java index 3c51850be0483..f2b2139c113ed 100644 --- a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/resource/ResourceMetaData.java +++ b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/resource/ResourceMetaData.java @@ -18,7 +18,6 @@ package org.apache.shardingsphere.infra.metadata.database.resource; import lombok.Getter; -import org.apache.shardingsphere.infra.datasource.pool.CatalogSwitchableDataSource; import org.apache.shardingsphere.infra.datasource.pool.props.creator.DataSourcePoolPropertiesCreator; import org.apache.shardingsphere.infra.datasource.pool.props.domain.DataSourcePoolProperties; import org.apache.shardingsphere.infra.metadata.database.resource.node.StorageNode; @@ -48,28 +47,20 @@ public final class ResourceMetaData { public ResourceMetaData(final Map dataSources) { this.dataSources = StorageNodeAggregator.aggregateDataSources(dataSources); Map storageNodes = StorageUnitNodeMapUtils.fromDataSources(dataSources); - Map dataSourcePoolPropertiesMap = dataSources.entrySet().stream().collect( + Map dataSourcePoolPropsMap = dataSources.entrySet().stream().collect( Collectors.toMap(Entry::getKey, entry -> DataSourcePoolPropertiesCreator.create(entry.getValue()), (oldValue, currentValue) -> oldValue, LinkedHashMap::new)); storageUnits = new LinkedHashMap<>(); for (Entry entry : storageNodes.entrySet()) { - DataSource dataSource = dataSources.get(entry.getValue().getName().getName()); - if (!(dataSource instanceof CatalogSwitchableDataSource)) { - dataSource = new CatalogSwitchableDataSource(dataSource, entry.getValue().getCatalog(), entry.getValue().getUrl()); - } - storageUnits.put(entry.getKey(), new StorageUnit(null, entry.getValue(), dataSourcePoolPropertiesMap.get(entry.getKey()), dataSource)); + storageUnits.put(entry.getKey(), new StorageUnit(null, entry.getValue(), dataSourcePoolPropsMap.get(entry.getKey()), dataSources.get(entry.getValue().getName().getName()))); } } public ResourceMetaData(final String databaseName, final Map dataSources, - final Map storageNodes, final Map propsMap) { + final Map storageNodes, final Map dataSourcePoolPropsMap) { this.dataSources = dataSources; storageUnits = new LinkedHashMap<>(); for (Entry entry : storageNodes.entrySet()) { - DataSource dataSource = dataSources.get(entry.getValue().getName()); - if (!(dataSource instanceof CatalogSwitchableDataSource)) { - dataSource = new CatalogSwitchableDataSource(dataSource, entry.getValue().getCatalog(), entry.getValue().getUrl()); - } - storageUnits.put(entry.getKey(), new StorageUnit(databaseName, entry.getValue(), propsMap.get(entry.getKey()), dataSource)); + storageUnits.put(entry.getKey(), new StorageUnit(databaseName, entry.getValue(), dataSourcePoolPropsMap.get(entry.getKey()), dataSources.get(entry.getValue().getName()))); } }