HDFS-9033. dfsadmin -metasave prints "NaN" for cache used%. Contributed by Brahma Reddy Battula.

This commit is contained in:
Akira Ajisaka 2015-09-09 17:20:46 +09:00
parent 94cf7ab9d2
commit 0113e4528d
3 changed files with 18 additions and 2 deletions

View File

@ -371,9 +371,11 @@ public class DatanodeInfo extends DatanodeID implements Node {
long c = getCapacity(); long c = getCapacity();
long r = getRemaining(); long r = getRemaining();
long u = getDfsUsed(); long u = getDfsUsed();
float usedPercent = getDfsUsedPercent();
long cc = getCacheCapacity(); long cc = getCacheCapacity();
long cr = getCacheRemaining(); long cr = getCacheRemaining();
long cu = getCacheUsed(); long cu = getCacheUsed();
float cacheUsedPercent = getCacheUsedPercent();
buffer.append(getName()); buffer.append(getName());
if (!NetworkTopology.DEFAULT_RACK.equals(location)) { if (!NetworkTopology.DEFAULT_RACK.equals(location)) {
buffer.append(" "+location); buffer.append(" "+location);
@ -387,11 +389,11 @@ public class DatanodeInfo extends DatanodeID implements Node {
} }
buffer.append(" " + c + "(" + StringUtils.byteDesc(c)+")"); buffer.append(" " + c + "(" + StringUtils.byteDesc(c)+")");
buffer.append(" " + u + "(" + StringUtils.byteDesc(u)+")"); buffer.append(" " + u + "(" + StringUtils.byteDesc(u)+")");
buffer.append(" " + percent2String(u/(double)c)); buffer.append(" " + percent2String(usedPercent));
buffer.append(" " + r + "(" + StringUtils.byteDesc(r)+")"); buffer.append(" " + r + "(" + StringUtils.byteDesc(r)+")");
buffer.append(" " + cc + "(" + StringUtils.byteDesc(cc)+")"); buffer.append(" " + cc + "(" + StringUtils.byteDesc(cc)+")");
buffer.append(" " + cu + "(" + StringUtils.byteDesc(cu)+")"); buffer.append(" " + cu + "(" + StringUtils.byteDesc(cu)+")");
buffer.append(" " + percent2String(cu/(double)cc)); buffer.append(" " + percent2String(cacheUsedPercent));
buffer.append(" " + cr + "(" + StringUtils.byteDesc(cr)+")"); buffer.append(" " + cr + "(" + StringUtils.byteDesc(cr)+")");
buffer.append(" " + new Date(lastUpdate)); buffer.append(" " + new Date(lastUpdate));
return buffer.toString(); return buffer.toString();

View File

@ -1358,6 +1358,9 @@ Release 2.7.2 - UNRELEASED
HDFS-8995. Flaw in registration bookeeping can make DN die on reconnect. HDFS-8995. Flaw in registration bookeeping can make DN die on reconnect.
(Kihwal Lee via yliu) (Kihwal Lee via yliu)
HDFS-9033. dfsadmin -metasave prints "NaN" for cache used%.
(Brahma Reddy Battula via aajisaka)
Release 2.7.1 - 2015-07-06 Release 2.7.1 - 2015-07-06
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -17,6 +17,7 @@
*/ */
package org.apache.hadoop.hdfs.server.namenode; package org.apache.hadoop.hdfs.server.namenode;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
@ -149,6 +150,16 @@ public class TestMetaSave {
assertTrue(line.equals("Mis-replicated blocks that have been postponed:")); assertTrue(line.equals("Mis-replicated blocks that have been postponed:"));
line = reader.readLine(); line = reader.readLine();
assertTrue(line.equals("Metasave: Blocks being replicated: 0")); assertTrue(line.equals("Metasave: Blocks being replicated: 0"));
line = reader.readLine();
assertTrue(line.equals("Metasave: Blocks 2 waiting deletion from 1 datanodes."));
//skip 2 lines to reach HDFS-9033 scenario.
line = reader.readLine();
line = reader.readLine();
line = reader.readLine();
assertTrue(line.equals("Metasave: Number of datanodes: 2"));
line = reader.readLine();
assertFalse(line.contains("NaN"));
} finally { } finally {
if (reader != null) if (reader != null)
reader.close(); reader.close();