HDFS-5419. Fixup test-patch.sh warnings on HDFS-4949 branch. (wang)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/HDFS-4949@1535607 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andrew Wang 2013-10-25 01:56:05 +00:00
parent e87b2a3684
commit dc2ee20aec
10 changed files with 80 additions and 42 deletions

View File

@ -65,9 +65,9 @@ public BatchedRemoteIterator(K prevKey) {
/** /**
* Perform the actual remote request. * Perform the actual remote request.
* *
* @param key The key to send. * @param prevKey The key to send.
* @return A list of replies. * @return A list of replies.
*/ */
public abstract BatchedEntries<E> makeRequest(K prevKey) throws IOException; public abstract BatchedEntries<E> makeRequest(K prevKey) throws IOException;

View File

@ -121,3 +121,5 @@ HDFS-4949 (Unreleased)
HDFS-5405. Fix possible RetryCache hang for caching RPC handlers in HDFS-5405. Fix possible RetryCache hang for caching RPC handlers in
FSNamesystem. (wang) FSNamesystem. (wang)
HDFS-5419. Fixup test-patch.sh warnings on HDFS-4949 branch. (wang)

View File

@ -346,4 +346,22 @@
<Method name="create" /> <Method name="create" />
<Bug pattern="UL_UNRELEASED_LOCK" /> <Bug pattern="UL_UNRELEASED_LOCK" />
</Match> </Match>
<!-- Manually verified to be okay, we want to throw away the top bit here -->
<Match>
<Class name="org.apache.hadoop.hdfs.server.namenode.CachedBlock" />
<Method name="getReplication" />
<Bug pattern="ICAST_QUESTIONABLE_UNSIGNED_RIGHT_SHIFT" />
</Match>
<!-- These two are used for shutting down and kicking the CRMon, do not need strong sync -->
<Match>
<Class name="org.apache.hadoop.hdfs.server.blockmanagement.CacheReplicationMonitor" />
<Field name="shutdown" />
<Bug pattern="IS2_INCONSISTENT_SYNC" />
</Match>
<Match>
<Class name="org.apache.hadoop.hdfs.server.blockmanagement.CacheReplicationMonitor" />
<Field name="rescanImmediately" />
<Bug pattern="IS2_INCONSISTENT_SYNC" />
</Match>
</FindBugsFilter> </FindBugsFilter>

View File

@ -115,25 +115,26 @@ public String toString() {
append(", ownerName:").append(ownerName). append(", ownerName:").append(ownerName).
append(", groupName:").append(groupName). append(", groupName:").append(groupName).
append(", mode:").append((mode == null) ? "null" : append(", mode:").append((mode == null) ? "null" :
String.format("0%03o", mode)). String.format("0%03o", mode.toShort())).
append(", weight:").append(weight). append(", weight:").append(weight).
append("}").toString(); append("}").toString();
} }
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
try { if (o == null) { return false; }
CachePoolInfo other = (CachePoolInfo)o; if (o == this) { return true; }
return new EqualsBuilder(). if (o.getClass() != getClass()) {
append(poolName, other.poolName).
append(ownerName, other.ownerName).
append(groupName, other.groupName).
append(mode, other.mode).
append(weight, other.weight).
isEquals();
} catch (ClassCastException e) {
return false; 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 @Override

View File

@ -82,6 +82,8 @@ public PathBasedCacheDescriptor getDescriptor() {
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (o == null) { return false; }
if (o == this) { return true; }
if (o.getClass() != this.getClass()) { if (o.getClass() != this.getClass()) {
return false; return false;
} }

View File

@ -83,6 +83,8 @@ public int hashCode() {
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (o == null) { return false; }
if (o == this) { return true; }
if (o.getClass() != this.getClass()) { if (o.getClass() != this.getClass()) {
return false; return false;
} }
@ -100,7 +102,7 @@ public boolean getMark() {
} }
public short getReplication() { public short getReplication() {
return (short)(replicationAndMark >>> 1); return (short) (replicationAndMark >>> 1);
} }
/** /**

View File

@ -720,7 +720,7 @@ public int run(Configuration conf, List<String> args) throws IOException {
return 0; return 0;
} }
String commandName = args.get(0); String commandName = args.get(0);
commandName.replaceAll("^[-]*", ""); commandName = commandName.replaceAll("^[-]*", "");
Command command = determineCommand(commandName); Command command = determineCommand(commandName);
if (command == null) { if (command == null) {
System.err.print("Sorry, I don't know the command '" + System.err.print("Sorry, I don't know the command '" +

View File

@ -124,23 +124,14 @@ public static class Builder {
public Builder() { public Builder() {
} }
/**
* See {@link #addField(String, Justification, boolean)
*/
public Builder addField(String title) { public Builder addField(String title) {
return addField(title, Justification.LEFT, false); return addField(title, Justification.LEFT, false);
} }
/**
* See {@link #addField(String, Justification, boolean)
*/
public Builder addField(String title, Justification justification) { public Builder addField(String title, Justification justification) {
return addField(title, justification, false); return addField(title, justification, false);
} }
/**
* See {@link #addField(String, Justification, boolean)
*/
public Builder addField(String title, boolean wrap) { public Builder addField(String title, boolean wrap) {
return addField(title, Justification.LEFT, wrap); return addField(title, Justification.LEFT, wrap);
} }
@ -150,7 +141,7 @@ public Builder addField(String title, boolean wrap) {
* *
* @param title Field title. * @param title Field title.
* @param justification Right or left justification. Defaults to left. * @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. * Defaults to Integer.MAX_VALUE.
* @return This Builder object * @return This Builder object
*/ */

View File

@ -298,16 +298,36 @@ private static Map<String, Object> toJsonMap(final DatanodeInfo datanodeinfo) {
return m; 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. */ /** Convert a Json map to an DatanodeInfo object. */
static DatanodeInfo toDatanodeInfo(final Map<?, ?> m) { static DatanodeInfo toDatanodeInfo(final Map<?, ?> m) {
if (m == null) { if (m == null) {
return null; return null;
} }
Object infoSecurePort = m.get("infoSecurePort");
if (infoSecurePort == null) {
infoSecurePort = 0l; // same as the default value in hdfs.proto
}
return new DatanodeInfo( return new DatanodeInfo(
(String)m.get("ipAddr"), (String)m.get("ipAddr"),
@ -315,19 +335,19 @@ static DatanodeInfo toDatanodeInfo(final Map<?, ?> m) {
(String)m.get("storageID"), (String)m.get("storageID"),
(int)(long)(Long)m.get("xferPort"), (int)(long)(Long)m.get("xferPort"),
(int)(long)(Long)m.get("infoPort"), (int)(long)(Long)m.get("infoPort"),
(int)(long)(Long)infoSecurePort, getInt(m, "infoSecurePort", 0),
(int)(long)(Long)m.get("ipcPort"), (int)(long)(Long)m.get("ipcPort"),
(Long)m.get("capacity"), getLong(m, "capacity", 0l),
(Long)m.get("dfsUsed"), getLong(m, "dfsUsed", 0l),
(Long)m.get("remaining"), getLong(m, "remaining", 0l),
(Long)m.get("blockPoolUsed"), getLong(m, "blockPoolUsed", 0l),
(Long)m.get("cacheCapacity"), getLong(m, "cacheCapacity", 0l),
(Long)m.get("cacheUsed"), getLong(m, "cacheUsed", 0l),
(Long)m.get("lastUpdate"), getLong(m, "lastUpdate", 0l),
(int)(long)(Long)m.get("xceiverCount"), getInt(m, "xceiverCount", 0),
(String)m.get("networkLocation"), getString(m, "networkLocation", ""),
AdminStates.valueOf((String)m.get("adminState"))); AdminStates.valueOf(getString(m, "adminState", "NORMAL")));
} }
/** Convert a DatanodeInfo[] to a Json array. */ /** Convert a DatanodeInfo[] to a Json array. */

View File

@ -79,6 +79,8 @@ public void testToDatanodeInfoWithoutSecurePort() {
response.put("xceiverCount", 4096l); response.put("xceiverCount", 4096l);
response.put("networkLocation", "foo.bar.baz"); response.put("networkLocation", "foo.bar.baz");
response.put("adminState", "NORMAL"); response.put("adminState", "NORMAL");
response.put("cacheCapacity", 123l);
response.put("cacheUsed", 321l);
JsonUtil.toDatanodeInfo(response); JsonUtil.toDatanodeInfo(response);
} }