szetszwo commented on code in PR #1466:
URL: https://github.com/apache/ratis/pull/1466#discussion_r3319558802
##########
ratis-grpc/src/main/java/org/apache/ratis/grpc/server/GrpcServicesImpl.java:
##########
@@ -235,7 +243,26 @@ Server newServer(GrpcClientProtocolService client,
ServerInterceptor interceptor
}
public GrpcServicesImpl build() {
- return new GrpcServicesImpl(this);
+ final RaftProperties props = server.getProperties();
+ final String id = server.getId() + "";
+ final boolean useEpoll = GrpcConfigKeys.useEpoll(props);
+ try {
+ serverBosses = NettyUtils.newEventLoopGroup(id + "-boss",
+ GrpcConfigKeys.Server.bossGroupSize(props), useEpoll);
+ serverWorkers = NettyUtils.newEventLoopGroup(id + "-server-workers",
+ GrpcConfigKeys.Server.workerGroupSize(props), useEpoll);
+ clientWorkers = NettyUtils.newEventLoopGroup(id + "-client-workers",
+ GrpcConfigKeys.Client.workerGroupSize(props), useEpoll);
+ return new GrpcServicesImpl(this);
+ } catch (Throwable t) {
+ NettyUtils.shutdownGracefully(clientWorkers, serverWorkers,
serverBosses);
+ if (t instanceof RuntimeException) {
+ throw (RuntimeException) t;
+ } else if (t instanceof Error) {
+ throw (Error) t;
+ }
+ throw new RuntimeException(t);
Review Comment:
We could just `throw t`. Java can take care the casting.
```java
} catch (Throwable t) {
NettyUtils.shutdownGracefully(clientWorkers, serverWorkers,
serverBosses);
throw t;
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]