diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/BatchedRemoteIterator.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/BatchedRemoteIterator.java index 1e9398b45c..607fffbcc7 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/BatchedRemoteIterator.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/BatchedRemoteIterator.java @@ -65,9 +65,9 @@ public BatchedRemoteIterator(K prevKey) { /** * Perform the actual remote request. - * - * @param key The key to send. - * @return A list of replies. + * + * @param prevKey The key to send. + * @return A list of replies. */ public abstract BatchedEntries makeRequest(K prevKey) throws IOException; diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES-HDFS-4949.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES-HDFS-4949.txt index e9f9902122..7045860f32 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES-HDFS-4949.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES-HDFS-4949.txt @@ -121,3 +121,5 @@ HDFS-4949 (Unreleased) HDFS-5405. Fix possible RetryCache hang for caching RPC handlers in FSNamesystem. (wang) + HDFS-5419. Fixup test-patch.sh warnings on HDFS-4949 branch. (wang) + diff --git a/hadoop-hdfs-project/hadoop-hdfs/dev-support/findbugsExcludeFile.xml b/hadoop-hdfs-project/hadoop-hdfs/dev-support/findbugsExcludeFile.xml index 77d9315bfc..1c64505079 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/dev-support/findbugsExcludeFile.xml +++ b/hadoop-hdfs-project/hadoop-hdfs/dev-support/findbugsExcludeFile.xml @@ -346,4 +346,22 @@ + + + + + + + + + + + + + + + + + + diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/CachePoolInfo.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/CachePoolInfo.java index 68cd0bb245..e944d3c299 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/CachePoolInfo.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/CachePoolInfo.java @@ -115,25 +115,26 @@ public String toString() { append(", ownerName:").append(ownerName). append(", groupName:").append(groupName). append(", mode:").append((mode == null) ? "null" : - String.format("0%03o", mode)). + String.format("0%03o", mode.toShort())). append(", weight:").append(weight). append("}").toString(); } @Override public boolean equals(Object o) { - try { - CachePoolInfo other = (CachePoolInfo)o; - return new EqualsBuilder(). - append(poolName, other.poolName). - append(ownerName, other.ownerName). - append(groupName, other.groupName). - append(mode, other.mode). - append(weight, other.weight). - isEquals(); - } catch (ClassCastException e) { + if (o == null) { return false; } + if (o == this) { return true; } + if (o.getClass() != getClass()) { return false; } + CachePoolInfo other = (CachePoolInfo)o; + return new EqualsBuilder(). + append(poolName, other.poolName). + append(ownerName, other.ownerName). + append(groupName, other.groupName). + append(mode, other.mode). + append(weight, other.weight). + isEquals(); } @Override diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/PathBasedCacheEntry.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/PathBasedCacheEntry.java index f500e53000..b07a26df8e 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/PathBasedCacheEntry.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/PathBasedCacheEntry.java @@ -82,6 +82,8 @@ public PathBasedCacheDescriptor getDescriptor() { @Override public boolean equals(Object o) { + if (o == null) { return false; } + if (o == this) { return true; } if (o.getClass() != this.getClass()) { return false; } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/CachedBlock.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/CachedBlock.java index 35c86d4a63..9584ea7100 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/CachedBlock.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/CachedBlock.java @@ -83,6 +83,8 @@ public int hashCode() { @Override public boolean equals(Object o) { + if (o == null) { return false; } + if (o == this) { return true; } if (o.getClass() != this.getClass()) { return false; } @@ -100,7 +102,7 @@ public boolean getMark() { } public short getReplication() { - return (short)(replicationAndMark >>> 1); + return (short) (replicationAndMark >>> 1); } /** diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/CacheAdmin.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/CacheAdmin.java index 10de3b3783..40af431f4b 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/CacheAdmin.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/CacheAdmin.java @@ -720,7 +720,7 @@ public int run(Configuration conf, List args) throws IOException { return 0; } String commandName = args.get(0); - commandName.replaceAll("^[-]*", ""); + commandName = commandName.replaceAll("^[-]*", ""); Command command = determineCommand(commandName); if (command == null) { System.err.print("Sorry, I don't know the command '" + diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/TableListing.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/TableListing.java index 857111d551..4d807cbbef 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/TableListing.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/TableListing.java @@ -124,23 +124,14 @@ public static class Builder { public Builder() { } - /** - * See {@link #addField(String, Justification, boolean) - */ public Builder addField(String title) { return addField(title, Justification.LEFT, false); } - /** - * See {@link #addField(String, Justification, boolean) - */ public Builder addField(String title, Justification justification) { return addField(title, justification, false); } - /** - * See {@link #addField(String, Justification, boolean) - */ public Builder addField(String title, boolean wrap) { return addField(title, Justification.LEFT, wrap); } @@ -150,7 +141,7 @@ public Builder addField(String title, boolean wrap) { * * @param title Field title. * @param justification Right or left justification. Defaults to left. - * @Param wrapWidth Width at which to auto-wrap the content of the cell. + * @param wrap Width at which to auto-wrap the content of the cell. * Defaults to Integer.MAX_VALUE. * @return This Builder object */ diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/JsonUtil.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/JsonUtil.java index 116bbae124..ab24fbe2a5 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/JsonUtil.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/JsonUtil.java @@ -298,16 +298,36 @@ private static Map toJsonMap(final DatanodeInfo datanodeinfo) { return m; } + private static int getInt(Map m, String key, final int defaultValue) { + Object value = m.get(key); + if (value == null) { + return defaultValue; + } + return (int) (long) (Long) value; + } + + private static long getLong(Map m, String key, final long defaultValue) { + Object value = m.get(key); + if (value == null) { + return defaultValue; + } + return (long) (Long) value; + } + + private static String getString(Map m, String key, + final String defaultValue) { + Object value = m.get(key); + if (value == null) { + return defaultValue; + } + return (String) value; + } + /** Convert a Json map to an DatanodeInfo object. */ static DatanodeInfo toDatanodeInfo(final Map m) { if (m == null) { return null; } - - Object infoSecurePort = m.get("infoSecurePort"); - if (infoSecurePort == null) { - infoSecurePort = 0l; // same as the default value in hdfs.proto - } return new DatanodeInfo( (String)m.get("ipAddr"), @@ -315,19 +335,19 @@ static DatanodeInfo toDatanodeInfo(final Map m) { (String)m.get("storageID"), (int)(long)(Long)m.get("xferPort"), (int)(long)(Long)m.get("infoPort"), - (int)(long)(Long)infoSecurePort, + getInt(m, "infoSecurePort", 0), (int)(long)(Long)m.get("ipcPort"), - (Long)m.get("capacity"), - (Long)m.get("dfsUsed"), - (Long)m.get("remaining"), - (Long)m.get("blockPoolUsed"), - (Long)m.get("cacheCapacity"), - (Long)m.get("cacheUsed"), - (Long)m.get("lastUpdate"), - (int)(long)(Long)m.get("xceiverCount"), - (String)m.get("networkLocation"), - AdminStates.valueOf((String)m.get("adminState"))); + getLong(m, "capacity", 0l), + getLong(m, "dfsUsed", 0l), + getLong(m, "remaining", 0l), + getLong(m, "blockPoolUsed", 0l), + getLong(m, "cacheCapacity", 0l), + getLong(m, "cacheUsed", 0l), + getLong(m, "lastUpdate", 0l), + getInt(m, "xceiverCount", 0), + getString(m, "networkLocation", ""), + AdminStates.valueOf(getString(m, "adminState", "NORMAL"))); } /** Convert a DatanodeInfo[] to a Json array. */ diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestJsonUtil.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestJsonUtil.java index 0dc00a6aac..f4f7095bcf 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestJsonUtil.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestJsonUtil.java @@ -79,6 +79,8 @@ public void testToDatanodeInfoWithoutSecurePort() { response.put("xceiverCount", 4096l); response.put("networkLocation", "foo.bar.baz"); response.put("adminState", "NORMAL"); + response.put("cacheCapacity", 123l); + response.put("cacheUsed", 321l); JsonUtil.toDatanodeInfo(response); }