hadoop-hdfs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From szets...@apache.org
Subject svn commit: r790733 - in /hadoop/hdfs/trunk: ./ src/java/org/apache/hadoop/hdfs/server/namenode/ src/java/org/apache/hadoop/hdfs/server/namenode/metrics/ src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/metrics/
Date Thu, 02 Jul 2009 20:28:50 GMT
Author: szetszwo
Date: Thu Jul  2 20:28:50 2009
New Revision: 790733

URL: http://svn.apache.org/viewvc?rev=790733&view=rev
Log:
HDFS-204. Add a new metrics FilesInGetListingOps to the Namenode.  Contributed by Jitendra
Nath Pandey

Added:
    hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/metrics/TestNNMetricFilesInGetListingOps.java
Modified:
    hadoop/hdfs/trunk/CHANGES.txt
    hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java
    hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/metrics/NameNodeMetrics.java

Modified: hadoop/hdfs/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/CHANGES.txt?rev=790733&r1=790732&r2=790733&view=diff
==============================================================================
--- hadoop/hdfs/trunk/CHANGES.txt (original)
+++ hadoop/hdfs/trunk/CHANGES.txt Thu Jul  2 20:28:50 2009
@@ -25,6 +25,9 @@
     HADOOP-6106. Updated hadoop-core and test jars from hudson trunk 
     build #12. (Giridharan Kesavan)
 
+    HDFS-204. Add a new metrics FilesInGetListingOps to the Namenode.
+    (Jitendra Nath Pandey via szetszwo)
+
   BUG FIXES
     HDFS-76. Better error message to users when commands fail because of 
     lack of quota. Allow quota to be set even if the limit is lower than

Modified: hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java?rev=790733&r1=790732&r2=790733&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java (original)
+++ hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java Thu Jul
 2 20:28:50 2009
@@ -744,6 +744,7 @@
     FileStatus[] files = namesystem.getListing(src);
     if (files != null) {
       myMetrics.numGetListingOps.inc();
+      myMetrics.numFilesInGetListingOps.inc(files.length);
     }
     return files;
   }

Modified: hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/metrics/NameNodeMetrics.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/metrics/NameNodeMetrics.java?rev=790733&r1=790732&r2=790733&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/metrics/NameNodeMetrics.java
(original)
+++ hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/metrics/NameNodeMetrics.java
Thu Jul  2 20:28:50 2009
@@ -81,6 +81,8 @@
                     new MetricsIntValue("fsImageLoadTime", registry, "Time loading FS Image
at Startup");
     public MetricsIntValue numBlocksCorrupted =
                     new MetricsIntValue("BlocksCorrupted", registry);
+    public MetricsTimeVaryingInt numFilesInGetListingOps = 
+                    new MetricsTimeVaryingInt("FilesInGetListingOps", registry);
 
       
     public NameNodeMetrics(Configuration conf, NamenodeRole nameNodeRole) {

Added: hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/metrics/TestNNMetricFilesInGetListingOps.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/metrics/TestNNMetricFilesInGetListingOps.java?rev=790733&view=auto
==============================================================================
--- hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/metrics/TestNNMetricFilesInGetListingOps.java
(added)
+++ hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/metrics/TestNNMetricFilesInGetListingOps.java
Thu Jul  2 20:28:50 2009
@@ -0,0 +1,81 @@
+/**
+ * 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.metrics;
+
+import java.io.IOException;
+import java.util.Random;
+
+import junit.framework.TestCase;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hdfs.DFSTestUtil;
+import org.apache.hadoop.hdfs.DistributedFileSystem;
+import org.apache.hadoop.hdfs.MiniDFSCluster;
+import org.apache.hadoop.hdfs.server.namenode.NameNode;
+
+/**
+ * Test case for FilesInGetListingOps metric in Namenode
+ */
+public class TestNNMetricFilesInGetListingOps extends TestCase {
+  private static final Configuration CONF = new Configuration();
+  static {
+    CONF.setLong("dfs.block.size", 100);
+    CONF.setInt("io.bytes.per.checksum", 1);
+    CONF.setLong("dfs.heartbeat.interval", 1L);
+    CONF.setInt("dfs.replication.interval", 1);
+  }
+     
+  private MiniDFSCluster cluster;
+  private NameNodeMetrics nnMetrics;
+  private DistributedFileSystem fs;
+  private Random rand = new Random();
+
+  @Override
+  protected void setUp() throws Exception {
+    cluster = new MiniDFSCluster(CONF, 1, true, null);
+    cluster.waitActive();
+    cluster.getNameNode();
+    nnMetrics = NameNode.getNameNodeMetrics();
+    fs = (DistributedFileSystem) cluster.getFileSystem();
+  }
+
+  @Override
+  protected void tearDown() throws Exception {
+    cluster.shutdown();
+  }
+
+  /** create a file with a length of <code>fileLen</code> */
+  private void createFile(String fileName, long fileLen, short replicas) throws IOException
{
+    Path filePath = new Path(fileName);
+    DFSTestUtil.createFile(fs, filePath, fileLen, replicas, rand.nextLong());
+  }
+     
+
+  public void testFilesInGetListingOps() throws Exception {
+    createFile("/tmp1/t1", 3200, (short)3);
+    createFile("/tmp1/t2", 3200, (short)3);
+    createFile("/tmp2/t1", 3200, (short)3);
+    createFile("/tmp2/t2", 3200, (short)3);
+    cluster.getNameNode().getListing("/tmp1") ;
+    assertEquals(2,nnMetrics.numFilesInGetListingOps.getCurrentIntervalValue());
+    cluster.getNameNode().getListing("/tmp2") ;
+    assertEquals(4,nnMetrics.numFilesInGetListingOps.getCurrentIntervalValue());
+  }
+}
+



Mime
View raw message