From 9bef0bfaa4aec65a6da48d8bf2cc33dcef74f8b2 Mon Sep 17 00:00:00 2001 From: zhangliang Date: Thu, 28 Sep 2023 23:48:54 +0800 Subject: [PATCH] Decouple StorageUnit and Map --- .../metadata/database/resource/unit/StorageUnit.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/resource/unit/StorageUnit.java b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/resource/unit/StorageUnit.java index da7c333e3aeb0..fd59f0d651c7e 100644 --- a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/resource/unit/StorageUnit.java +++ b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/resource/unit/StorageUnit.java @@ -39,20 +39,20 @@ @Getter public final class StorageUnit { + private final DataSource dataSource; + private final DataSourcePoolProperties dataSourcePoolProperties; private final StorageNode storageNode; - private final DataSource dataSource; - private final DatabaseType storageType; private final ConnectionProperties connectionProperties; - public StorageUnit(final String databaseName, final DataSource dataSource, final DataSourcePoolProperties props, final StorageNode storageNode) { - this.dataSourcePoolProperties = props; - this.storageNode = storageNode; + public StorageUnit(final String databaseName, final DataSource dataSource, final DataSourcePoolProperties dataSourcePoolProperties, final StorageNode storageNode) { this.dataSource = new CatalogSwitchableDataSource(dataSource, storageNode.getCatalog(), storageNode.getUrl()); + this.dataSourcePoolProperties = dataSourcePoolProperties; + this.storageNode = storageNode; boolean isDataSourceEnabled = !DataSourceStateManager.getInstance().getEnabledDataSources(databaseName, Collections.singletonMap(storageNode.getName().getName(), dataSource)).isEmpty(); storageType = createStorageType(isDataSourceEnabled); connectionProperties = createConnectionProperties(isDataSourceEnabled);