This is an automated email from the ASF dual-hosted git repository.
chenglei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/master by this push:
new 02f26368e26 HBASE-27207 ConnectionUtils.allOf should be moved to
FutureUtils (#4627)
02f26368e26 is described below
commit 02f26368e26763209d2d0c01ed6f2d28623cdbee
Author: chenglei <[email protected]>
AuthorDate: Fri Jul 15 17:04:03 2022 +0800
HBASE-27207 ConnectionUtils.allOf should be moved to FutureUtils (#4627)
Signed-off-by: Duo Zhang <[email protected]>
---
.../java/org/apache/hadoop/hbase/client/AsyncTable.java | 2 +-
.../org/apache/hadoop/hbase/client/ConnectionUtils.java | 5 -----
.../java/org/apache/hadoop/hbase/util/FutureUtils.java | 15 +++++++++++++++
3 files changed, 16 insertions(+), 6 deletions(-)
diff --git
a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncTable.java
b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncTable.java
index 5497b4a0b72..b9a439f067b 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncTable.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncTable.java
@@ -18,8 +18,8 @@
package org.apache.hadoop.hbase.client;
import static java.util.stream.Collectors.toList;
-import static org.apache.hadoop.hbase.client.ConnectionUtils.allOf;
import static
org.apache.hadoop.hbase.client.ConnectionUtils.toCheckExistenceOnly;
+import static org.apache.hadoop.hbase.util.FutureUtils.allOf;
import java.util.List;
import java.util.concurrent.CompletableFuture;
diff --git
a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionUtils.java
b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionUtils.java
index 2124a0aa003..61eb69ac09e 100644
---
a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionUtils.java
+++
b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionUtils.java
@@ -306,11 +306,6 @@ public final class ConnectionUtils {
return Bytes.compareTo(info.getStartKey(), scan.getStopRow()) <= 0;
}
- static <T> CompletableFuture<List<T>> allOf(List<CompletableFuture<T>>
futures) {
- return CompletableFuture.allOf(futures.toArray(new CompletableFuture[0]))
- .thenApply(v -> futures.stream().map(f ->
f.getNow(null)).collect(toList()));
- }
-
public static ScanResultCache createScanResultCache(Scan scan) {
if (scan.getAllowPartialResults()) {
return new AllowPartialScanResultCache();
diff --git
a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/FutureUtils.java
b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/FutureUtils.java
index 041a0859106..dc70edd0905 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/FutureUtils.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/FutureUtils.java
@@ -17,8 +17,11 @@
*/
package org.apache.hadoop.hbase.util;
+import static java.util.stream.Collectors.toList;
+
import java.io.IOException;
import java.io.InterruptedIOException;
+import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionException;
import java.util.concurrent.ExecutionException;
@@ -197,4 +200,16 @@ public final class FutureUtils {
future.completeExceptionally(e);
return future;
}
+
+ /**
+ * Returns a new CompletableFuture that is completed when all of the given
CompletableFutures
+ * complete. If any of the given CompletableFutures complete exceptionally,
then the returned
+ * CompletableFuture also does so, with a CompletionException holding this
exception as its cause.
+ * Otherwise, the results of all given CompletableFutures could be obtained
by the new returned
+ * CompletableFuture.
+ */
+ public static <T> CompletableFuture<List<T>>
allOf(List<CompletableFuture<T>> futures) {
+ return CompletableFuture.allOf(futures.toArray(new CompletableFuture[0]))
+ .thenApply(v -> futures.stream().map(f ->
f.getNow(null)).collect(toList()));
+ }
}