You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/01/24 15:22:52 UTC

[GitHub] [shardingsphere] terrymanu commented on a change in pull request #15020: MGRDatabaseDiscoveryType add check data source does it exist mgr group.

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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org