You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by su...@apache.org on 2010/07/16 08:07:06 UTC

svn commit: r964689 - in /hadoop/common/trunk: CHANGES.txt src/java/org/apache/hadoop/fs/FileSystem.java

Author: suresh
Date: Fri Jul 16 06:07:06 2010
New Revision: 964689

URL: http://svn.apache.org/viewvc?rev=964689&view=rev
Log:
HADOOP-6859 - Introduce additional statistics to FileSystem to track file system operations. Contributed by Suresh Srinivas.

Modified:
    hadoop/common/trunk/CHANGES.txt
    hadoop/common/trunk/src/java/org/apache/hadoop/fs/FileSystem.java

Modified: hadoop/common/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/CHANGES.txt?rev=964689&r1=964688&r2=964689&view=diff
==============================================================================
--- hadoop/common/trunk/CHANGES.txt (original)
+++ hadoop/common/trunk/CHANGES.txt Fri Jul 16 06:07:06 2010
@@ -18,6 +18,9 @@ Trunk (unreleased changes)
 
     HADOOP-6853. Common component of HDFS-1045. (jghoman)
 
+    HADOOP-6859 - Introduce additional statistics to FileSystem to track 
+    file system operations (suresh)
+
   IMPROVEMENTS
 
     HADOOP-6644. util.Shell getGROUPS_FOR_USER_COMMAND method name 

Modified: hadoop/common/trunk/src/java/org/apache/hadoop/fs/FileSystem.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/java/org/apache/hadoop/fs/FileSystem.java?rev=964689&r1=964688&r2=964689&view=diff
==============================================================================
--- hadoop/common/trunk/src/java/org/apache/hadoop/fs/FileSystem.java (original)
+++ hadoop/common/trunk/src/java/org/apache/hadoop/fs/FileSystem.java Fri Jul 16 06:07:06 2010
@@ -33,8 +33,8 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.TreeSet;
+import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicLong;
-import java.util.regex.Pattern;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -42,7 +42,6 @@ import org.apache.hadoop.classification.
 import org.apache.hadoop.classification.InterfaceStability;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configured;
-import org.apache.hadoop.fs.Options.CreateOpts;
 import org.apache.hadoop.fs.Options.Rename;
 import org.apache.hadoop.fs.permission.FsPermission;
 import org.apache.hadoop.fs.CommonConfigurationKeys;
@@ -1783,6 +1782,9 @@ public abstract class FileSystem extends
     private final String scheme;
     private AtomicLong bytesRead = new AtomicLong();
     private AtomicLong bytesWritten = new AtomicLong();
+    private AtomicInteger readOps = new AtomicInteger();
+    private AtomicInteger largeReadOps = new AtomicInteger();
+    private AtomicInteger writeOps = new AtomicInteger();
     
     public Statistics(String scheme) {
       this.scheme = scheme;
@@ -1805,6 +1807,30 @@ public abstract class FileSystem extends
     }
     
     /**
+     * Increment the number of read operations
+     * @param count number of read operations
+     */
+    public void incrementReadOps(int count) {
+      readOps.getAndAdd(count);
+    }
+
+    /**
+     * Increment the number of large read operations
+     * @param count number of large read operations
+     */
+    public void incrementLargeReadOps(int count) {
+      largeReadOps.getAndAdd(count);
+    }
+
+    /**
+     * Increment the number of write operations
+     * @param count number of write operations
+     */
+    public void incrementWriteOps(int count) {
+      writeOps.getAndAdd(count);
+    }
+
+    /**
      * Get the total number of bytes read
      * @return the number of bytes
      */
@@ -1820,9 +1846,36 @@ public abstract class FileSystem extends
       return bytesWritten.get();
     }
     
+    /**
+     * Get the number of file system read operations such as list files
+     * @return number of read operations
+     */
+    public int getReadOps() {
+      return readOps.get() + largeReadOps.get();
+    }
+
+    /**
+     * Get the number of large file system read operations such as list files
+     * under a large directory
+     * @return number of large read operations
+     */
+    public int getLargeReadOps() {
+      return largeReadOps.get();
+    }
+
+    /**
+     * Get the number of file system write operations such as create, append 
+     * rename etc.
+     * @return number of write operations
+     */
+    public int getWriteOps() {
+      return writeOps.get();
+    }
+
     public String toString() {
-      return bytesRead + " bytes read and " + bytesWritten + 
-             " bytes written";
+      return bytesRead + " bytes read, " + bytesWritten + " bytes written, "
+          + readOps + " read ops, " + largeReadOps + " large read ops, "
+          + writeOps + " write ops";
     }
     
     /**