From fa30224e95d920adaea0ec65c360359044e3f754 Mon Sep 17 00:00:00 2001 From: Ayush Saxena Date: Wed, 3 Jun 2020 12:47:15 +0530 Subject: [PATCH] HDFS-11041. Unable to unregister FsDatasetState MBean if DataNode is shutdown twice. Contributed by Wei-Chiu Chuang. (cherry picked from commit e8cb2ae409bc1d62f23efef485d1c6f1ff21e86c) --- .../hdfs/server/datanode/fsdataset/impl/FsDatasetImpl.java | 1 + .../hadoop/hdfs/server/datanode/SimulatedFSDataset.java | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsDatasetImpl.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsDatasetImpl.java index 2ab4b83a3d..d263d7dfd3 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsDatasetImpl.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsDatasetImpl.java @@ -2353,6 +2353,7 @@ public void shutdown() { if (mbeanName != null) { MBeans.unregister(mbeanName); + mbeanName = null; } if (asyncDiskService != null) { diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/SimulatedFSDataset.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/SimulatedFSDataset.java index 113da585c9..417ad3ce74 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/SimulatedFSDataset.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/SimulatedFSDataset.java @@ -1367,7 +1367,10 @@ void registerMBean(final String storageId) { @Override public void shutdown() { - if (mbeanName != null) MBeans.unregister(mbeanName); + if (mbeanName != null) { + MBeans.unregister(mbeanName); + mbeanName = null; + } } @Override