Uploaded image for project: 'Hadoop HDFS'
  1. Hadoop HDFS
  2. HDFS-17531 RBF: Asynchronous router RPC
  3. HDFS-17543

[ARR] AsyncUtil makes asynchronous code more concise and easier.

    XMLWordPrintableJSON

Details

    Description

      Describe

      Using the original Java CompletableFuture to implement an asynchronous router is not conducive to the development of the open source community due to poor code readability and maintainability. Therefore, I have implemented a lightweight tool that encapsulates CompletableFuture.

      By using this AsyncUtil, it is easy to write readable asynchronous code, which is easy for everyone to understand. I have provided an example of this tool class in UT, demonstrating how to change synchronous methods to asynchronous code.

       

      Examples and tests

      SyncClass provides some common synchronization methods
      AsyncClass is the corresponding asynchronous implementation
      Use TestAsyncUtil to simultaneously test the methods corresponding to SyncClass and AsyncClass, ensuring that both asynchronous and synchronous methods return the same results

       

      NOTE: In HDFS-17545, I used this tool to implement RouterAsyncRpcClient which extends RouterRpcClient.  You can also view RouterAsyncRpcClient to understand the use of this tool.

      Attachments

        1. HDFS-17543.001.patch
          98 kB
          Jian Zhang

        Issue Links

          Activity

            People

              keepromise Jian Zhang
              keepromise Jian Zhang
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: