未验证 提交 100823cb 编写于 作者: L Leon Yang 提交者: GitHub

Support DNS period resolving mechanism (#6240)

上级 43e2458e
......@@ -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 periodic resolving mechanism to update backend service.
#### OAP-Backend
* Make meter receiver support MAL.
......
......@@ -163,11 +163,14 @@ public class Config {
* 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.
*/
public static boolean IS_RESOLVE_DNS_PERIODICALLY = false;
}
public static class Profile {
......
......@@ -21,6 +21,8 @@ package org.apache.skywalking.apm.agent.core.remote;
import io.grpc.Channel;
import io.grpc.Status;
import io.grpc.StatusRuntimeException;
import java.net.InetAddress;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
......@@ -29,6 +31,8 @@ import java.util.Random;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import org.apache.skywalking.apm.agent.core.boot.BootService;
import org.apache.skywalking.apm.agent.core.boot.DefaultImplementor;
import org.apache.skywalking.apm.agent.core.boot.DefaultNamedThreadFactory;
......@@ -37,6 +41,8 @@ import org.apache.skywalking.apm.agent.core.logging.api.ILog;
import org.apache.skywalking.apm.agent.core.logging.api.LogManager;
import org.apache.skywalking.apm.util.RunnableWithExceptionProtection;
import static org.apache.skywalking.apm.agent.core.conf.Config.Collector.IS_RESOLVE_DNS_PERIODICALLY;
@DefaultImplementor
public class GRPCChannelManager implements BootService, Runnable {
private static final ILog LOGGER = LogManager.getLogger(GRPCChannelManager.class);
......@@ -92,6 +98,23 @@ public class GRPCChannelManager implements BootService, Runnable {
@Override
public void run() {
LOGGER.debug("Selected collector grpc service running, reconnect:{}.", reconnect);
if (IS_RESOLVE_DNS_PERIODICALLY && reconnect) {
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);
}
}
if (reconnect) {
if (grpcServers.size() > 0) {
String server = "";
......
......@@ -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.|`false`|
`logging.level`|Log level: TRACE, DEBUG, INFO, WARN, ERROR, OFF. Default is info.|`INFO`|
`logging.file_name`|Log file name.|`skywalking-api.log`|
`logging.output`| Log output. Default is FILE. Use CONSOLE means output to stdout. |`FILE`|
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册