Skip to content

Commit

Permalink
Remove twice CatalogSwitchableDataSource wrap on ResourceMetaData (#2…
Browse files Browse the repository at this point in the history
  • Loading branch information
terrymanu authored Oct 5, 2023
1 parent eaaabab commit b5e7f6d
Showing 1 changed file with 2 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -52,11 +51,7 @@ public ResourceMetaData(final Map<String, DataSource> dataSources) {
Collectors.toMap(Entry::getKey, entry -> DataSourcePoolPropertiesCreator.create(entry.getValue()), (oldValue, currentValue) -> oldValue, LinkedHashMap::new));
storageUnits = new LinkedHashMap<>();
for (Entry<String, StorageNode> 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(), dataSourcePoolPropsMap.get(entry.getKey()), dataSource));
storageUnits.put(entry.getKey(), new StorageUnit(null, entry.getValue(), dataSourcePoolPropsMap.get(entry.getKey()), dataSources.get(entry.getValue().getName().getName())));
}
}

Expand All @@ -65,11 +60,7 @@ public ResourceMetaData(final String databaseName, final Map<StorageNodeName, Da
this.dataSources = dataSources;
storageUnits = new LinkedHashMap<>();
for (Entry<String, StorageNode> 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(), dataSourcePoolPropsMap.get(entry.getKey()), dataSource));
storageUnits.put(entry.getKey(), new StorageUnit(databaseName, entry.getValue(), dataSourcePoolPropsMap.get(entry.getKey()), dataSources.get(entry.getValue().getName())));
}
}

Expand Down

0 comments on commit b5e7f6d

Please sign in to comment.