YARN-9394. Use new API of RackResolver to get better performance. Contributed by Lantao Jin.
This commit is contained in:
parent
a92806d05a
commit
945e8c6064
@ -40,6 +40,7 @@
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.io.Text;
|
||||
import org.apache.hadoop.ipc.RPC;
|
||||
import org.apache.hadoop.net.Node;
|
||||
import org.apache.hadoop.security.UserGroupInformation;
|
||||
import org.apache.hadoop.yarn.api.ApplicationMasterProtocol;
|
||||
import org.apache.hadoop.yarn.api.protocolrecords.AllocateRequest;
|
||||
@ -763,10 +764,11 @@ public synchronized List<? extends Collection<T>> getMatchingRequests(
|
||||
private Set<String> resolveRacks(List<String> nodes) {
|
||||
Set<String> racks = new HashSet<String>();
|
||||
if (nodes != null) {
|
||||
for (String node : nodes) {
|
||||
List<Node> tmpList = RackResolver.resolve(nodes);
|
||||
for (Node node : tmpList) {
|
||||
String rack = node.getNetworkLocation();
|
||||
// Ensure node requests are accompanied by requests for
|
||||
// corresponding rack
|
||||
String rack = RackResolver.resolve(node).getNetworkLocation();
|
||||
if (rack == null) {
|
||||
LOG.warn("Failed to resolve rack for node " + node + ".");
|
||||
} else {
|
||||
@ -774,7 +776,6 @@ private Set<String> resolveRacks(List<String> nodes) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return racks;
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
@ -254,7 +254,7 @@ private static class MyResolver implements DNSToSwitchMapping {
|
||||
|
||||
@Override
|
||||
public List<String> resolve(List<String> names) {
|
||||
return Arrays.asList("/rack1");
|
||||
return Collections.nCopies(names.size(), "/rack1");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user