From f75deca0f9dc3f2790be5e13fe376d33b3a08816 Mon Sep 17 00:00:00 2001 From: Eli Collins Date: Wed, 15 Aug 2012 22:43:01 +0000 Subject: [PATCH] HDFS-3048. Small race in BlockManager#close. Contributed by Andy Isaacson git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1373664 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 2 ++ .../hdfs/server/blockmanagement/BlockManager.java | 15 +++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index ce3643fb34e..94eb359bd79 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -614,6 +614,8 @@ Branch-2 ( Unreleased changes ) header when offset is specified and length is omitted. (Ravi Prakash via szetszwo) + HDFS-3048. Small race in BlockManager#close. (Andy Isaacson via 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/blockmanagement/BlockManager.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java index 1d0afd7fa1f..6e8130de867 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java @@ -373,10 +373,17 @@ public class BlockManager { } public void close() { - if (pendingReplications != null) pendingReplications.stop(); - blocksMap.close(); - datanodeManager.close(); - if (replicationThread != null) replicationThread.interrupt(); + try { + if (replicationThread != null) { + replicationThread.interrupt(); + replicationThread.join(3000); + } + } catch (InterruptedException ie) { + } finally { + if (pendingReplications != null) pendingReplications.stop(); + blocksMap.close(); + datanodeManager.close(); + } } /** @return the datanodeManager */