You are viewing a plain text version of this content. The canonical link for it is here.
Posted to hdfs-commits@hadoop.apache.org by co...@apache.org on 2013/07/27 01:59:38 UTC
svn commit: r1507530 - in
/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs: ./
src/main/java/org/apache/hadoop/hdfs/server/namenode/
src/test/java/org/apache/hadoop/hdfs/server/namenode/
Author: cos
Date: Fri Jul 26 23:59:37 2013
New Revision: 1507530
URL: http://svn.apache.org/r1507530
Log:
HDFS-5004. Add additional JMX bean for NameNode status data. Contributed by Trevor Lorimer.
Added:
hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNodeStatusMXBean.java
Modified:
hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java
hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNodeMXBean.java
hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeMXBean.java
Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt?rev=1507530&r1=1507529&r2=1507530&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt (original)
+++ hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt Fri Jul 26 23:59:37 2013
@@ -126,6 +126,9 @@ Trunk (Unreleased)
HDFS-4904. Remove JournalService. (Arpit Agarwal via cnauroth)
+ HDFS-5004. Add additional JMX bean for NameNode status data
+ (Trevor Lorimer via cos)
+
OPTIMIZATIONS
BUG FIXES
Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java?rev=1507530&r1=1507529&r2=1507530&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java (original)
+++ hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java Fri Jul 26 23:59:37 2013
@@ -6346,6 +6346,24 @@ public class FSNamesystem implements Nam
return dir;
}
+ @Override // NameNodeMXBean
+ public String getCorruptFiles() {
+ List<String> list = new ArrayList<String>();
+ Collection<FSNamesystem.CorruptFileBlockInfo> corruptFileBlocks;
+ try {
+ corruptFileBlocks = listCorruptFileBlocks("/", null);
+ int corruptFileCount = corruptFileBlocks.size();
+ if (corruptFileCount != 0) {
+ for (FSNamesystem.CorruptFileBlockInfo c : corruptFileBlocks) {
+ list.add(c.toString());
+ }
+ }
+ } catch (IOException e) {
+ LOG.warn("Get corrupt file blocks returned error: " + e.getMessage());
+ }
+ return JSON.toString(list);
+ }
+
/**
* Verifies that the given identifier and password are valid and match.
* @param identifier Token identifier.
Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java?rev=1507530&r1=1507529&r2=1507530&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java (original)
+++ hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java Fri Jul 26 23:59:37 2013
@@ -67,6 +67,7 @@ import org.apache.hadoop.hdfs.server.pro
import org.apache.hadoop.ipc.Server;
import org.apache.hadoop.ipc.StandbyException;
import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem;
+import org.apache.hadoop.metrics2.util.MBeans;
import org.apache.hadoop.net.NetUtils;
import org.apache.hadoop.security.AccessControlException;
import org.apache.hadoop.security.RefreshUserMappingsProtocol;
@@ -123,7 +124,7 @@ import com.google.common.collect.Lists;
* NameNode state, for example partial blocksMap etc.
**********************************************************/
@InterfaceAudience.Private
-public class NameNode {
+public class NameNode implements NameNodeStatusMXBean {
static{
HdfsConfiguration.init();
}
@@ -531,6 +532,7 @@ public class NameNode {
/** Start the services common to active and standby states */
private void startCommonServices(Configuration conf) throws IOException {
namesystem.startCommonServices(conf, haContext);
+ registerNNSMXBean();
if (NamenodeRole.NAMENODE != role) {
startHttpServer(conf);
httpServer.setNameNodeAddress(getNameNodeAddress());
@@ -1369,6 +1371,43 @@ public class NameNode {
}
/**
+ * Register NameNodeStatusMXBean
+ */
+ private void registerNNSMXBean() {
+ MBeans.register("NameNode", "NameNodeStatus", this);
+ }
+
+ @Override // NameNodeStatusMXBean
+ public String getNNRole() {
+ String roleStr = "";
+ NamenodeRole role = getRole();
+ if (null != role) {
+ roleStr = role.toString();
+ }
+ return roleStr;
+ }
+
+ @Override // NameNodeStatusMXBean
+ public String getState() {
+ String servStateStr = "";
+ HAServiceState servState = getServiceState();
+ if (null != servState) {
+ servStateStr = servState.toString();
+ }
+ return servStateStr;
+ }
+
+ @Override // NameNodeStatusMXBean
+ public String getHostAndPort() {
+ return getNameNodeAddressHostPortString();
+ }
+
+ @Override // NameNodeStatusMXBean
+ public boolean isSecurityEnabled() {
+ return UserGroupInformation.isSecurityEnabled();
+ }
+
+ /**
* Shutdown the NN immediately in an ungraceful way. Used when it would be
* unsafe for the NN to continue operating, e.g. during a failed HA state
* transition.
Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNodeMXBean.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNodeMXBean.java?rev=1507530&r1=1507529&r2=1507530&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNodeMXBean.java (original)
+++ hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNodeMXBean.java Fri Jul 26 23:59:37 2013
@@ -202,4 +202,11 @@ public interface NameNodeMXBean {
* @return the compilation information, as a JSON string.
*/
public String getCompileInfo();
+
+ /**
+ * Get the list of corrupt files
+ *
+ * @return the list of corrupt files, as a JSON string.
+ */
+ public String getCorruptFiles();
}
Added: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNodeStatusMXBean.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNodeStatusMXBean.java?rev=1507530&view=auto
==============================================================================
--- hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNodeStatusMXBean.java (added)
+++ hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNodeStatusMXBean.java Fri Jul 26 23:59:37 2013
@@ -0,0 +1,57 @@
+/**
+ * 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 org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.classification.InterfaceStability;
+
+/**
+ * This is the JMX management interface for NameNode status information
+ */
+@InterfaceAudience.Public
+@InterfaceStability.Evolving
+public interface NameNodeStatusMXBean {
+
+ /**
+ * Gets the NameNode role.
+ *
+ * @return the NameNode role.
+ */
+ public String getNNRole();
+
+ /**
+ * Gets the NameNode state.
+ *
+ * @return the NameNode state.
+ */
+ public String getState();
+
+ /**
+ * Gets the host and port colon separated.
+ *
+ * @return host and port colon separated.
+ */
+ public String getHostAndPort();
+
+ /**
+ * Gets if security is enabled.
+ *
+ * @return true, if security is enabled.
+ */
+ public boolean isSecurityEnabled();
+}
Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeMXBean.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeMXBean.java?rev=1507530&r1=1507529&r2=1507530&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeMXBean.java (original)
+++ hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeMXBean.java Fri Jul 26 23:59:37 2013
@@ -126,6 +126,10 @@ public class TestNameNodeMXBean {
// get attribute "CompileInfo"
String compileInfo = (String) mbs.getAttribute(mxbeanName, "CompileInfo");
assertEquals("Bad value for CompileInfo", fsn.getCompileInfo(), compileInfo);
+ // get attribute CorruptFiles
+ String corruptFiles = (String) (mbs.getAttribute(mxbeanName,
+ "CorruptFiles"));
+ assertEquals("Bad value for CorruptFiles", fsn.getCorruptFiles(), corruptFiles);
// get attribute NameDirStatuses
String nameDirStatuses = (String) (mbs.getAttribute(mxbeanName,
"NameDirStatuses"));