From 10c4d6df615d6b3a267ce041cb6572f40c728390 Mon Sep 17 00:00:00 2001 From: Jing Zhao Date: Wed, 26 Aug 2015 16:26:18 -0700 Subject: [PATCH] HDFS-8896. DataNode object isn't GCed when shutdown, because it has GC root in ShutdownHookManager. Contributed by Walter Su. (cherry picked from commit f44b599003bb79b1ec9b92e7546546523ec01676) --- .../java/org/apache/hadoop/util/ShutdownHookManager.java | 6 ++++++ hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 +++ .../test/java/org/apache/hadoop/hdfs/MiniDFSCluster.java | 2 ++ 3 files changed, 11 insertions(+) diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ShutdownHookManager.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ShutdownHookManager.java index 989c96a8e37..85533dbffae 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ShutdownHookManager.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ShutdownHookManager.java @@ -187,4 +187,10 @@ public class ShutdownHookManager { return shutdownInProgress.get(); } + /** + * clear all registered shutdownHooks. + */ + public void clearShutdownHooks() { + hooks.clear(); + } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 5332fc2d530..001ca187835 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -496,6 +496,9 @@ Release 2.8.0 - UNRELEASED HDFS-8951. Move the shortcircuit package to hdfs-client. (Mingliang Liu via wheat9) + HDFS-8896. DataNode object isn't GCed when shutdown, because it has GC + root in ShutdownHookManager. (Walter Su via jing9) + OPTIMIZATIONS HDFS-8026. Trace FSOutputSummer#writeChecksumChunks rather than diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/MiniDFSCluster.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/MiniDFSCluster.java index ed686e2bbf4..5ec9b14f025 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/MiniDFSCluster.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/MiniDFSCluster.java @@ -119,6 +119,7 @@ import org.apache.hadoop.security.UserGroupInformation; import org.apache.hadoop.security.authorize.ProxyUsers; import org.apache.hadoop.test.GenericTestUtils; import org.apache.hadoop.util.ExitUtil; +import org.apache.hadoop.util.ShutdownHookManager; import org.apache.hadoop.util.StringUtils; import org.apache.hadoop.util.ToolRunner; @@ -1759,6 +1760,7 @@ public class MiniDFSCluster { nameNode = null; } } + ShutdownHookManager.get().clearShutdownHooks(); if (base_dir != null) { if (deleteDfsDir) { base_dir.delete();