You are viewing a plain text version of this content. The canonical link for it is here.
Posted to hdfs-commits@hadoop.apache.org by sz...@apache.org on 2011/05/04 00:16:30 UTC
svn commit: r1099285 - in /hadoop/hdfs/trunk: CHANGES.txt
src/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
src/java/org/apache/hadoop/hdfs/server/namenode/NamenodeJspHelper.java
Author: szetszwo
Date: Tue May 3 22:16:29 2011
New Revision: 1099285
URL: http://svn.apache.org/viewvc?rev=1099285&view=rev
Log:
HDFS-1773. Do not show decommissioned datanodes, which are not in both include and exclude lists, on web and JMX interfaces. Contributed by Tanping Wang
Modified:
hadoop/hdfs/trunk/CHANGES.txt
hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/NamenodeJspHelper.java
Modified: hadoop/hdfs/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/CHANGES.txt?rev=1099285&r1=1099284&r2=1099285&view=diff
==============================================================================
--- hadoop/hdfs/trunk/CHANGES.txt (original)
+++ hadoop/hdfs/trunk/CHANGES.txt Tue May 3 22:16:29 2011
@@ -487,6 +487,10 @@ Trunk (unreleased changes)
HDFS-1876. One MiniDFSCluster constructor ignores numDataNodes parameter
(todd)
+ HDFS-1773. Do not show decommissioned datanodes, which are not in both
+ include and exclude lists, on web and JMX interfaces.
+ (Tanping Wang via szetszwo)
+
Release 0.22.0 - Unreleased
NEW FEATURES
Modified: hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java?rev=1099285&r1=1099284&r2=1099285&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java (original)
+++ hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java Tue May 3 22:16:29 2011
@@ -5517,6 +5517,7 @@ public class FSNamesystem implements FSC
final Map<String, Object> info = new HashMap<String, Object>();
final ArrayList<DatanodeDescriptor> aliveNodeList =
this.getDatanodeListForReport(DatanodeReportType.LIVE);
+ removeDecomNodeFromList(aliveNodeList);
for (DatanodeDescriptor node : aliveNodeList) {
final Map<String, Object> innerinfo = new HashMap<String, Object>();
innerinfo.put("lastContact", getLastContact(node));
@@ -5536,6 +5537,7 @@ public class FSNamesystem implements FSC
final Map<String, Object> info = new HashMap<String, Object>();
final ArrayList<DatanodeDescriptor> deadNodeList =
this.getDatanodeListForReport(DatanodeReportType.DEAD);
+ removeDecomNodeFromList(deadNodeList);
for (DatanodeDescriptor node : deadNodeList) {
final Map<String, Object> innerinfo = new HashMap<String, Object>();
innerinfo.put("lastContact", getLastContact(node));
@@ -5584,4 +5586,49 @@ public class FSNamesystem implements FSC
public String getBlockPoolId() {
return blockPoolId;
}
+
+ /**
+ * Remove an already decommissioned data node who is neither in include nor
+ * exclude hosts lists from the the list of live or dead nodes. This is used
+ * to not display an already decommssioned data node to the operators.
+ * The operation procedure of making a already decommissioned data node not
+ * to be displayed is as following:
+ * <ol>
+ * <li>
+ * Host must have been in the include hosts list and the include hosts list
+ * must not be empty.
+ * </li>
+ * <li>
+ * Host is decommissioned by remaining in the include hosts list and added
+ * into the exclude hosts list. Name node is updated with the new
+ * information by issuing dfsadmin -refreshNodes command.
+ * </li>
+ * <li>
+ * Host is removed from both include hosts and exclude hosts lists. Name
+ * node is updated with the new informationby issuing dfsamin -refreshNodes
+ * command.
+ * <li>
+ * </ol>
+ *
+ * @param nodeList
+ * , array list of live or dead nodes.
+ */
+ void removeDecomNodeFromList(ArrayList<DatanodeDescriptor> nodeList) {
+ // If the include list is empty, any nodes are welcomed and it does not
+ // make sense to exclude any nodes from the cluster. Therefore, no remove.
+ if (hostsReader.getHosts().isEmpty()) {
+ return;
+ }
+
+ for (Iterator<DatanodeDescriptor> it = nodeList.iterator(); it.hasNext();) {
+ DatanodeDescriptor node = it.next();
+ if ((!inHostsList(node, null)) && (!inExcludedHostsList(node, null))
+ && node.isDecommissioned()) {
+ // Include list is not empty, an existing datanode does not appear
+ // in both include or exclude lists and it has been decommissioned.
+ // Remove it from the node list.
+ it.remove();
+ }
+ }
+ }
}
Modified: hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/NamenodeJspHelper.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/NamenodeJspHelper.java?rev=1099285&r1=1099284&r2=1099285&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/NamenodeJspHelper.java (original)
+++ hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/NamenodeJspHelper.java Tue May 3 22:16:29 2011
@@ -217,7 +217,12 @@ class NamenodeJspHelper {
ArrayList<DatanodeDescriptor> live = new ArrayList<DatanodeDescriptor>();
ArrayList<DatanodeDescriptor> dead = new ArrayList<DatanodeDescriptor>();
fsn.DFSNodesStatus(live, dead);
-
+ // If a data node has been first included in the include list,
+ // then decommissioned, then removed from both include and exclude list.
+ // We make the web console to "forget" this node by not displaying it.
+ fsn.removeDecomNodeFromList(live);
+ fsn.removeDecomNodeFromList(dead);
+
int liveDecommissioned = 0;
for (DatanodeDescriptor d : live) {
liveDecommissioned += d.isDecommissioned() ? 1 : 0;
@@ -536,6 +541,8 @@ class NamenodeJspHelper {
ArrayList<DatanodeDescriptor> dead = new ArrayList<DatanodeDescriptor>();
final NameNode nn = (NameNode)context.getAttribute("name.node");
nn.getNamesystem().DFSNodesStatus(live, dead);
+ nn.getNamesystem().removeDecomNodeFromList(live);
+ nn.getNamesystem().removeDecomNodeFromList(dead);
InetSocketAddress nnSocketAddress = (InetSocketAddress) context
.getAttribute(NameNode.NAMENODE_ADDRESS_ATTRIBUTE_KEY);
String nnaddr = nnSocketAddress.getAddress().getHostAddress() + ":"