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 st...@apache.org on 2022/08/08 13:37:50 UTC
[hadoop] branch branch-3.3 updated: HADOOP-18373. IOStatisticsContext tuning (#4705)
This is an automated email from the ASF dual-hosted git repository.
stevel pushed a commit to branch branch-3.3
in repository https://gitbox.apache.org/repos/asf/hadoop.git
The following commit(s) were added to refs/heads/branch-3.3 by this push:
new 04557695317 HADOOP-18373. IOStatisticsContext tuning (#4705)
04557695317 is described below
commit 04557695317ebd43edd39d4fa7791d945a10e04c
Author: Viraj Jasani <vj...@apache.org>
AuthorDate: Mon Aug 8 02:42:57 2022 -0700
HADOOP-18373. IOStatisticsContext tuning (#4705)
The name of the option to enable/disable thread level statistics is
"fs.iostatistics.thread.level.enabled";
There is also an enabled() probe in IOStatisticsContext which can
be used to see if the thread level statistics is active.
Contributed by Viraj Jasani
---
.../org/apache/hadoop/fs/CommonConfigurationKeys.java | 6 +++---
.../hadoop/fs/statistics/IOStatisticsContext.java | 10 ++++++++++
.../statistics/impl/IOStatisticsContextIntegration.java | 17 +++++++++++++----
.../hadoop/fs/s3a/ITestS3AIOStatisticsContext.java | 2 ++
.../hadoop-aws/src/test/resources/core-site.xml | 6 ++++++
5 files changed, 34 insertions(+), 7 deletions(-)
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/CommonConfigurationKeys.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/CommonConfigurationKeys.java
index 9345211a317..79593117b13 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/CommonConfigurationKeys.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/CommonConfigurationKeys.java
@@ -477,13 +477,13 @@ public class CommonConfigurationKeys extends CommonConfigurationKeysPublic {
* Thread-level IOStats Support.
* {@value}
*/
- public static final String THREAD_LEVEL_IOSTATISTICS_ENABLED =
- "fs.thread.level.iostatistics.enabled";
+ public static final String IOSTATISTICS_THREAD_LEVEL_ENABLED =
+ "fs.iostatistics.thread.level.enabled";
/**
* Default value for Thread-level IOStats Support is true.
*/
- public static final boolean THREAD_LEVEL_IOSTATISTICS_ENABLED_DEFAULT =
+ public static final boolean IOSTATISTICS_THREAD_LEVEL_ENABLED_DEFAULT =
true;
}
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/statistics/IOStatisticsContext.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/statistics/IOStatisticsContext.java
index fb10b93848f..557c57ea4d6 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/statistics/IOStatisticsContext.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/statistics/IOStatisticsContext.java
@@ -80,4 +80,14 @@ public interface IOStatisticsContext extends IOStatisticsSource {
IOStatisticsContextIntegration.setThreadIOStatisticsContext(
statisticsContext);
}
+
+ /**
+ * Static probe to check if the thread-level IO statistics enabled.
+ *
+ * @return if the thread-level IO statistics enabled.
+ */
+ static boolean enabled() {
+ return IOStatisticsContextIntegration.isIOStatisticsThreadLevelEnabled();
+ }
+
}
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/statistics/impl/IOStatisticsContextIntegration.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/statistics/impl/IOStatisticsContextIntegration.java
index 483d1e4570f..2a394e6a1cd 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/statistics/impl/IOStatisticsContextIntegration.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/statistics/impl/IOStatisticsContextIntegration.java
@@ -29,8 +29,8 @@ import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.impl.WeakReferenceThreadMap;
import org.apache.hadoop.fs.statistics.IOStatisticsContext;
-import static org.apache.hadoop.fs.CommonConfigurationKeys.THREAD_LEVEL_IOSTATISTICS_ENABLED;
-import static org.apache.hadoop.fs.CommonConfigurationKeys.THREAD_LEVEL_IOSTATISTICS_ENABLED_DEFAULT;
+import static org.apache.hadoop.fs.CommonConfigurationKeys.IOSTATISTICS_THREAD_LEVEL_ENABLED;
+import static org.apache.hadoop.fs.CommonConfigurationKeys.IOSTATISTICS_THREAD_LEVEL_ENABLED_DEFAULT;
/**
* A Utility class for IOStatisticsContext, which helps in creating and
@@ -76,8 +76,17 @@ public final class IOStatisticsContextIntegration {
// Work out if the current context has thread level IOStatistics enabled.
final Configuration configuration = new Configuration();
isThreadIOStatsEnabled =
- configuration.getBoolean(THREAD_LEVEL_IOSTATISTICS_ENABLED,
- THREAD_LEVEL_IOSTATISTICS_ENABLED_DEFAULT);
+ configuration.getBoolean(IOSTATISTICS_THREAD_LEVEL_ENABLED,
+ IOSTATISTICS_THREAD_LEVEL_ENABLED_DEFAULT);
+ }
+
+ /**
+ * Static probe to check if the thread-level IO statistics enabled.
+ *
+ * @return if the thread-level IO statistics enabled.
+ */
+ public static boolean isIOStatisticsThreadLevelEnabled() {
+ return isThreadIOStatsEnabled;
}
/**
diff --git a/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/ITestS3AIOStatisticsContext.java b/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/ITestS3AIOStatisticsContext.java
index 19c40c64661..d2ae9d7dc3c 100644
--- a/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/ITestS3AIOStatisticsContext.java
+++ b/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/ITestS3AIOStatisticsContext.java
@@ -153,6 +153,8 @@ public class ITestS3AIOStatisticsContext extends AbstractS3ATestBase {
* @return thread context
*/
private static IOStatisticsContext getAndResetThreadStatisticsContext() {
+ assertTrue("thread-level IOStatistics should be enabled by default",
+ IOStatisticsContext.enabled());
IOStatisticsContext context =
IOStatisticsContext.getCurrentIOStatisticsContext();
context.reset();
diff --git a/hadoop-tools/hadoop-aws/src/test/resources/core-site.xml b/hadoop-tools/hadoop-aws/src/test/resources/core-site.xml
index 1525f51d9d6..600ea3a178d 100644
--- a/hadoop-tools/hadoop-aws/src/test/resources/core-site.xml
+++ b/hadoop-tools/hadoop-aws/src/test/resources/core-site.xml
@@ -178,6 +178,12 @@
<value>true</value>
</property>
+ <!-- Enable IOStatisticsContext support for Thread level. -->
+ <property>
+ <name>fs.iostatistics.thread.level.enabled</name>
+ <value>true</value>
+ </property>
+
<!--
To run these tests.
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org