[ https://issues.apache.org/jira/browse/HDFS-17543?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17852995#comment-17852995 ]
ASF GitHub Bot commented on HDFS-17543: --------------------------------------- KeeProMise commented on code in PR #6868: URL: https://github.com/apache/hadoop/pull/6868#discussion_r1630547741 ########## hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/async/AsyncForEachRun.java: ########## @@ -0,0 +1,97 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hdfs.server.federation.router.async; + +import java.io.IOException; +import java.util.Iterator; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionException; + +public class AsyncForEachRun<I, T, R> implements AsyncRun<R> { Review Comment: @hfutatzhanghb Thanks for your suggestion, I will add javadoc for these classes > [ARR]: AsyncUtil makes asynchronous code more concise and easier. > ----------------------------------------------------------------- > > Key: HDFS-17543 > URL: https://issues.apache.org/jira/browse/HDFS-17543 > Project: Hadoop HDFS > Issue Type: Sub-task > Reporter: Jian Zhang > Assignee: Jian Zhang > Priority: Major > Labels: pull-request-available > > *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. -- This message was sent by Atlassian Jira (v8.20.10#820010) --------------------------------------------------------------------- To unsubscribe, e-mail: hdfs-issues-unsubscr...@hadoop.apache.org For additional commands, e-mail: hdfs-issues-h...@hadoop.apache.org