Package com.yahoo.statistics
Class StatisticsImpl
- java.lang.Object
-
- com.yahoo.component.AbstractComponent
-
- com.yahoo.statistics.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
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.yahoo.statistics.Statistics
Statistics.NullImplementation
-
-
Field Summary
-
Fields inherited from interface com.yahoo.statistics.Statistics
nullImplementation
-
-
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.
-
-
-
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 classcom.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 interfaceStatistics
-
remove
public void remove(java.lang.String name)
Remove a named handler from the set of working handlers.- Specified by:
remove
in interfaceStatistics
-
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 interfaceStatistics
-
purge
public int purge()
Purges all cancelled Handles from internal Map and Timer.- Specified by:
purge
in interfaceStatistics
- Returns:
- return value from java.util.Timer.purge()
-
-