YARN-9179. Fix NPE in AbstractYarnScheduler#updateNewContainerInfo.
This commit is contained in:
parent
05c84ab01c
commit
614af50625
|
@ -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);
|
||||||
|
|
Loading…
Reference in New Issue