org.apache.commons.monitoring.impl.values
Class CompositeCounter

java.lang.Object
  extended by org.apache.commons.monitoring.impl.values.AbstractStatValue<Counter>
      extended by org.apache.commons.monitoring.impl.values.ThreadSafeCounter
          extended by org.apache.commons.monitoring.impl.values.CompositeCounter
All Implemented Interfaces:
Composite<Counter>, Counter, StatValue

public class CompositeCounter
extends ThreadSafeCounter
implements Composite<Counter>

A composite implementation of Counter that delegates to a primary implementation and maintains a collection of secondary counters.

Typical use is to create monitoring graphs : On regular time intervals, a new secondary counter is registered to computes stats for the current period, and then removed.

Author:
Nicolas De Loof

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.commons.monitoring.StatValue
StatValue.Listener
 
Constructor Summary
CompositeCounter(Role<Counter> role)
           
 
Method Summary
 void add(long delta, Unit unit)
          Add value to the counter.
 Counter createSecondary()
          Create a secondary instance
 java.util.Collection<Counter> getSecondary()
           
 void removeSecondary(Counter counter)
          Deregister a secondary instance
 void set(long l, Unit unit)
          
 
Methods inherited from class org.apache.commons.monitoring.impl.values.ThreadSafeCounter
computeStats, get, getMean, getSquares, getSum, reset
 
Methods inherited from class org.apache.commons.monitoring.impl.values.AbstractStatValue
addListener, fireValueChanged, getHits, getMax, getMin, getMonitor, getRole, getStandardDeviation, getUnit, normalize, removeListener, setMonitor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.commons.monitoring.Counter
getHits
 
Methods inherited from interface org.apache.commons.monitoring.StatValue
addListener, getMax, getMin, getMonitor, getRole, getStandardDeviation, getUnit, removeListener, setMonitor
 

Constructor Detail

CompositeCounter

public CompositeCounter(Role<Counter> role)
Method Detail

getSecondary

public java.util.Collection<Counter> getSecondary()
Specified by:
getSecondary in interface Composite<Counter>
Returns:
an (unmodifiable) collection of secondary instances

createSecondary

public Counter createSecondary()
Description copied from interface: Composite
Create a secondary instance

Specified by:
createSecondary in interface Composite<Counter>

removeSecondary

public void removeSecondary(Counter counter)
Description copied from interface: Composite
Deregister a secondary instance

Specified by:
removeSecondary in interface Composite<Counter>

add

public void add(long delta,
                Unit unit)
Description copied from interface: Counter
Add value to the counter. Delta should not be negative (in such case a Gauge should be used).

Specified by:
add in interface Counter
Overrides:
add in class ThreadSafeCounter

set

public void set(long l,
                Unit unit)
Description copied from class: ThreadSafeCounter

Specified by:
set in interface StatValue
Overrides:
set in class ThreadSafeCounter
Parameters:
l - the value to set


Copyright © 2008 The Apache Software Foundation. All Rights Reserved.