Просмотр исходного кода

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/trunk@681437 13f79535-47bb-0310-9956-ffa450edef68

Christopher Douglas 17 лет назад
Родитель
Сommit
5aa44d8e2b

+ 3 - 0
CHANGES.txt

@@ -982,6 +982,9 @@ Release 0.18.0 - Unreleased
     
     HADOOP-3827.  Fixed compression of empty map-outputs. (acmurthy) 
 
+    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/hdfs/server/namenode/FSNamesystem.java

@@ -388,7 +388,6 @@ public class FSNamesystem implements FSConstants, FSNamesystemMBean {
    */
   FSNamesystem(FSImage fsImage, Configuration conf) throws IOException {
     setConfigurationParameters(conf);
-    this.registerMBean(conf);
     this.dir = new FSDirectory(fsImage, this, conf);
   }
 
@@ -4322,7 +4321,7 @@ public 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 - 10
src/hdfs/org/apache/hadoop/hdfs/server/namenode/metrics/FSNamesystemMetrics.java

@@ -22,10 +22,7 @@ import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hdfs.server.namenode.FSNamesystem;
 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;
 
 /**
  * 
@@ -42,7 +39,6 @@ import org.apache.hadoop.metrics.util.MetricsTimeVaryingRate;
 public class FSNamesystemMetrics implements Updater {
   private static Log log = LogFactory.getLog(FSNamesystemMetrics.class);
   private final MetricsRecord metricsRecord;
-  private FSNamesystem fsNameSystem;
    
   public MetricsIntValue filesTotal = new MetricsIntValue("FilesTotal");
   public MetricsIntValue blocksTotal = new MetricsIntValue("BlocksTotal");
@@ -53,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");
-  public FSNamesystemMetrics(Configuration conf, FSNamesystem fsNameSystem) {
+  public FSNamesystemMetrics(Configuration conf) {
     String sessionId = conf.get("session.id");
-    this.fsNameSystem = fsNameSystem;
      
     // Create a record for FSNamesystem metrics
     MetricsContext metricsContext = MetricsUtil.getContext("dfs");
@@ -65,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)));
@@ -89,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);