net.floodlightcontroller.counter
Class SimpleCounter

java.lang.Object
  extended by net.floodlightcontroller.counter.SimpleCounter
All Implemented Interfaces:
ICounter

public class SimpleCounter
extends java.lang.Object
implements ICounter

This is a simple counter implementation that doesn't support data series. The idea is that floodlight only keeps the realtime value for each counter, statd, a statistics collection daemon, samples counters at a user-defined interval and pushes the values to a database, which keeps time-based data series.

Author:
Kanzhe

Nested Class Summary
 
Nested classes/interfaces inherited from interface net.floodlightcontroller.counter.ICounter
ICounter.DateSpan
 
Field Summary
protected  CounterValue counter
           
protected  java.util.Date samplingTime
           
protected  java.util.Date startDate
           
 
Constructor Summary
protected SimpleCounter(java.util.Date startDate, CounterValue.CounterType type)
          Protected constructor - use createCounter factory method instead
 
Method Summary
static ICounter createCounter(java.util.Date startDate, CounterValue.CounterType type)
          Factory method to create a new counter instance.
static ICounter createCounter(ICounter copy)
          Factory method to create a copy of a counter instance.
 java.util.Date getCounterDate()
          This is the method to retrieve the last sampling time.
 CounterValue getCounterValue()
          This is the method to retrieve the current value.
 void increment()
          This is the key method that has to be both fast and very thread-safe.
 void increment(java.util.Date d, long delta)
          Used primarily for flushing thread local updates
protected  void init(java.util.Date startDate, CounterValue.CounterType type)
           
 void reset(java.util.Date startDate)
          Reset value.
 void setCounter(java.util.Date d, CounterValue value)
          Counter value setter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

counter

protected CounterValue counter

samplingTime

protected java.util.Date samplingTime

startDate

protected java.util.Date startDate
Constructor Detail

SimpleCounter

protected SimpleCounter(java.util.Date startDate,
                        CounterValue.CounterType type)
Protected constructor - use createCounter factory method instead

Parameters:
startDate -
Method Detail

createCounter

public static ICounter createCounter(java.util.Date startDate,
                                     CounterValue.CounterType type)
Factory method to create a new counter instance.

Parameters:
startDate -
Returns:

createCounter

public static ICounter createCounter(ICounter copy)
Factory method to create a copy of a counter instance.

Parameters:
startDate -
Returns:

init

protected void init(java.util.Date startDate,
                    CounterValue.CounterType type)

increment

public void increment()
This is the key method that has to be both fast and very thread-safe.

Specified by:
increment in interface ICounter

increment

public void increment(java.util.Date d,
                      long delta)
Description copied from interface: ICounter
Used primarily for flushing thread local updates

Specified by:
increment in interface ICounter

setCounter

public void setCounter(java.util.Date d,
                       CounterValue value)
Description copied from interface: ICounter
Counter value setter

Specified by:
setCounter in interface ICounter

getCounterValue

public CounterValue getCounterValue()
This is the method to retrieve the current value.

Specified by:
getCounterValue in interface ICounter

getCounterDate

public java.util.Date getCounterDate()
This is the method to retrieve the last sampling time.

Specified by:
getCounterDate in interface ICounter

reset

public void reset(java.util.Date startDate)
Reset value.

Specified by:
reset in interface ICounter