Author: sandy
Date: Fri Jun 13 20:57:41 2014
New Revision: 1602519
URL: http://svn.apache.org/r1602519
Log:
HADOOP-10688. Expose thread-level FileSystem StatisticsData (Sandy Ryza)
Modified:
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/CHANGES.txt
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java
Modified:
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/CHANGES.txt
URL:
http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/CHANGES.txt?rev=1602519&r1=1602518&r2=1602519&view=diff
==============================================================================
---
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/CHANGES.txt
(original)
+++
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/CHANGES.txt
Fri Jun 13 20:57:41 2014
@@ -80,6 +80,8 @@ Release 2.5.0 - UNRELEASED
HADOOP-10691. Improve the readability of 'hadoop fs -help'.
(Lei Xu via wang)
+ HADOOP-10688. Expose thread-level FileSystem StatisticsData (Sandy Ryza)
+
OPTIMIZATIONS
BUG FIXES
Modified:
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java
URL:
http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java?rev=1602519&r1=1602518&r2=1602519&view=diff
==============================================================================
---
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java
(original)
+++
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java
Fri Jun 13 20:57:41 2014
@@ -2805,7 +2805,7 @@ public abstract class FileSystem extends
* be perceived as atomic with respect to other threads, which is all we
* need.
*/
- private static class StatisticsData {
+ public static class StatisticsData {
volatile long bytesRead;
volatile long bytesWritten;
volatile int readOps;
@@ -2850,6 +2850,26 @@ public abstract class FileSystem extends
+ readOps + " read ops, " + largeReadOps + " large read ops, "
+ writeOps + " write ops";
}
+
+ public long getBytesRead() {
+ return bytesRead;
+ }
+
+ public long getBytesWritten() {
+ return bytesWritten;
+ }
+
+ public int getReadOps() {
+ return readOps;
+ }
+
+ public int getLargeReadOps() {
+ return largeReadOps;
+ }
+
+ public int getWriteOps() {
+ return writeOps;
+ }
}
private interface StatisticsAggregator<T> {
@@ -2908,7 +2928,7 @@ public abstract class FileSystem extends
/**
* Get or create the thread-local data associated with the current thread.
*/
- private StatisticsData getThreadData() {
+ public StatisticsData getThreadStatistics() {
StatisticsData data = threadData.get();
if (data == null) {
data = new StatisticsData(
@@ -2929,7 +2949,7 @@ public abstract class FileSystem extends
* @param newBytes the additional bytes read
*/
public void incrementBytesRead(long newBytes) {
- getThreadData().bytesRead += newBytes;
+ getThreadStatistics().bytesRead += newBytes;
}
/**
@@ -2937,7 +2957,7 @@ public abstract class FileSystem extends
* @param newBytes the additional bytes written
*/
public void incrementBytesWritten(long newBytes) {
- getThreadData().bytesWritten += newBytes;
+ getThreadStatistics().bytesWritten += newBytes;
}
/**
@@ -2945,7 +2965,7 @@ public abstract class FileSystem extends
* @param count number of read operations
*/
public void incrementReadOps(int count) {
- getThreadData().readOps += count;
+ getThreadStatistics().readOps += count;
}
/**
@@ -2953,7 +2973,7 @@ public abstract class FileSystem extends
* @param count number of large read operations
*/
public void incrementLargeReadOps(int count) {
- getThreadData().largeReadOps += count;
+ getThreadStatistics().largeReadOps += count;
}
/**
@@ -2961,7 +2981,7 @@ public abstract class FileSystem extends
* @param count number of write operations
*/
public void incrementWriteOps(int count) {
- getThreadData().writeOps += count;
+ getThreadStatistics().writeOps += count;
}
/**