Class IOStatisticsContextIntegration
java.lang.Object
org.apache.hadoop.fs.statistics.impl.IOStatisticsContextIntegration
A Utility class for IOStatisticsContext, which helps in creating and
getting the current active context. Static methods in this class allows to
get the current context to start aggregating the IOStatistics.
Static initializer is used to work out if the feature to collect
thread-level IOStatistics is enabled or not and the corresponding
implementation class is called for it.
Weak Reference thread map to be used to keep track of different context's
to avoid long-lived memory leakages as these references would be cleaned
up at GC.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic voidA method to enable IOStatisticsContext to override if set otherwise in the configurations for tests.static IOStatisticsContextGet the current thread's IOStatisticsContext instance.static IOStatisticsContextgetThreadSpecificIOStatisticsContext(long testThreadId) Get thread ID specific IOStatistics values if statistics are enabled and the thread ID is in the map.static booleanStatic probe to check if the thread-level IO statistics enabled.static voidsetThreadIOStatisticsContext(IOStatisticsContext statisticsContext) Set the IOStatisticsContext for the current thread.
-
Field Details
-
INSTANCE_ID
ID for next instance to create.
-
-
Method Details
-
isIOStatisticsThreadLevelEnabled
public static boolean isIOStatisticsThreadLevelEnabled()Static probe to check if the thread-level IO statistics enabled.- Returns:
- if the thread-level IO statistics enabled.
-
getCurrentIOStatisticsContext
Get the current thread's IOStatisticsContext instance. If no instance is present for this thread ID, create one using the factory.- Returns:
- instance of IOStatisticsContext.
-
setThreadIOStatisticsContext
Set the IOStatisticsContext for the current thread.- Parameters:
statisticsContext- IOStatistics context instance for the current thread. If null, the context is reset.
-
getThreadSpecificIOStatisticsContext
@VisibleForTesting public static IOStatisticsContext getThreadSpecificIOStatisticsContext(long testThreadId) Get thread ID specific IOStatistics values if statistics are enabled and the thread ID is in the map.- Parameters:
testThreadId- thread ID.- Returns:
- IOStatisticsContext if found in the map.
-
enableIOStatisticsContext
@VisibleForTesting public static void enableIOStatisticsContext()A method to enable IOStatisticsContext to override if set otherwise in the configurations for tests.
-