Author: wheat9 Date: Thu Apr 24 07:17:17 2014 New Revision: 1589616 URL: http://svn.apache.org/r1589616 Log: HDFS-6278. Merge r1589613 from trunk.
Added: hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/SecondaryNameNodeInfoMXBean.java - copied unchanged from r1589613, hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/SecondaryNameNodeInfoMXBean.java hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/VersionInfoMXBean.java - copied unchanged from r1589613, hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/VersionInfoMXBean.java hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/secondary/snn.js - copied unchanged from r1589613, hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/secondary/snn.js hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/secondary/status.html - copied unchanged from r1589613, hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/secondary/status.html hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/static/dfs-dust.js - copied unchanged from r1589613, hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/static/dfs-dust.js Removed: hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/dfs-dust.js Modified: hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/SecondaryNameNode.java hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/dfshealth.html hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/explorer.html hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/secondary/index.html hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestCheckpoint.java hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestSecondaryWebUi.java Modified: hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt?rev=1589616&r1=1589615&r2=1589616&view=diff ============================================================================== --- hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt (original) +++ hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt Thu Apr 24 07:17:17 2014 @@ -57,6 +57,8 @@ Release 2.5.0 - UNRELEASED HDFS-6265. Prepare HDFS codebase for JUnit 4.11. (cnauroth) + HDFS-6278. Create HTML5-based UI for SNN. (wheat9) + OPTIMIZATIONS HDFS-6214. Webhdfs has poor throughput for files >2GB (daryn) Modified: hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/SecondaryNameNode.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/SecondaryNameNode.java?rev=1589616&r1=1589615&r2=1589616&view=diff ============================================================================== --- hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/SecondaryNameNode.java (original) +++ hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/SecondaryNameNode.java Thu Apr 24 07:17:17 2014 @@ -27,11 +27,9 @@ import java.net.URI; import java.net.URL; import java.security.PrivilegedAction; import java.security.PrivilegedExceptionAction; -import java.util.Collection; -import java.util.Date; -import java.util.Iterator; -import java.util.List; +import java.util.*; +import com.google.common.collect.Lists; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.CommandLineParser; import org.apache.commons.cli.HelpFormatter; @@ -70,6 +68,7 @@ import org.apache.hadoop.io.MD5Hash; import org.apache.hadoop.ipc.RemoteException; import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem; import org.apache.hadoop.metrics2.source.JvmMetrics; +import org.apache.hadoop.metrics2.util.MBeans; import org.apache.hadoop.net.NetUtils; import org.apache.hadoop.security.SecurityUtil; import org.apache.hadoop.security.UserGroupInformation; @@ -80,6 +79,9 @@ import org.apache.hadoop.util.Time; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; +import org.apache.hadoop.util.VersionInfo; + +import javax.management.ObjectName; /********************************************************** * The Secondary NameNode is a helper to the primary NameNode. @@ -95,7 +97,8 @@ import com.google.common.collect.Immutab * **********************************************************/ @InterfaceAudience.Private -public class SecondaryNameNode implements Runnable { +public class SecondaryNameNode implements Runnable, + SecondaryNameNodeInfoMXBean { static{ HdfsConfiguration.init(); @@ -122,7 +125,7 @@ public class SecondaryNameNode implement private FSNamesystem namesystem; private Thread checkpointThread; - + private ObjectName nameNodeStatusBeanName; @Override public String toString() { @@ -169,11 +172,6 @@ public class SecondaryNameNode implement this.namenode = namenode; } - @VisibleForTesting - List<URI> getCheckpointDirs() { - return ImmutableList.copyOf(checkpointDirs); - } - /** * Create a connection to the primary namenode. */ @@ -265,6 +263,9 @@ public class SecondaryNameNode implement DFSConfigKeys.DFS_SECONDARY_NAMENODE_KERBEROS_INTERNAL_SPNEGO_PRINCIPAL_KEY, DFSConfigKeys.DFS_SECONDARY_NAMENODE_KEYTAB_FILE_KEY); + nameNodeStatusBeanName = MBeans.register("SecondaryNameNode", + "SecondaryNameNodeInfo", this); + infoServer = builder.build(); infoServer.setAttribute("secondary.name.node", this); @@ -330,6 +331,10 @@ public class SecondaryNameNode implement } catch (Exception e) { LOG.warn("Exception shutting down SecondaryNameNode", e); } + if (nameNodeStatusBeanName != null) { + MBeans.unregister(nameNodeStatusBeanName); + nameNodeStatusBeanName = null; + } try { if (checkpointImage != null) { checkpointImage.close(); @@ -679,6 +684,50 @@ public class SecondaryNameNode implement checkpointThread.start(); } + @Override // SecondaryNameNodeInfoMXXBean + public String getHostAndPort() { + return NetUtils.getHostPortString(nameNodeAddr); + } + + @Override // SecondaryNameNodeInfoMXXBean + public long getStartTime() { + return starttime; + } + + @Override // SecondaryNameNodeInfoMXXBean + public long getLastCheckpointTime() { + return lastCheckpointTime; + } + + @Override // SecondaryNameNodeInfoMXXBean + public String[] getCheckpointDirectories() { + ArrayList<String> r = Lists.newArrayListWithCapacity(checkpointDirs.size()); + for (URI d : checkpointDirs) { + r.add(d.toString()); + } + return r.toArray(new String[r.size()]); + } + + @Override // SecondaryNameNodeInfoMXXBean + public String[] getCheckpointEditlogDirectories() { + ArrayList<String> r = Lists.newArrayListWithCapacity(checkpointEditsDirs.size()); + for (URI d : checkpointEditsDirs) { + r.add(d.toString()); + } + return r.toArray(new String[r.size()]); + } + + @Override // VersionInfoMXBean + public String getCompileInfo() { + return VersionInfo.getDate() + " by " + VersionInfo.getUser() + + " from " + VersionInfo.getBranch(); + } + + @Override // VersionInfoMXBean + public String getSoftwareVersion() { + return VersionInfo.getVersion(); + } + /** * Container for parsed command-line options. Modified: hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/dfshealth.html URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/dfshealth.html?rev=1589616&r1=1589615&r2=1589616&view=diff ============================================================================== --- hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/dfshealth.html (original) +++ hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/dfshealth.html Thu Apr 24 07:17:17 2014 @@ -351,7 +351,7 @@ </script><script type="text/javascript" src="/static/bootstrap-3.0.2/js/bootstrap.min.js"> </script><script type="text/javascript" src="/static/dust-full-2.0.0.min.js"> </script><script type="text/javascript" src="/static/dust-helpers-1.1.1.min.js"> -</script><script type="text/javascript" src="dfs-dust.js"> +</script><script type="text/javascript" src="/static/dfs-dust.js"> </script><script type="text/javascript" src="dfshealth.js"> </script> </body> Modified: hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/explorer.html URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/explorer.html?rev=1589616&r1=1589615&r2=1589616&view=diff ============================================================================== --- hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/explorer.html (original) +++ hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/explorer.html Thu Apr 24 07:17:17 2014 @@ -122,7 +122,7 @@ </script><script type="text/javascript" src="/static/bootstrap-3.0.2/js/bootstrap.min.js"> </script><script type="text/javascript" src="/static/dust-full-2.0.0.min.js"> </script><script type="text/javascript" src="/static/dust-helpers-1.1.1.min.js"> - </script><script type="text/javascript" src="dfs-dust.js"> + </script><script type="text/javascript" src="/static/dfs-dust.js"> </script><script type="text/javascript" src="explorer.js"> </script> <hr /> Modified: hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/secondary/index.html URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/secondary/index.html?rev=1589616&r1=1589615&r2=1589616&view=diff ============================================================================== --- hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/secondary/index.html (original) +++ hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/secondary/index.html Thu Apr 24 07:17:17 2014 @@ -1,5 +1,3 @@ -<meta HTTP-EQUIV="REFRESH" content="0;url=status.jsp"/> -<html> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with @@ -16,14 +14,22 @@ See the License for the specific language governing permissions and limitations under the License. --> -<head><title>Hadoop Administration</title></head> - +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> + <meta http-equiv="REFRESH" content="0;url=status.html" /> + <title>Hadoop Administration</title> +</head> <body> +<script type="text/javascript"> +//<![CDATA[ +window.location.href='status.html'; +//]]> +</script> <h1>Hadoop Administration</h1> - -<ul> - <li><a href="status.jsp">Status</a></li> +<ul> + <li><a href="status.jsp">Status</a></li> </ul> - -</body> -</html> +</body> +</html> \ No newline at end of file Modified: hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestCheckpoint.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestCheckpoint.java?rev=1589616&r1=1589615&r2=1589616&view=diff ============================================================================== --- hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestCheckpoint.java (original) +++ hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestCheckpoint.java Thu Apr 24 07:17:17 2014 @@ -2444,8 +2444,8 @@ public class TestCheckpoint { private static List<File> getCheckpointCurrentDirs(SecondaryNameNode secondary) { List<File> ret = Lists.newArrayList(); - for (URI u : secondary.getCheckpointDirs()) { - File checkpointDir = new File(u.getPath()); + for (String u : secondary.getCheckpointDirectories()) { + File checkpointDir = new File(URI.create(u).getPath()); ret.add(new File(checkpointDir, "current")); } return ret; Modified: hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestSecondaryWebUi.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestSecondaryWebUi.java?rev=1589616&r1=1589615&r2=1589616&view=diff ============================================================================== --- hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestSecondaryWebUi.java (original) +++ hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestSecondaryWebUi.java Thu Apr 24 07:17:17 2014 @@ -17,20 +17,18 @@ */ package org.apache.hadoop.hdfs.server.namenode; -import static org.junit.Assert.assertTrue; - -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; - import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hdfs.DFSConfigKeys; -import org.apache.hadoop.hdfs.DFSTestUtil; import org.apache.hadoop.hdfs.MiniDFSCluster; import org.junit.AfterClass; +import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; +import javax.management.*; +import java.io.IOException; +import java.lang.management.ManagementFactory; + public class TestSecondaryWebUi { private static MiniDFSCluster cluster; @@ -59,18 +57,20 @@ public class TestSecondaryWebUi { } @Test - public void testSecondaryWebUi() throws IOException { - String pageContents = DFSTestUtil.urlGet(new URL("http://localhost:" + - SecondaryNameNode.getHttpAddress(conf).getPort() + "/status.jsp")); - assertTrue("Didn't find \"Last Checkpoint\"", - pageContents.contains("Last Checkpoint")); - } - - @Test - public void testSecondaryWebJmx() throws MalformedURLException, IOException { - String pageContents = DFSTestUtil.urlGet(new URL("http://localhost:" + - SecondaryNameNode.getHttpAddress(conf).getPort() + "/jmx")); - assertTrue(pageContents.contains( - "Hadoop:service=SecondaryNameNode,name=JvmMetrics")); + public void testSecondaryWebUi() + throws IOException, MalformedObjectNameException, + AttributeNotFoundException, MBeanException, + ReflectionException, InstanceNotFoundException { + MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); + ObjectName mxbeanName = new ObjectName( + "Hadoop:service=SecondaryNameNode,name=SecondaryNameNodeInfo"); + + String[] checkpointDir = (String[]) mbs.getAttribute(mxbeanName, + "CheckpointDirectories"); + Assert.assertArrayEquals(checkpointDir, snn.getCheckpointDirectories()); + String[] checkpointEditlogDir = (String[]) mbs.getAttribute(mxbeanName, + "CheckpointEditlogDirectories"); + Assert.assertArrayEquals(checkpointEditlogDir, + snn.getCheckpointEditlogDirectories()); } }