Class DiskUsageStatistics

java.lang.Object
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:
Last modified
$Date: 2017-05-22 14:35:27 +0200 (må, 22 maj 2017) $
  • Field Details

  • Constructor Details

    • DiskUsageStatistics

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

    • 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