diff --git a/infra/common/src/main/java/org/apache/shardingsphere/infra/state/datasource/DataSourceStateManager.java b/infra/common/src/main/java/org/apache/shardingsphere/infra/state/datasource/DataSourceStateManager.java index 30935c38d53ac..0a52864bb6662 100644 --- a/infra/common/src/main/java/org/apache/shardingsphere/infra/state/datasource/DataSourceStateManager.java +++ b/infra/common/src/main/java/org/apache/shardingsphere/infra/state/datasource/DataSourceStateManager.java @@ -23,6 +23,7 @@ import org.apache.shardingsphere.infra.config.database.DatabaseConfiguration; import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions; import org.apache.shardingsphere.infra.metadata.database.resource.unit.StorageUnit; +import org.apache.shardingsphere.infra.metadata.database.schema.QualifiedDataSource; import org.apache.shardingsphere.infra.state.datasource.exception.UnavailableDataSourceException; import javax.sql.DataSource; @@ -148,12 +149,11 @@ private void checkForceConnection(final Map dataSources) { /** * Update data source state. * - * @param databaseName database name - * @param actualDataSourceName actual data source name + * @param qualifiedDataSource qualified data source * @param dataSourceState data source state */ - public void updateState(final String databaseName, final String actualDataSourceName, final DataSourceState dataSourceState) { - dataSourceStates.put(getCacheKey(databaseName, actualDataSourceName), dataSourceState); + public void updateState(final QualifiedDataSource qualifiedDataSource, final DataSourceState dataSourceState) { + dataSourceStates.put(getCacheKey(qualifiedDataSource.getDatabaseName(), qualifiedDataSource.getDataSourceName()), dataSourceState); } private String getCacheKey(final String databaseName, final String dataSourceName) { diff --git a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/subscriber/StateChangedSubscriber.java b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/subscriber/StateChangedSubscriber.java index 1ca255a7bb12f..4cbdb49f595f8 100644 --- a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/subscriber/StateChangedSubscriber.java +++ b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/subscriber/StateChangedSubscriber.java @@ -63,8 +63,7 @@ public synchronized void renew(final StorageNodeChangedEvent event) { if (!contextManager.getMetaDataContexts().getMetaData().containsDatabase(qualifiedDataSource.getDatabaseName())) { return; } - DataSourceStateManager.getInstance().updateState( - qualifiedDataSource.getDatabaseName(), qualifiedDataSource.getDataSourceName(), DataSourceState.valueOf(event.getDataSource().getStatus().name())); + DataSourceStateManager.getInstance().updateState(qualifiedDataSource, DataSourceState.valueOf(event.getDataSource().getStatus().name())); ShardingSphereDatabase database = contextManager.getMetaDataContexts().getMetaData().getDatabase(qualifiedDataSource.getDatabaseName()); for (StaticDataSourceRuleAttribute each : database.getRuleMetaData().getAttributes(StaticDataSourceRuleAttribute.class)) { each.updateStatus(qualifiedDataSource, event.getDataSource().getStatus());