hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From omal...@apache.org
Subject svn commit: r1077668 - in /hadoop/common/branches/branch-0.20-security-patches/src/hdfs/org/apache/hadoop/hdfs/server: datanode/DataNode.java namenode/FSNamesystem.java
Date Fri, 04 Mar 2011 04:42:11 GMT
Author: omalley
Date: Fri Mar  4 04:42:10 2011
New Revision: 1077668

URL: http://svn.apache.org/viewvc?rev=1077668&view=rev
Log:
commit 1856c0e09ca79043cfb5822de3d0a171d2dbdcfb
Author: Tanping Wang <tanping@yahoo-inc.com>
Date:   Thu Sep 9 16:58:47 2010 -0700

    []unregister namenode datanode info MXBean.

Modified:
    hadoop/common/branches/branch-0.20-security-patches/src/hdfs/org/apache/hadoop/hdfs/server/datanode/DataNode.java
    hadoop/common/branches/branch-0.20-security-patches/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java

Modified: hadoop/common/branches/branch-0.20-security-patches/src/hdfs/org/apache/hadoop/hdfs/server/datanode/DataNode.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/hdfs/org/apache/hadoop/hdfs/server/datanode/DataNode.java?rev=1077668&r1=1077667&r2=1077668&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/hdfs/org/apache/hadoop/hdfs/server/datanode/DataNode.java
(original)
+++ hadoop/common/branches/branch-0.20-security-patches/src/hdfs/org/apache/hadoop/hdfs/server/datanode/DataNode.java
Fri Mar  4 04:42:10 2011
@@ -116,6 +116,7 @@ import org.mortbay.util.ajax.JSON;
 import java.lang.management.ManagementFactory;  
 
 import javax.management.InstanceAlreadyExistsException;
+import javax.management.InstanceNotFoundException;
 import javax.management.MBeanRegistrationException;
 import javax.management.MBeanServer; 
 import javax.management.ObjectName;
@@ -236,6 +237,8 @@ public class DataNode extends Configured
 
   private SecureResources secureResources = null;
   
+  private ObjectName mxBeanName = null;
+  
   /**
    * Current system time.
    * @return current time in msec.
@@ -466,12 +469,30 @@ public class DataNode extends Configured
 
   private void registerMXBean() {
     // register MXBean
-    MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); 
-    try {
-      ObjectName mxbeanName = new ObjectName("HadoopInfo:type=DataNodeInfo");
-      mbs.registerMBean(this, mxbeanName);
-    } catch ( javax.management.JMException e ) {
-      LOG.warn("Failed to register NameNode MXBean", e);
+    final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); 
+    if (mxBeanName == null) {
+      try {
+        mxBeanName = new ObjectName("HadoopInfo:type=DataNodeInfo");
+        mbs.registerMBean(this, mxBeanName);
+      } catch ( javax.management.JMException e ) {
+        LOG.warn("Failed to register DataNodeMXBean", e);
+      }
+    }
+  }
+  
+  private void unRegisterMXBean() {
+    if (mxBeanName == null)
+      return;
+    final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); 
+    if (mbs.isRegistered(mxBeanName)){
+      try {
+        mbs.unregisterMBean(mxBeanName);
+      } catch (InstanceNotFoundException e ) {
+        LOG.warn(mxBeanName, e);
+      } catch (javax.management.JMException e) {
+        LOG.warn("Error unregistering "+ mxBeanName, e);
+      }
+      mxBeanName = null;
     }
   }
   
@@ -684,6 +705,7 @@ public class DataNode extends Configured
    * Otherwise, deadlock might occur.
    */
   public void shutdown() {
+    this.unRegisterMXBean();
     if (infoServer != null) {
       try {
         infoServer.stop();

Modified: hadoop/common/branches/branch-0.20-security-patches/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java?rev=1077668&r1=1077667&r2=1077668&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
(original)
+++ hadoop/common/branches/branch-0.20-security-patches/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
Fri Mar  4 04:42:10 2011
@@ -49,6 +49,7 @@ import java.util.TreeSet;
 import java.util.Map.Entry;
 import java.util.concurrent.TimeUnit;
 
+import javax.management.InstanceNotFoundException;
 import javax.management.MBeanServer;
 import javax.management.NotCompliantMBeanException;
 import javax.management.ObjectName;
@@ -343,6 +344,8 @@ public class FSNamesystem implements FSC
   // precision of access times.
   private long accessTimePrecision = 0;
   
+  private ObjectName mxBeanName = null;
+  
   /**
    * FSNamesystem constructor.
    */
@@ -4804,6 +4807,8 @@ public class FSNamesystem implements FSC
   public void shutdown() {
     if (mbeanName != null)
       MBeans.unregister(mbeanName);
+    if (mxBeanName != null)
+      unRegisterMXBean();
   }
   
 
@@ -5158,15 +5163,32 @@ public class FSNamesystem implements FSC
    */
   private void registerMXBean() {
     // register MXBean
-    MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
-    try {
-      ObjectName mxbeanName = new ObjectName("HadoopInfo:type=NameNodeInfo");
-      mbs.registerMBean(this, mxbeanName);
-    } catch ( javax.management.JMException e ) {
-      LOG.warn("Failed to register NameNodeMXBean", e);
+    final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
+    if (mxBeanName == null) {
+      try {
+        mxBeanName = new ObjectName("HadoopInfo:type=NameNodeInfo");
+        mbs.registerMBean(this, mxBeanName);
+      } catch ( javax.management.JMException e ) {
+        LOG.warn("Failed to register NameNodeMXBean", e);
+      }
     }
   }
 
+  private void unRegisterMXBean() {
+    if (mxBeanName == null)
+      return;
+    final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
+    if (mbs.isRegistered(mxBeanName)){
+      try {
+        mbs.unregisterMBean(mxBeanName);
+      } catch (InstanceNotFoundException e ) {
+        LOG.warn(mxBeanName, e);
+      } catch (javax.management.JMException e) {
+        LOG.warn("Error unregistering "+ mxBeanName, e);
+      }
+      mxBeanName = null;
+    }
+  }
   /**
    * Class representing Namenode information for JMX interfaces
    */



Mime
View raw message