diff --git a/hadoop-mapreduce-project/CHANGES.txt b/hadoop-mapreduce-project/CHANGES.txt
index 8468afb5bf5..76a042a2e1f 100644
--- a/hadoop-mapreduce-project/CHANGES.txt
+++ b/hadoop-mapreduce-project/CHANGES.txt
@@ -123,6 +123,8 @@ Release 2.0.5-beta - UNRELEASED
MAPREDUCE-5113. Streaming input/output types are ignored with java
mapper/reducer. (sandyr via tucu)
+ MAPREDUCE-5098. Fix findbugs warnings in gridmix. (kkambatl via tucu)
+
Release 2.0.4-alpha - UNRELEASED
INCOMPATIBLE CHANGES
diff --git a/hadoop-tools/hadoop-gridmix/dev-support/findbugs-exclude.xml b/hadoop-tools/hadoop-gridmix/dev-support/findbugs-exclude.xml
new file mode 100644
index 00000000000..92458d4a213
--- /dev/null
+++ b/hadoop-tools/hadoop-gridmix/dev-support/findbugs-exclude.xml
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/hadoop-tools/hadoop-gridmix/pom.xml b/hadoop-tools/hadoop-gridmix/pom.xml
index a9774d166bd..61fdd0ecdab 100644
--- a/hadoop-tools/hadoop-gridmix/pom.xml
+++ b/hadoop-tools/hadoop-gridmix/pom.xml
@@ -100,6 +100,16 @@
+
+ org.codehaus.mojo
+ findbugs-maven-plugin
+
+ true
+ true
+ ${basedir}/dev-support/findbugs-exclude.xml
+ Max
+
+
org.apache.maven.plugins
maven-antrun-plugin
diff --git a/hadoop-tools/hadoop-gridmix/src/main/java/org/apache/hadoop/mapred/gridmix/JobMonitor.java b/hadoop-tools/hadoop-gridmix/src/main/java/org/apache/hadoop/mapred/gridmix/JobMonitor.java
index 64e0c7a0bea..341c49a9c99 100644
--- a/hadoop-tools/hadoop-gridmix/src/main/java/org/apache/hadoop/mapred/gridmix/JobMonitor.java
+++ b/hadoop-tools/hadoop-gridmix/src/main/java/org/apache/hadoop/mapred/gridmix/JobMonitor.java
@@ -86,9 +86,7 @@ class JobMonitor implements Gridmix.Component {
* Add a running job's status to the polling queue.
*/
public void add(JobStats job) throws InterruptedException {
- synchronized (runningJobs) {
runningJobs.put(job);
- }
}
/**
@@ -147,12 +145,10 @@ class JobMonitor implements Gridmix.Component {
boolean shutdown;
while (true) {
try {
- synchronized (runningJobs) {
- synchronized (mJobs) {
- graceful = JobMonitor.this.graceful;
- shutdown = JobMonitor.this.shutdown;
- runningJobs.drainTo(mJobs);
- }
+ synchronized (mJobs) {
+ graceful = JobMonitor.this.graceful;
+ shutdown = JobMonitor.this.shutdown;
+ runningJobs.drainTo(mJobs);
}
// shutdown conditions; either shutdown requested and all jobs
@@ -160,11 +156,9 @@ class JobMonitor implements Gridmix.Component {
// submitted jobs not in the monitored set
if (shutdown) {
if (!graceful) {
- synchronized (runningJobs) {
- while (!runningJobs.isEmpty()) {
- synchronized (mJobs) {
- runningJobs.drainTo(mJobs);
- }
+ while (!runningJobs.isEmpty()) {
+ synchronized (mJobs) {
+ runningJobs.drainTo(mJobs);
}
}
break;
diff --git a/hadoop-tools/hadoop-gridmix/src/main/java/org/apache/hadoop/mapred/gridmix/SleepJob.java b/hadoop-tools/hadoop-gridmix/src/main/java/org/apache/hadoop/mapred/gridmix/SleepJob.java
index a9f2999dd3c..6c2a0480bb8 100644
--- a/hadoop-tools/hadoop-gridmix/src/main/java/org/apache/hadoop/mapred/gridmix/SleepJob.java
+++ b/hadoop-tools/hadoop-gridmix/src/main/java/org/apache/hadoop/mapred/gridmix/SleepJob.java
@@ -84,7 +84,7 @@ public class SleepJob extends GridmixJob {
String[] hosts) throws IOException {
super(conf, submissionMillis, jobdesc, outRoot, ugi, seq);
this.fakeLocations = numLocations;
- this.hosts = hosts;
+ this.hosts = hosts.clone();
this.selector = (fakeLocations > 0)? new Selector(hosts.length, (float) fakeLocations
/ hosts.length, rand.get()) : null;
this.mapTasksOnly = conf.getBoolean(SLEEPJOB_MAPTASK_ONLY, false);
@@ -289,9 +289,9 @@ public class SleepJob extends GridmixJob {
this.id = id;
this.sleepDuration = sleepDuration;
nSpec = reduceDurations.length;
- this.reduceDurations = reduceDurations;
+ this.reduceDurations = reduceDurations.clone();
this.nMaps = nMaps;
- this.locations = locations;
+ this.locations = locations.clone();
}
@Override
@@ -349,7 +349,7 @@ public class SleepJob extends GridmixJob {
@Override
public String[] getLocations() {
- return locations;
+ return locations.clone();
}
}
diff --git a/hadoop-tools/hadoop-gridmix/src/main/java/org/apache/hadoop/mapred/gridmix/emulators/resourceusage/TotalHeapUsageEmulatorPlugin.java b/hadoop-tools/hadoop-gridmix/src/main/java/org/apache/hadoop/mapred/gridmix/emulators/resourceusage/TotalHeapUsageEmulatorPlugin.java
index b9971dc2af5..4cfe1b533a2 100644
--- a/hadoop-tools/hadoop-gridmix/src/main/java/org/apache/hadoop/mapred/gridmix/emulators/resourceusage/TotalHeapUsageEmulatorPlugin.java
+++ b/hadoop-tools/hadoop-gridmix/src/main/java/org/apache/hadoop/mapred/gridmix/emulators/resourceusage/TotalHeapUsageEmulatorPlugin.java
@@ -93,7 +93,7 @@ implements ResourceUsageEmulatorPlugin {
private static final float DEFAULT_HEAP_LOAD_RATIO = 0.1F;
- public static int ONE_MB = 1024 * 1024;
+ public static final int ONE_MB = 1024 * 1024;
/**
* Defines the core heap usage emulation algorithm. This engine is expected
@@ -129,7 +129,8 @@ implements ResourceUsageEmulatorPlugin {
public static class DefaultHeapUsageEmulator
implements HeapUsageEmulatorCore {
// store the unit loads in a list
- protected static ArrayList