2.17.2: 2011-06-17

net.sf.basedb.core
Class DiskUsageStatistics

java.lang.Object
  extended by net.sf.basedb.core.DiskUsageStatistics

public class DiskUsageStatistics
extends Object

Get disk usage statistics for the BASE server. The statistics information is lazily loaded and internally cached. Ie. calling getSummary(User) only hits the database the first time the method is called for a user. Use the reset() method to clear the internal cache.

You can control how long summaries are cached by setting a maximum age with the setMaxAge(int) method.

Version:
2.2
Author:
nicklas
See Also:
DiskUsage.getStatistics(DbControl)
Last modified
$Date: 2008-09-11 22:11:02 +0200 (Thu, 11 Sep 2008) $

Nested Class Summary
 class DiskUsageStatistics.Summary
          Holds summary disk usage information for the total disk usage or for a specific user or group.
 
Field Summary
private  DbControl dc
           
private  int maxAge
           
private  List<QuotaType> quotaTypes
           
private  Map<Object,DiskUsageStatistics.Summary> summaries
           
private static Long ZERO
           
 
Constructor Summary
DiskUsageStatistics(DbControl dc)
          Create a new disk usage statistics object.
 
Method Summary
 int getMaxAge()
          Get the max age in seconds for a disk usage summary object before it is reloaded from the database again.
 List<QuotaType> getQuotaTypes()
          Get the list of quota types that are registered for DiskConsumable items.
 DiskUsageStatistics.Summary getSummary(Group group)
          Get a summary of the disk usage for the specified group.
 DiskUsageStatistics.Summary getSummary(User user)
          Get a summary of the disk usage for the specified user.
 DiskUsageStatistics.Summary getTotalSummary()
          Get a summary of the total disk usage.
 void reset()
          Reset the internal cache of already loaded statistics.
 void setDbControl(DbControl dc)
          Set the DbControl which will be used to get statisics if it is not cached.
 void setMaxAge(int maxAge)
          Set the max age in seconds for a disk usage summary object before it is reloaded from the database again.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ZERO

private static final Long ZERO

dc

private DbControl dc

summaries

private Map<Object,DiskUsageStatistics.Summary> summaries

quotaTypes

private List<QuotaType> quotaTypes

maxAge

private int maxAge
Constructor Detail

DiskUsageStatistics

DiskUsageStatistics(DbControl dc)
Create a new disk usage statistics object.

Method Detail

setDbControl

public void setDbControl(DbControl dc)
Set the DbControl which will be used to get statisics if it is not cached.

Parameters:
dc - An open DbControl object

setMaxAge

public void setMaxAge(int maxAge)
Set the max age in seconds for a disk usage summary object before it is reloaded from the database again. A negative value keeps the object forever, a value of zero disabled caching.

Parameters:
maxAge - Number of seconds to keep summary in the cache, or zero to disable the cache or a negative value to cache forever

getMaxAge

public int getMaxAge()
Get the max age in seconds for a disk usage summary object before it is reloaded from the database again. A negative value keeps the object forever, a value of zero disabled caching. The default value is -1.


reset

public void reset()
Reset the internal cache of already loaded statistics.


getQuotaTypes

public List<QuotaType> getQuotaTypes()
Get the list of quota types that are registered for DiskConsumable items.

Returns:
A list with QuotaType objects

getTotalSummary

public DiskUsageStatistics.Summary getTotalSummary()
Get a summary of the total disk usage. This method will first check if a cached summary exists and only hit the database if not.

Returns:
A summary object

getSummary

public DiskUsageStatistics.Summary getSummary(User user)
Get a summary of the disk usage for the specified user. This method will first check if a cached summary exists and only hit the database if not.

Parameters:
user - The user to get the disk usage for
Returns:
A summary object

getSummary

public DiskUsageStatistics.Summary getSummary(Group group)
Get a summary of the disk usage for the specified group. This method will first check if a cached summary exists and only hit the database if not.

Parameters:
group - The group to get the disk usage for
Returns:
A summary object

2.17.2: 2011-06-17