diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 39453d120c6..5189eabf4cc 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -790,6 +790,9 @@ Release 2.7.0 - UNRELEASED HDFS-7676. Fix TestFileTruncate to avoid bug of HDFS-7611. (shv) + HDFS-49. MiniDFSCluster.stopDataNode will always shut down a node in + the cluster if a matching name is not found. (stevel) + Release 2.6.1 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/MiniDFSCluster.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/MiniDFSCluster.java index 7367ffbc32e..8551263e935 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/MiniDFSCluster.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/MiniDFSCluster.java @@ -1923,6 +1923,9 @@ public class MiniDFSCluster { /* * Shutdown a particular datanode + * @param i node index + * @return null if the node index is out of range, else the properties of the + * removed node */ public synchronized DataNodeProperties stopDataNode(int i) { if (i < 0 || i >= dataNodes.size()) { @@ -1941,18 +1944,20 @@ public class MiniDFSCluster { /* * Shutdown a datanode by name. + * @return the removed datanode or null if there was no match */ public synchronized DataNodeProperties stopDataNode(String dnName) { - int i; - for (i = 0; i < dataNodes.size(); i++) { + int node = -1; + for (int i = 0; i < dataNodes.size(); i++) { DataNode dn = dataNodes.get(i).datanode; LOG.info("DN name=" + dnName + " found DN=" + dn + " with name=" + dn.getDisplayName()); if (dnName.equals(dn.getDatanodeId().getXferAddr())) { + node = i; break; } } - return stopDataNode(i); + return stopDataNode(node); } /**