From b786be0307b841af547465b5ee22a583776c3c2b Mon Sep 17 00:00:00 2001 From: Vinod Kumar Vavilapalli Date: Tue, 28 Jan 2014 20:17:27 +0000 Subject: [PATCH] YARN-1597. Fixed Findbugs warnings on branch YARN-321. Contributed by Vinod Kumar Vavilapalli. svn merge --ignore-ancestry -c 1557958 ../YARN-321 git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1562217 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-yarn-project/CHANGES.txt | 3 +++ .../ApplicationHistoryManagerImpl.java | 21 +++++++++++-------- .../FileSystemApplicationHistoryStore.java | 3 +-- .../ahs/RMApplicationHistoryWriter.java | 2 +- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index 925f1f00089..eac5d72b51d 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -81,6 +81,9 @@ Branch YARN-321: Generic ApplicationHistoryService YARN-1596. Fixed Javadoc warnings on branch YARN-321. (Vinod Kumar Vavilapalli via zjshen) + YARN-1597. Fixed Findbugs warnings on branch YARN-321. (Vinod Kumar Vavilapalli + via zjshen) + Release 2.4.0 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryManagerImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryManagerImpl.java index 6ac8ed94ac7..2a97ff00dc5 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryManagerImpl.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryManagerImpl.java @@ -21,6 +21,7 @@ package org.apache.hadoop.yarn.server.applicationhistoryservice; import java.io.IOException; import java.util.HashMap; import java.util.Map; +import java.util.Map.Entry; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -94,9 +95,10 @@ public class ApplicationHistoryManagerImpl extends AbstractService implements Map histData = historyStore .getAllApplications(); HashMap applicationsReport = new HashMap(); - for (ApplicationId appId : histData.keySet()) { - applicationsReport.put(appId, convertToApplicationReport(histData - .get(appId))); + for (Entry entry : histData + .entrySet()) { + applicationsReport.put(entry.getKey(), + convertToApplicationReport(entry.getValue())); } return applicationsReport; } @@ -171,9 +173,10 @@ public class ApplicationHistoryManagerImpl extends AbstractService implements Map histData = historyStore .getApplicationAttempts(appId); HashMap applicationAttemptsReport = new HashMap(); - for (ApplicationAttemptId appAttemptId : histData.keySet()) { - applicationAttemptsReport.put(appAttemptId, - convertToApplicationAttemptReport(histData.get(appAttemptId))); + for (Entry entry : histData + .entrySet()) { + applicationAttemptsReport.put(entry.getKey(), + convertToApplicationAttemptReport(entry.getValue())); } return applicationAttemptsReport; } @@ -201,9 +204,9 @@ public class ApplicationHistoryManagerImpl extends AbstractService implements Map histData = historyStore .getContainers(appAttemptId); HashMap containersReport = new HashMap(); - for (ContainerId container : histData.keySet()) { - containersReport.put(container, convertToContainerReport(histData - .get(container))); + for (Entry entry : histData.entrySet()) { + containersReport.put(entry.getKey(), + convertToContainerReport(entry.getValue())); } return containersReport; } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/FileSystemApplicationHistoryStore.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/FileSystemApplicationHistoryStore.java index b4d97f314db..afc24d7234e 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/FileSystemApplicationHistoryStore.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/FileSystemApplicationHistoryStore.java @@ -739,7 +739,6 @@ public class FileSystemApplicationHistoryStore extends AbstractService } } - private FSDataInputStream fsdis; private TFile.Reader reader; private TFile.Reader.Scanner scanner; @@ -773,7 +772,7 @@ public class FileSystemApplicationHistoryStore extends AbstractService } public void close() { - IOUtils.cleanup(LOG, scanner, reader, fsdis); + IOUtils.cleanup(LOG, scanner, reader); } } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ahs/RMApplicationHistoryWriter.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ahs/RMApplicationHistoryWriter.java index 354fcc4c638..fa17e200237 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ahs/RMApplicationHistoryWriter.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ahs/RMApplicationHistoryWriter.java @@ -319,7 +319,7 @@ public class RMApplicationHistoryWriter extends CompositeService { // dispatcher, such that all the writing events of one application will // be handled by one thread, the scheduled order of the these events // will be preserved - int index = Math.abs(event.hashCode()) % dispatchers.size(); + int index = (event.hashCode() & Integer.MAX_VALUE) % dispatchers.size(); dispatchers.get(index).getEventHandler().handle(event); }