Class Duration

java.lang.Object
org.apache.hadoop.yarn.service.utils.Duration
All Implemented Interfaces:
Closeable, AutoCloseable

public class Duration extends Object implements Closeable
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

      public Duration start()
      Start
      Returns:
      self
    • close

      public final void close()
      The close operation relays to finish(). Implementing it allows Duration instances to be automatically finish()'d in Java7 try blocks for when used in measuring durations.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
    • 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

      public String toString()
      Overrides:
      toString in class Object