YARN-6515. Fix warnings from Spotbugs in hadoop-yarn-server-nodemanager. Contributed by Naganarasimha G R.
(cherry picked from commit 1a18d5e514
)
Conflicts:
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
This commit is contained in:
parent
3044a13080
commit
8cd8b4152d
|
@ -661,7 +661,6 @@ public class NodeStatusUpdaterImpl extends AbstractService implements
|
||||||
public void removeOrTrackCompletedContainersFromContext(
|
public void removeOrTrackCompletedContainersFromContext(
|
||||||
List<ContainerId> containerIds) throws IOException {
|
List<ContainerId> containerIds) throws IOException {
|
||||||
Set<ContainerId> removedContainers = new HashSet<ContainerId>();
|
Set<ContainerId> removedContainers = new HashSet<ContainerId>();
|
||||||
Set<ContainerId> removedNullContainers = new HashSet<ContainerId>();
|
|
||||||
|
|
||||||
pendingContainersToRemove.addAll(containerIds);
|
pendingContainersToRemove.addAll(containerIds);
|
||||||
Iterator<ContainerId> iter = pendingContainersToRemove.iterator();
|
Iterator<ContainerId> iter = pendingContainersToRemove.iterator();
|
||||||
|
@ -671,7 +670,6 @@ public class NodeStatusUpdaterImpl extends AbstractService implements
|
||||||
Container nmContainer = context.getContainers().get(containerId);
|
Container nmContainer = context.getContainers().get(containerId);
|
||||||
if (nmContainer == null) {
|
if (nmContainer == null) {
|
||||||
iter.remove();
|
iter.remove();
|
||||||
removedNullContainers.add(containerId);
|
|
||||||
} else if (nmContainer.getContainerState().equals(
|
} else if (nmContainer.getContainerState().equals(
|
||||||
org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerState.DONE)) {
|
org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerState.DONE)) {
|
||||||
context.getContainers().remove(containerId);
|
context.getContainers().remove(containerId);
|
||||||
|
@ -734,11 +732,12 @@ public class NodeStatusUpdaterImpl extends AbstractService implements
|
||||||
public void removeVeryOldStoppedContainersFromCache() {
|
public void removeVeryOldStoppedContainersFromCache() {
|
||||||
synchronized (recentlyStoppedContainers) {
|
synchronized (recentlyStoppedContainers) {
|
||||||
long currentTime = System.currentTimeMillis();
|
long currentTime = System.currentTimeMillis();
|
||||||
Iterator<ContainerId> i =
|
Iterator<Entry<ContainerId, Long>> i =
|
||||||
recentlyStoppedContainers.keySet().iterator();
|
recentlyStoppedContainers.entrySet().iterator();
|
||||||
while (i.hasNext()) {
|
while (i.hasNext()) {
|
||||||
ContainerId cid = i.next();
|
Entry<ContainerId, Long> mapEntry = i.next();
|
||||||
if (recentlyStoppedContainers.get(cid) < currentTime) {
|
ContainerId cid = mapEntry.getKey();
|
||||||
|
if (mapEntry.getValue() < currentTime) {
|
||||||
if (!context.getContainers().containsKey(cid)) {
|
if (!context.getContainers().containsKey(cid)) {
|
||||||
i.remove();
|
i.remove();
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -17,6 +17,8 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer;
|
package org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer;
|
||||||
|
|
||||||
|
import static org.apache.hadoop.util.Shell.getAllShells;
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -31,6 +33,7 @@ import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.Stack;
|
import java.util.Stack;
|
||||||
import java.util.concurrent.Callable;
|
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.annotations.VisibleForTesting;
|
||||||
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||||
|
|
||||||
import static org.apache.hadoop.util.Shell.getAllShells;
|
|
||||||
|
|
||||||
public class ContainerLocalizer {
|
public class ContainerLocalizer {
|
||||||
|
|
||||||
static final Logger LOG =
|
static final Logger LOG =
|
||||||
|
@ -350,13 +351,13 @@ public class ContainerLocalizer {
|
||||||
final List<LocalResourceStatus> currentResources =
|
final List<LocalResourceStatus> currentResources =
|
||||||
new ArrayList<LocalResourceStatus>();
|
new ArrayList<LocalResourceStatus>();
|
||||||
// TODO: Synchronization??
|
// TODO: Synchronization??
|
||||||
for (Iterator<LocalResource> i = pendingResources.keySet().iterator();
|
for (Iterator<Entry<LocalResource, Future<Path>>> i =
|
||||||
i.hasNext();) {
|
pendingResources.entrySet().iterator(); i.hasNext();) {
|
||||||
LocalResource rsrc = i.next();
|
Entry<LocalResource, Future<Path>> mapEntry = i.next();
|
||||||
LocalResourceStatus stat =
|
LocalResourceStatus stat =
|
||||||
recordFactory.newRecordInstance(LocalResourceStatus.class);
|
recordFactory.newRecordInstance(LocalResourceStatus.class);
|
||||||
stat.setResource(rsrc);
|
stat.setResource(mapEntry.getKey());
|
||||||
Future<Path> fPath = pendingResources.get(rsrc);
|
Future<Path> fPath = mapEntry.getValue();
|
||||||
if (fPath.isDone()) {
|
if (fPath.isDone()) {
|
||||||
try {
|
try {
|
||||||
Path localPath = fPath.get();
|
Path localPath = fPath.get();
|
||||||
|
|
|
@ -130,7 +130,7 @@ public class ContainerMetrics implements MetricsSource {
|
||||||
/**
|
/**
|
||||||
* Simple metrics cache to help prevent re-registrations.
|
* Simple metrics cache to help prevent re-registrations.
|
||||||
*/
|
*/
|
||||||
protected final static Map<ContainerId, ContainerMetrics>
|
private final static Map<ContainerId, ContainerMetrics>
|
||||||
usageMetrics = new HashMap<>();
|
usageMetrics = new HashMap<>();
|
||||||
// Create a timer to unregister container metrics,
|
// Create a timer to unregister container metrics,
|
||||||
// whose associated thread run as a daemon.
|
// whose associated thread run as a daemon.
|
||||||
|
|
Loading…
Reference in New Issue