com.netflix.servo.monitor
Class ResettableCounter

java.lang.Object
  extended by com.netflix.servo.monitor.AbstractMonitor<java.lang.Number>
      extended by com.netflix.servo.monitor.ResettableCounter
All Implemented Interfaces:
Counter, Monitor<java.lang.Number>, NumericMonitor<java.lang.Number>, ResettableMonitor<java.lang.Number>

public class ResettableCounter
extends AbstractMonitor<java.lang.Number>
implements Counter, ResettableMonitor<java.lang.Number>

Counter implementation that keeps track of updates since the last reset.


Field Summary
 
Fields inherited from class com.netflix.servo.monitor.AbstractMonitor
config
 
Constructor Summary
ResettableCounter(MonitorConfig config)
          Create a new instance of the counter.
ResettableCounter(MonitorConfig config, long estPollingInterval)
          Deprecated. Polling intervals are configured via the system wide property servo.pollers instead
 
Method Summary
 boolean equals(java.lang.Object obj)
          
 java.lang.Number getAndResetValue()
          Return the value and reset the monitor state for the default polling interval.
 java.lang.Number getAndResetValue(int pollerIdx)
          Return the value and reset the monitor state for a given polling interval.
 long getCount()
          Returns the raw count instead of the rate.
 java.lang.Number getValue()
          Returns the current value for the monitor.
 int hashCode()
          
 void increment()
          Update the count by one.
 void increment(long amount)
          Update the count by the specified amount.
 java.lang.String toString()
          
 
Methods inherited from class com.netflix.servo.monitor.AbstractMonitor
getConfig
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.netflix.servo.monitor.Monitor
getConfig
 

Constructor Detail

ResettableCounter

public ResettableCounter(MonitorConfig config)
Create a new instance of the counter.


ResettableCounter

@Deprecated
public ResettableCounter(MonitorConfig config,
                                    long estPollingInterval)
Deprecated. Polling intervals are configured via the system wide property servo.pollers instead

Create a new instance of the counter.

Parameters:
config - configuration for the monitor
estPollingInterval - ignored
Method Detail

increment

public void increment()
Update the count by one.

Specified by:
increment in interface Counter

increment

public void increment(long amount)
Update the count by the specified amount.

Specified by:
increment in interface Counter

getValue

public java.lang.Number getValue()
Returns the current value for the monitor.

Specified by:
getValue in interface Monitor<java.lang.Number>

getAndResetValue

public java.lang.Number getAndResetValue()
Return the value and reset the monitor state for the default polling interval.

Specified by:
getAndResetValue in interface ResettableMonitor<java.lang.Number>

getAndResetValue

public java.lang.Number getAndResetValue(int pollerIdx)
Return the value and reset the monitor state for a given polling interval. This allows us to support multiple pollers, for example a 10second and 60second poller.

Specified by:
getAndResetValue in interface ResettableMonitor<java.lang.Number>

getCount

public long getCount()
Returns the raw count instead of the rate. This can be useful for unit tests.


equals

public boolean equals(java.lang.Object obj)

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()

Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object