|
@@ -34,6 +34,8 @@ import org.apache.hadoop.fs.FileSystem;
|
|
import org.apache.hadoop.fs.Path;
|
|
import org.apache.hadoop.fs.Path;
|
|
import org.apache.hadoop.conf.Configuration;
|
|
import org.apache.hadoop.conf.Configuration;
|
|
import org.apache.hadoop.hdfs.MiniDFSCluster;
|
|
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.junit.Test;
|
|
import org.mortbay.util.ajax.JSON;
|
|
import org.mortbay.util.ajax.JSON;
|
|
|
|
|
|
@@ -139,12 +141,16 @@ public class TestFSNamesystemMBean {
|
|
MiniDFSCluster cluster = null;
|
|
MiniDFSCluster cluster = null;
|
|
FSNamesystem fsn = null;
|
|
FSNamesystem fsn = null;
|
|
|
|
|
|
|
|
+ int jmxCachePeriod = 1;
|
|
|
|
+ new ConfigBuilder().add("namenode.period", jmxCachePeriod)
|
|
|
|
+ .save(TestMetricsConfig.getTestFilename("hadoop-metrics2-namenode"));
|
|
try {
|
|
try {
|
|
cluster = new MiniDFSCluster.Builder(conf).build();
|
|
cluster = new MiniDFSCluster.Builder(conf).build();
|
|
cluster.waitActive();
|
|
cluster.waitActive();
|
|
|
|
|
|
fsn = cluster.getNameNode().namesystem;
|
|
fsn = cluster.getNameNode().namesystem;
|
|
fsn.writeLock();
|
|
fsn.writeLock();
|
|
|
|
+ Thread.sleep(jmxCachePeriod * 1000);
|
|
|
|
|
|
MBeanClient client = new MBeanClient();
|
|
MBeanClient client = new MBeanClient();
|
|
client.start();
|
|
client.start();
|
|
@@ -167,11 +173,15 @@ public class TestFSNamesystemMBean {
|
|
@Test
|
|
@Test
|
|
public void testWithFSEditLogLock() throws Exception {
|
|
public void testWithFSEditLogLock() throws Exception {
|
|
Configuration conf = new Configuration();
|
|
Configuration conf = new Configuration();
|
|
|
|
+ int jmxCachePeriod = 1;
|
|
|
|
+ new ConfigBuilder().add("namenode.period", jmxCachePeriod)
|
|
|
|
+ .save(TestMetricsConfig.getTestFilename("hadoop-metrics2-namenode"));
|
|
MiniDFSCluster cluster = null;
|
|
MiniDFSCluster cluster = null;
|
|
try {
|
|
try {
|
|
cluster = new MiniDFSCluster.Builder(conf).build();
|
|
cluster = new MiniDFSCluster.Builder(conf).build();
|
|
cluster.waitActive();
|
|
cluster.waitActive();
|
|
synchronized (cluster.getNameNode().getFSImage().getEditLog()) {
|
|
synchronized (cluster.getNameNode().getFSImage().getEditLog()) {
|
|
|
|
+ Thread.sleep(jmxCachePeriod * 1000);
|
|
MBeanClient client = new MBeanClient();
|
|
MBeanClient client = new MBeanClient();
|
|
client.start();
|
|
client.start();
|
|
client.join(20000);
|
|
client.join(20000);
|