Package com.yahoo.statistics
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
ConstructorDescriptionStatisticsImpl
(StatisticsConfig config) Build a statistics manager based on the given config values. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Cancel internal worker thread and do any other necessary cleanup.Get current config used.int
purge()
Purges all cancelled Handles from internal Map and Timer.void
Add a new handle to be scheduled for periodic logging.void
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
-
Constructor Details
-
StatisticsImpl
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 interfacecom.yahoo.component.Deconstructable
- Overrides:
deconstruct
in classcom.yahoo.component.AbstractComponent
-
register
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
Remove a named handler from the set of working handlers.- Specified by:
remove
in interfaceStatistics
-
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()
-