AsyncRpcProtocolPBUtil (Apache Hadoop HDFS-RBF 3.5.0 API)
Description: declaration: package: org.apache.hadoop.hdfs.protocolPB, class: AsyncRpcProtocolPBUtil

Package org.apache.hadoop.hdfs.protocolPB

# Class AsyncRpcProtocolPBUtil

java.lang.Object
org.apache.hadoop.hdfs.protocolPB.AsyncRpcProtocolPBUtil

public final class AsyncRpcProtocolPBUtil extends Object

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:
  - `ProtobufRpcEngine2`
  - `Client`
  - `CompletableFuture`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final org.slf4j.Logger`
  `LOG`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static <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> 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.
  `static void`
  `setAsyncResponderExecutor(Executor asyncResponderExecutor)`
  Sets the executor used for handling responses asynchronously within the utility class.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## 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 IOException
    Asynchronously 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.IpcCall` to prepare the RPC call and the `ApplyFunction` to 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 type `R` of the response.
    Returns:
      An object of type `R` that 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

    public static void setAsyncResponderExecutor(Executor asyncResponderExecutor)
    Sets the executor used for handling responses asynchronously within the utility class.
    Parameters:
      `asyncResponderExecutor` - The executor to be used for handling responses asynchronously.