This is an automated email from the ASF dual-hosted git repository.

menghaoran 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 162ce33  modify governance api reference in JDBCTrafficExecutor 
(#14564)
162ce33 is described below

commit 162ce334a8fee98a892c357454aa0c391158e011
Author: Zhengqiang Duan <[email protected]>
AuthorDate: Thu Jan 6 14:55:11 2022 +0800

    modify governance api reference in JDBCTrafficExecutor (#14564)
---
 .../shardingsphere/traffic/executor/jdbc/JDBCTrafficExecutor.java | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git 
a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/main/java/org/apache/shardingsphere/traffic/executor/jdbc/JDBCTrafficExecutor.java
 
b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/main/java/org/apache/shardingsphere/traffic/executor/jdbc/JDBCTrafficExecutor.java
index 96fe1b7..4701588 100644
--- 
a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/main/java/org/apache/shardingsphere/traffic/executor/jdbc/JDBCTrafficExecutor.java
+++ 
b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/main/java/org/apache/shardingsphere/traffic/executor/jdbc/JDBCTrafficExecutor.java
@@ -25,6 +25,7 @@ import 
org.apache.shardingsphere.infra.database.metadata.DataSourceMetaData;
 import org.apache.shardingsphere.infra.database.type.DatabaseTypeRegistry;
 import org.apache.shardingsphere.infra.exception.ShardingSphereException;
 import org.apache.shardingsphere.infra.instance.ComputeNodeInstance;
+import org.apache.shardingsphere.infra.instance.InstanceId;
 import org.apache.shardingsphere.infra.instance.InstanceType;
 import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
 import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
@@ -88,7 +89,7 @@ public final class JDBCTrafficExecutor implements 
TrafficExecutor {
                                                                          final 
DataSourceConfiguration dataSourceConfigSample, final String schema) {
         Map<String, DataSourceConfiguration> result = new LinkedHashMap<>();
         for (ComputeNodeInstance each : instances) {
-            result.put(each.getIp() + "@" + each.getPort(), 
createDataSourceConfig(each, dataSourceConfigSample, schema));
+            result.put(each.getInstanceDefinition().getInstanceId().getId(), 
createDataSourceConfig(each, dataSourceConfigSample, schema));
         }
         return result;
     }
@@ -112,8 +113,9 @@ public final class JDBCTrafficExecutor implements 
TrafficExecutor {
         String jdbcUrl = String.valueOf(props.get(JDBC_URL));
         String username = String.valueOf(props.get(USER_NAME));
         DataSourceMetaData dataSourceMetaData = 
DatabaseTypeRegistry.getDatabaseTypeByURL(jdbcUrl).getDataSourceMetaData(jdbcUrl,
 username);
-        return jdbcUrl.replace(dataSourceMetaData.getHostname(), 
instance.getIp())
-                .replace(String.valueOf(dataSourceMetaData.getPort()), 
instance.getPort()).replace(dataSourceMetaData.getCatalog(), schema);
+        InstanceId instanceId = 
instance.getInstanceDefinition().getInstanceId();
+        return jdbcUrl.replace(dataSourceMetaData.getHostname(), 
instanceId.getIp())
+                .replace(String.valueOf(dataSourceMetaData.getPort()), 
String.valueOf(instanceId.getPort()).replace(dataSourceMetaData.getCatalog(), 
schema));
     }
     
     @SuppressWarnings({"unchecked", "rawtypes"})

Reply via email to