From 84314d99e5aab13d2b011d2dd35de9314248192e Mon Sep 17 00:00:00 2001 From: Eli Collins Date: Tue, 7 Aug 2012 20:23:11 +0000 Subject: [PATCH] HDFS-3754. BlockSender doesn't shutdown ReadaheadPool threads. Contributed by Eli Collins git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1370496 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 2 ++ .../apache/hadoop/hdfs/server/datanode/BlockSender.java | 8 ++------ .../org/apache/hadoop/hdfs/server/datanode/DataNode.java | 6 ++++++ 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index bc27db3aea1..6ab29d18a76 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -410,6 +410,8 @@ Release 2.0.1-alpha - UNRELEASED HDFS-3579. libhdfs: fix exception handling. (Colin Patrick McCabe via atm) + HDFS-3754. BlockSender doesn't shutdown ReadaheadPool threads. (eli) + BREAKDOWN OF HDFS-3042 SUBTASKS HDFS-2185. HDFS portion of ZK-based FailoverController (todd) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BlockSender.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BlockSender.java index 133a550bd9d..d8cba720037 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BlockSender.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BlockSender.java @@ -20,7 +20,6 @@ package org.apache.hadoop.hdfs.server.datanode; import java.io.BufferedInputStream; import java.io.DataInputStream; import java.io.DataOutputStream; -import java.io.EOFException; import java.io.FileDescriptor; import java.io.FileInputStream; import java.io.FileNotFoundException; @@ -38,7 +37,6 @@ import org.apache.hadoop.fs.ChecksumException; import org.apache.hadoop.hdfs.protocol.ExtendedBlock; import org.apache.hadoop.hdfs.protocol.HdfsConstants; import org.apache.hadoop.hdfs.protocol.datatransfer.PacketHeader; -import org.apache.hadoop.hdfs.server.common.Util; import org.apache.hadoop.hdfs.util.DataTransferThrottler; import org.apache.hadoop.io.IOUtils; import org.apache.hadoop.io.LongWritable; @@ -163,8 +161,6 @@ class BlockSender implements java.io.Closeable { */ private static final long LONG_READ_THRESHOLD_BYTES = 256 * 1024; - private static ReadaheadPool readaheadPool = - ReadaheadPool.getInstance(); /** * Constructor @@ -691,8 +687,8 @@ class BlockSender implements java.io.Closeable { } // Perform readahead if necessary - if (readaheadLength > 0 && readaheadPool != null) { - curReadahead = readaheadPool.readaheadStream( + if (readaheadLength > 0 && datanode.readaheadPool != null) { + curReadahead = datanode.readaheadPool.readaheadStream( clientTraceFmt, blockInFd, offset, readaheadLength, Long.MAX_VALUE, curReadahead); diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java index 0ebde007542..fd226e854f2 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java @@ -146,6 +146,7 @@ import org.apache.hadoop.hdfs.web.WebHdfsFileSystem; import org.apache.hadoop.hdfs.web.resources.Param; import org.apache.hadoop.http.HttpServer; import org.apache.hadoop.io.IOUtils; +import org.apache.hadoop.io.ReadaheadPool; import org.apache.hadoop.ipc.ProtobufRpcEngine; import org.apache.hadoop.ipc.RPC; import org.apache.hadoop.ipc.RemoteException; @@ -278,6 +279,7 @@ public class DataNode extends Configured private Configuration conf; private final String userWithLocalPathAccess; + ReadaheadPool readaheadPool; /** * Create the DataNode given a configuration and an array of dataDirs. @@ -673,6 +675,10 @@ public class DataNode extends Configured blockPoolManager = new BlockPoolManager(this); blockPoolManager.refreshNamenodes(conf); + + // Create the ReadaheadPool from the DataNode context so we can + // exit without having to explicitly shutdown its thread pool. + readaheadPool = ReadaheadPool.getInstance(); } /**