Browse Source

HADOOP-3865. Remove reference to FSNamesystem from metrics preventing
garbage collection. Contributed by Lohit Vijayarenu


git-svn-id: https://svn.apache.org/repos/asf/hadoop/core/branches/branch-0.18@681436 13f79535-47bb-0310-9956-ffa450edef68

Christopher Douglas 17 years ago
parent
commit
885cf27633

+ 3 - 0
CHANGES.txt

@@ -776,6 +776,9 @@ Release 0.18.0 - Unreleased
     HADOOP-3855. Fixes an import problem introduced by HADOOP-3827.
     (Arun Murthy via ddas)
 
+    HADOOP-3865. Remove reference to FSNamesystem from metrics preventing
+    garbage collection. (Lohit Vijayarenu via cdouglas)
+
 Release 0.17.2 - Unreleased
 
   BUG FIXES

+ 1 - 2
src/hdfs/org/apache/hadoop/dfs/FSNamesystem.java

@@ -376,7 +376,6 @@ class FSNamesystem implements FSConstants, FSNamesystemMBean {
    */
   FSNamesystem(FSImage fsImage, Configuration conf) throws IOException {
     setConfigurationParameters(conf);
-    this.registerMBean(conf);
     this.dir = new FSDirectory(fsImage, this, conf);
   }
 
@@ -4265,7 +4264,7 @@ class FSNamesystem implements FSConstants, FSNamesystemMBean {
     // package naming for mbeans and their impl.
     StandardMBean bean;
     try {
-      myFSMetrics = new FSNamesystemMetrics(conf, this);
+      myFSMetrics = new FSNamesystemMetrics(conf);
       bean = new StandardMBean(this,FSNamesystemMBean.class);
       mbeanName = MBeanUtil.registerMBean("NameNode", "FSNamesystemStatus", bean);
     } catch (NotCompliantMBeanException e) {

+ 2 - 9
src/hdfs/org/apache/hadoop/dfs/FSNamesystemMetrics.java

@@ -21,10 +21,7 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.metrics.*;
-import org.apache.hadoop.metrics.jvm.JvmMetrics;
 import org.apache.hadoop.metrics.util.MetricsIntValue;
-import org.apache.hadoop.metrics.util.MetricsTimeVaryingInt;
-import org.apache.hadoop.metrics.util.MetricsTimeVaryingRate;
 
 /**
  * 
@@ -52,9 +49,8 @@ public class FSNamesystemMetrics implements Updater {
   public MetricsIntValue pendingReplicationBlocks = new MetricsIntValue("PendingReplicationBlocks");
   public MetricsIntValue underReplicatedBlocks = new MetricsIntValue("UnderReplicatedBlocks");
   public MetricsIntValue scheduledReplicationBlocks = new MetricsIntValue("ScheduledReplicationBlocks");
-  FSNamesystemMetrics(Configuration conf, FSNamesystem fsNameSystem) {
+  FSNamesystemMetrics(Configuration conf) {
     String sessionId = conf.get("session.id");
-    this.fsNameSystem = fsNameSystem;
      
     // Create a record for FSNamesystem metrics
     MetricsContext metricsContext = MetricsUtil.getContext("dfs");
@@ -64,10 +60,6 @@ public class FSNamesystemMetrics implements Updater {
     log.info("Initializing FSNamesystemMeterics using context object:" +
               metricsContext.getClass().getName());
   }
-  public void shutdown() {
-    if (fsNameSystem != null) 
-      fsNameSystem.shutdown();
-  }
 
   private int roundBytesToGBytes(long bytes) {
     return Math.round(((float)bytes/(1024 * 1024 * 1024)));
@@ -88,6 +80,7 @@ public class FSNamesystemMetrics implements Updater {
    */
   public void doUpdates(MetricsContext unused) {
     synchronized (this) {
+      FSNamesystem fsNameSystem = FSNamesystem.getFSNamesystem();
       filesTotal.set((int)fsNameSystem.getFilesTotal());
       filesTotal.pushMetric(metricsRecord);