Class AsyncRpcProtocolPBUtil
java.lang.Object
org.apache.hadoop.hdfs.protocolPB.AsyncRpcProtocolPBUtil
This utility class encapsulates the logic required to initiate asynchronous RPCs,
handle responses, and propagate exceptions. It works in conjunction with
ProtobufRpcEngine2 and Client to facilitate the asynchronous
nature of the operations.
- See Also:
-
ProtobufRpcEngine2ClientCompletableFuture
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic <T,R> R asyncIpcClient(org.apache.hadoop.ipc.internal.ShadedProtobufHelper.IpcCall<T> call, ApplyFunction<T, R> response, Class<R> clazz) Asynchronously invokes an RPC call and applies a response transformation function to the result.static <T> voidasyncRouterServer(org.apache.hadoop.hdfs.protocolPB.AsyncRpcProtocolPBUtil.ServerReq<T> req, org.apache.hadoop.hdfs.protocolPB.AsyncRpcProtocolPBUtil.ServerRes<T> res) Asynchronously invokes an RPC call and applies a response transformation function to the result on server-side.static voidsetAsyncResponderExecutor(Executor asyncResponderExecutor) Sets the executor used for handling responses asynchronously within the utility class.
-
Field Details
-
LOG
public static final org.slf4j.Logger LOG
-
-
Method Details
-
asyncIpcClient
public static <T,R> R asyncIpcClient(org.apache.hadoop.ipc.internal.ShadedProtobufHelper.IpcCall<T> call, ApplyFunction<T, R> response, Class<R> clazz) throws IOExceptionAsynchronously invokes an RPC call and applies a response transformation function to the result. This method is generic and can be used to handle any type of RPC call.The method uses the
ShadedProtobufHelper.IpcCallto prepare the RPC call and theApplyFunctionto process the response. It also handles exceptions that may occur during the RPC call and wraps them in a user-friendly manner.- Type Parameters:
T- Type of the call's result.R- Type of method return.- Parameters:
call- The IPC call encapsulating the RPC request.response- The function to apply to the response of the RPC call.clazz- The class object representing the typeRof the response.- Returns:
- An object of type
Rthat is the result of applying the response function to the RPC call result. - Throws:
IOException- If an I/O error occurs during the asynchronous RPC call.
-
asyncRouterServer
public static <T> void asyncRouterServer(org.apache.hadoop.hdfs.protocolPB.AsyncRpcProtocolPBUtil.ServerReq<T> req, org.apache.hadoop.hdfs.protocolPB.AsyncRpcProtocolPBUtil.ServerRes<T> res) Asynchronously invokes an RPC call and applies a response transformation function to the result on server-side.- Type Parameters:
T- Type of the call's result.- Parameters:
req- The IPC call encapsulating the RPC request on server-side.res- The function to apply to the response of the RPC call on server-side.
-
setAsyncResponderExecutor
Sets the executor used for handling responses asynchronously within the utility class.- Parameters:
asyncResponderExecutor- The executor to be used for handling responses asynchronously.
-