Type Parameters:
R - the type of the result produced by the asynchronous operation
All Superinterfaces:
Async<R>
All Known Implementing Classes:
AsyncForEachRun
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface AsyncRun<R> extends Async<R>
The AsyncRun interface represents an asynchronous operation that can be executed in the context of the Hadoop Distributed File System (HDFS) Federation router. Implementations of this interface are responsible for performing a task and completing a CompletableFuture with the result of the operation.

The run method of this interface is intended to be used in an asynchronous workflow, where the operation may involve I/O tasks or other long-running processes. By implementing this interface, classes can define custom asynchronous behavior that can be chained with other asynchronous operations using utility methods provided by the AsyncUtil class.

For example, an implementation of AsyncRun could perform a non-blocking read or write operation to HDFS, and upon completion, it could use AsyncUtil methods to handle the result or propagate any exceptions that occurred during the operation.

See Also:
  • Field Summary

    Fields inherited from interface org.apache.hadoop.hdfs.server.federation.router.async.utils.Async

    CUR_COMPLETABLE_FUTURE
  • Method Summary

    Modifier and Type
    Method
    Description
    Provides an asynchronous version of the run method, which returns a CompletableFuture representing the result of the operation.
    void
    run()
    Executes the asynchronous operation represented by this AsyncRun instance.

    Methods inherited from interface org.apache.hadoop.hdfs.server.federation.router.async.utils.Async

    getCurCompletableFuture, result, setCurCompletableFuture
  • Method Details

    • run

      void run() throws IOException
      Executes the asynchronous operation represented by this AsyncRun instance. This method is expected to perform the operation and, upon completion, complete the current thread's CompletableFuture with the result.
      Throws:
      IOException - if an I/O error occurs during the execution of the operation
    • async

      default CompletableFuture<R> async() throws IOException
      Provides an asynchronous version of the run method, which returns a CompletableFuture representing the result of the operation. This method is typically used in an asynchronous workflow to initiate the operation without waiting for its completion.
      Returns:
      a CompletableFuture that completes with the result of the operation
      Throws:
      IOException - if an I/O error occurs during the initiation of the operation