From 513718f92dc572da22a995830fe203b969f23493 Mon Sep 17 00:00:00 2001 From: Eli Collins Date: Sun, 20 Nov 2011 04:13:32 +0000 Subject: [PATCH] HDFS-2568. Use a set to manage child sockets in XceiverServer. Contributed by Harsh J git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1204122 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 +++ .../hadoop/hdfs/server/datanode/DataXceiver.java | 2 +- .../hadoop/hdfs/server/datanode/DataXceiverServer.java | 10 +++++----- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 761067cfe6..a6366b2edb 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -124,6 +124,9 @@ Release 0.23.1 - UNRELEASED HDFS-208. name node should warn if only one dir is listed in dfs.name.dir. (Uma Maheswara Rao G via eli) + HDFS-2568. Use a set to manage child sockets in XceiverServer. + (harsh via eli) + HDFS-2536. Remove unused imports. (harsh via eli) OPTIMIZATIONS diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataXceiver.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataXceiver.java index 999eb0f950..6f2697ce5c 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataXceiver.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataXceiver.java @@ -126,7 +126,7 @@ private void updateCurrentThreadName(String status) { public void run() { int opsProcessed = 0; Op op = null; - dataXceiverServer.childSockets.put(s, s); + dataXceiverServer.childSockets.add(s); try { int stdTimeout = s.getSoTimeout(); diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataXceiverServer.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataXceiverServer.java index c0d782a5c7..f6dcb8f52d 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataXceiverServer.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataXceiverServer.java @@ -23,9 +23,9 @@ import java.net.SocketTimeoutException; import java.nio.channels.AsynchronousCloseException; import java.util.Collections; -import java.util.HashMap; +import java.util.HashSet; import java.util.Iterator; -import java.util.Map; +import java.util.Set; import org.apache.commons.logging.Log; import org.apache.hadoop.conf.Configuration; @@ -48,8 +48,8 @@ class DataXceiverServer implements Runnable { ServerSocket ss; DataNode datanode; // Record all sockets opened for data transfer - Map childSockets = Collections.synchronizedMap( - new HashMap()); + Set childSockets = Collections.synchronizedSet( + new HashSet()); /** * Maximal number of concurrent xceivers per node. @@ -184,7 +184,7 @@ void kill() { // close all the sockets that were accepted earlier synchronized (childSockets) { - for (Iterator it = childSockets.values().iterator(); + for (Iterator it = childSockets.iterator(); it.hasNext();) { Socket thissock = it.next(); try {