armeria
armeria copied to clipboard
[Issue-4917] Add blockingTaskExecutor in Thrift services
Motivation:
Add blockingTaskExecutor in Thrift services #4917
Modifications:
- Add useBlockingTaskExecutor into THttpServiceBuilder.java
- Apply useBlockingTaskExecutor into THttpService.java
Result:
- Closes #4917. (If this resolves the issue.)
- User can use useBlockingTaskExecutor from THttpServiceBuilder.java
๐ Build Scanยฎ (commit: 7876ae5459e6a633115982364d720e6b557f46e6)
Job name | Status | Build Scanยฎ |
---|---|---|
build-windows-latest-jdk-21 | โ | https://ge.armeria.dev/s/zyv5ychb74cyi |
build-self-hosted-unsafe-jdk-8 | โ | https://ge.armeria.dev/s/5gbtn7jfo3hbk |
build-self-hosted-unsafe-jdk-21-snapshot-blockhound | โ | https://ge.armeria.dev/s/mkiwhxqqwo4bc |
build-self-hosted-unsafe-jdk-17-min-java-17-coverage | โ | https://ge.armeria.dev/s/axbcmxzdpuqvy |
build-self-hosted-unsafe-jdk-17-min-java-11 | โ | https://ge.armeria.dev/s/yjdw3q4vjeymi |
build-self-hosted-unsafe-jdk-17-leak | โ (failure) | https://ge.armeria.dev/s/yq5kpsjeqryju |
build-self-hosted-unsafe-jdk-11 | โ | https://ge.armeria.dev/s/owj3lbzt64qjw |
build-macos-12-jdk-21 | โ | https://ge.armeria.dev/s/pjwk7fj7hxgpq |
Oops, I realized that we also need to fix ThriftCallService not to use blocking task executor twice: https://github.com/line/armeria/blob/10424c711cb22a2b001f9bd737453a25743dc18d/thrift/thrift0.13/src/main/java/com/linecorp/armeria/server/thrift/ThriftCallService.java#L186
private static void invoke(
ServiceRequestContext ctx,
Object impl, ThriftFunction func, List<Object> args, CompletableRpcResponse reply) {
try {
final TBase<?, ?> tArgs = func.newArgs(args);
if (func.isAsync()) {
invokeAsynchronously(impl, func, tArgs, reply);
} else if (ctx.eventLoop().inEventLoop()) {
invokeSynchronously(ctx, impl, func, tArgs, reply);
} else {
invokeSynchronously0(ctx, impl, func, tArgs, reply);
}
} catch (Throwable t) {
reply.completeExceptionally(t);
}
}
private static void invokeSynchronously(
ServiceRequestContext ctx, Object impl,
ThriftFunction func, TBase<?, ?> args, CompletableRpcResponse reply) {
ctx.blockingTaskExecutor().execute(() -> invokeSynchronously0(ctx, impl, func, args, reply));
}
private static void invokeSynchronously0(
ServiceRequestContext ctx, Object impl,
ThriftFunction func, TBase<?, ?> args, CompletableRpcResponse reply) {
...
}
@trustin
I fix to decide whether to check useBlockingTaskExecutor
in ThriftCallService
instead of THttpService
.
Would you check this?
https://github.com/line/armeria/blob/096390525fcc3835a21004e466c39109e2f8b490/thrift/thrift0.13/src/main/java/com/linecorp/armeria/server/thrift/ThriftCallService.java#L125-L139
Oops, I realized that we also need to fix ThriftCallService not to use blocking task executor twice:
https://github.com/line/armeria/blob/10424c711cb22a2b001f9bd737453a25743dc18d/thrift/thrift0.13/src/main/java/com/linecorp/armeria/server/thrift/ThriftCallService.java#L186
private static void invoke( ServiceRequestContext ctx, Object impl, ThriftFunction func, List<Object> args, CompletableRpcResponse reply) { try { final TBase<?, ?> tArgs = func.newArgs(args); if (func.isAsync()) { invokeAsynchronously(impl, func, tArgs, reply); } else if (ctx.eventLoop().inEventLoop()) { invokeSynchronously(ctx, impl, func, tArgs, reply); } else { invokeSynchronously0(ctx, impl, func, tArgs, reply); } } catch (Throwable t) { reply.completeExceptionally(t); } } private static void invokeSynchronously( ServiceRequestContext ctx, Object impl, ThriftFunction func, TBase<?, ?> args, CompletableRpcResponse reply) { ctx.blockingTaskExecutor().execute(() -> invokeSynchronously0(ctx, impl, func, args, reply)); } private static void invokeSynchronously0( ServiceRequestContext ctx, Object impl, ThriftFunction func, TBase<?, ?> args, CompletableRpcResponse reply) { ... }
@minwoox Thank you for your review.
I fix to check in ThriftCallService
!
Revised and cleaned up the PR description and commit message.
Nice work @ChangguHan !!! ๐๐