From 99e201dfe2295be830efcc80be34706802da30be Mon Sep 17 00:00:00 2001 From: Giovanni Matteo Fumarola Date: Fri, 30 Nov 2018 11:07:11 -0800 Subject: [PATCH] HDFS-14105. Replace TreeSet in NamenodeFsck with HashSet. Contributed by Beluga Behr. --- .../hadoop/hdfs/server/namenode/NamenodeFsck.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NamenodeFsck.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NamenodeFsck.java index b4c0a935ab..095a6ffffc 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NamenodeFsck.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NamenodeFsck.java @@ -30,10 +30,11 @@ import java.util.Collection; import java.util.Date; import java.util.HashMap; +import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; -import java.util.TreeSet; +import java.util.Set; import java.util.concurrent.ThreadLocalRandom; import org.apache.commons.io.IOUtils; @@ -1021,10 +1022,10 @@ private void copyBlocksToLostFound(String parent, HdfsFileStatus file, * around. */ private void copyBlock(final DFSClient dfs, LocatedBlock lblock, - OutputStream fos) throws Exception { + OutputStream fos) throws Exception { int failures = 0; InetSocketAddress targetAddr = null; - TreeSet deadNodes = new TreeSet(); + Set deadNodes = new HashSet(); BlockReader blockReader = null; ExtendedBlock block = lblock.getBlock(); @@ -1132,9 +1133,8 @@ public DataEncryptionKey newDataEncryptionKey() throws IOException { * That's the local one, if available. */ private DatanodeInfo bestNode(DFSClient dfs, DatanodeInfo[] nodes, - TreeSet deadNodes) throws IOException { - if ((nodes == null) || - (nodes.length - deadNodes.size() < 1)) { + Set deadNodes) throws IOException { + if ((nodes == null) || (nodes.length - deadNodes.size() < 1)) { throw new IOException("No live nodes contain current block"); } DatanodeInfo chosenNode;