From 1b9f6d2fc6e35d255759f984b46ac4d9b1edb6f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E5=BB=B6?= <1060026287@qq.com> Date: Sun, 4 Apr 2021 18:03:06 +0800 Subject: [PATCH] Grpc max message size support config by user. (#564) * grpc max message size support config by user. * code format. * code format. * code clean. * reuse GrpcRaftRpcFactory.RPC_MAX_INBOUND_MESSAGE_SIZE in RpcClient. * add prefix 'jraft'. --- .../com/alipay/sofa/jraft/rpc/impl/GrpcClient.java | 1 + .../sofa/jraft/rpc/impl/GrpcRaftRpcFactory.java | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/jraft-extension/rpc-grpc-impl/src/main/java/com/alipay/sofa/jraft/rpc/impl/GrpcClient.java b/jraft-extension/rpc-grpc-impl/src/main/java/com/alipay/sofa/jraft/rpc/impl/GrpcClient.java index 0f6ee740a..7d29a54ad 100644 --- a/jraft-extension/rpc-grpc-impl/src/main/java/com/alipay/sofa/jraft/rpc/impl/GrpcClient.java +++ b/jraft-extension/rpc-grpc-impl/src/main/java/com/alipay/sofa/jraft/rpc/impl/GrpcClient.java @@ -183,6 +183,7 @@ private ManagedChannel getChannel(final Endpoint endpoint) { final ManagedChannel ch = ManagedChannelBuilder.forAddress(ep.getIp(), ep.getPort()) // .usePlaintext() // .directExecutor() // + .maxInboundMessageSize(GrpcRaftRpcFactory.RPC_MAX_INBOUND_MESSAGE_SIZE) // .build(); // channel connection event ch.notifyWhenStateChanged(ConnectivityState.READY, () -> { diff --git a/jraft-extension/rpc-grpc-impl/src/main/java/com/alipay/sofa/jraft/rpc/impl/GrpcRaftRpcFactory.java b/jraft-extension/rpc-grpc-impl/src/main/java/com/alipay/sofa/jraft/rpc/impl/GrpcRaftRpcFactory.java index 9934dbb34..dccea2525 100644 --- a/jraft-extension/rpc-grpc-impl/src/main/java/com/alipay/sofa/jraft/rpc/impl/GrpcRaftRpcFactory.java +++ b/jraft-extension/rpc-grpc-impl/src/main/java/com/alipay/sofa/jraft/rpc/impl/GrpcRaftRpcFactory.java @@ -41,9 +41,14 @@ public class GrpcRaftRpcFactory implements RaftRpcFactory { static final String FIXED_METHOD_NAME = "_call"; - static final int RPC_SERVER_PROCESSOR_POOL_SIZE = SystemPropertyUtil.getInt( - "grpc.default_rpc_server_processor_pool_size", - 100); + static final int RPC_SERVER_PROCESSOR_POOL_SIZE = SystemPropertyUtil + .getInt( + "jraft.grpc.default_rpc_server_processor_pool_size", + 100); + + static final int RPC_MAX_INBOUND_MESSAGE_SIZE = SystemPropertyUtil.getInt( + "jraft.grpc.max_inbound_message_size.bytes", + 4 * 1024 * 1024); static final RpcResponseFactory RESPONSE_FACTORY = new GrpcResponseFactory(); @@ -86,6 +91,7 @@ public RpcServer createRpcServer(final Endpoint endpoint, final ConfigHelper