Package org.apache.hadoop.fs.statistics
Class IOStatisticsLogging
java.lang.Object
org.apache.hadoop.fs.statistics.IOStatisticsLogging
Utility operations convert IO Statistics sources/instances
to strings, especially for robustly logging.
-
Method Summary
Modifier and TypeMethodDescriptionstatic ObjectdemandStringifyIOStatistics(IOStatistics statistics) On demand stringifier of an IOStatistics instance.static ObjectdemandStringifyIOStatisticsSource(org.apache.hadoop.fs.statistics.IOStatisticsSource source) On demand stringifier of an IOStatisticsSource instance.static StringioStatisticsSourceToString(Object source) Extract the statistics from a source object -or "" if it is not an instance ofIOStatistics,IOStatisticsSourceor the retrieved statistics are null.static StringioStatisticsToPrettyString(IOStatistics statistics) Convert IOStatistics to a string form, with all the metrics sorted and empty value stripped.static StringioStatisticsToString(IOStatistics statistics) Convert IOStatistics to a string form.static voidlogIOStatisticsAtDebug(String message, Object source) Extract any statistics from the source and log to this class's log at debug, if the log is set to log at debug.static voidlogIOStatisticsAtDebug(org.slf4j.Logger log, String message, Object source) Extract any statistics from the source and log at debug, if the log is set to log at debug.static voidlogIOStatisticsAtLevel(org.slf4j.Logger log, String level, Object source) A method to log IOStatistics from a source at different levels.
-
Method Details
-
ioStatisticsSourceToString
Extract the statistics from a source object -or "" if it is not an instance ofIOStatistics,IOStatisticsSourceor the retrieved statistics are null.Exceptions are caught and downgraded to debug logging.
- Parameters:
source- source of statistics.- Returns:
- a string for logging.
-
ioStatisticsToString
Convert IOStatistics to a string form.- Parameters:
statistics- A statistics instance.- Returns:
- string value or the empty string if null
-
ioStatisticsToPrettyString
Convert IOStatistics to a string form, with all the metrics sorted and empty value stripped. This is more expensive than the simple conversion, so should only be used for logging/output where it's known/highly likely that the caller wants to see the values. Not for debug logging.- Parameters:
statistics- A statistics instance.- Returns:
- string value or the empty string if null
-
demandStringifyIOStatisticsSource
public static Object demandStringifyIOStatisticsSource(@Nullable org.apache.hadoop.fs.statistics.IOStatisticsSource source) On demand stringifier of an IOStatisticsSource instance.Whenever this object's toString() method is called, it evaluates the statistics.
This is designed to affordable to use in log statements.
- Parameters:
source- source of statistics -may be null.- Returns:
- an object whose toString() operation returns the current values.
-
demandStringifyIOStatistics
On demand stringifier of an IOStatistics instance.Whenever this object's toString() method is called, it evaluates the statistics.
This is for use in log statements where for the cost of creation of this entry is low; it is affordable to use in log statements.
- Parameters:
statistics- statistics to stringify -may be null.- Returns:
- an object whose toString() operation returns the current values.
-
logIOStatisticsAtDebug
Extract any statistics from the source and log at debug, if the log is set to log at debug. No-op if logging is not at debug or the source is null/of the wrong type/doesn't provide statistics.- Parameters:
log- log to log tomessage- message for log -this must contain "{}" for the statistics report to actually get logged.source- source object
-
logIOStatisticsAtDebug
Extract any statistics from the source and log to this class's log at debug, if the log is set to log at debug. No-op if logging is not at debug or the source is null/of the wrong type/doesn't provide statistics.- Parameters:
message- message for log -this must contain "{}" for the statistics report to actually get logged.source- source object
-
logIOStatisticsAtLevel
A method to log IOStatistics from a source at different levels.- Parameters:
log- Logger for logging.level- LOG level.source- Source to LOG.
-