Package net.sf.basedb.core
Class DiskUsageStatistics
java.lang.Object
net.sf.basedb.core.DiskUsageStatistics
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) $
-
Nested Class Summary
Modifier and TypeClassDescriptionclass
Holds summary disk usage information for the total disk usage or for a specific user or group. -
Field Summary
-
Constructor Summary
ConstructorDescriptionCreate a new disk usage statistics object. -
Method Summary
Modifier and TypeMethodDescriptionint
Get the max age in seconds for a disk usage summary object before it is reloaded from the database again.Get the list of quota types that are registered forDiskConsumable
items.getSummary
(Group group) Get a summary of the disk usage for the specified group.getSummary
(User user) Get a summary of the disk usage for the specified user.Get a summary of the total disk usage.void
reset()
Reset the internal cache of already loaded statistics.void
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.
-
Field Details
-
ZERO
-
dc
-
summaries
-
quotaTypes
-
maxAge
private int maxAge
-
-
Constructor Details
-
DiskUsageStatistics
DiskUsageStatistics(DbControl dc) Create a new disk usage statistics object.
-
-
Method Details
-
setDbControl
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
Get the list of quota types that are registered forDiskConsumable
items.- Returns:
- A list with QuotaType objects
-
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
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
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
-