org.apache.cocoon.monitoring.statistics
Class StatisticsCollector

java.lang.Object
  extended by org.apache.cocoon.monitoring.statistics.StatisticsCollector
All Implemented Interfaces:
StatisticsSourceEnabled

public class StatisticsCollector
extends Object
implements StatisticsSourceEnabled


Field Summary
static long DEFAULT_MAX_KEEP_TIME
          Default value of maxKeepTime: 24h.
static long DEFAULT_REFRESH_DELAY
          Default refresh time: 10s;
 
Constructor Summary
StatisticsCollector()
          This constructor uses default values of DEFAULT_MAX_KEEP_TIME, and DEFAULT_REFRESH_DELAY to pass into StatisticsCollector(long, long)
StatisticsCollector(long maxKeepTime, long refreshDelay)
           
 
Method Summary
 double getHitCount(String key)
          Returns sum for all hit count for given key.
 double getHitCountSum()
          Returns all hit count for this statistics source (sum of all hit counts for all contained key's).
 Map<String,Double> getHits()
          Returns unordered Map of summed value of all hit
 Map<String,Long> getHits(long time)
          Returns unordered Map, where key is source name and value is sum of hit count, limited only to entry's that are younger then time parameter
 long getRequestCount(String key, long time)
          Returns hit count for particular key in particular time
 void incerementCounter(String key)
          Increment value of counter for particular key.
 void putKey(String key)
          Only adds key into counter but don't increment hit count for this key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_REFRESH_DELAY

public static final long DEFAULT_REFRESH_DELAY
Default refresh time: 10s;

See Also:
Constant Field Values

DEFAULT_MAX_KEEP_TIME

public static final long DEFAULT_MAX_KEEP_TIME
Default value of maxKeepTime: 24h.

See Also:
Constant Field Values
Constructor Detail

StatisticsCollector

public StatisticsCollector()
This constructor uses default values of DEFAULT_MAX_KEEP_TIME, and DEFAULT_REFRESH_DELAY to pass into StatisticsCollector(long, long)


StatisticsCollector

public StatisticsCollector(long maxKeepTime,
                           long refreshDelay)
Parameters:
maxKeepTime - how long (in milliseconds) should be statistics data kept in collector
refreshDelay - delay time (in milliseconds) between run of cleaning thread, that will remove entry's are older than value in maxKeepTime
Method Detail

getHits

public Map<String,Double> getHits()
Description copied from interface: StatisticsSourceEnabled
Returns unordered Map of summed value of all hit

Specified by:
getHits in interface StatisticsSourceEnabled

getHits

public Map<String,Long> getHits(long time)
Description copied from interface: StatisticsSourceEnabled
Returns unordered Map, where key is source name and value is sum of hit count, limited only to entry's that are younger then time parameter

Specified by:
getHits in interface StatisticsSourceEnabled

getHitCount

public double getHitCount(String key)
Description copied from interface: StatisticsSourceEnabled
Returns sum for all hit count for given key. It will return 0 if given key does not have any statistics data (that means, that 0 if given key does not exist in statistics source).

Specified by:
getHitCount in interface StatisticsSourceEnabled
Returns:
hit count for passed arguments

getHitCountSum

public double getHitCountSum()
Description copied from interface: StatisticsSourceEnabled
Returns all hit count for this statistics source (sum of all hit counts for all contained key's).

Specified by:
getHitCountSum in interface StatisticsSourceEnabled

getRequestCount

public long getRequestCount(String key,
                            long time)
Description copied from interface: StatisticsSourceEnabled
Returns hit count for particular key in particular time

Specified by:
getRequestCount in interface StatisticsSourceEnabled

putKey

public void putKey(String key)
Only adds key into counter but don't increment hit count for this key. It is useful if you want to have this key in a list of all used key's with value 0 (i.e. for registered but never used cache entry's).

Parameters:
key -

incerementCounter

public void incerementCounter(String key)
Increment value of counter for particular key.

In fact this method adds actual time (in milliseconds) into list that is connected with this key.

Parameters:
key -


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