Skip to content

Commit

Permalink
Grpc max message size support config by user. (#564)
Browse files Browse the repository at this point in the history
* 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'.
  • Loading branch information
horizonzy authored Apr 4, 2021
1 parent 5c12c2a commit 1b9f6d2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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, () -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -86,6 +91,7 @@ public RpcServer createRpcServer(final Endpoint endpoint, final ConfigHelper<Rpc
final Server server = ServerBuilder.forPort(port) //
.fallbackHandlerRegistry(handlerRegistry) //
.directExecutor() //
.maxInboundMessageSize(RPC_MAX_INBOUND_MESSAGE_SIZE) //
.build();
final RpcServer rpcServer = new GrpcServer(server, handlerRegistry, this.parserClasses, getMarshallerRegistry());
if (helper != null) {
Expand Down

0 comments on commit 1b9f6d2

Please sign in to comment.