hzhaop commented on code in PR #777:
URL: https://github.com/apache/skywalking-java/pull/777#discussion_r2501490545


##########
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/remote/GRPCChannelManager.java:
##########
@@ -130,32 +141,33 @@ public void run() {
                 String server = "";
                 try {
                     int index = Math.abs(random.nextInt()) % 
grpcServers.size();
+
+                    server = grpcServers.get(index);
+                    String[] ipAndPort = server.split(":");
+
                     if (index != selectedIdx) {
                         selectedIdx = index;
+                        LOGGER.debug("Connecting to different gRPC server {}. 
Shutting down existing channel if any.", server);
+                        createNewChannel(ipAndPort[0], 
Integer.parseInt(ipAndPort[1]));
+                    } else {
+                        // Same server, increment reconnectCount and check 
state
+                        reconnectCount++;

Review Comment:
   The reconnectCount modifications are safe because run() is executed by a 
single-threaded ScheduledExecutor, ensuring no concurrent access occurs.



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