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 d776bdf3676..af59e34c254 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 @@ -661,7 +661,6 @@ public class NodeStatusUpdaterImpl extends AbstractService implements public void removeOrTrackCompletedContainersFromContext( List containerIds) throws IOException { Set removedContainers = new HashSet(); - Set removedNullContainers = new HashSet(); pendingContainersToRemove.addAll(containerIds); Iterator iter = pendingContainersToRemove.iterator(); @@ -671,7 +670,6 @@ public class NodeStatusUpdaterImpl extends AbstractService implements Container nmContainer = context.getContainers().get(containerId); if (nmContainer == null) { iter.remove(); - removedNullContainers.add(containerId); } else if (nmContainer.getContainerState().equals( org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerState.DONE)) { context.getContainers().remove(containerId); @@ -734,11 +732,12 @@ public class NodeStatusUpdaterImpl extends AbstractService implements public void removeVeryOldStoppedContainersFromCache() { synchronized (recentlyStoppedContainers) { long currentTime = System.currentTimeMillis(); - Iterator i = - recentlyStoppedContainers.keySet().iterator(); + Iterator> i = + recentlyStoppedContainers.entrySet().iterator(); while (i.hasNext()) { - ContainerId cid = i.next(); - if (recentlyStoppedContainers.get(cid) < currentTime) { + Entry mapEntry = i.next(); + ContainerId cid = mapEntry.getKey(); + if (mapEntry.getValue() < currentTime) { if (!context.getContainers().containsKey(cid)) { i.remove(); try { 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/localizer/ContainerLocalizer.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/localizer/ContainerLocalizer.java index 1e959d5e5c5..7bcae6d1c3b 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/localizer/ContainerLocalizer.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/localizer/ContainerLocalizer.java @@ -17,6 +17,8 @@ */ package org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer; +import static org.apache.hadoop.util.Shell.getAllShells; + import com.google.common.base.Preconditions; import java.io.DataInputStream; import java.io.File; @@ -31,6 +33,7 @@ import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import java.util.Set; import java.util.Stack; import java.util.concurrent.Callable; @@ -83,8 +86,6 @@ import org.apache.hadoop.yarn.util.FSDownload; import com.google.common.annotations.VisibleForTesting; import com.google.common.util.concurrent.ThreadFactoryBuilder; -import static org.apache.hadoop.util.Shell.getAllShells; - public class ContainerLocalizer { static final Logger LOG = @@ -350,13 +351,13 @@ public class ContainerLocalizer { final List currentResources = new ArrayList(); // TODO: Synchronization?? - for (Iterator i = pendingResources.keySet().iterator(); - i.hasNext();) { - LocalResource rsrc = i.next(); + for (Iterator>> i = + pendingResources.entrySet().iterator(); i.hasNext();) { + Entry> mapEntry = i.next(); LocalResourceStatus stat = recordFactory.newRecordInstance(LocalResourceStatus.class); - stat.setResource(rsrc); - Future fPath = pendingResources.get(rsrc); + stat.setResource(mapEntry.getKey()); + Future fPath = mapEntry.getValue(); if (fPath.isDone()) { try { Path localPath = fPath.get(); 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/monitor/ContainerMetrics.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/monitor/ContainerMetrics.java index 07b3deadc4d..a6aa337239f 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/monitor/ContainerMetrics.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/monitor/ContainerMetrics.java @@ -130,7 +130,7 @@ public class ContainerMetrics implements MetricsSource { /** * Simple metrics cache to help prevent re-registrations. */ - protected final static Map + private final static Map usageMetrics = new HashMap<>(); // Create a timer to unregister container metrics, // whose associated thread run as a daemon.