funky-eyes commented on code in PR #7069:
URL: https://github.com/apache/incubator-seata/pull/7069#discussion_r1895184697


##########
discovery/seata-discovery-raft/src/main/java/org/apache/seata/discovery/registry/raft/RaftRegistryServiceImpl.java:
##########
@@ -276,9 +294,82 @@ private static boolean isTokenExpired() {
         return System.currentTimeMillis() >= tokenExpiredTime;
     }
 
-    private InetSocketAddress convertInetSocketAddress(Node node) {
-        Node.Endpoint endpoint = node.getTransaction();
-        return new InetSocketAddress(endpoint.getHost(), endpoint.getPort());
+    private static String selectControlEndpointStr(Node node) {
+        InetSocketAddress control = selectControlEndpoint(node);
+        return NetUtil.toStringAddress(control);
+    }
+
+    private static String selectTransactionEndpointStr(Node node) {
+        InetSocketAddress transaction = selectTransactionEndpoint( node);
+        return NetUtil.toStringAddress(transaction);
+    }
+
+    private static InetSocketAddress selectControlEndpoint(Node node) {
+        return selectEndpoint("control", node);
+    }
+
+    private static InetSocketAddress selectTransactionEndpoint(Node node) {
+        return selectEndpoint("transaction", node);
+    }
+
+    private static InetSocketAddress selectEndpoint(String type, Node node) {
+        if (StringUtils.isBlank(PREFERRED_NETWORKS)) {
+            // 采取默认的方式,直接使用node.control  node.transaction

Review Comment:
   ```suggestion
               // Use the default method, directly using node.control and 
node.transaction
   ```



##########
server/src/main/java/org/apache/seata/server/cluster/raft/RaftStateMachine.java:
##########
@@ -366,7 +366,7 @@ public RaftClusterMetadata 
changeOrInitRaftClusterMetadata() {
                     Integer.parseInt(
                         
((Environment)ObjectHolder.INSTANCE.getObject(OBJECT_KEY_SPRING_CONFIGURABLE_ENVIRONMENT))
                             .getProperty("server.port", String.valueOf(7091))),
-                    group, Collections.emptyMap());
+                    group, new HashMap<>());

Review Comment:
   Why change to new HashMap < > ()



##########
discovery/seata-discovery-raft/src/main/java/org/apache/seata/discovery/registry/raft/RaftRegistryServiceImpl.java:
##########
@@ -276,9 +294,82 @@ private static boolean isTokenExpired() {
         return System.currentTimeMillis() >= tokenExpiredTime;
     }
 
-    private InetSocketAddress convertInetSocketAddress(Node node) {
-        Node.Endpoint endpoint = node.getTransaction();
-        return new InetSocketAddress(endpoint.getHost(), endpoint.getPort());
+    private static String selectControlEndpointStr(Node node) {
+        InetSocketAddress control = selectControlEndpoint(node);
+        return NetUtil.toStringAddress(control);
+    }
+
+    private static String selectTransactionEndpointStr(Node node) {
+        InetSocketAddress transaction = selectTransactionEndpoint( node);
+        return NetUtil.toStringAddress(transaction);
+    }
+
+    private static InetSocketAddress selectControlEndpoint(Node node) {
+        return selectEndpoint("control", node);
+    }
+
+    private static InetSocketAddress selectTransactionEndpoint(Node node) {
+        return selectEndpoint("transaction", node);
+    }
+
+    private static InetSocketAddress selectEndpoint(String type, Node node) {
+        if (StringUtils.isBlank(PREFERRED_NETWORKS)) {

Review Comment:
   请增加这些方法的测试用例
   Please add test cases for these methods



##########
server/src/main/java/org/apache/seata/server/cluster/raft/sync/msg/dto/RaftClusterMetadata.java:
##########
@@ -55,6 +58,10 @@ public Node createNode(String host, int txPort, int 
internalPort, int controlPor
         node.setGroup(group);
         node.setVersion(Version.getCurrent());
         node.setInternal(node.createEndpoint(host, internalPort, "raft"));
+        String serverRegistryMetadataExternalValue = 
System.getProperty("SERVER_REGISTRY_METADATA_EXTERNAL_VALUE");

Review Comment:
   不应该这样读取,如果有用户直接使用properties配置文件去配置怎么办?应该通过下面这样的方式读取
   It should not be read like this. What if a user directly uses the properties 
configuration file to configure it? It should be read in the following way
   ```
   ConfigurableEnvironment 
environment=ObjectHolder.INSTANCE.getObject(OBJECT_KEY_SPRING_CONFIGURABLE_ENVIRONMENT);
   
environment.resolvePlaceholders("${seata.registry.metadata.external:${registry.metadata.external:}}")
   ```
   



##########
server/src/main/java/org/apache/seata/server/cluster/raft/RaftStateMachine.java:
##########
@@ -406,7 +406,7 @@ private void syncCurrentNodeInfo(PeerId leaderPeerId) {
                     Integer.parseInt(
                         
((Environment)ObjectHolder.INSTANCE.getObject(OBJECT_KEY_SPRING_CONFIGURABLE_ENVIRONMENT))
                             .getProperty("server.port", String.valueOf(7091))),
-                    group, Collections.emptyMap());
+                    group, new HashMap<>());

Review Comment:
   ditto



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to