HADOOP-9152. HDFS can report negative DFS Used on clusters with very small amounts of data. Contributed by Brock Noland.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1423602 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Aaron Myers 2012-12-18 19:49:14 +00:00
parent 9189917be5
commit 371abd6e21
3 changed files with 12 additions and 1 deletions

View File

@ -505,6 +505,9 @@ Release 2.0.3-alpha - Unreleased
HADOOP-9135. JniBasedUnixGroupsMappingWithFallback should log at debug
rather than info during fallback. (Colin Patrick McCabe via todd)
HADOOP-9152. HDFS can report negative DFS Used on clusters with very small
amounts of data. (Brock Noland via atm)
Release 2.0.2-alpha - 2012-09-07
INCOMPATIBLE CHANGES

View File

@ -136,7 +136,7 @@ public long getUsed() throws IOException {
}
}
return used.longValue();
return Math.max(used.longValue(), 0L);
}
/**

View File

@ -103,4 +103,12 @@ public void testDU() throws IOException, InterruptedException {
duSize >= writtenSize &&
writtenSize <= (duSize + slack));
}
public void testDUGetUsedWillNotReturnNegative() throws IOException {
File file = new File(DU_DIR, "data");
assertTrue(file.createNewFile());
DU du = new DU(file, 10000);
du.decDfsUsed(Long.MAX_VALUE);
long duSize = du.getUsed();
assertTrue(String.valueOf(duSize), duSize >= 0L);
}
}