com.opensymphony.oscache.extra
Class StatisticListenerImpl

java.lang.Object
  extended by com.opensymphony.oscache.extra.StatisticListenerImpl
All Implemented Interfaces:
CacheEntryEventListener, CacheEventListener, CacheMapAccessEventListener, ScopeEventListener, EventListener

public class StatisticListenerImpl
extends Object
implements CacheMapAccessEventListener, CacheEntryEventListener, ScopeEventListener

A simple implementation of a statistic reporter which uses the event listeners. It uses the events to count the cache hit and misses and of course the flushes.

We are not using any synchronized so that this does not become a bottleneck. The consequence is that on retrieving values, the operations that are currently being done won't be counted.


Field Summary
private static int entriesAdded
          Miss counter sum.
private static int entriesRemoved
          Stale hit counter.
private static int entriesUpdated
          Flush hit counter.
private static int flushCount
          Flush hit counter.
private static int hitCount
          Hit counter.
private static int hitCountSum
          Hit counter sum.
private static int missCount
          Miss counter.
private static int missCountSum
          Miss counter sum.
private static int staleHitCount
          Stale hit counter.
private static int staleHitCountSum
          Stale hit counter.
 
Constructor Summary
StatisticListenerImpl()
          Constructor, empty for us.
 
Method Summary
 void accessed(CacheMapAccessEvent event)
          This method handles an event each time the cache is accessed.
 void cacheEntryAdded(CacheEntryEvent event)
          Event fired when an entry is added to the cache.
 void cacheEntryFlushed(CacheEntryEvent event)
          Event fired when an entry is flushed from the cache.
 void cacheEntryRemoved(CacheEntryEvent event)
          Event fired when an entry is removed from the cache.
 void cacheEntryUpdated(CacheEntryEvent event)
          Event fired when an entry is updated in the cache.
 void cacheFlushed(CachewideEvent event)
          An event that is fired when an entire cache gets flushed.
 void cacheGroupFlushed(CacheGroupEvent event)
          Event fired when a group is flushed from the cache.
 void cachePatternFlushed(CachePatternEvent event)
          Event fired when a key pattern is flushed from the cache.
private  void flushed(String info)
          Logs the flush of the cache.
 int getEntriesAdded()
           
 int getEntriesRemoved()
           
 int getEntriesUpdated()
           
 int getFlushCount()
           
 int getHitCount()
           
 int getHitCountSum()
           
 int getMissCount()
           
 int getMissCountSum()
           
 int getStaleHitCount()
           
 int getStaleHitCountSum()
           
 void scopeFlushed(ScopeEvent event)
          Event fired when a specific or all scopes are flushed.
 String toString()
          Return the counters in a string form.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

hitCount

private static int hitCount
Hit counter.


missCount

private static int missCount
Miss counter.


staleHitCount

private static int staleHitCount
Stale hit counter.


hitCountSum

private static int hitCountSum
Hit counter sum.


missCountSum

private static int missCountSum
Miss counter sum.


staleHitCountSum

private static int staleHitCountSum
Stale hit counter.


flushCount

private static int flushCount
Flush hit counter.


entriesAdded

private static int entriesAdded
Miss counter sum.


entriesRemoved

private static int entriesRemoved
Stale hit counter.


entriesUpdated

private static int entriesUpdated
Flush hit counter.

Constructor Detail

StatisticListenerImpl

public StatisticListenerImpl()
Constructor, empty for us.

Method Detail

accessed

public void accessed(CacheMapAccessEvent event)
This method handles an event each time the cache is accessed.

Specified by:
accessed in interface CacheMapAccessEventListener
Parameters:
event - The event triggered when the cache was accessed
See Also:
CacheMapAccessEventListener.accessed(CacheMapAccessEvent)

flushed

private void flushed(String info)
Logs the flush of the cache.

Parameters:
info - the string to be logged.

scopeFlushed

public void scopeFlushed(ScopeEvent event)
Event fired when a specific or all scopes are flushed.

Specified by:
scopeFlushed in interface ScopeEventListener
Parameters:
event - ScopeEvent
See Also:
ScopeEventListener.scopeFlushed(ScopeEvent)

cacheEntryAdded

public void cacheEntryAdded(CacheEntryEvent event)
Event fired when an entry is added to the cache.

Specified by:
cacheEntryAdded in interface CacheEntryEventListener
Parameters:
event - CacheEntryEvent
See Also:
CacheEntryEventListener.cacheEntryAdded(CacheEntryEvent)

cacheEntryFlushed

public void cacheEntryFlushed(CacheEntryEvent event)
Event fired when an entry is flushed from the cache.

Specified by:
cacheEntryFlushed in interface CacheEntryEventListener
Parameters:
event - CacheEntryEvent
See Also:
CacheEntryEventListener.cacheEntryFlushed(CacheEntryEvent)

cacheEntryRemoved

public void cacheEntryRemoved(CacheEntryEvent event)
Event fired when an entry is removed from the cache.

Specified by:
cacheEntryRemoved in interface CacheEntryEventListener
Parameters:
event - CacheEntryEvent
See Also:
CacheEntryEventListener.cacheEntryRemoved(CacheEntryEvent)

cacheEntryUpdated

public void cacheEntryUpdated(CacheEntryEvent event)
Event fired when an entry is updated in the cache.

Specified by:
cacheEntryUpdated in interface CacheEntryEventListener
Parameters:
event - CacheEntryEvent
See Also:
CacheEntryEventListener.cacheEntryUpdated(CacheEntryEvent)

cacheGroupFlushed

public void cacheGroupFlushed(CacheGroupEvent event)
Event fired when a group is flushed from the cache.

Specified by:
cacheGroupFlushed in interface CacheEntryEventListener
Parameters:
event - CacheGroupEvent
See Also:
CacheEntryEventListener.cacheGroupFlushed(CacheGroupEvent)

cachePatternFlushed

public void cachePatternFlushed(CachePatternEvent event)
Event fired when a key pattern is flushed from the cache.

Specified by:
cachePatternFlushed in interface CacheEntryEventListener
Parameters:
event - CachePatternEvent
See Also:
CacheEntryEventListener.cachePatternFlushed(CachePatternEvent)

cacheFlushed

public void cacheFlushed(CachewideEvent event)
An event that is fired when an entire cache gets flushed.

Specified by:
cacheFlushed in interface CacheEntryEventListener
Parameters:
event - CachewideEvent
See Also:
CacheEntryEventListener.cacheFlushed(CachewideEvent)

toString

public String toString()
Return the counters in a string form.

Overrides:
toString in class Object
Returns:
String

getEntriesAdded

public int getEntriesAdded()
Returns:
Returns the entriesAdded.

getEntriesRemoved

public int getEntriesRemoved()
Returns:
Returns the entriesRemoved.

getEntriesUpdated

public int getEntriesUpdated()
Returns:
Returns the entriesUpdated.

getFlushCount

public int getFlushCount()
Returns:
Returns the flushCount.

getHitCount

public int getHitCount()
Returns:
Returns the hitCount.

getHitCountSum

public int getHitCountSum()
Returns:
Returns the hitCountSum.

getMissCount

public int getMissCount()
Returns:
Returns the missCount.

getMissCountSum

public int getMissCountSum()
Returns:
Returns the missCountSum.

getStaleHitCount

public int getStaleHitCount()
Returns:
Returns the staleHitCount.

getStaleHitCountSum

public int getStaleHitCountSum()
Returns:
Returns the staleHitCountSum.


Copyright © 2011 OpenSymphony. All Rights Reserved.