Browse Source

HDFS-16080. RBF: Invoking method in all locations should break the loop after successful result (#3121). Contributed by Viraj Jasani.

Signed-off-by: Ayush Saxena <ayushsaxena@apache.org>
Viraj Jasani 3 years ago
parent
commit
d9eccb1eb3

+ 3 - 11
hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterRpcClient.java

@@ -1129,25 +1129,17 @@ public class RouterRpcClient {
    * Invoke method in all locations and return success if any succeeds.
    * Invoke method in all locations and return success if any succeeds.
    *
    *
    * @param <T> The type of the remote location.
    * @param <T> The type of the remote location.
-   * @param <R> The type of the remote method return.
    * @param locations List of remote locations to call concurrently.
    * @param locations List of remote locations to call concurrently.
    * @param method The remote method and parameters to invoke.
    * @param method The remote method and parameters to invoke.
    * @return If the call succeeds in any location.
    * @return If the call succeeds in any location.
    * @throws IOException If any of the calls return an exception.
    * @throws IOException If any of the calls return an exception.
    */
    */
-  public <T extends RemoteLocationContext, R> boolean invokeAll(
+  public <T extends RemoteLocationContext> boolean invokeAll(
       final Collection<T> locations, final RemoteMethod method)
       final Collection<T> locations, final RemoteMethod method)
-          throws IOException {
-    boolean anyResult = false;
+      throws IOException {
     Map<T, Boolean> results =
     Map<T, Boolean> results =
         invokeConcurrent(locations, method, false, false, Boolean.class);
         invokeConcurrent(locations, method, false, false, Boolean.class);
-    for (Boolean value : results.values()) {
-      boolean result = value.booleanValue();
-      if (result) {
-        anyResult = true;
-      }
-    }
-    return anyResult;
+    return results.containsValue(true);
   }
   }
 
 
   /**
   /**