From b0b39668519dfb7066da6a5f0c6163fd106a6946 Mon Sep 17 00:00:00 2001 From: Akira Ajisaka Date: Wed, 18 Jan 2017 17:53:21 +0900 Subject: [PATCH] HDFS-11290. TestFSNameSystemMBean should wait until JMX cache is cleared. Contributed by Erik Krogen. (cherry picked from commit b1a9ec856b572894e769f052aea2340fc3f23c78) (cherry picked from commit db47bd15dd80a4a5727607832c16635cb0ec7726) --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 +++ .../hdfs/server/namenode/TestFSNamesystemMBean.java | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index ad49975789a..c4580d9f59b 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -213,6 +213,9 @@ Release 2.7.4 - UNRELEASED HDFS-11263. ClassCastException when we use Bzipcodec for Fsimage compression. (Brahma Reddy Battula) + HDFS-11290. TestFSNameSystemMBean should wait until JMX cache is cleared. + (Eric Krogen via aajisaka) + Release 2.7.3 - 2016-08-25 INCOMPATIBLE CHANGES diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSNamesystemMBean.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSNamesystemMBean.java index 764c6270f88..ef016ecfa0e 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSNamesystemMBean.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSNamesystemMBean.java @@ -32,6 +32,8 @@ import javax.management.ObjectName; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hdfs.MiniDFSCluster; +import org.apache.hadoop.metrics2.impl.ConfigBuilder; +import org.apache.hadoop.metrics2.impl.TestMetricsConfig; import org.junit.Test; import org.mortbay.util.ajax.JSON; @@ -137,12 +139,16 @@ public class TestFSNamesystemMBean { MiniDFSCluster cluster = null; FSNamesystem fsn = null; + int jmxCachePeriod = 1; + new ConfigBuilder().add("namenode.period", jmxCachePeriod) + .save(TestMetricsConfig.getTestFilename("hadoop-metrics2-namenode")); try { cluster = new MiniDFSCluster.Builder(conf).build(); cluster.waitActive(); fsn = cluster.getNameNode().namesystem; fsn.writeLock(); + Thread.sleep(jmxCachePeriod * 1000); MBeanClient client = new MBeanClient(); client.start(); @@ -165,11 +171,15 @@ public class TestFSNamesystemMBean { @Test public void testWithFSEditLogLock() throws Exception { Configuration conf = new Configuration(); + int jmxCachePeriod = 1; + new ConfigBuilder().add("namenode.period", jmxCachePeriod) + .save(TestMetricsConfig.getTestFilename("hadoop-metrics2-namenode")); MiniDFSCluster cluster = null; try { cluster = new MiniDFSCluster.Builder(conf).build(); cluster.waitActive(); synchronized (cluster.getNameNode().getFSImage().getEditLog()) { + Thread.sleep(jmxCachePeriod * 1000); MBeanClient client = new MBeanClient(); client.start(); client.join(20000);