YARN-9179. Fix NPE in AbstractYarnScheduler#updateNewContainerInfo.

This commit is contained in:
Akira Ajisaka 2019-01-15 12:59:59 +09:00
parent 05c84ab01c
commit 614af50625
No known key found for this signature in database
GPG Key ID: C1EDBB9CA400FD50
1 changed files with 18 additions and 11 deletions

View File

@ -1040,20 +1040,27 @@ public abstract class AbstractYarnScheduler
for (Map.Entry<ApplicationId, ContainerStatus> c : updateExistContainers) { for (Map.Entry<ApplicationId, ContainerStatus> c : updateExistContainers) {
SchedulerApplication<T> app = applications.get(c.getKey()); SchedulerApplication<T> app = applications.get(c.getKey());
ContainerId containerId = c.getValue().getContainerId(); ContainerId containerId = c.getValue().getContainerId();
String strExposedPorts = c.getValue().getExposedPorts(); if (app == null || app.getCurrentAppAttempt() == null) {
Map<String, List<Map<String, String>>> exposedPorts = null; continue;
if (null != strExposedPorts && !strExposedPorts.isEmpty()) {
Gson gson = new Gson();
exposedPorts = gson.fromJson(strExposedPorts,
new TypeToken<Map<String, List<Map<String, String>>>>()
{}.getType());
} }
RMContainer rmContainer RMContainer rmContainer
= app.getCurrentAppAttempt().getRMContainer(containerId); = app.getCurrentAppAttempt().getRMContainer(containerId);
if (null != rmContainer && if (rmContainer == null) {
(null == rmContainer.getExposedPorts() continue;
|| rmContainer.getExposedPorts().size() == 0)) { }
// exposed ports are already set for the container, skip
if (rmContainer.getExposedPorts() != null &&
rmContainer.getExposedPorts().size() > 0) {
continue;
}
String strExposedPorts = c.getValue().getExposedPorts();
if (null != strExposedPorts && !strExposedPorts.isEmpty()) {
Gson gson = new Gson();
Map<String, List<Map<String, String>>> exposedPorts =
gson.fromJson(strExposedPorts,
new TypeToken<Map<String, List<Map<String, String>>>>()
{}.getType());
LOG.info("update exist container " + containerId.getContainerId() LOG.info("update exist container " + containerId.getContainerId()
+ ", strExposedPorts = " + strExposedPorts); + ", strExposedPorts = " + strExposedPorts);
rmContainer.setExposedPorts(exposedPorts); rmContainer.setExposedPorts(exposedPorts);