terrymanu commented on a change in pull request #15020:
URL: https://github.com/apache/shardingsphere/pull/15020#discussion_r790848814



##########
File path: 
shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-mgr/src/main/java/org/apache/shardingsphere/dbdiscovery/mgr/MGRDatabaseDiscoveryType.java
##########
@@ -114,6 +116,27 @@ private void checkIsSinglePrimaryMode(final Statement 
statement) throws SQLExcep
         }
     }
     
+    private void checkDataSourceInReplicationGroup(final Statement statement, 
final Map<String, DataSource> dataSourceMap) throws SQLException {
+        List<String> memberDataSourceURLs = new ArrayList<>();
+        try (ResultSet resultSet = statement.executeQuery(MEMBER_LIST)) {
+            while (resultSet.next()) {
+                memberDataSourceURLs.add(String.format("%s:%s", 
resultSet.getString("MEMBER_HOST"), resultSet.getString("MEMBER_PORT")));
+            }
+        }
+        for (Entry<String, DataSource> entry : dataSourceMap.entrySet()) {
+            boolean exist = false;

Review comment:
       How about extract them to a private method to check existed?

##########
File path: 
shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-mgr/src/main/java/org/apache/shardingsphere/dbdiscovery/mgr/MGRDatabaseDiscoveryType.java
##########
@@ -114,6 +116,27 @@ private void checkIsSinglePrimaryMode(final Statement 
statement) throws SQLExcep
         }
     }
     
+    private void checkDataSourceInReplicationGroup(final Statement statement, 
final Map<String, DataSource> dataSourceMap) throws SQLException {
+        List<String> memberDataSourceURLs = new ArrayList<>();

Review comment:
       It is better use Collection and LinkedList if do not use 
memberDataSourceURLs.get(i)




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to