public class StandardQuotaStrategy extends Object implements QuotaManagerStrategy, UsageTracker
When a cache file has been written that results in cleanThresholdPct (default 80%) of maxUsageBytes being exceeded then the cached content cleaner is invoked (if not already running) in a new thread.
When the CachingContentStore is about to write a cache file but the disk usage is in excess of panicThresholdPct (default 90%) then the cache file is not written and the cleaner is started (if not already running) in a new thread.
This quota manager works in conjunction with the cleaner to update disk usage levels in memory. When the quota manager shuts down the current disk usage is saved to disk in {ContentCacheImpl.cacheRoot}/cache-usage.ser
Upon startup, if the cache-usage.ser file exists then the current usage is seeded with that value and the cleaner is invoked in a new thread so that the value can be updated more accurately (perhaps some files were deleted manually after shutdown for example).
Constructor and Description |
---|
StandardQuotaStrategy() |
Modifier and Type | Method and Description |
---|---|
long |
addUsageBytes(long sizeDelta) |
boolean |
afterWritingCacheFile(long contentSizeBytes)
Called immediately after writing a cache file - specifying the size of the file that was written.
|
boolean |
beforeWritingCacheFile(long contentSizeBytes)
Called immediately before writing a cache file or (when cacheOnInBound is set to true
for the CachingContentStore) before handing a ContentWriter to a content producer.
|
long |
getCurrentUsageBytes() |
double |
getCurrentUsageMB() |
protected long |
getMaxFileSizeBytes() |
int |
getMaxFileSizeMB() |
long |
getMaxUsageBytes() |
long |
getMaxUsageMB() |
void |
init()
Lifecycle method.
|
void |
setCache(ContentCacheImpl cache) |
void |
setCleaner(CachedContentCleaner cleaner) |
void |
setCleanThresholdPct(int cleanThresholdPct) |
void |
setCurrentUsageBytes(long newDiskUsage) |
void |
setMaxFileSizeMB(int maxFileSizeMB) |
void |
setMaxUsageBytes(long maxUsageBytes) |
void |
setMaxUsageMB(long maxUsageMB) |
void |
setNormalCleanThresholdSec(long normalCleanThresholdSec) |
void |
setPanicThresholdPct(int panicThresholdPct) |
void |
setTargetUsagePct(int targetUsagePct) |
void |
shutdown()
Lifecycle method.
|
public void init()
public void shutdown()
public boolean beforeWritingCacheFile(long contentSizeBytes)
QuotaManagerStrategy
In the latter case, the contentSize will be unknown (0), since the content length hasn't been established yet.
beforeWritingCacheFile
in interface QuotaManagerStrategy
contentSizeBytes
- The size of the content that will be written or 0 if not known.public boolean afterWritingCacheFile(long contentSizeBytes)
QuotaManagerStrategy
afterWritingCacheFile
in interface QuotaManagerStrategy
contentSizeBytes
- The size of the content that was written.public void setMaxUsageMB(long maxUsageMB)
public void setMaxUsageBytes(long maxUsageBytes)
public void setPanicThresholdPct(int panicThresholdPct)
public void setCleanThresholdPct(int cleanThresholdPct)
public void setTargetUsagePct(int targetUsagePct)
public void setNormalCleanThresholdSec(long normalCleanThresholdSec)
public void setCache(ContentCacheImpl cache)
public void setCleaner(CachedContentCleaner cleaner)
public long getCurrentUsageBytes()
getCurrentUsageBytes
in interface UsageTracker
public double getCurrentUsageMB()
public long getMaxUsageBytes()
public long getMaxUsageMB()
public int getMaxFileSizeMB()
protected long getMaxFileSizeBytes()
public void setMaxFileSizeMB(int maxFileSizeMB)
public long addUsageBytes(long sizeDelta)
addUsageBytes
in interface UsageTracker
public void setCurrentUsageBytes(long newDiskUsage)
setCurrentUsageBytes
in interface UsageTracker
Copyright © 2005–2017 Alfresco Software. All rights reserved.