YARN-8829. Cluster metrics can fail with IndexOutOfBoundsException. Contributed by Akshay Agarwal.

This commit is contained in:
bibinchundatt 2018-09-28 12:32:37 +05:30
parent 284aca8b63
commit 7093afd874
2 changed files with 10 additions and 1 deletions

View File

@ -654,7 +654,7 @@ public Object call() throws Exception {
exceptions.put(subClusterId, ioe);
}
}
if (results.isEmpty()) {
if (results.isEmpty() && !clusterIds.isEmpty()) {
SubClusterId subClusterId = clusterIds.get(0);
IOException ioe = exceptions.get(subClusterId);
if (ioe != null) {

View File

@ -22,6 +22,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationReportRequest;
import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationReportResponse;
import org.apache.hadoop.yarn.api.protocolrecords.GetClusterMetricsRequest;
@ -412,5 +413,13 @@ public void testGetClusterMetricsRequest() throws YarnException, IOException {
interceptor.getClusterMetrics(GetClusterMetricsRequest.newInstance());
Assert.assertEquals(subClusters.size(),
response.getClusterMetrics().getNumNodeManagers());
ClientMethod remoteMethod = new ClientMethod("getClusterMetrics",
new Class[] {GetClusterMetricsRequest.class},
new Object[] {GetClusterMetricsRequest.newInstance()});
Map<SubClusterId, GetClusterMetricsResponse> clusterMetrics =interceptor.
invokeConcurrent(new ArrayList<>(), remoteMethod,
GetClusterMetricsResponse.class);
Assert.assertEquals(true, clusterMetrics.isEmpty());
}
}