You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by li...@apache.org on 2019/11/17 03:01:11 UTC

[dubbo] branch master updated: add start status for gRPC server

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

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


The following commit(s) were added to refs/heads/master by this push:
     new efb8e30  add start status for gRPC server
     new 13ef73a  Merge branch 'master' of https://github.com/apache/dubbo
efb8e30 is described below

commit efb8e304c77be92d1af4f90689cdab625fc15a99
Author: ken.lj <ke...@gmail.com>
AuthorDate: Sun Nov 17 10:31:13 2019 +0800

    add start status for gRPC server
---
 .../java/org/apache/dubbo/rpc/protocol/grpc/GrpcProtocol.java  | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/dubbo-rpc/dubbo-rpc-grpc/src/main/java/org/apache/dubbo/rpc/protocol/grpc/GrpcProtocol.java b/dubbo-rpc/dubbo-rpc-grpc/src/main/java/org/apache/dubbo/rpc/protocol/grpc/GrpcProtocol.java
index 83aaf7b..8a1188f 100644
--- a/dubbo-rpc/dubbo-rpc-grpc/src/main/java/org/apache/dubbo/rpc/protocol/grpc/GrpcProtocol.java
+++ b/dubbo-rpc/dubbo-rpc-grpc/src/main/java/org/apache/dubbo/rpc/protocol/grpc/GrpcProtocol.java
@@ -93,7 +93,9 @@ public class GrpcProtocol extends AbstractProxyProtocol {
         }
         grpcServer.getRegistry().addService((BindableService) originalImpl, url.getServiceKey());
 
-        grpcServer.start();
+        if (!grpcServer.isStarted()) {
+            grpcServer.start();
+        }
 
         return () -> grpcServer.getRegistry().removeService(url.getServiceKey());
     }
@@ -167,6 +169,7 @@ public class GrpcProtocol extends AbstractProxyProtocol {
 
         private Server originalServer;
         private DubboHandlerRegistry handlerRegistry;
+        private volatile boolean started;
 
         public GrpcRemotingServer(Server server, DubboHandlerRegistry handlerRegistry) {
             this.originalServer = server;
@@ -176,6 +179,7 @@ public class GrpcProtocol extends AbstractProxyProtocol {
         public void start() throws RpcException {
             try {
                 originalServer.start();
+                started = true;
             } catch (IOException e) {
                 throw new RpcException("Starting gRPC server failed. ", e);
             }
@@ -190,6 +194,10 @@ public class GrpcProtocol extends AbstractProxyProtocol {
             return originalServer;
         }
 
+        public boolean isStarted() {
+            return started;
+        }
+
         @Override
         public void close() {
             originalServer.shutdown();