Interface AsyncRun<R>
- 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.
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 TypeMethodDescriptiondefault CompletableFuture<R>async()Provides an asynchronous version of therunmethod, which returns aCompletableFuturerepresenting the result of the operation.voidrun()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
Executes the asynchronous operation represented by this AsyncRun instance. This method is expected to perform the operation and, upon completion, complete the current thread'sCompletableFuturewith the result.- Throws:
IOException- if an I/O error occurs during the execution of the operation
-
async
Provides an asynchronous version of therunmethod, which returns aCompletableFuturerepresenting 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
-