YARN-5753. fix NPE in AMRMClientImpl.getMatchingRequests() (haibochen via rkanter)
This commit is contained in:
parent
d3bb69a667
commit
44fdf00964
@ -664,15 +664,20 @@ public synchronized List<? extends Collection<T>> getMatchingRequests(
|
||||
List<LinkedHashSet<T>> list = new LinkedList<LinkedHashSet<T>>();
|
||||
|
||||
RemoteRequestsTable remoteRequestsTable = getTable(0);
|
||||
List<ResourceRequestInfo<T>> matchingRequests =
|
||||
remoteRequestsTable.getMatchingRequests(priority, resourceName,
|
||||
executionType, capability);
|
||||
// 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) {
|
||||
if (canFit(resReqInfo.remoteRequest.getCapability(), capability) &&
|
||||
!resReqInfo.containerRequests.isEmpty()) {
|
||||
list.add(resReqInfo.containerRequests);
|
||||
|
||||
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) {
|
||||
if (canFit(resReqInfo.remoteRequest.getCapability(), capability) &&
|
||||
!resReqInfo.containerRequests.isEmpty()) {
|
||||
list.add(resReqInfo.containerRequests);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// no match found
|
||||
|
@ -236,6 +236,20 @@ public static void tearDown() {
|
||||
}
|
||||
}
|
||||
|
||||
@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
Block a user