Skip to content

Commit 06f0f7d

Browse files
authored
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
1 parent d8d3325 commit 06f0f7d

File tree

5 files changed

+34
-7
lines changed

5 files changed

+34
-7
lines changed

hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/CommonConfigurationKeys.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -480,13 +480,13 @@ public class CommonConfigurationKeys extends CommonConfigurationKeysPublic {
480480
* Thread-level IOStats Support.
481481
* {@value}
482482
*/
483-
public static final String THREAD_LEVEL_IOSTATISTICS_ENABLED =
484-
"fs.thread.level.iostatistics.enabled";
483+
public static final String IOSTATISTICS_THREAD_LEVEL_ENABLED =
484+
"fs.iostatistics.thread.level.enabled";
485485

486486
/**
487487
* Default value for Thread-level IOStats Support is true.
488488
*/
489-
public static final boolean THREAD_LEVEL_IOSTATISTICS_ENABLED_DEFAULT =
489+
public static final boolean IOSTATISTICS_THREAD_LEVEL_ENABLED_DEFAULT =
490490
true;
491491

492492
}

hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/statistics/IOStatisticsContext.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,14 @@ static void setThreadIOStatisticsContext(
8080
IOStatisticsContextIntegration.setThreadIOStatisticsContext(
8181
statisticsContext);
8282
}
83+
84+
/**
85+
* Static probe to check if the thread-level IO statistics enabled.
86+
*
87+
* @return if the thread-level IO statistics enabled.
88+
*/
89+
static boolean enabled() {
90+
return IOStatisticsContextIntegration.isIOStatisticsThreadLevelEnabled();
91+
}
92+
8393
}

hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/statistics/impl/IOStatisticsContextIntegration.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
import org.apache.hadoop.fs.impl.WeakReferenceThreadMap;
3030
import org.apache.hadoop.fs.statistics.IOStatisticsContext;
3131

32-
import static org.apache.hadoop.fs.CommonConfigurationKeys.THREAD_LEVEL_IOSTATISTICS_ENABLED;
33-
import static org.apache.hadoop.fs.CommonConfigurationKeys.THREAD_LEVEL_IOSTATISTICS_ENABLED_DEFAULT;
32+
import static org.apache.hadoop.fs.CommonConfigurationKeys.IOSTATISTICS_THREAD_LEVEL_ENABLED;
33+
import static org.apache.hadoop.fs.CommonConfigurationKeys.IOSTATISTICS_THREAD_LEVEL_ENABLED_DEFAULT;
3434

3535
/**
3636
* A Utility class for IOStatisticsContext, which helps in creating and
@@ -76,8 +76,17 @@ public final class IOStatisticsContextIntegration {
7676
// Work out if the current context has thread level IOStatistics enabled.
7777
final Configuration configuration = new Configuration();
7878
isThreadIOStatsEnabled =
79-
configuration.getBoolean(THREAD_LEVEL_IOSTATISTICS_ENABLED,
80-
THREAD_LEVEL_IOSTATISTICS_ENABLED_DEFAULT);
79+
configuration.getBoolean(IOSTATISTICS_THREAD_LEVEL_ENABLED,
80+
IOSTATISTICS_THREAD_LEVEL_ENABLED_DEFAULT);
81+
}
82+
83+
/**
84+
* Static probe to check if the thread-level IO statistics enabled.
85+
*
86+
* @return if the thread-level IO statistics enabled.
87+
*/
88+
public static boolean isIOStatisticsThreadLevelEnabled() {
89+
return isThreadIOStatsEnabled;
8190
}
8291

8392
/**

hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/ITestS3AIOStatisticsContext.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ public void testS3AInputStreamIOStatisticsContext()
153153
* @return thread context
154154
*/
155155
private static IOStatisticsContext getAndResetThreadStatisticsContext() {
156+
assertTrue("thread-level IOStatistics should be enabled by default",
157+
IOStatisticsContext.enabled());
156158
IOStatisticsContext context =
157159
IOStatisticsContext.getCurrentIOStatisticsContext();
158160
context.reset();

hadoop-tools/hadoop-aws/src/test/resources/core-site.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,12 @@
178178
<value>true</value>
179179
</property>
180180

181+
<!-- Enable IOStatisticsContext support for Thread level. -->
182+
<property>
183+
<name>fs.iostatistics.thread.level.enabled</name>
184+
<value>true</value>
185+
</property>
186+
181187
<!--
182188
To run these tests.
183189

0 commit comments

Comments
 (0)