net.sf.ehcache.distribution.jgroups.jmx
Class AtomicRate

java.lang.Object
  extended by net.sf.ehcache.distribution.jgroups.jmx.AtomicRate

public final class AtomicRate
extends Object

Tracks a rate (counter / time) using a bucket based approach to reduce overhead.

This is thread safe

Author:
Eric Dalquist

Constructor Summary
AtomicRate(int duration, TimeUnit unit)
           
 
Method Summary
 void count()
          Increment the counter
 double getRate()
           
 long getRateDuration()
           
 TimeUnit getRateUnit()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AtomicRate

public AtomicRate(int duration,
                  TimeUnit unit)
Parameters:
duration - Duration the rate spans
unit - The time unit for the duration
Method Detail

getRateUnit

public TimeUnit getRateUnit()
Returns:
The TimeUnit the rate is over

getRateDuration

public long getRateDuration()
Returns:
The duration the rate covers, returned in the scale of the getRateUnit()

count

public void count()
Increment the counter


getRate

public double getRate()
Returns:
The current rate. The rate returned is in the TimeUnit used provided in the constructor.


Copyright © 2003-2012 Terracotta, Inc.. All Rights Reserved.