This is an automated email from the ASF dual-hosted git repository.
zhaojinchao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new b5c2157df1b [bug]databaseDiscovery can not find master (#18944)
b5c2157df1b is described below
commit b5c2157df1bd7f67f3ed5f188f66272c46e1b7de
Author: natehuang <[email protected]>
AuthorDate: Tue Sep 27 11:27:31 2022 +0800
[bug]databaseDiscovery can not find master (#18944)
---
.../dbdiscovery/algorithm/DatabaseDiscoveryEngine.java | 11 +----------
1 file changed, 1 insertion(+), 10 deletions(-)
diff --git
a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/algorithm/DatabaseDiscoveryEngine.java
b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/algorithm/DatabaseDiscoveryEngine.java
index 87a36fe1909..02c18a4e2a2 100644
---
a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/algorithm/DatabaseDiscoveryEngine.java
+++
b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/algorithm/DatabaseDiscoveryEngine.java
@@ -33,7 +33,6 @@ import
org.apache.shardingsphere.mode.metadata.storage.event.PrimaryDataSourceCh
import javax.sql.DataSource;
import java.sql.SQLException;
import java.util.Collection;
-import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Optional;
@@ -81,7 +80,7 @@ public final class DatabaseDiscoveryEngine {
}
private Optional<String> findPrimaryDataSourceName(final Map<String,
DataSource> dataSourceMap, final Collection<String> disabledDataSourceNames) {
- for (Entry<String, DataSource> entry :
getActiveDataSourceMap(dataSourceMap, disabledDataSourceNames).entrySet()) {
+ for (Entry<String, DataSource> entry : dataSourceMap.entrySet()) {
try {
if
(databaseDiscoveryProviderAlgorithm.isPrimaryInstance(entry.getValue())) {
return Optional.of(entry.getKey());
@@ -93,14 +92,6 @@ public final class DatabaseDiscoveryEngine {
return Optional.empty();
}
- private Map<String, DataSource> getActiveDataSourceMap(final Map<String,
DataSource> dataSourceMap, final Collection<String> disabledDataSourceNames) {
- Map<String, DataSource> result = new HashMap<>(dataSourceMap);
- if (!disabledDataSourceNames.isEmpty()) {
- result.entrySet().removeIf(each ->
disabledDataSourceNames.contains(each.getKey()));
- }
- return result;
- }
-
private void postReplicaDataSourceDisabledEvent(final String databaseName,
final String groupName, final String primaryDataSourceName,
final Map<String,
DataSource> dataSourceMap, final Collection<String> disabledDataSourceNames) {
int enabledReplicasCount = dataSourceMap.size() -
disabledDataSourceNames.size() - 1;