From 66581bea14e808a64ae88eb6558ff8249454e30c Mon Sep 17 00:00:00 2001 From: zhangliang Date: Wed, 4 Oct 2023 19:41:24 +0800 Subject: [PATCH] Rename StorageNodeAggregator --- ...taSourceProvidedDatabaseConfiguration.java | 4 +- .../database/resource/ResourceMetaData.java | 4 +- .../resource/node/StorageNodeAggregator.java | 78 +++++++++++++++++++ .../resource/node/StorageNodeUtils.java | 45 ----------- .../unit/StorageUnitNodeMapUtils.java | 18 ----- .../switcher/NewResourceSwitchManager.java | 25 +++--- .../switcher/ResourceSwitchManager.java | 19 ++--- .../mode/manager/ContextManagerTest.java | 6 +- 8 files changed, 108 insertions(+), 91 deletions(-) create mode 100644 infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/resource/node/StorageNodeAggregator.java delete mode 100644 infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/resource/node/StorageNodeUtils.java diff --git a/infra/common/src/main/java/org/apache/shardingsphere/infra/config/database/impl/DataSourceProvidedDatabaseConfiguration.java b/infra/common/src/main/java/org/apache/shardingsphere/infra/config/database/impl/DataSourceProvidedDatabaseConfiguration.java index 19773c8075002..14aaf77972c91 100644 --- a/infra/common/src/main/java/org/apache/shardingsphere/infra/config/database/impl/DataSourceProvidedDatabaseConfiguration.java +++ b/infra/common/src/main/java/org/apache/shardingsphere/infra/config/database/impl/DataSourceProvidedDatabaseConfiguration.java @@ -24,7 +24,7 @@ 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.StorageResource; -import org.apache.shardingsphere.infra.metadata.database.resource.node.StorageNodeUtils; +import org.apache.shardingsphere.infra.metadata.database.resource.node.StorageNodeAggregator; import org.apache.shardingsphere.infra.metadata.database.resource.unit.StorageUnitNodeMapUtils; import javax.sql.DataSource; @@ -49,7 +49,7 @@ public final class DataSourceProvidedDatabaseConfiguration implements DatabaseCo public DataSourceProvidedDatabaseConfiguration(final Map dataSources, final Collection ruleConfigs) { this.ruleConfigurations = ruleConfigs; - storageResource = new StorageResource(StorageNodeUtils.getStorageNodeDataSources(dataSources), StorageUnitNodeMapUtils.fromDataSources(dataSources)); + storageResource = new StorageResource(StorageNodeAggregator.aggregateDataSources(dataSources), StorageUnitNodeMapUtils.fromDataSources(dataSources)); dataSourcePoolPropertiesMap = createDataSourcePoolPropertiesMap(dataSources); } 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 63aa082230ac0..241db864c3db9 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 @@ -25,7 +25,7 @@ import org.apache.shardingsphere.infra.datasource.pool.props.domain.DataSourcePoolProperties; import org.apache.shardingsphere.infra.metadata.database.resource.node.StorageNode; import org.apache.shardingsphere.infra.metadata.database.resource.node.StorageNodeName; -import org.apache.shardingsphere.infra.metadata.database.resource.node.StorageNodeUtils; +import org.apache.shardingsphere.infra.metadata.database.resource.node.StorageNodeAggregator; import org.apache.shardingsphere.infra.metadata.database.resource.unit.StorageUnitMetaData; import org.apache.shardingsphere.infra.metadata.database.resource.unit.StorageUnitNodeMapUtils; @@ -48,7 +48,7 @@ public final class ResourceMetaData { private final Map storageUnitMetaDataMap; public ResourceMetaData(final Map dataSources) { - this.dataSources = StorageNodeUtils.getStorageNodeDataSources(dataSources); + this.dataSources = StorageNodeAggregator.aggregateDataSources(dataSources); Map storageNodes = StorageUnitNodeMapUtils.fromDataSources(dataSources); Map dataSourcePoolPropertiesMap = dataSources.entrySet().stream().collect( Collectors.toMap(Entry::getKey, entry -> DataSourcePoolPropertiesCreator.create(entry.getValue()), (oldValue, currentValue) -> oldValue, LinkedHashMap::new)); diff --git a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/resource/node/StorageNodeAggregator.java b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/resource/node/StorageNodeAggregator.java new file mode 100644 index 0000000000000..7f4212beea8f3 --- /dev/null +++ b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/resource/node/StorageNodeAggregator.java @@ -0,0 +1,78 @@ +/* + * 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.infra.metadata.database.resource.node; + +import lombok.AccessLevel; +import lombok.NoArgsConstructor; +import org.apache.shardingsphere.infra.database.core.connector.url.JdbcUrl; +import org.apache.shardingsphere.infra.database.core.connector.url.StandardJdbcUrlParser; +import org.apache.shardingsphere.infra.database.core.connector.url.UnrecognizedDatabaseURLException; +import org.apache.shardingsphere.infra.database.core.type.DatabaseTypeFactory; +import org.apache.shardingsphere.infra.database.core.type.DatabaseTypeRegistry; +import org.apache.shardingsphere.infra.datasource.pool.props.domain.DataSourcePoolProperties; + +import javax.sql.DataSource; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Map.Entry; +import java.util.stream.Collectors; + +/** + * Storage node aggregator. + */ +@NoArgsConstructor(access = AccessLevel.PRIVATE) +public final class StorageNodeAggregator { + + /** + * Aggregate data source map to storage node name grouped. + * + * @param dataSourceMap storage unit name and data source map + * @return storage node name and data source map + */ + public static Map aggregateDataSources(final Map dataSourceMap) { + return dataSourceMap.entrySet().stream().collect( + Collectors.toMap(entry -> new StorageNodeName(entry.getKey()), Entry::getValue, (oldValue, currentValue) -> currentValue, () -> new LinkedHashMap<>(dataSourceMap.size(), 1F))); + } + + /** + * Aggregate data source pool properties map to storage node name grouped. + * + * @param storageUnitDataSourcePoolPropsMap storage unit name and data source pool properties map + * @return storage node name and data source pool properties map + */ + public static Map aggregateDataSourcePoolProperties(final Map storageUnitDataSourcePoolPropsMap) { + Map result = new LinkedHashMap<>(); + for (Entry entry : storageUnitDataSourcePoolPropsMap.entrySet()) { + Map standardProps = entry.getValue().getConnectionPropertySynonyms().getStandardProperties(); + String url = standardProps.get("url").toString(); + boolean isInstanceConnectionAvailable = new DatabaseTypeRegistry(DatabaseTypeFactory.get(url)).getDialectDatabaseMetaData().isInstanceConnectionAvailable(); + StorageNodeName storageNodeName = getStorageNodeName(entry.getKey(), url, standardProps.get("username").toString(), isInstanceConnectionAvailable); + result.putIfAbsent(storageNodeName, entry.getValue()); + } + return result; + } + + private static StorageNodeName getStorageNodeName(final String dataSourceName, final String url, final String username, final boolean isInstanceConnectionAvailable) { + try { + JdbcUrl jdbcUrl = new StandardJdbcUrlParser().parse(url); + return isInstanceConnectionAvailable ? new StorageNodeName(jdbcUrl.getHostname(), jdbcUrl.getPort(), username) : new StorageNodeName(dataSourceName); + } catch (final UnrecognizedDatabaseURLException ex) { + return new StorageNodeName(dataSourceName); + } + } +} diff --git a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/resource/node/StorageNodeUtils.java b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/resource/node/StorageNodeUtils.java deleted file mode 100644 index 3b6fca81e8dcf..0000000000000 --- a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/resource/node/StorageNodeUtils.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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.infra.metadata.database.resource.node; - -import lombok.AccessLevel; -import lombok.NoArgsConstructor; - -import javax.sql.DataSource; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.Map.Entry; -import java.util.stream.Collectors; - -/** - * Storage node utility class. - */ -@NoArgsConstructor(access = AccessLevel.PRIVATE) -public final class StorageNodeUtils { - - /** - * Get storage node data sources. - * - * @param dataSources data sources - * @return storage node data sources - */ - public static Map getStorageNodeDataSources(final Map dataSources) { - return dataSources.entrySet().stream().collect( - Collectors.toMap(entry -> new StorageNodeName(entry.getKey()), Entry::getValue, (oldValue, currentValue) -> currentValue, () -> new LinkedHashMap<>(dataSources.size(), 1F))); - } -} diff --git a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/resource/unit/StorageUnitNodeMapUtils.java b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/resource/unit/StorageUnitNodeMapUtils.java index cad759e89088c..8217a4ca8486d 100644 --- a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/resource/unit/StorageUnitNodeMapUtils.java +++ b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/resource/unit/StorageUnitNodeMapUtils.java @@ -93,22 +93,4 @@ private static StorageNodeName getStorageNodeName(final String dataSourceName, f private static StorageNode createStorageNode(final StorageNodeName storageNodeName, final String url, final boolean isInstanceConnectionAvailable) { return isInstanceConnectionAvailable ? new StorageNode(storageNodeName, url, new StandardJdbcUrlParser().parse(url).getDatabase()) : new StorageNode(storageNodeName, url); } - - /** - * Get storage node grouped data source pool properties map. - * - * @param storageUnitDataSourcePoolProps storage unit grouped data source pool properties map - * @return storage node grouped data source pool properties map - */ - public static Map getStorageNodeDataSourcePoolProperties(final Map storageUnitDataSourcePoolProps) { - Map result = new LinkedHashMap<>(); - for (Entry entry : storageUnitDataSourcePoolProps.entrySet()) { - Map standardProps = entry.getValue().getConnectionPropertySynonyms().getStandardProperties(); - String url = standardProps.get("url").toString(); - boolean isInstanceConnectionAvailable = new DatabaseTypeRegistry(DatabaseTypeFactory.get(url)).getDialectDatabaseMetaData().isInstanceConnectionAvailable(); - StorageNodeName storageNodeName = getStorageNodeName(entry.getKey(), url, standardProps.get("username").toString(), isInstanceConnectionAvailable); - result.putIfAbsent(storageNodeName, entry.getValue()); - } - return result; - } } diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/manager/switcher/NewResourceSwitchManager.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/manager/switcher/NewResourceSwitchManager.java index a42ab2cf70df0..27c866d8fa8ae 100644 --- a/mode/core/src/main/java/org/apache/shardingsphere/mode/manager/switcher/NewResourceSwitchManager.java +++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/manager/switcher/NewResourceSwitchManager.java @@ -23,6 +23,7 @@ import org.apache.shardingsphere.infra.metadata.database.resource.StorageResource; import org.apache.shardingsphere.infra.metadata.database.resource.node.StorageNode; import org.apache.shardingsphere.infra.metadata.database.resource.node.StorageNodeName; +import org.apache.shardingsphere.infra.metadata.database.resource.node.StorageNodeAggregator; import org.apache.shardingsphere.infra.metadata.database.resource.unit.StorageUnitNodeMapUtils; import javax.sql.DataSource; @@ -43,26 +44,26 @@ public final class NewResourceSwitchManager { * Register storage unit. * * @param resourceMetaData resource meta data - * @param storageUnitDataSourcePoolProps storage unit grouped data source pool properties map + * @param storageUnitDataSourcePoolPropsMap storage unit grouped data source pool properties map * @return created switching resource */ - public SwitchingResource registerStorageUnit(final ResourceMetaData resourceMetaData, final Map storageUnitDataSourcePoolProps) { + public SwitchingResource registerStorageUnit(final ResourceMetaData resourceMetaData, final Map storageUnitDataSourcePoolPropsMap) { Map mergedPropsMap = new LinkedHashMap<>(resourceMetaData.getStorageUnitMetaDataMap().entrySet().stream() .collect(Collectors.toMap(Entry::getKey, entry -> entry.getValue().getStorageUnit().getDataSourcePoolProperties(), (oldValue, currentValue) -> oldValue, LinkedHashMap::new))); - mergedPropsMap.putAll(storageUnitDataSourcePoolProps); - Map toBeCreatedStorageUintNodeMap = StorageUnitNodeMapUtils.fromDataSourcePoolProperties(storageUnitDataSourcePoolProps); - return new SwitchingResource(resourceMetaData, getRegisterNewStorageResource(resourceMetaData, toBeCreatedStorageUintNodeMap, storageUnitDataSourcePoolProps), + mergedPropsMap.putAll(storageUnitDataSourcePoolPropsMap); + Map toBeCreatedStorageUintNodeMap = StorageUnitNodeMapUtils.fromDataSourcePoolProperties(storageUnitDataSourcePoolPropsMap); + return new SwitchingResource(resourceMetaData, + getRegisterNewStorageResource(resourceMetaData, toBeCreatedStorageUintNodeMap, StorageNodeAggregator.aggregateDataSourcePoolProperties(storageUnitDataSourcePoolPropsMap)), new StorageResource(Collections.emptyMap(), Collections.emptyMap()), mergedPropsMap); } private StorageResource getRegisterNewStorageResource(final ResourceMetaData resourceMetaData, - final Map storageUintNodeMap, final Map storageUnitDataSourcePoolProps) { + final Map storageUintNodeMap, final Map dataSourcePoolPropsMap) { Collection storageNodeNames = storageUintNodeMap.values().stream().map(StorageNode::getName).collect(Collectors.toSet()); - Map storageNodeDataSourcePoolProps = StorageUnitNodeMapUtils.getStorageNodeDataSourcePoolProperties(storageUnitDataSourcePoolProps); Map newStorageNodes = new LinkedHashMap<>(storageNodeNames.size(), 1F); for (StorageNodeName each : storageNodeNames) { if (!resourceMetaData.getDataSources().containsKey(each)) { - newStorageNodes.put(each, DataSourcePoolCreator.create(storageNodeDataSourcePoolProps.get(each))); + newStorageNodes.put(each, DataSourcePoolCreator.create(dataSourcePoolPropsMap.get(each))); } } return new StorageResource(newStorageNodes, storageUintNodeMap); @@ -80,16 +81,16 @@ public SwitchingResource alterStorageUnit(final ResourceMetaData resourceMetaDat .collect(Collectors.toMap(Entry::getKey, entry -> entry.getValue().getStorageUnit().getDataSourcePoolProperties(), (oldValue, currentValue) -> oldValue, LinkedHashMap::new))); mergedDataSourcePoolPropertiesMap.putAll(propsMap); Map toBeAlteredStorageUintNodeMap = StorageUnitNodeMapUtils.fromDataSourcePoolProperties(mergedDataSourcePoolPropertiesMap); - return new SwitchingResource(resourceMetaData, getAlterNewStorageResource(toBeAlteredStorageUintNodeMap, mergedDataSourcePoolPropertiesMap), + return new SwitchingResource(resourceMetaData, + getAlterNewStorageResource(toBeAlteredStorageUintNodeMap, StorageNodeAggregator.aggregateDataSourcePoolProperties(mergedDataSourcePoolPropertiesMap)), getStaleStorageResource(resourceMetaData, toBeAlteredStorageUintNodeMap), mergedDataSourcePoolPropertiesMap); } - private StorageResource getAlterNewStorageResource(final Map storageUintNodeMap, final Map storageUnitDataSourcePoolProps) { + private StorageResource getAlterNewStorageResource(final Map storageUintNodeMap, final Map dataSourcePoolPropsMap) { Collection toBeAlteredStorageNodeNames = storageUintNodeMap.values().stream().map(StorageNode::getName).collect(Collectors.toSet()); - Map storageNodeDataSourcePoolProps = StorageUnitNodeMapUtils.getStorageNodeDataSourcePoolProperties(storageUnitDataSourcePoolProps); Map storageNodes = new LinkedHashMap<>(toBeAlteredStorageNodeNames.size(), 1F); for (StorageNodeName each : toBeAlteredStorageNodeNames) { - storageNodes.put(each, DataSourcePoolCreator.create(storageNodeDataSourcePoolProps.get(each))); + storageNodes.put(each, DataSourcePoolCreator.create(dataSourcePoolPropsMap.get(each))); } return new StorageResource(storageNodes, storageUintNodeMap); } diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/manager/switcher/ResourceSwitchManager.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/manager/switcher/ResourceSwitchManager.java index b42f05bc6d16d..56956920c09f9 100644 --- a/mode/core/src/main/java/org/apache/shardingsphere/mode/manager/switcher/ResourceSwitchManager.java +++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/manager/switcher/ResourceSwitchManager.java @@ -24,6 +24,7 @@ import org.apache.shardingsphere.infra.metadata.database.resource.StorageResource; import org.apache.shardingsphere.infra.metadata.database.resource.node.StorageNode; import org.apache.shardingsphere.infra.metadata.database.resource.node.StorageNodeName; +import org.apache.shardingsphere.infra.metadata.database.resource.node.StorageNodeAggregator; import org.apache.shardingsphere.infra.metadata.database.resource.unit.StorageUnitMetaData; import org.apache.shardingsphere.infra.metadata.database.resource.unit.StorageUnitNodeMapUtils; @@ -52,7 +53,8 @@ public SwitchingResource create(final ResourceMetaData resourceMetaData, final M .collect(Collectors.toMap(Entry::getKey, entry -> entry.getValue().getStorageUnit().getDataSourcePoolProperties(), (oldValue, currentValue) -> oldValue, LinkedHashMap::new))); mergedPropsMap.putAll(toBeChangedPropsMap); Map toBeChangedStorageUnitNodeMap = StorageUnitNodeMapUtils.fromDataSourcePoolProperties(toBeChangedPropsMap); - return new SwitchingResource(resourceMetaData, createNewStorageResource(resourceMetaData, toBeChangedStorageUnitNodeMap, toBeChangedPropsMap), + return new SwitchingResource(resourceMetaData, + createNewStorageResource(resourceMetaData, toBeChangedStorageUnitNodeMap, StorageNodeAggregator.aggregateDataSourcePoolProperties(toBeChangedPropsMap)), getStaleDataSources(resourceMetaData, toBeChangedStorageUnitNodeMap, mergedPropsMap), mergedPropsMap); } @@ -91,15 +93,15 @@ public SwitchingResource createByAlterDataSourcePoolProperties(final ResourceMet staleStorageResource.getStorageUnitNodeMap().putAll( getToBeDeletedStorageUnitNodeMap(resourceMetaData.getStorageUnitMetaDataMap(), toBeChangedStorageUnitNodeMap.keySet())); return new SwitchingResource(resourceMetaData, - createNewStorageResource(resourceMetaData, toBeChangedStorageUnitNodeMap, toBeChangedPropsMap), staleStorageResource, mergedDataSourcePoolPropertiesMap); + createNewStorageResource(resourceMetaData, toBeChangedStorageUnitNodeMap, StorageNodeAggregator.aggregateDataSourcePoolProperties(toBeChangedPropsMap)), + staleStorageResource, mergedDataSourcePoolPropertiesMap); } private StorageResource createNewStorageResource(final ResourceMetaData resourceMetaData, - final Map toBeChangedStorageUnitNodeMap, final Map storageUnitDataSourcePoolProps) { + final Map toBeChangedStorageUnitNodeMap, final Map dataSourcePoolPropsMap) { Collection toBeChangedStorageNodeName = toBeChangedStorageUnitNodeMap.values().stream().map(StorageNode::getName).collect(Collectors.toSet()); - Map storageNodeDataSourcePoolProps = StorageUnitNodeMapUtils.getStorageNodeDataSourcePoolProperties(storageUnitDataSourcePoolProps); Map storageNodes = - getNewStorageNodes(resourceMetaData, toBeChangedStorageNodeName, storageNodeDataSourcePoolProps); + getNewStorageNodes(resourceMetaData, toBeChangedStorageNodeName, dataSourcePoolPropsMap); Map storageUnitNodeMap = getNewStorageUnitNodeMap(resourceMetaData, toBeChangedStorageUnitNodeMap); return new StorageResource(storageNodes, storageUnitNodeMap); } @@ -166,16 +168,15 @@ private StorageResource getToBeRemovedStaleDataSources(final ResourceMetaData re } private StorageResource getStaleDataSources(final ResourceMetaData resourceMetaData, final Map toBeChangedStorageUnitNodeMap, - final Map storageUnitDataSourcePoolProps) { + final Map storageUnitDataSourcePoolPropsMap) { Map storageNodes = new LinkedHashMap<>(resourceMetaData.getDataSources().size(), 1F); Map storageUnitNodeMap = new LinkedHashMap<>(resourceMetaData.getStorageUnitMetaDataMap().size(), 1F); - storageNodes.putAll(getToBeChangedDataSources(resourceMetaData.getDataSources(), StorageUnitNodeMapUtils.getStorageNodeDataSourcePoolProperties(storageUnitDataSourcePoolProps))); + storageNodes.putAll(getToBeChangedDataSources(resourceMetaData.getDataSources(), StorageNodeAggregator.aggregateDataSourcePoolProperties(storageUnitDataSourcePoolPropsMap))); storageUnitNodeMap.putAll(getChangedStorageUnitNodeMap(resourceMetaData.getStorageUnitMetaDataMap(), toBeChangedStorageUnitNodeMap)); return new StorageResource(storageNodes, storageUnitNodeMap); } - private Map getToBeChangedDataSources(final Map storageNodes, - final Map propsMap) { + private Map getToBeChangedDataSources(final Map storageNodes, final Map propsMap) { Map result = new LinkedHashMap<>(storageNodes.size(), 1F); for (Entry entry : propsMap.entrySet()) { StorageNodeName storageNodeName = entry.getKey(); 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 b9329f189fe00..bf6bcdf42c7b7 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 @@ -30,7 +30,7 @@ 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.node.StorageNodeName; -import org.apache.shardingsphere.infra.metadata.database.resource.node.StorageNodeUtils; +import org.apache.shardingsphere.infra.metadata.database.resource.node.StorageNodeAggregator; import org.apache.shardingsphere.infra.metadata.database.resource.unit.StorageUnitMetaData; import org.apache.shardingsphere.infra.metadata.database.resource.unit.StorageUnitNodeMapUtils; import org.apache.shardingsphere.infra.metadata.database.rule.RuleMetaData; @@ -226,7 +226,7 @@ private void assertAlteredDataSource(final MockedDataSource actual) { void assertAlterRuleConfiguration() { ResourceMetaData resourceMetaData = mock(ResourceMetaData.class, RETURNS_DEEP_STUBS); Map dataSources = Collections.singletonMap("foo_ds", new MockedDataSource()); - when(resourceMetaData.getDataSources()).thenReturn(StorageNodeUtils.getStorageNodeDataSources(dataSources)); + when(resourceMetaData.getDataSources()).thenReturn(StorageNodeAggregator.aggregateDataSources(dataSources)); when(resourceMetaData.getStorageUnitMetaDataMap()).thenReturn(Collections.emptyMap()); ShardingSphereDatabase database = new ShardingSphereDatabase("foo_db", TypedSPILoader.getService(DatabaseType.class, "FIXTURE"), resourceMetaData, mock(RuleMetaData.class), Collections.emptyMap()); @@ -254,7 +254,7 @@ private ResourceMetaData createOriginalResource() { Map originalDataSources = new LinkedHashMap<>(2, 1F); originalDataSources.put("ds_1", new MockedDataSource()); originalDataSources.put("ds_2", new MockedDataSource()); - Map storageNodeDataSourceMap = StorageNodeUtils.getStorageNodeDataSources(originalDataSources); + Map storageNodeDataSourceMap = StorageNodeAggregator.aggregateDataSources(originalDataSources); Map storageUnitNodeMap = StorageUnitNodeMapUtils.fromDataSources(originalDataSources); Map metaDataMap = new LinkedHashMap<>(2, 1F); for (Entry entry : storageUnitNodeMap.entrySet()) {