|
@@ -67,6 +67,7 @@ import org.apache.hadoop.hdfs.server.protocol.NamespaceInfo;
|
|
|
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());
|
|
@@ -1368,6 +1370,43 @@ public class NameNode {
|
|
|
return state.getServiceState();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 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
|