HDFS-11290. TestFSNameSystemMBean should wait until JMX cache is cleared. Contributed by Erik Krogen.
This commit is contained in:
parent
e224c96234
commit
b1a9ec856b
@ -34,6 +34,8 @@
|
||||
import org.apache.hadoop.fs.Path;
|
||||
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.eclipse.jetty.util.ajax.JSON;
|
||||
|
||||
@ -139,12 +141,16 @@ public void testWithFSNamesystemWriteLock() throws Exception {
|
||||
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();
|
||||
@ -167,11 +173,15 @@ public void testWithFSNamesystemWriteLock() throws Exception {
|
||||
@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);
|
||||
|
Loading…
Reference in New Issue
Block a user