public class DefaultStatisticsService extends java.lang.Object implements StatisticsService, CacheManagerListener
Constructor and Description |
---|
DefaultStatisticsService() |
Modifier and Type | Method and Description |
---|---|
void |
cacheAdded(java.lang.String alias,
Cache<?,?> cache)
Fires just after the @{link Cache} was made
Status.AVAILABLE , but wasn't yet made available
to other threads by the CacheManager . |
void |
cacheRemoved(java.lang.String alias,
Cache<?,?> cache)
Fires just after the @{link Cache} was deregistered with the
CacheManager , but wasn't yet made
Status.UNINITIALIZED . |
void |
cleanForNode(java.lang.Object node)
Clears all associations
|
java.util.Map<java.lang.String,org.terracotta.management.model.stats.Statistic<? extends java.io.Serializable>> |
collectStatistics(java.lang.String cacheName,
java.util.Collection<java.lang.String> statisticNames,
long since)
Returns the statistics for the cache
|
<K,V> void |
createCacheRegistry(java.lang.String cacheName,
Cache<K,V> cache,
java.util.function.LongSupplier timeSource)
Create statistics registry
|
<T extends java.lang.Enum<T>> |
createOperationStatistics(java.lang.String name,
java.lang.Class<T> outcome,
java.lang.String tag,
java.lang.Object context)
Create operation statistic for provided type
|
void |
deRegisterFromParent(java.lang.Object toDeassociate,
java.lang.Object parent)
De-registers object from the parent
|
java.util.Collection<org.terracotta.management.model.capabilities.descriptors.StatisticDescriptor> |
getCacheDescriptors(java.lang.String cacheName)
Returns the Statistics descriptor for the cache with the given alias
|
CacheStatistics |
getCacheStatistics(java.lang.String cacheName)
Return the object containing the statistics for a given cache name.
|
boolean |
isStarted() |
void |
registerCacheStatistics(java.lang.String cacheName)
Registers a cache for statistics
|
<T extends java.lang.Enum<T>,K,V> |
registerDerivedStatistics(java.lang.String cacheName,
Cache<K,V> cache,
java.lang.String statName,
T outcome,
java.lang.String derivedName,
LatencyHistogramConfiguration configuration)
Registers derived statistics for the cache
|
<T extends java.io.Serializable> |
registerStatistic(java.lang.Object context,
java.lang.String name,
org.terracotta.management.model.stats.StatisticType type,
java.util.Set<java.lang.String> tags,
java.util.function.Supplier<T> valueSupplier)
Register statistics with value supplier
|
<K,V,S extends java.lang.Enum<S>,T extends java.lang.Enum<T>> |
registerStoreStatistics(Store<K,V> store,
java.lang.String targetName,
int tierHeight,
java.lang.String tag,
java.util.Map<T,java.util.Set<S>> translation,
java.lang.String statisticName)
Registers store of the cache for statistics
|
void |
registerWithParent(java.lang.Object toAssociate,
java.lang.Object parent)
Registers the object to parent
|
void |
start(ServiceProvider<Service> serviceProvider)
Start this service using the provided configuration and
ServiceProvider . |
void |
stateTransition(Status from,
Status to)
Is notified when a state transition occurred.
|
void |
stop()
Stops this service.
|
public CacheStatistics getCacheStatistics(java.lang.String cacheName)
StatisticsService
getCacheStatistics
in interface StatisticsService
cacheName
- name (alias) of the cachepublic void registerWithParent(java.lang.Object toAssociate, java.lang.Object parent)
StatisticsService
registerWithParent
in interface StatisticsService
toAssociate
- object to associateparent
- to which object is associatedpublic <K,V,S extends java.lang.Enum<S>,T extends java.lang.Enum<T>> OperationStatistic<T> registerStoreStatistics(Store<K,V> store, java.lang.String targetName, int tierHeight, java.lang.String tag, java.util.Map<T,java.util.Set<S>> translation, java.lang.String statisticName)
StatisticsService
registerStoreStatistics
in interface StatisticsService
store
- Store
of the cache to be registeredtargetName
- statistics name after translationtierHeight
- of the storetag
- with which the statistics is associatedtranslation
- relationship among maintained statisticsstatisticName
- name of the statisticpublic void deRegisterFromParent(java.lang.Object toDeassociate, java.lang.Object parent)
StatisticsService
deRegisterFromParent
in interface StatisticsService
toDeassociate
- object to dissociateparent
- to which object is associatedpublic void cleanForNode(java.lang.Object node)
StatisticsService
cleanForNode
in interface StatisticsService
node
- for which all associations are clearedpublic <K,V> void createCacheRegistry(java.lang.String cacheName, Cache<K,V> cache, java.util.function.LongSupplier timeSource)
StatisticsService
createCacheRegistry
in interface StatisticsService
cacheName
- name (alias) of the cachecache
- the Cache
associated with the given aliastimeSource
- source of time for statistics maintenancepublic void registerCacheStatistics(java.lang.String cacheName)
StatisticsService
registerCacheStatistics
in interface StatisticsService
cacheName
- name (alias) of the cachepublic java.util.Collection<org.terracotta.management.model.capabilities.descriptors.StatisticDescriptor> getCacheDescriptors(java.lang.String cacheName)
StatisticsService
getCacheDescriptors
in interface StatisticsService
cacheName
- name (alias) of the cacheStatisticDescriptor
s of the cachepublic <T extends java.lang.Enum<T>,K,V> void registerDerivedStatistics(java.lang.String cacheName, Cache<K,V> cache, java.lang.String statName, T outcome, java.lang.String derivedName, LatencyHistogramConfiguration configuration)
StatisticsService
registerDerivedStatistics
in interface StatisticsService
T
- the generic type of statisticscacheName
- name (alias) of the cachecache
- the cache associated with the given aliasstatName
- name of the statisticoutcome
- Class of the type of statisticsderivedName
- visible name of the statisticsconfiguration
- the histogram configuration for statisticspublic java.util.Map<java.lang.String,org.terracotta.management.model.stats.Statistic<? extends java.io.Serializable>> collectStatistics(java.lang.String cacheName, java.util.Collection<java.lang.String> statisticNames, long since)
StatisticsService
collectStatistics
in interface StatisticsService
cacheName
- name (alias) of the cachestatisticNames
- names of the statisticssince
- time since statistics needs to be collectedpublic <T extends java.io.Serializable> void registerStatistic(java.lang.Object context, java.lang.String name, org.terracotta.management.model.stats.StatisticType type, java.util.Set<java.lang.String> tags, java.util.function.Supplier<T> valueSupplier)
StatisticsService
registerStatistic
in interface StatisticsService
T
- the generic typecontext
- association objectname
- of the statisticstype
- StatisticType to be registeredtags
- with which the statistics is associatedvalueSupplier
- supplies the value to maintain statisticspublic <T extends java.lang.Enum<T>> OperationObserver<T> createOperationStatistics(java.lang.String name, java.lang.Class<T> outcome, java.lang.String tag, java.lang.Object context)
StatisticsService
createOperationStatistics
in interface StatisticsService
name
- of the operation observeroutcome
- Class of the type of statistictag
- with which the statistics is associatedcontext
- association objectpublic boolean isStarted()
public void start(ServiceProvider<Service> serviceProvider)
Service
ServiceProvider
.
The service provider allows a service to retrieve and use other services.
A Service
retrieved at this stage may not yet be started. The recommended usage pattern therefore, is to keep a
reference to the dependent Service
but use it only when specific methods are invoked on subtypes.
public void stop()
Service
public void stateTransition(Status from, Status to)
StateChangeListener
stateTransition
in interface StateChangeListener
from
- previous stateto
- new statepublic void cacheAdded(java.lang.String alias, Cache<?,?> cache)
CacheManagerListener
Status.AVAILABLE
, but wasn't yet made available
to other threads by the CacheManager
. Nonetheless, no other thread can add another Cache
instance by the same alias.cacheAdded
in interface CacheManagerListener
alias
- the alias the Cache
is being registered oncache
- the actual Cache
addedpublic void cacheRemoved(java.lang.String alias, Cache<?,?> cache)
CacheManagerListener
CacheManager
, but wasn't yet made
Status.UNINITIALIZED
. So that no other thread can get a handle to this Cache
anymore,
but the CacheManagerListener
can still interact with itcacheRemoved
in interface CacheManagerListener
alias
- the alias the Cache
is being deregisteredcache
- the actual Cache
being removed