提交 7958ba9a 编写于 作者: K kezhenxu94 提交者: wu-sheng

Fix bug: state not updated when GRPC auto reconnect to the same server (#3181)

上级 d66f775f
......@@ -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;
......
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册