Revert "HDFS-11696. Fix warnings from Spotbugs in hadoop-hdfs. Contributed by Yiqun Lin."

This reverts commit 89a8edc014.

 Conflicts:
	hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/DFSAdmin.java
This commit is contained in:
Andrew Wang 2017-06-29 13:54:16 -07:00
parent 5a75f73893
commit 441378e7e4
9 changed files with 33 additions and 62 deletions

View File

@ -2883,12 +2883,9 @@ public class DFSClient implements java.io.Closeable, RemotePeerFactory,
} }
synchronized (DFSClient.class) { synchronized (DFSClient.class) {
if (STRIPED_READ_THREAD_POOL == null) { if (STRIPED_READ_THREAD_POOL == null) {
// Only after thread pool is fully constructed then save it to STRIPED_READ_THREAD_POOL = DFSUtilClient.getThreadPoolExecutor(1,
// volatile field.
ThreadPoolExecutor threadPool = DFSUtilClient.getThreadPoolExecutor(1,
numThreads, 60, "StripedRead-", true); numThreads, 60, "StripedRead-", true);
threadPool.allowCoreThreadTimeOut(true); STRIPED_READ_THREAD_POOL.allowCoreThreadTimeOut(true);
STRIPED_READ_THREAD_POOL = threadPool;
} }
} }
} }

View File

@ -101,9 +101,8 @@ public final class SlowDiskReports {
} }
boolean areEqual; boolean areEqual;
for (Map.Entry<String, Map<DiskOp, Double>> entry : this.slowDisks for (String disk : this.slowDisks.keySet()) {
.entrySet()) { if (!this.slowDisks.get(disk).equals(that.slowDisks.get(disk))) {
if (!entry.getValue().equals(that.slowDisks.get(entry.getKey()))) {
return false; return false;
} }
} }

View File

@ -252,9 +252,4 @@
<Class name="org.apache.hadoop.hdfs.server.datanode.checker.AbstractFuture" /> <Class name="org.apache.hadoop.hdfs.server.datanode.checker.AbstractFuture" />
<Bug pattern="NS_DANGEROUS_NON_SHORT_CIRCUIT" /> <Bug pattern="NS_DANGEROUS_NON_SHORT_CIRCUIT" />
</Match> </Match>
<Match>
<Class name="org.apache.hadoop.hdfs.server.namenode.NNUpgradeUtil$1" />
<Method name="visitFile" />
<Bug pattern="NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE" />
</Match>
</FindBugsFilter> </FindBugsFilter>

View File

@ -299,18 +299,14 @@ public class JournalNode implements Tool, Configurable, JournalNodeMXBean {
return file.isDirectory(); return file.isDirectory();
} }
}); });
for (File journalDir : journalDirs) {
if (journalDirs != null) { String jid = journalDir.getName();
for (File journalDir : journalDirs) { if (!status.containsKey(jid)) {
String jid = journalDir.getName(); Map<String, String> jMap = new HashMap<String, String>();
if (!status.containsKey(jid)) { jMap.put("Formatted", "true");
Map<String, String> jMap = new HashMap<String, String>(); status.put(jid, jMap);
jMap.put("Formatted", "true");
status.put(jid, jMap);
}
} }
} }
return JSON.toString(status); return JSON.toString(status);
} }

View File

@ -190,8 +190,6 @@ public interface HdfsServerConstants {
} }
public void setClusterId(String cid) { public void setClusterId(String cid) {
Preconditions.checkState(this == UPGRADE || this == UPGRADEONLY
|| this == FORMAT);
clusterId = cid; clusterId = cid;
} }
@ -216,7 +214,6 @@ public interface HdfsServerConstants {
} }
public void setForce(int force) { public void setForce(int force) {
Preconditions.checkState(this == RECOVER);
this.force = force; this.force = force;
} }
@ -229,7 +226,6 @@ public interface HdfsServerConstants {
} }
public void setForceFormat(boolean force) { public void setForceFormat(boolean force) {
Preconditions.checkState(this == FORMAT);
isForceFormat = force; isForceFormat = force;
} }
@ -238,7 +234,6 @@ public interface HdfsServerConstants {
} }
public void setInteractiveFormat(boolean interactive) { public void setInteractiveFormat(boolean interactive) {
Preconditions.checkState(this == FORMAT);
isInteractiveFormat = interactive; isInteractiveFormat = interactive;
} }

View File

@ -1336,14 +1336,10 @@ public class DataStorage extends Storage {
return name.startsWith(BLOCK_SUBDIR_PREFIX); return name.startsWith(BLOCK_SUBDIR_PREFIX);
} }
}); });
for(int i = 0; i < otherNames.length; i++)
if (otherNames != null) { linkBlocksHelper(new File(from, otherNames[i]),
for (int i = 0; i < otherNames.length; i++) { new File(to, otherNames[i]), oldLV, hl, upgradeToIdBasedLayout,
linkBlocksHelper(new File(from, otherNames[i]), blockRoot, idBasedLayoutSingleLinks);
new File(to, otherNames[i]), oldLV, hl, upgradeToIdBasedLayout,
blockRoot, idBasedLayoutSingleLinks);
}
}
} }
/** /**

View File

@ -255,27 +255,24 @@ public class NNStorageRetentionManager {
}); });
// Check whether there is any work to do. // Check whether there is any work to do.
if (filesInStorage != null if (filesInStorage.length <= numCheckpointsToRetain) {
&& filesInStorage.length <= numCheckpointsToRetain) {
return; return;
} }
// Create a sorted list of txids from the file names. // Create a sorted list of txids from the file names.
TreeSet<Long> sortedTxIds = new TreeSet<Long>(); TreeSet<Long> sortedTxIds = new TreeSet<Long>();
if (filesInStorage != null) { for (String fName : filesInStorage) {
for (String fName : filesInStorage) { // Extract the transaction id from the file name.
// Extract the transaction id from the file name. long fTxId;
long fTxId; try {
try { fTxId = Long.parseLong(fName.substring(oivImagePrefix.length() + 1));
fTxId = Long.parseLong(fName.substring(oivImagePrefix.length() + 1)); } catch (NumberFormatException nfe) {
} catch (NumberFormatException nfe) { // This should not happen since we have already filtered it.
// This should not happen since we have already filtered it. // Log and continue.
// Log and continue. LOG.warn("Invalid file name. Skipping " + fName);
LOG.warn("Invalid file name. Skipping " + fName); continue;
continue;
}
sortedTxIds.add(Long.valueOf(fTxId));
} }
sortedTxIds.add(Long.valueOf(fTxId));
} }
int numFilesToDelete = sortedTxIds.size() - numCheckpointsToRetain; int numFilesToDelete = sortedTxIds.size() - numCheckpointsToRetain;

View File

@ -1977,7 +1977,7 @@ public class DFSAdmin extends FsShell {
return exitCode; return exitCode;
} }
} else if ("-report".equals(cmd)) { } else if ("-report".equals(cmd)) {
if (argv.length > 6) { if (argv.length < 1) {
printUsage(cmd); printUsage(cmd);
return exitCode; return exitCode;
} }
@ -2007,7 +2007,7 @@ public class DFSAdmin extends FsShell {
return exitCode; return exitCode;
} }
} else if (RollingUpgradeCommand.matches(cmd)) { } else if (RollingUpgradeCommand.matches(cmd)) {
if (argv.length > 2) { if (argv.length < 1 || argv.length > 2) {
printUsage(cmd); printUsage(cmd);
return exitCode; return exitCode;
} }
@ -2082,7 +2082,7 @@ public class DFSAdmin extends FsShell {
return exitCode; return exitCode;
} }
} else if ("-triggerBlockReport".equals(cmd)) { } else if ("-triggerBlockReport".equals(cmd)) {
if ((argv.length != 2) && (argv.length != 3)) { if (argv.length < 1) {
printUsage(cmd); printUsage(cmd);
return exitCode; return exitCode;
} }

View File

@ -722,13 +722,9 @@ class ImageLoaderCurrent implements ImageLoader {
if (supportSnapshot && supportInodeId) { if (supportSnapshot && supportInodeId) {
dirNodeMap.put(inodeId, pathName); dirNodeMap.put(inodeId, pathName);
} }
v.visit(ImageElement.NS_QUOTA, numBlocks == -1 ? in.readLong() : -1);
v.visit(ImageElement.NS_QUOTA, in.readLong()); if (NameNodeLayoutVersion.supports(Feature.DISKSPACE_QUOTA, imageVersion))
if (NameNodeLayoutVersion.supports(Feature.DISKSPACE_QUOTA, v.visit(ImageElement.DS_QUOTA, numBlocks == -1 ? in.readLong() : -1);
imageVersion)) {
v.visit(ImageElement.DS_QUOTA, in.readLong());
}
if (supportSnapshot) { if (supportSnapshot) {
boolean snapshottable = in.readBoolean(); boolean snapshottable = in.readBoolean();
if (!snapshottable) { if (!snapshottable) {