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>
This commit is contained in:
Viraj Jasani 2021-06-20 17:19:05 +05:30 committed by Ayush Saxena
parent 92ade1f6f9
commit ef3a2a3b3b

View File

@ -1018,25 +1018,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.containsValue(true);
}
/**