Fix bug that the agent heart beats too frequently (#4640)
* Fix bug that the agent heart beats too frequently Co-authored-by: 吴晟 Wu Sheng <wu.sheng@foxmail.com>
This commit is contained in:
parent
4ce2e9e873
commit
00e8f2d886
|
|
@ -117,9 +117,9 @@ public class Config {
|
|||
*/
|
||||
public static long GRPC_CHANNEL_CHECK_INTERVAL = 30;
|
||||
/**
|
||||
* service and endpoint registry check interval
|
||||
* The period in which the agent report a heartbeat to the backend.
|
||||
*/
|
||||
public static long APP_AND_SERVICE_REGISTER_CHECK_INTERVAL = 3;
|
||||
public static long HEARTBEAT_PERIOD = 30;
|
||||
/**
|
||||
* Collector skywalking trace receiver service addresses.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ public class ServiceManagementClient implements BootService, Runnable, GRPCChann
|
|||
|
||||
private volatile GRPCChannelStatus status = GRPCChannelStatus.DISCONNECT;
|
||||
private volatile ManagementServiceGrpc.ManagementServiceBlockingStub managementServiceBlockingStub;
|
||||
private volatile ScheduledFuture<?> serviceRegisterFuture;
|
||||
private volatile ScheduledFuture<?> heartbeatFuture;
|
||||
private volatile boolean instancePropertiesSubmitted = false;
|
||||
|
||||
@Override
|
||||
|
|
@ -85,13 +85,13 @@ public class ServiceManagementClient implements BootService, Runnable, GRPCChann
|
|||
|
||||
@Override
|
||||
public void boot() {
|
||||
serviceRegisterFuture = Executors.newSingleThreadScheduledExecutor(
|
||||
new DefaultNamedThreadFactory("ServiceRegisterClient")
|
||||
heartbeatFuture = Executors.newSingleThreadScheduledExecutor(
|
||||
new DefaultNamedThreadFactory("ServiceManagementClient")
|
||||
).scheduleAtFixedRate(
|
||||
new RunnableWithExceptionProtection(
|
||||
this,
|
||||
t -> logger.error("unexpected exception.", t)
|
||||
), 0, Config.Collector.APP_AND_SERVICE_REGISTER_CHECK_INTERVAL,
|
||||
), 0, Config.Collector.HEARTBEAT_PERIOD,
|
||||
TimeUnit.SECONDS
|
||||
);
|
||||
}
|
||||
|
|
@ -102,14 +102,14 @@ public class ServiceManagementClient implements BootService, Runnable, GRPCChann
|
|||
|
||||
@Override
|
||||
public void shutdown() {
|
||||
serviceRegisterFuture.cancel(true);
|
||||
heartbeatFuture.cancel(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
logger.debug("ServiceManagementClient running, status:{}.", status);
|
||||
|
||||
while (GRPCChannelStatus.CONNECTED.equals(status)) {
|
||||
if (GRPCChannelStatus.CONNECTED.equals(status)) {
|
||||
try {
|
||||
if (managementServiceBlockingStub != null) {
|
||||
if (!instancePropertiesSubmitted) {
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ property key | Description | Default |
|
|||
`agent.operation_name_threshold `|The operationName max length, setting this value > 190 is not recommended.|`150`|
|
||||
`agent.keep_tracing`|Keep tracing even the backend is not available if this value is `true`.|`false`|
|
||||
`collector.grpc_channel_check_interval`|grpc channel status check interval.|`30`|
|
||||
`collector.app_and_service_register_check_interval`|application and service registry check interval.|`3`|
|
||||
`collector.heartbeat_period`|agent heartbeat report period. Unit, second.|`30`|
|
||||
`collector.backend_service`|Collector SkyWalking trace receiver service addresses.|`127.0.0.1:11800`|
|
||||
`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`|
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ healthCheck http://localhost:12800/receiveData
|
|||
# start applications
|
||||
export agent_opts="-javaagent:${SCENARIO_HOME}/agent/skywalking-agent.jar
|
||||
-Dskywalking.collector.grpc_channel_check_interval=2
|
||||
-Dskywalking.collector.app_and_service_register_check_interval=2
|
||||
-Dskywalking.collector.heartbeat_period=2
|
||||
-Dskywalking.collector.discovery_check_interval=2
|
||||
-Dskywalking.collector.backend_service=localhost:19876
|
||||
-Dskywalking.agent.service_name=${SCENARIO_NAME}
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ echo "${AGENT_FILE_PATH}/skywalking-agent.jar"
|
|||
if [ -f "${AGENT_FILE_PATH}/skywalking-agent.jar" ]; then
|
||||
CATALINA_OPTS="$CATALINA_OPTS -javaagent:${AGENT_FILE_PATH}/skywalking-agent.jar
|
||||
-Dskywalking.collector.grpc_channel_check_interval=2
|
||||
-Dskywalking.collector.app_and_service_register_check_interval=2
|
||||
-Dskywalking.collector.heartbeat_period=2
|
||||
-Dskywalking.collector.discovery_check_interval=2
|
||||
-Dskywalking.collector.backend_service=localhost:19876
|
||||
-Dskywalking.agent.service_name=${SCENARIO_NAME}
|
||||
|
|
|
|||
Loading…
Reference in New Issue