HADOOP-14400. Fix warnings from spotbugs in hadoop-tools. Contributed by Weiwei Yang.

(cherry picked from commit 2ba9903932)
This commit is contained in:
Akira Ajisaka 2017-05-10 05:57:12 -05:00 committed by Masatake Iwasaki
parent 7dedf344de
commit 2dffc1d8cb
5 changed files with 22 additions and 22 deletions

View File

@ -3010,8 +3010,6 @@ public class NativeAzureFileSystem extends FileSystem {
ArrayList<String> keysToCreateAsFolder = new ArrayList<String>(); ArrayList<String> keysToCreateAsFolder = new ArrayList<String>();
ArrayList<String> keysToUpdateAsFolder = new ArrayList<String>();
boolean childCreated = false;
// Check that there is no file in the parent chain of the given path. // Check that there is no file in the parent chain of the given path.
for (Path current = absolutePath, parent = current.getParent(); for (Path current = absolutePath, parent = current.getParent();
parent != null; // Stop when you get to the root parent != null; // Stop when you get to the root
@ -3023,14 +3021,6 @@ public class NativeAzureFileSystem extends FileSystem {
+ current + " is an existing file."); + current + " is an existing file.");
} else if (currentMetadata == null) { } else if (currentMetadata == null) {
keysToCreateAsFolder.add(currentKey); keysToCreateAsFolder.add(currentKey);
childCreated = true;
} else {
// The directory already exists. Its last modified time need to be
// updated if there is a child directory created under it.
if (childCreated) {
keysToUpdateAsFolder.add(currentKey);
}
childCreated = false;
} }
} }

View File

@ -131,9 +131,7 @@ class InputStriper {
static final Comparator<Entry<String,Double>> hostRank = static final Comparator<Entry<String,Double>> hostRank =
new Comparator<Entry<String,Double>>() { new Comparator<Entry<String,Double>>() {
public int compare(Entry<String,Double> a, Entry<String,Double> b) { public int compare(Entry<String,Double> a, Entry<String,Double> b) {
final double va = a.getValue(); return Double.compare(a.getValue(), b.getValue());
final double vb = b.getValue(); }
return va > vb ? -1 : va < vb ? 1 : 0;
}
}; };
} }

View File

@ -19,6 +19,8 @@ package org.apache.hadoop.mapred.gridmix.emulators.resourceusage;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import com.google.common.annotations.VisibleForTesting;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.mapred.gridmix.Progressive; import org.apache.hadoop.mapred.gridmix.Progressive;
import org.apache.hadoop.tools.rumen.ResourceUsageMetrics; import org.apache.hadoop.tools.rumen.ResourceUsageMetrics;
@ -129,7 +131,7 @@ implements ResourceUsageEmulatorPlugin {
public static class DefaultHeapUsageEmulator public static class DefaultHeapUsageEmulator
implements HeapUsageEmulatorCore { implements HeapUsageEmulatorCore {
// store the unit loads in a list // store the unit loads in a list
protected static final ArrayList<Object> heapSpace = private static final ArrayList<Object> heapSpace =
new ArrayList<Object>(); new ArrayList<Object>();
/** /**
@ -143,6 +145,16 @@ implements ResourceUsageEmulatorPlugin {
} }
} }
/**
* Gets the total number of 1mb objects stored in the emulator.
*
* @return total number of 1mb objects.
*/
@VisibleForTesting
public int getHeapSpaceSize() {
return heapSpace.size();
}
/** /**
* This will initialize the core and check if the core can emulate the * This will initialize the core and check if the core can emulate the
* desired target on the underlying hardware. * desired target on the underlying hardware.

View File

@ -58,7 +58,7 @@ public class TestGridmixMemoryEmulation {
// Get the total number of 1mb objects stored within // Get the total number of 1mb objects stored within
long getHeapUsageInMB() { long getHeapUsageInMB() {
return heapSpace.size(); return getHeapSpaceSize();
} }
@Override @Override

View File

@ -131,7 +131,7 @@ public class MapReduceJobPropertiesParser implements JobPropertyParser {
/** /**
* Extracts the -Xmx heap option from the specified string. * Extracts the -Xmx heap option from the specified string.
*/ */
public static void extractMaxHeapOpts(String javaOptions, public static void extractMaxHeapOpts(final String javaOptions,
List<String> heapOpts, List<String> heapOpts,
List<String> others) { List<String> others) {
for (String opt : javaOptions.split(" ")) { for (String opt : javaOptions.split(" ")) {
@ -161,6 +161,7 @@ public class MapReduceJobPropertiesParser implements JobPropertyParser {
// Maps the value of the specified key. // Maps the value of the specified key.
private DataType<?> fromString(String key, String value) { private DataType<?> fromString(String key, String value) {
DefaultDataType defaultValue = new DefaultDataType(value);
if (value != null) { if (value != null) {
// check known configs // check known configs
// job-name // job-name
@ -191,14 +192,13 @@ public class MapReduceJobPropertiesParser implements JobPropertyParser {
// check if the config parameter represents a number // check if the config parameter represents a number
try { try {
format.parse(value); format.parse(value);
return new DefaultDataType(value); return defaultValue;
} catch (ParseException pe) {} } catch (ParseException pe) {}
// check if the config parameters represents a boolean // check if the config parameters represents a boolean
// avoiding exceptions // avoiding exceptions
if ("true".equals(value) || "false".equals(value)) { if ("true".equals(value) || "false".equals(value)) {
Boolean.parseBoolean(value); return defaultValue;
return new DefaultDataType(value);
} }
// check if the config parameter represents a class // check if the config parameter represents a class
@ -209,7 +209,7 @@ public class MapReduceJobPropertiesParser implements JobPropertyParser {
// handle distributed cache sizes and timestamps // handle distributed cache sizes and timestamps
if (latestKey.endsWith("sizes") if (latestKey.endsWith("sizes")
|| latestKey.endsWith(".timestamps")) { || latestKey.endsWith(".timestamps")) {
new DefaultDataType(value); return defaultValue;
} }
// check if the config parameter represents a file-system path // check if the config parameter represents a file-system path