HDFS-4096. Merge change r1523091 from trunk.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1523092 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
039c10e0d9
commit
988d4c123e
|
@ -34,6 +34,9 @@ Release 2.3.0 - UNRELEASED
|
|||
HDFS-4879. Add "blocked ArrayList" collection to avoid CMS full GCs
|
||||
(Todd Lipcon via Colin Patrick McCabe)
|
||||
|
||||
HDFS-4096. Add snapshot information to namenode WebUI. (Haohui Mai via
|
||||
jing9)
|
||||
|
||||
OPTIMIZATIONS
|
||||
|
||||
BUG FIXES
|
||||
|
|
|
@ -4182,6 +4182,15 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|||
return this.snapshotManager.getNumSnapshots();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSnapshotStats() {
|
||||
Map<String, Object> info = new HashMap<String, Object>();
|
||||
info.put("SnapshottableDirectories", this.getNumSnapshottableDirs());
|
||||
info.put("Snapshots", this.getNumSnapshots());
|
||||
return JSON.toString(info);
|
||||
}
|
||||
|
||||
|
||||
int getNumberOfDatanodes(DatanodeReportType type) {
|
||||
readLock();
|
||||
try {
|
||||
|
|
|
@ -203,6 +203,17 @@ class NamenodeJspHelper {
|
|||
return "";
|
||||
}
|
||||
|
||||
static void generateSnapshotReport(JspWriter out, FSNamesystem fsn)
|
||||
throws IOException {
|
||||
out.println("<div id=\"snapshotstats\"><div class=\"dfstable\">"
|
||||
+ "<table class=\"storage\" title=\"Snapshot Summary\">\n"
|
||||
+ "<thead><tr><td><b>Snapshottable directories</b></td>"
|
||||
+ "<td><b>Snapshotted directories</b></td></tr></thead>");
|
||||
|
||||
out.println(String.format("<td>%d</td><td>%d</td>", fsn.getNumSnapshottableDirs(), fsn.getNumSnapshots()));
|
||||
out.println("</table></div></div>");
|
||||
}
|
||||
|
||||
static class HealthJsp {
|
||||
private int rowNum = 0;
|
||||
private int colNum = 0;
|
||||
|
|
|
@ -130,4 +130,9 @@ public interface FSNamesystemMBean {
|
|||
* @return number of decommissioned dead data nodes
|
||||
*/
|
||||
public int getNumDecomDeadDataNodes();
|
||||
|
||||
/**
|
||||
* The statistics of snapshots
|
||||
*/
|
||||
public String getSnapshotStats();
|
||||
}
|
||||
|
|
|
@ -73,7 +73,10 @@
|
|||
<% healthjsp.generateJournalReport(out, nn, request); %>
|
||||
<hr/>
|
||||
<% healthjsp.generateConfReport(out, nn, request); %>
|
||||
<hr>
|
||||
<hr/>
|
||||
<h3>Snapshot Summary</h3>
|
||||
<% NamenodeJspHelper.generateSnapshotReport(out, fsn); %>
|
||||
<hr/>
|
||||
<h3>Startup Progress</h3>
|
||||
<% healthjsp.generateStartupProgress(out, nn.getStartupProgress()); %>
|
||||
<%
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.hadoop.hdfs.server.namenode;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.management.MBeanServer;
|
||||
import javax.management.ObjectName;
|
||||
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.hdfs.MiniDFSCluster;
|
||||
import org.junit.Test;
|
||||
import org.mortbay.util.ajax.JSON;
|
||||
|
||||
/**
|
||||
* Class for testing {@link NameNodeMXBean} implementation
|
||||
*/
|
||||
public class TestFSNamesystemMBean {
|
||||
|
||||
@Test
|
||||
public void test() throws Exception {
|
||||
Configuration conf = new Configuration();
|
||||
MiniDFSCluster cluster = null;
|
||||
|
||||
try {
|
||||
cluster = new MiniDFSCluster.Builder(conf).build();
|
||||
cluster.waitActive();
|
||||
|
||||
FSNamesystem fsn = cluster.getNameNode().namesystem;
|
||||
|
||||
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
|
||||
ObjectName mxbeanName = new ObjectName(
|
||||
"Hadoop:service=NameNode,name=FSNamesystemState");
|
||||
|
||||
String snapshotStats = (String) (mbs.getAttribute(mxbeanName,
|
||||
"SnapshotStats"));
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> stat = (Map<String, Object>) JSON
|
||||
.parse(snapshotStats);
|
||||
|
||||
assertTrue(stat.containsKey("SnapshottableDirectories")
|
||||
&& (Long) stat.get("SnapshottableDirectories") == fsn
|
||||
.getNumSnapshottableDirs());
|
||||
assertTrue(stat.containsKey("Snapshots")
|
||||
&& (Long) stat.get("Snapshots") == fsn.getNumSnapshots());
|
||||
|
||||
} finally {
|
||||
if (cluster != null) {
|
||||
cluster.shutdown();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue