Class StatisticsImpl

java.lang.Object
com.yahoo.component.AbstractComponent
com.yahoo.statistics.StatisticsImpl
All Implemented Interfaces:
com.yahoo.component.Component, com.yahoo.component.Deconstructable, Statistics, 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
  • Nested Class Summary

    Nested classes/interfaces inherited from interface com.yahoo.statistics.Statistics

    Statistics.NullImplementation
  • Field Summary

    Fields inherited from class com.yahoo.component.AbstractComponent

    isDeconstructable

    Fields inherited from interface com.yahoo.statistics.Statistics

    nullImplementation
  • Constructor Summary

    Constructors
    Constructor
    Description
    Build a statistics manager based on the given config values.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Cancel internal worker thread and do any other necessary cleanup.
    Get current config used.
    int
    Purges all cancelled Handles from internal Map and Timer.
    void
    Add a new handle to be scheduled for periodic logging.
    void
    remove(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 Details

    • StatisticsImpl

      public StatisticsImpl(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:
      IllegalArgumentException - if logging interval is smaller than collection interval, or collection interval is not a multiplum of logging interval
      Since:
      5.1.4
  • Method Details

    • 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.
      Specified by:
      deconstruct in interface com.yahoo.component.Deconstructable
      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(String name)
      Remove a named handler from the set of working handlers.
      Specified by:
      remove in interface Statistics
    • getConfig

      public 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()