[ 
https://issues.apache.org/jira/browse/HDFS-16080?focusedWorklogId=611878&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-611878
 ]

ASF GitHub Bot logged work on HDFS-16080:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 18/Jun/21 20:52
            Start Date: 18/Jun/21 20:52
    Worklog Time Spent: 10m 
      Work Description: virajjasani commented on a change in pull request #3121:
URL: https://github.com/apache/hadoop/pull/3121#discussion_r654572527



##########
File path: 
hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterRpcClient.java
##########
@@ -1129,25 +1129,17 @@ private static boolean isExpectedValue(Object 
expectedValue, Object value) {
    * Invoke method in all locations and return success if any succeeds.
    *
    * @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 method The remote method and parameters to invoke.
    * @return If the call succeeds in any location.
    * @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)
-          throws IOException {
-    boolean anyResult = false;
+      throws IOException {
     Map<T, Boolean> results =
         invokeConcurrent(locations, method, false, false, Boolean.class);
-    for (Boolean value : results.values()) {
-      boolean result = value.booleanValue();
-      if (result) {
-        anyResult = true;
-      }
-    }
-    return anyResult;
+    return results.values().stream().anyMatch(value -> value);

Review comment:
       Hmm nice one. I think one is not much better than the other, it's just 
about using stream vs for loop (and could open up for multiple discussions :) 
). I agree that using containsValue() should be more lightweight so I am fine 
using it if you have strong preference.
   
   `TreeMap.containsValue()`:
   ```
       public boolean containsValue(Object value) {
           for (Entry<K,V> e = getFirstEntry(); e != null; e = successor(e))
               if (valEquals(value, e.value))
                   return true;
           return false;
       }
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

            Worklog Id:     (was: 611878)
    Remaining Estimate: 0h
            Time Spent: 10m

> RBF: Invoking method in all locations should break the loop after successful 
> result
> -----------------------------------------------------------------------------------
>
>                 Key: HDFS-16080
>                 URL: https://issues.apache.org/jira/browse/HDFS-16080
>             Project: Hadoop HDFS
>          Issue Type: Improvement
>            Reporter: Viraj Jasani
>            Assignee: Viraj Jasani
>            Priority: Minor
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> rename, delete and mkdir used by Router client usually calls multiple 
> locations if the path is present in multiple sub-clusters. After invoking 
> multiple concurrent proxy calls to multiple clients, we iterate through all 
> results and mark anyResult true if at least one of them was successful. We 
> should break the loop if one of the proxy call result was successful rather 
> than iterating over remaining calls.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to