YARN-5753. fix NPE in AMRMClientImpl.getMatchingRequests() (haibochen via rkanter)
This commit is contained in:
parent
d3bb69a667
commit
44fdf00964
|
@ -664,9 +664,12 @@ public class AMRMClientImpl<T extends ContainerRequest> extends AMRMClient<T> {
|
|||
List<LinkedHashSet<T>> list = new LinkedList<LinkedHashSet<T>>();
|
||||
|
||||
RemoteRequestsTable remoteRequestsTable = getTable(0);
|
||||
|
||||
if (null != remoteRequestsTable) {
|
||||
List<ResourceRequestInfo<T>> matchingRequests =
|
||||
remoteRequestsTable.getMatchingRequests(priority, resourceName,
|
||||
executionType, capability);
|
||||
if (null != matchingRequests) {
|
||||
// If no exact match. Container may be larger than what was requested.
|
||||
// get all resources <= capability. map is reverse sorted.
|
||||
for (ResourceRequestInfo<T> resReqInfo : matchingRequests) {
|
||||
|
@ -675,6 +678,8 @@ public class AMRMClientImpl<T extends ContainerRequest> extends AMRMClient<T> {
|
|||
list.add(resReqInfo.containerRequests);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// no match found
|
||||
return list;
|
||||
}
|
||||
|
|
|
@ -236,6 +236,20 @@ public class TestAMRMClient {
|
|||
}
|
||||
}
|
||||
|
||||
@Test (timeout = 60000)
|
||||
public void testAMRMClientNoMatchingRequests()
|
||||
throws IOException, YarnException {
|
||||
AMRMClient<ContainerRequest> amClient = AMRMClient.createAMRMClient();
|
||||
amClient.init(conf);
|
||||
amClient.start();
|
||||
amClient.registerApplicationMaster("Host", 10000, "");
|
||||
|
||||
Resource testCapability1 = Resource.newInstance(1024, 2);
|
||||
List<? extends Collection<ContainerRequest>> matches =
|
||||
amClient.getMatchingRequests(priority, node, testCapability1);
|
||||
assertEquals("Expected no macthing requests.", matches.size(), 0);
|
||||
}
|
||||
|
||||
@Test (timeout=60000)
|
||||
public void testAMRMClientMatchingFit() throws YarnException, IOException {
|
||||
AMRMClient<ContainerRequest> amClient = null;
|
||||
|
|
Loading…
Reference in New Issue