HDFS-7301. TestMissingBlocksAlert should use MXBeans instead of old web UI. Contributed by Zhe Zhang.
This commit is contained in:
parent
c2790932bd
commit
d51ea6a248
|
@ -106,6 +106,9 @@ Release 2.7.0 - UNRELEASED
|
||||||
TestBlockReaderFactory failures resulting from TemporarySocketDirectory GC.
|
TestBlockReaderFactory failures resulting from TemporarySocketDirectory GC.
|
||||||
(Jinghui Wang via Colin Patrick McCabe)
|
(Jinghui Wang via Colin Patrick McCabe)
|
||||||
|
|
||||||
|
HDFS-7301. TestMissingBlocksAlert should use MXBeans instead of old web UI.
|
||||||
|
(Zhe Zhang via wheat9)
|
||||||
|
|
||||||
Release 2.6.0 - UNRELEASED
|
Release 2.6.0 - UNRELEASED
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
|
|
@ -17,13 +17,6 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.hadoop.hdfs;
|
package org.apache.hadoop.hdfs;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertFalse;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.URL;
|
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.apache.hadoop.conf.Configuration;
|
import org.apache.hadoop.conf.Configuration;
|
||||||
|
@ -32,8 +25,16 @@ import org.apache.hadoop.fs.FSDataInputStream;
|
||||||
import org.apache.hadoop.fs.Path;
|
import org.apache.hadoop.fs.Path;
|
||||||
import org.apache.hadoop.hdfs.protocol.ExtendedBlock;
|
import org.apache.hadoop.hdfs.protocol.ExtendedBlock;
|
||||||
import org.apache.hadoop.hdfs.server.blockmanagement.BlockManager;
|
import org.apache.hadoop.hdfs.server.blockmanagement.BlockManager;
|
||||||
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import javax.management.*;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.lang.management.ManagementFactory;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The test makes sure that NameNode detects presense blocks that do not have
|
* The test makes sure that NameNode detects presense blocks that do not have
|
||||||
* any valid replicas. In addition, it verifies that HDFS front page displays
|
* any valid replicas. In addition, it verifies that HDFS front page displays
|
||||||
|
@ -45,8 +46,11 @@ public class TestMissingBlocksAlert {
|
||||||
LogFactory.getLog(TestMissingBlocksAlert.class);
|
LogFactory.getLog(TestMissingBlocksAlert.class);
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMissingBlocksAlert() throws IOException,
|
public void testMissingBlocksAlert()
|
||||||
InterruptedException {
|
throws IOException, InterruptedException,
|
||||||
|
MalformedObjectNameException, AttributeNotFoundException,
|
||||||
|
MBeanException, ReflectionException,
|
||||||
|
InstanceNotFoundException {
|
||||||
|
|
||||||
MiniDFSCluster cluster = null;
|
MiniDFSCluster cluster = null;
|
||||||
|
|
||||||
|
@ -95,14 +99,11 @@ public class TestMissingBlocksAlert {
|
||||||
assertEquals(4, dfs.getUnderReplicatedBlocksCount());
|
assertEquals(4, dfs.getUnderReplicatedBlocksCount());
|
||||||
assertEquals(3, bm.getUnderReplicatedNotMissingBlocks());
|
assertEquals(3, bm.getUnderReplicatedNotMissingBlocks());
|
||||||
|
|
||||||
|
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
|
||||||
// Now verify that it shows up on webui
|
ObjectName mxbeanName = new ObjectName(
|
||||||
URL url = new URL("http://" + conf.get(DFSConfigKeys.DFS_NAMENODE_HTTP_ADDRESS_KEY) +
|
"Hadoop:service=NameNode,name=NameNodeInfo");
|
||||||
"/dfshealth.jsp");
|
Assert.assertEquals(1, (long)(Long) mbs.getAttribute(mxbeanName,
|
||||||
String dfsFrontPage = DFSTestUtil.urlGet(url);
|
"NumberOfMissingBlocks"));
|
||||||
String warnStr = "WARNING : There are ";
|
|
||||||
assertTrue("HDFS Front page does not contain expected warning",
|
|
||||||
dfsFrontPage.contains(warnStr + "1 missing blocks"));
|
|
||||||
|
|
||||||
// now do the reverse : remove the file expect the number of missing
|
// now do the reverse : remove the file expect the number of missing
|
||||||
// blocks to go to zero
|
// blocks to go to zero
|
||||||
|
@ -117,11 +118,8 @@ public class TestMissingBlocksAlert {
|
||||||
assertEquals(2, dfs.getUnderReplicatedBlocksCount());
|
assertEquals(2, dfs.getUnderReplicatedBlocksCount());
|
||||||
assertEquals(2, bm.getUnderReplicatedNotMissingBlocks());
|
assertEquals(2, bm.getUnderReplicatedNotMissingBlocks());
|
||||||
|
|
||||||
// and make sure WARNING disappears
|
Assert.assertEquals(0, (long)(Long) mbs.getAttribute(mxbeanName,
|
||||||
// Now verify that it shows up on webui
|
"NumberOfMissingBlocks"));
|
||||||
dfsFrontPage = DFSTestUtil.urlGet(url);
|
|
||||||
assertFalse("HDFS Front page contains unexpected warning",
|
|
||||||
dfsFrontPage.contains(warnStr));
|
|
||||||
} finally {
|
} finally {
|
||||||
if (cluster != null) {
|
if (cluster != null) {
|
||||||
cluster.shutdown();
|
cluster.shutdown();
|
||||||
|
|
Loading…
Reference in New Issue