Class Duration
java.lang.Object
org.apache.hadoop.yarn.service.utils.Duration
- All Implemented Interfaces:
Closeable,AutoCloseable
A duration in milliseconds. This class can be used
to count time, and to be polled to see if a time limit has
passed.
-
Field Details
-
start
public long start -
finish
public long finish -
limit
public final long limit
-
-
Constructor Details
-
Duration
public Duration()Create a duration instance with a limit of 0 -
Duration
public Duration(long limit) Create a duration with a limit specified in millis- Parameters:
limit- duration in milliseconds
-
-
Method Details
-
start
Start- Returns:
- self
-
close
public final void close()The close operation relays tofinish(). Implementing it allows Duration instances to be automatically finish()'d in Java7 try blocks for when used in measuring durations.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
finish
public void finish() -
now
protected long now() -
getInterval
public long getInterval() -
getLimitExceeded
public boolean getLimitExceeded()return true if the limit has been exceeded- Returns:
- true if a limit was set and the current time exceeds it.
-
toString
-