You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uniffle.apache.org by ro...@apache.org on 2022/07/26 14:59:29 UTC

[incubator-uniffle] branch master updated: [Improvement] Shutdown the grpc executors pool when closing (#83)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 3522e07  [Improvement] Shutdown the grpc executors pool when closing (#83)
3522e07 is described below

commit 3522e07f1905af5847a46c43448a5b7159ab6298
Author: Junfan Zhang <ju...@outlook.com>
AuthorDate: Tue Jul 26 22:59:25 2022 +0800

    [Improvement] Shutdown the grpc executors pool when closing (#83)
    
    ### What changes were proposed in this pull request?
    [Improvement] Shutdown the grpc executors pool when closing
    
    ### Why are the changes needed?
    Although the executor pool is used in grpc, but the grpc server won't take ownership of the given executor. It's caller's responsibility to shut down the executor when it's desired.
    
    ### Does this PR introduce _any_ user-facing change?
    No
    
    ### How was this patch tested?
    No need.
---
 common/src/main/java/org/apache/uniffle/common/rpc/GrpcServer.java | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/common/src/main/java/org/apache/uniffle/common/rpc/GrpcServer.java b/common/src/main/java/org/apache/uniffle/common/rpc/GrpcServer.java
index 1b22196..5f14782 100644
--- a/common/src/main/java/org/apache/uniffle/common/rpc/GrpcServer.java
+++ b/common/src/main/java/org/apache/uniffle/common/rpc/GrpcServer.java
@@ -41,12 +41,13 @@ public class GrpcServer implements ServerInterface {
 
   private final Server server;
   private final int port;
+  private final ExecutorService pool;
 
   public GrpcServer(RssBaseConf conf, BindableService service, GRPCMetrics grpcMetrics) {
     this.port = conf.getInteger(RssBaseConf.RPC_SERVER_PORT);
     long maxInboundMessageSize = conf.getLong(RssBaseConf.RPC_MESSAGE_MAX_SIZE);
     int rpcExecutorSize = conf.getInteger(RssBaseConf.RPC_EXECUTOR_SIZE);
-    ExecutorService pool = new ThreadPoolExecutor(
+    pool = new ThreadPoolExecutor(
         rpcExecutorSize,
         rpcExecutorSize * 2,
         10,
@@ -89,6 +90,9 @@ public class GrpcServer implements ServerInterface {
       server.shutdown().awaitTermination(10, TimeUnit.SECONDS);
       LOG.info("GRPC server stopped!");
     }
+    if (pool != null) {
+      pool.shutdown();
+    }
   }
 
   public void blockUntilShutdown() throws InterruptedException {