From f159bd401a10e4da8d8797fc7f6814cdf3881f2d Mon Sep 17 00:00:00 2001 From: Eli Collins Date: Wed, 6 Jun 2012 21:01:59 +0000 Subject: [PATCH] HDFS-3505. DirectoryScanner does not join all threads in shutdown. Contributed Colin Patrick McCabe git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1347122 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 +++ .../hdfs/server/datanode/DirectoryScanner.java | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 00781b1a65d..52b5f613623 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -156,6 +156,9 @@ Release 2.0.1-alpha - UNRELEASED HDFS-3266. DFSTestUtil#waitCorruptReplicas doesn't sleep between checks. (Madhukara Phatak via atm) + HDFS-3505. DirectoryScanner does not join all threads in shutdown. + (Colin Patrick McCabe via eli) + Release 2.0.0-alpha - 05-23-2012 INCOMPATIBLE CHANGES diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DirectoryScanner.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DirectoryScanner.java index eac68d970b9..3a143357ac8 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DirectoryScanner.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DirectoryScanner.java @@ -302,6 +302,22 @@ public class DirectoryScanner implements Runnable { shouldRun = false; if (masterThread != null) masterThread.shutdown(); if (reportCompileThreadPool != null) reportCompileThreadPool.shutdown(); + if (masterThread != null) { + try { + masterThread.awaitTermination(1, TimeUnit.MINUTES); + } catch (InterruptedException e) { + LOG.error("interrupted while waiting for masterThread to " + + "terminate", e); + } + } + if (reportCompileThreadPool != null) { + try { + reportCompileThreadPool.awaitTermination(1, TimeUnit.MINUTES); + } catch (InterruptedException e) { + LOG.error("interrupted while waiting for reportCompileThreadPool to " + + "terminate", e); + } + } if (!retainDiffs) clear(); }