This is an automated email from the ASF dual-hosted git repository.

wusheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/skywalking.git


The following commit(s) were added to refs/heads/master by this push:
     new 7958ba9  Fix bug: state not updated when GRPC auto reconnect to the 
same server (#3181)
7958ba9 is described below

commit 7958ba9affd4e6140005f764d358ce9666589ace
Author: kezhenxu94 <[email protected]>
AuthorDate: Mon Jul 29 12:57:07 2019 +0800

    Fix bug: state not updated when GRPC auto reconnect to the same server 
(#3181)
---
 .../org/apache/skywalking/apm/agent/core/remote/GRPCChannel.java  | 5 +++++
 .../skywalking/apm/agent/core/remote/GRPCChannelManager.java      | 8 +++++++-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git 
a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/remote/GRPCChannel.java
 
b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/remote/GRPCChannel.java
old mode 100644
new mode 100755
index 12756cc..267d3cc
--- 
a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/remote/GRPCChannel.java
+++ 
b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/remote/GRPCChannel.java
@@ -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;
diff --git 
a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/remote/GRPCChannelManager.java
 
b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/remote/GRPCChannelManager.java
old mode 100644
new mode 100755
index 62458f8..f9213dd
--- 
a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/remote/GRPCChannelManager.java
+++ 
b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/remote/GRPCChannelManager.java
@@ -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);

Reply via email to