zjcnb commented on a change in pull request #15020:
URL: https://github.com/apache/shardingsphere/pull/15020#discussion_r791490580
##########
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 +115,31 @@ private void checkIsSinglePrimaryMode(final Statement
statement) throws SQLExcep
}
}
+ private void checkDataSourceInReplicationGroup(final Statement statement,
final Map<String, DataSource> dataSourceMap) throws SQLException {
+ Collection<String> memberDataSourceURLs = new LinkedList<>();
+ 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()) {
+ checkDataSourceExistGroupMember(entry.getKey(), entry.getValue(),
memberDataSourceURLs);
+ }
+ }
+
+ private void checkDataSourceExistGroupMember(final String datasourceName,
final DataSource dataSource, final Collection<String> memberDataSourceURLs)
throws SQLException {
Review comment:
Ok.
##########
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 +115,31 @@ private void checkIsSinglePrimaryMode(final Statement
statement) throws SQLExcep
}
}
+ private void checkDataSourceInReplicationGroup(final Statement statement,
final Map<String, DataSource> dataSourceMap) throws SQLException {
+ Collection<String> memberDataSourceURLs = new LinkedList<>();
+ 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()) {
+ checkDataSourceExistGroupMember(entry.getKey(), entry.getValue(),
memberDataSourceURLs);
+ }
+ }
+
+ private void checkDataSourceExistGroupMember(final String datasourceName,
final DataSource dataSource, final Collection<String> memberDataSourceURLs)
throws SQLException {
+ boolean exist = false;
Review comment:
Done.
--
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]