YARN-8829. Cluster metrics can fail with IndexOutOfBoundsException. Contributed by Akshay Agarwal.
This commit is contained in:
parent
284aca8b63
commit
7093afd874
|
@ -654,7 +654,7 @@ public class FederationClientInterceptor
|
||||||
exceptions.put(subClusterId, ioe);
|
exceptions.put(subClusterId, ioe);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (results.isEmpty()) {
|
if (results.isEmpty() && !clusterIds.isEmpty()) {
|
||||||
SubClusterId subClusterId = clusterIds.get(0);
|
SubClusterId subClusterId = clusterIds.get(0);
|
||||||
IOException ioe = exceptions.get(subClusterId);
|
IOException ioe = exceptions.get(subClusterId);
|
||||||
if (ioe != null) {
|
if (ioe != null) {
|
||||||
|
|
|
@ -22,6 +22,7 @@ import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationReportRequest;
|
import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationReportRequest;
|
||||||
import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationReportResponse;
|
import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationReportResponse;
|
||||||
import org.apache.hadoop.yarn.api.protocolrecords.GetClusterMetricsRequest;
|
import org.apache.hadoop.yarn.api.protocolrecords.GetClusterMetricsRequest;
|
||||||
|
@ -412,5 +413,13 @@ public class TestFederationClientInterceptor extends BaseRouterClientRMTest {
|
||||||
interceptor.getClusterMetrics(GetClusterMetricsRequest.newInstance());
|
interceptor.getClusterMetrics(GetClusterMetricsRequest.newInstance());
|
||||||
Assert.assertEquals(subClusters.size(),
|
Assert.assertEquals(subClusters.size(),
|
||||||
response.getClusterMetrics().getNumNodeManagers());
|
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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue