From 7a82d7bcea8124e1b65c275fac15bf2047d17471 Mon Sep 17 00:00:00 2001 From: Arun Suresh Date: Sun, 20 Aug 2017 08:55:13 -0700 Subject: [PATCH] YARN-6979. [Addendum patch] Fixed classname and added javadocs. (Kartheek Muthyala via asuresh) --- ...nt.java => CMgrUpdateContainersEvent.java} | 27 +++++++++++++------ .../ContainerManagerEventType.java | 2 +- .../nodemanager/NodeStatusUpdaterImpl.java | 8 +++--- .../ContainerManagerImpl.java | 10 +++---- 4 files changed, 28 insertions(+), 19 deletions(-) rename hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/{CMgrDecreaseContainersResourceEvent.java => CMgrUpdateContainersEvent.java} (57%) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/CMgrDecreaseContainersResourceEvent.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/CMgrUpdateContainersEvent.java similarity index 57% rename from hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/CMgrDecreaseContainersResourceEvent.java rename to hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/CMgrUpdateContainersEvent.java index 9479d0bcdd7..5e41701faa6 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/CMgrDecreaseContainersResourceEvent.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/CMgrUpdateContainersEvent.java @@ -21,17 +21,28 @@ package org.apache.hadoop.yarn.server.nodemanager; import org.apache.hadoop.yarn.api.records.Container; import java.util.List; -public class CMgrDecreaseContainersResourceEvent extends ContainerManagerEvent { +/** + * Event used by the NodeStatusUpdater to notify the ContainerManager of + * container update commands it received from the RM. + */ +public class CMgrUpdateContainersEvent extends ContainerManagerEvent { - private final List containersToDecrease; + private final List containersToUpdate; - public CMgrDecreaseContainersResourceEvent(List - containersToDecrease) { - super(ContainerManagerEventType.DECREASE_CONTAINERS_RESOURCE); - this.containersToDecrease = containersToDecrease; + /** + * Create event. + * @param containersToUpdate Container to update. + */ + public CMgrUpdateContainersEvent(List containersToUpdate) { + super(ContainerManagerEventType.UPDATE_CONTAINERS); + this.containersToUpdate = containersToUpdate; } - public List getContainersToDecrease() { - return this.containersToDecrease; + /** + * Get containers to update. + * @return List of containers to update. + */ + public List getContainersToUpdate() { + return this.containersToUpdate; } } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/ContainerManagerEventType.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/ContainerManagerEventType.java index 8861bc7577f..8c5f7e21f1d 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/ContainerManagerEventType.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/ContainerManagerEventType.java @@ -21,6 +21,6 @@ package org.apache.hadoop.yarn.server.nodemanager; public enum ContainerManagerEventType { FINISH_APPS, FINISH_CONTAINERS, - DECREASE_CONTAINERS_RESOURCE, + UPDATE_CONTAINERS, SIGNAL_CONTAINERS } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/NodeStatusUpdaterImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/NodeStatusUpdaterImpl.java index 1d9256f6242..ade42e3907a 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/NodeStatusUpdaterImpl.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/NodeStatusUpdaterImpl.java @@ -1099,12 +1099,10 @@ public class NodeStatusUpdaterImpl extends AbstractService implements parseCredentials(systemCredentials)); } List - containersToDecrease = response.getContainersToUpdate(); - if (!containersToDecrease.isEmpty()) { + containersToUpdate = response.getContainersToUpdate(); + if (!containersToUpdate.isEmpty()) { dispatcher.getEventHandler().handle( - new CMgrDecreaseContainersResourceEvent( - containersToDecrease) - ); + new CMgrUpdateContainersEvent(containersToUpdate)); } // SignalContainer request originally comes from end users via diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/ContainerManagerImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/ContainerManagerImpl.java index 12931bc2fca..22484b7c8ca 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/ContainerManagerImpl.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/ContainerManagerImpl.java @@ -96,7 +96,7 @@ import org.apache.hadoop.yarn.server.api.records.ContainerQueuingLimit; import org.apache.hadoop.yarn.server.api.records.OpportunisticContainersStatus; import org.apache.hadoop.yarn.server.nodemanager.CMgrCompletedAppsEvent; import org.apache.hadoop.yarn.server.nodemanager.CMgrCompletedContainersEvent; -import org.apache.hadoop.yarn.server.nodemanager.CMgrDecreaseContainersResourceEvent; +import org.apache.hadoop.yarn.server.nodemanager.CMgrUpdateContainersEvent; import org.apache.hadoop.yarn.server.nodemanager.CMgrSignalContainersEvent; import org.apache.hadoop.yarn.server.nodemanager.ContainerExecutor; import org.apache.hadoop.yarn.server.nodemanager.ContainerManagerEvent; @@ -1599,11 +1599,11 @@ public class ContainerManagerImpl extends CompositeService implements "Container Killed by ResourceManager")); } break; - case DECREASE_CONTAINERS_RESOURCE: - CMgrDecreaseContainersResourceEvent containersDecreasedEvent = - (CMgrDecreaseContainersResourceEvent) event; + case UPDATE_CONTAINERS: + CMgrUpdateContainersEvent containersDecreasedEvent = + (CMgrUpdateContainersEvent) event; for (org.apache.hadoop.yarn.api.records.Container container - : containersDecreasedEvent.getContainersToDecrease()) { + : containersDecreasedEvent.getContainersToUpdate()) { try { ContainerTokenIdentifier containerTokenIdentifier = BuilderUtils.newContainerTokenIdentifier(