Package org.apache.hadoop.util
Class DurationInfo
java.lang.Object
org.apache.hadoop.util.OperationDuration
org.apache.hadoop.util.DurationInfo
- All Implemented Interfaces:
AutoCloseable
A duration with logging of final state at info or debug
in the
close() call.
This allows it to be used in a try-with-resources clause, and have the
duration automatically logged.-
Constructor Summary
ConstructorsConstructorDescriptionDurationInfo(org.slf4j.Logger log, boolean logAtInfo, String format, Object... args) Create the duration text from aString.format()code call and log either at info or debug.DurationInfo(org.slf4j.Logger log, String format, Object... args) Create the duration text from aString.format()code call; log output at info level. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()toString()Return the duration asOperationDuration.humanTime(long).Methods inherited from class org.apache.hadoop.util.OperationDuration
asDuration, finished, getDurationString, humanTime, time, value
-
Constructor Details
-
DurationInfo
Create the duration text from aString.format()code call; log output at info level.- Parameters:
log- log to write toformat- format stringargs- list of arguments
-
DurationInfo
Create the duration text from aString.format()code call and log either at info or debug.- Parameters:
log- log to write tologAtInfo- should the log be at info, rather than debugformat- format stringargs- list of arguments
-
-
Method Details
-
toString
Description copied from class:OperationDurationReturn the duration asOperationDuration.humanTime(long).- Overrides:
toStringin classOperationDuration- Returns:
- a printable duration.
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-