HDFS-6397. NN shows inconsistent value in deadnode count. Contributed by Mohammad Kamrul Islam.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1595978 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f74e446355
commit
35058fc020
@ -578,6 +578,9 @@ Release 2.4.1 - UNRELEASED
|
||||
HDFS-6325. Append should fail if the last block has insufficient number of
|
||||
replicas (Keith Pak via cos)
|
||||
|
||||
HDFS-6397. NN shows inconsistent value in deadnode count.
|
||||
(Mohammad Kamrul Islam via kihwal)
|
||||
|
||||
Release 2.4.0 - 2014-04-07
|
||||
|
||||
INCOMPATIBLE CHANGES
|
||||
|
@ -1057,15 +1057,7 @@ public int getNumLiveDataNodes() {
|
||||
|
||||
/** @return the number of dead datanodes. */
|
||||
public int getNumDeadDataNodes() {
|
||||
int numDead = 0;
|
||||
synchronized (datanodeMap) {
|
||||
for(DatanodeDescriptor dn : datanodeMap.values()) {
|
||||
if (isDatanodeDead(dn) ) {
|
||||
numDead++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return numDead;
|
||||
return getDatanodeListForReport(DatanodeReportType.DEAD).size();
|
||||
}
|
||||
|
||||
/** @return list of datanodes where decommissioning is in progress. */
|
||||
|
@ -129,4 +129,44 @@ public void testHostsExcludeInUI() throws Exception {
|
||||
cluster.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHostsIncludeForDeadCount() throws Exception {
|
||||
Configuration conf = getConf();
|
||||
|
||||
// Configure an excludes file
|
||||
FileSystem localFileSys = FileSystem.getLocal(conf);
|
||||
Path workingDir = localFileSys.getWorkingDirectory();
|
||||
Path dir = new Path(workingDir, "build/test/data/temp/decommission");
|
||||
Path excludeFile = new Path(dir, "exclude");
|
||||
Path includeFile = new Path(dir, "include");
|
||||
assertTrue(localFileSys.mkdirs(dir));
|
||||
StringBuilder includeHosts = new StringBuilder();
|
||||
includeHosts.append("localhost:52").append("\n").append("127.0.0.1:7777")
|
||||
.append("\n");
|
||||
DFSTestUtil.writeFile(localFileSys, excludeFile, "");
|
||||
DFSTestUtil.writeFile(localFileSys, includeFile, includeHosts.toString());
|
||||
conf.set(DFSConfigKeys.DFS_HOSTS_EXCLUDE, excludeFile.toUri().getPath());
|
||||
conf.set(DFSConfigKeys.DFS_HOSTS, includeFile.toUri().getPath());
|
||||
|
||||
MiniDFSCluster cluster = null;
|
||||
try {
|
||||
cluster = new MiniDFSCluster.Builder(conf).numDataNodes(0).build();
|
||||
final FSNamesystem ns = cluster.getNameNode().getNamesystem();
|
||||
assertTrue(ns.getNumDeadDataNodes() == 2);
|
||||
assertTrue(ns.getNumLiveDataNodes() == 0);
|
||||
|
||||
// Testing using MBeans
|
||||
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
|
||||
ObjectName mxbeanName = new ObjectName(
|
||||
"Hadoop:service=NameNode,name=FSNamesystemState");
|
||||
String nodes = mbs.getAttribute(mxbeanName, "NumDeadDataNodes") + "";
|
||||
assertTrue((Integer) mbs.getAttribute(mxbeanName, "NumDeadDataNodes") == 2);
|
||||
assertTrue((Integer) mbs.getAttribute(mxbeanName, "NumLiveDataNodes") == 0);
|
||||
} finally {
|
||||
if (cluster != null) {
|
||||
cluster.shutdown();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user