HDFS-14105. Replace TreeSet in NamenodeFsck with HashSet. Contributed by Beluga Behr.

This commit is contained in:
Giovanni Matteo Fumarola 2018-11-30 11:07:11 -08:00
parent b09cfad432
commit 99e201dfe2

View File

@ -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<DatanodeInfo> deadNodes = new TreeSet<DatanodeInfo>();
Set<DatanodeInfo> deadNodes = new HashSet<DatanodeInfo>();
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<DatanodeInfo> deadNodes) throws IOException {
if ((nodes == null) ||
(nodes.length - deadNodes.size() < 1)) {
Set<DatanodeInfo> deadNodes) throws IOException {
if ((nodes == null) || (nodes.length - deadNodes.size() < 1)) {
throw new IOException("No live nodes contain current block");
}
DatanodeInfo chosenNode;