Fix bug: state not updated when GRPC auto reconnect to the same server (#3181)
This commit is contained in:
parent
d66f775fe5
commit
7958ba9aff
5
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/remote/GRPCChannel.java
Normal file → Executable file
5
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/remote/GRPCChannel.java
Normal file → Executable file
|
|
@ -19,6 +19,7 @@
|
|||
package org.apache.skywalking.apm.agent.core.remote;
|
||||
|
||||
import io.grpc.Channel;
|
||||
import io.grpc.ConnectivityState;
|
||||
import io.grpc.ManagedChannel;
|
||||
import io.grpc.ManagedChannelBuilder;
|
||||
import io.grpc.netty.NettyChannelBuilder;
|
||||
|
|
@ -73,6 +74,10 @@ public class GRPCChannel {
|
|||
return originChannel.isShutdown();
|
||||
}
|
||||
|
||||
public boolean isConnected() {
|
||||
return originChannel.getState(false) == ConnectivityState.READY;
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private final String host;
|
||||
private final int port;
|
||||
|
|
|
|||
8
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/remote/GRPCChannelManager.java
Normal file → Executable file
8
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/remote/GRPCChannelManager.java
Normal file → Executable file
|
|
@ -105,9 +105,15 @@ public class GRPCChannelManager implements BootService, Runnable {
|
|||
.build();
|
||||
|
||||
notify(GRPCChannelStatus.CONNECTED);
|
||||
reconnect = false;
|
||||
} else if (managedChannel.isConnected()) {
|
||||
// Reconnect to the same server is automatically done by GRPC,
|
||||
// therefore we are responsible to check the connectivity and
|
||||
// set the state and notify listeners
|
||||
notify(GRPCChannelStatus.CONNECTED);
|
||||
reconnect = false;
|
||||
}
|
||||
|
||||
reconnect = false;
|
||||
return;
|
||||
} catch (Throwable t) {
|
||||
logger.error(t, "Create channel to {} fail.", server);
|
||||
|
|
|
|||
Loading…
Reference in New Issue