Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import org.apache.hadoop.classification.VisibleForTesting;
import org.apache.hadoop.thirdparty.com.google.common.net.HostAndPort;

import static org.apache.hadoop.hdfs.server.federation.router.async.utils.AsyncUtil.syncReturn;

/**
* The local subcluster (where the writer is) should be tried first. The writer
Expand Down Expand Up @@ -143,9 +144,16 @@ private Map<String, String> getDatanodesSubcluster() {
@Override
public Map<String, DatanodeStorageReport[]> run() {
try {
return rpcServer.getDatanodeStorageReportMap(
DatanodeReportType.ALL);
} catch (IOException e) {
Map<String, DatanodeStorageReport[]> result;
if (rpcServer.isAsync()) {
rpcServer.getDatanodeStorageReportMapAsync(DatanodeReportType.ALL);
result = syncReturn(Map.class);
} else {
result = rpcServer.getDatanodeStorageReportMap(
DatanodeReportType.ALL);
}
return result;
} catch (Exception e) {
LOG.error("Cannot get the datanodes from the RPC server", e);
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public static <R> R syncReturn(Class<R> clazz)
try {
return (R) completableFuture.get();
} catch (ExecutionException e) {
throw (Exception)e.getCause();
throw (Exception) e.getCause();
}
}

Expand Down