Class PerfCounterQueryHandler

  • All Implemented Interfaces:
    java.lang.AutoCloseable

    @NotThreadSafe
    public final class PerfCounterQueryHandler
    extends java.lang.Object
    implements java.lang.AutoCloseable
    Utility to handle Performance Counter Queries

    This class is not thread safe. Each query handler instance should only be used in a single thread, preferably in a try-with-resources block.

    • Constructor Detail

      • PerfCounterQueryHandler

        public PerfCounterQueryHandler()
    • Method Detail

      • addCounterToQuery

        public boolean addCounterToQuery​(PerfDataUtil.PerfCounter counter)
        Begin monitoring a Performance Data counter.
        Parameters:
        counter - A PerfCounter object.
        Returns:
        True if the counter was successfully added to the query.
      • removeCounterFromQuery

        public boolean removeCounterFromQuery​(PerfDataUtil.PerfCounter counter)
        Stop monitoring a Performance Data counter.
        Parameters:
        counter - A PerfCounter object
        Returns:
        True if the counter was successfully removed.
      • removeAllCounters

        public void removeAllCounters()
        Stop monitoring all Performance Data counters and release their resources
      • updateQuery

        public long updateQuery()
        Update all counters on this query.
        Returns:
        The timestamp for the update of all the counters, in milliseconds since the epoch, or 0 if the update failed
      • queryCounter

        public long queryCounter​(PerfDataUtil.PerfCounter counter)
        Query the raw counter value of a Performance Data counter. Further mathematical manipulation/conversion is left to the caller.
        Parameters:
        counter - The counter to query
        Returns:
        The raw value of the counter
      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable