Class StatisticsImpl

  • All Implemented Interfaces:
    com.yahoo.component.Component, Statistics, java.lang.Comparable<com.yahoo.component.Component>

    public final class StatisticsImpl
    extends com.yahoo.component.AbstractComponent
    implements Statistics
    Centralized book keeping for statistics module. Times logging and reads config. It is normally obtained through injection, but may be initialized manually for testing or when an injection mechanism is unavailable. Logging will be disabled by initializing the Statistics class with a null config object.
    Author:
    Steinar Knutsen
    • Field Summary

      • Fields inherited from class com.yahoo.component.AbstractComponent

        isDeconstructable
    • Constructor Summary

      Constructors 
      Constructor Description
      StatisticsImpl​(com.yahoo.container.StatisticsConfig config)
      Build a statistics manager based on the given config values.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void deconstruct()
      Cancel internal worker thread and do any other necessary cleanup.
      com.yahoo.container.StatisticsConfig getConfig()
      Get current config used.
      int purge()
      Purges all cancelled Handles from internal Map and Timer.
      void register​(Handle h)
      Add a new handle to be scheduled for periodic logging.
      void remove​(java.lang.String name)
      Remove a named handler from the set of working handlers.
      • Methods inherited from class com.yahoo.component.AbstractComponent

        clone, compareTo, getClassName, getId, getIdString, hasInitializedId, initId, isDeconstructable, setIsDeconstructable, toString
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • StatisticsImpl

        public StatisticsImpl​(com.yahoo.container.StatisticsConfig config)
        Build a statistics manager based on the given config values. Use a config builder for testing if logging is necessary, set the config argument to the constructor to null is logging is not necessary.
        Parameters:
        config - settings for logging interval and configured events. Setting it to null disables logging.
        Throws:
        java.lang.IllegalArgumentException - if logging interval is smaller than collection interval, or collection interval is not a multiplum of logging interval
        Since:
        5.1.4
    • Method Detail

      • deconstruct

        public void deconstruct()
        Cancel internal worker thread and do any other necessary cleanup. The internal worker thread is a daemon thread, so not calling this will not hamper a clean exit from the VM.
        Overrides:
        deconstruct in class com.yahoo.component.AbstractComponent
      • register

        public void register​(Handle h)
        Add a new handle to be scheduled for periodic logging. If a handle already exists with the same name, it will be cancelled and removed from the internal state of this object.
        Specified by:
        register in interface Statistics
      • remove

        public void remove​(java.lang.String name)
        Remove a named handler from the set of working handlers.
        Specified by:
        remove in interface Statistics
      • getConfig

        public com.yahoo.container.StatisticsConfig getConfig()
        Get current config used. This may be a null reference, depending on how the instance was constructed.
        Specified by:
        getConfig in interface Statistics
      • purge

        public int purge()
        Purges all cancelled Handles from internal Map and Timer.
        Specified by:
        purge in interface Statistics
        Returns:
        return value from java.util.Timer.purge()