wu-sheng commented on a change in pull request #6240:
URL: https://github.com/apache/skywalking/pull/6240#discussion_r561735751



##########
File path: 
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/Config.java
##########
@@ -163,11 +163,14 @@
          * Get profile task list interval
          */
         public static int GET_PROFILE_TASK_INTERVAL = 20;
-
         /**
          * Get agent dynamic config interval
          */
         public static int GET_AGENT_DYNAMIC_CONFIG_INTERVAL = 20;
+        /**
+         * If true, skywalking agent will enable periodically resolving DNS to 
update receiver service addresses. Otherwise disable

Review comment:
       ```suggestion
            * If true, skywalking agent will enable periodically resolving DNS 
to update receiver service addresses. 
   ```

##########
File path: 
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/Config.java
##########
@@ -163,11 +163,14 @@
          * Get profile task list interval
          */
         public static int GET_PROFILE_TASK_INTERVAL = 20;
-
         /**
          * Get agent dynamic config interval
          */
         public static int GET_AGENT_DYNAMIC_CONFIG_INTERVAL = 20;
+        /**
+         * If true, skywalking agent will enable periodically resolving DNS to 
update receiver service addresses. Otherwise disable
+         */
+        public static boolean DNS_PERIOD_RESOLVE_ACTIVE = false;

Review comment:
       ```suggestion
           public static boolean IS_RESOLVE_DNS_PERIODICALLY = false;
   ```
   I think the current naming style is like this.

##########
File path: 
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/remote/GRPCChannelManager.java
##########
@@ -91,6 +97,23 @@ public void shutdown() {
 
     @Override
     public void run() {
+        if (DNS_PERIOD_RESOLVE_ACTIVE) {
+            String backendService = 
Config.Collector.BACKEND_SERVICE.split(",")[0];
+            try {
+                String[] domainAndPort = backendService.split(":");
+
+                List<String> newGrpcServers = Arrays
+                        .stream(InetAddress.getAllByName(domainAndPort[0]))
+                        .map(InetAddress::getHostAddress)
+                        .map(ip -> String.format("%s:%s", ip, 
domainAndPort[1]))
+                        .collect(Collectors.toList());
+
+                grpcServers = newGrpcServers;
+            } catch (Throwable t) {
+                LOGGER.error(t, "Failed to resolve {} of backend service.", 
backendService);
+            }
+        }
+

Review comment:
       I think this should be called only when gRPC connection available. 
`reconnect==true`

##########
File path: docs/en/setup/service-agent/java-agent/README.md
##########
@@ -95,6 +95,7 @@ property key | Description | Default |
 `collector.grpc_upstream_timeout`|How long grpc client will timeout in sending 
data to upstream. Unit is second.|`30` seconds|
 `collector.get_profile_task_interval`|Sniffer get profile task list 
interval.|`20`|
 `collector.get_agent_dynamic_config_interval`|Sniffer get agent dynamic config 
interval|`20`|
+`collector.dns_period_resolve_active`|If true, skywalking agent will enable 
periodically resolving DNS to update receiver service addresses. Otherwise 
disable|`false`|

Review comment:
       ```suggestion
   `collector.dns_period_resolve_active`|If true, skywalking agent will enable 
periodically resolving DNS to update receiver service addresses. |`false`|
   ```
   
   Also should follow latest naming suggestion.

##########
File path: CHANGES.md
##########
@@ -37,6 +37,7 @@ Release Notes.
 * Fix RestTemplate plugin recording url tag with wrong port
 * Support collecting logs and forwarding through gRPC.
 * Support config `agent.sample_n_per_3_secs` can be changed in the runtime.
+* Support DNS period resolving mechanism to update backend service.

Review comment:
       ```suggestion
   * Support DNS periodic resolving mechanism to update backend service 
addresses.
   ```




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

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


Reply via email to