You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ratis.apache.org by sz...@apache.org on 2020/09/28 11:26:03 UTC

[incubator-ratis] branch master updated: RATIS-1072: Should not shutdown and re-create channel/stub in GrpcServerProtocolClient when StreamObserver::onError() is called. (#206) Contributed by Glen Geng

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

szetszwo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ratis.git


The following commit(s) were added to refs/heads/master by this push:
     new 5b435ec  RATIS-1072: Should not shutdown and re-create channel/stub in GrpcServerProtocolClient when StreamObserver::onError() is called. (#206)  Contributed by Glen Geng
5b435ec is described below

commit 5b435ec1c749d20b1e147798fca43ed764620e2b
Author: GlenGeng <gl...@tencent.com>
AuthorDate: Mon Sep 28 19:25:57 2020 +0800

    RATIS-1072: Should not shutdown and re-create channel/stub in GrpcServerProtocolClient when StreamObserver::onError() is called. (#206)  Contributed by Glen Geng
---
 .../main/java/org/apache/ratis/grpc/server/GrpcLogAppender.java    | 7 ++++++-
 .../org/apache/ratis/grpc/server/GrpcServerProtocolClient.java     | 5 +++++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/ratis-grpc/src/main/java/org/apache/ratis/grpc/server/GrpcLogAppender.java b/ratis-grpc/src/main/java/org/apache/ratis/grpc/server/GrpcLogAppender.java
index 84d1a09..8fbcc25 100644
--- a/ratis-grpc/src/main/java/org/apache/ratis/grpc/server/GrpcLogAppender.java
+++ b/ratis-grpc/src/main/java/org/apache/ratis/grpc/server/GrpcLogAppender.java
@@ -86,7 +86,12 @@ public class GrpcLogAppender extends LogAppender {
   }
 
   private synchronized void resetClient(AppendEntriesRequest request, boolean onError) {
-    rpcService.getProxies().resetProxy(getFollowerId());
+    try {
+      getClient().resetConnectBackoff();
+    } catch (IOException ie) {
+      LOG.warn(this + ": Failed to getClient for " + getFollowerId(), ie);
+    }
+
     appendLogRequestObserver = null;
     firstResponseReceived = false;
 
diff --git a/ratis-grpc/src/main/java/org/apache/ratis/grpc/server/GrpcServerProtocolClient.java b/ratis-grpc/src/main/java/org/apache/ratis/grpc/server/GrpcServerProtocolClient.java
index 399089a..ea1db78 100644
--- a/ratis-grpc/src/main/java/org/apache/ratis/grpc/server/GrpcServerProtocolClient.java
+++ b/ratis-grpc/src/main/java/org/apache/ratis/grpc/server/GrpcServerProtocolClient.java
@@ -110,4 +110,9 @@ public class GrpcServerProtocolClient implements Closeable {
     return asyncStub.withDeadlineAfter(requestTimeoutDuration.getDuration(), requestTimeoutDuration.getUnit())
         .installSnapshot(responseHandler);
   }
+
+  // short-circuit the backoff timer and make them reconnect immediately.
+  public void resetConnectBackoff() {
+    channel.resetConnectBackoff();
+  }
 }