Package org.apache.bookkeeper.stats
Class CachingStatsLogger
- java.lang.Object
-
- org.apache.bookkeeper.stats.CachingStatsLogger
-
- All Implemented Interfaces:
StatsLogger
public class CachingStatsLogger extends java.lang.Object implements StatsLogger
AStatsLogger
that caches the stats objects created by otherStatsLogger
.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.concurrent.ConcurrentMap<java.lang.String,Counter>
counters
protected java.util.concurrent.ConcurrentMap<java.lang.String,OpStatsLogger>
opStatsLoggers
protected java.util.concurrent.ConcurrentMap<java.lang.String,StatsLogger>
scopeStatsLoggers
protected StatsLogger
underlying
-
Constructor Summary
Constructors Constructor Description CachingStatsLogger(StatsLogger statsLogger)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object obj)
Counter
getCounter(java.lang.String name)
OpStatsLogger
getOpStatsLogger(java.lang.String name)
Counter
getThreadScopedCounter(java.lang.String name)
Thread-scoped stats not currently supported.OpStatsLogger
getThreadScopedOpStatsLogger(java.lang.String name)
Thread-scoped stats not currently supported.int
hashCode()
<T extends java.lang.Number>
voidregisterGauge(java.lang.String name, Gauge<T> gauge)
Register given gauge as name name.void
removeScope(java.lang.String name, StatsLogger statsLogger)
Remove the given statsLogger for scope name.StatsLogger
scope(java.lang.String name)
Provide the stats logger under scope name.java.lang.String
toString()
<T extends java.lang.Number>
voidunregisterGauge(java.lang.String name, Gauge<T> gauge)
Unregister given gauge from name name.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.bookkeeper.stats.StatsLogger
scopeLabel
-
-
-
-
Field Detail
-
underlying
protected final StatsLogger underlying
-
counters
protected final java.util.concurrent.ConcurrentMap<java.lang.String,Counter> counters
-
opStatsLoggers
protected final java.util.concurrent.ConcurrentMap<java.lang.String,OpStatsLogger> opStatsLoggers
-
scopeStatsLoggers
protected final java.util.concurrent.ConcurrentMap<java.lang.String,StatsLogger> scopeStatsLoggers
-
-
Constructor Detail
-
CachingStatsLogger
public CachingStatsLogger(StatsLogger statsLogger)
-
-
Method Detail
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getOpStatsLogger
public OpStatsLogger getOpStatsLogger(java.lang.String name)
- Specified by:
getOpStatsLogger
in interfaceStatsLogger
- Parameters:
name
- Stats Name- Returns:
- Get the logger for an OpStat described by the name.
-
getCounter
public Counter getCounter(java.lang.String name)
- Specified by:
getCounter
in interfaceStatsLogger
- Parameters:
name
- Stats Name- Returns:
- Get the logger for a simple stat described by the name
-
registerGauge
public <T extends java.lang.Number> void registerGauge(java.lang.String name, Gauge<T> gauge)
Description copied from interface:StatsLogger
Register given gauge as name name.- Specified by:
registerGauge
in interfaceStatsLogger
- Parameters:
name
- gauge namegauge
- gauge function
-
unregisterGauge
public <T extends java.lang.Number> void unregisterGauge(java.lang.String name, Gauge<T> gauge)
Description copied from interface:StatsLogger
Unregister given gauge from name name.- Specified by:
unregisterGauge
in interfaceStatsLogger
- Parameters:
name
- name of the gaugegauge
- gauge function
-
scope
public StatsLogger scope(java.lang.String name)
Description copied from interface:StatsLogger
Provide the stats logger under scope name.- Specified by:
scope
in interfaceStatsLogger
- Parameters:
name
- scope name.- Returns:
- stats logger under scope name.
-
removeScope
public void removeScope(java.lang.String name, StatsLogger statsLogger)
Description copied from interface:StatsLogger
Remove the given statsLogger for scope name. It can be no-op if the underlying stats provider doesn't have the ability to remove scope.- Specified by:
removeScope
in interfaceStatsLogger
- Parameters:
name
- name of the scopestatsLogger
- the stats logger of this scope.
-
getThreadScopedOpStatsLogger
public OpStatsLogger getThreadScopedOpStatsLogger(java.lang.String name)
Thread-scoped stats not currently supported.- Specified by:
getThreadScopedOpStatsLogger
in interfaceStatsLogger
- Parameters:
name
- Stats Name- Returns:
- Get the logger for an OpStat described by the name with extra labels for the threadpool/threadname and thread no. Lone threads always have 0 as their thread no.
-
getThreadScopedCounter
public Counter getThreadScopedCounter(java.lang.String name)
Thread-scoped stats not currently supported.- Specified by:
getThreadScopedCounter
in interfaceStatsLogger
- Parameters:
name
- Stats Name- Returns:
- Get the logger for a simple stat described by the name with extra labels for the threadpool/threadname and thread no. Lone threads always have 0 as their thread no.
-
-