* @see {@link org.geowebcache.diskquota.ExpirationPolicy#expireByLayerNames}
*/
public void expireByLayerNames(final Set<String> layerNames, final QuotaResolver quotaResolver, final QuotaStore pageStore)
throws InterruptedException {
Quota limit;
Quota used;
Quota excess;
while (true) {
if (shutDown || Thread.currentThread().isInterrupted()) {
throw new InterruptedException();
}
// get it everytime in case the admin changed it while we're processsing
limit = quotaResolver.getLimit();
used = quotaResolver.getUsed();
excess = used.difference(limit);
if (excess.getBytes().compareTo(BigInteger.ZERO) <= 0) {
log.info("Reached back Quota: " + limit.toNiceString() + " (" + used.toNiceString() + ") for layers "
+ layerNames);
return;
}
// same thing, check it every time
ExpirationPolicy expirationPolicy = quotaResolver.getExpirationPolicy();
if (null == expirationPolicy) {
log.warn("Aborting disk quota enforcement task, no expiration policy defined for layers "
+ layerNames);
return;
}
TilePage tilePage = null;
if (ExpirationPolicy.LFU.equals(expirationPolicy)) {
tilePage = pageStore.getLeastFrequentlyUsedPage(layerNames);
} else if (ExpirationPolicy.LRU.equals(expirationPolicy)) {
tilePage = pageStore.getLeastRecentlyUsedPage(layerNames);
} else {
throw new IllegalStateException("Unrecognized expiration policy: "
+ expirationPolicy);
}
if (tilePage == null) {
limit = quotaResolver.getLimit();
Quota usedQuota = quotaResolver.getUsed();
if (excess.getBytes().compareTo(BigInteger.ZERO) > 0) {
log.warn("No more pages to expire, check if youd disk quota"
+ " database is out of date with your blob store. Quota: "
+ limit.toNiceString() + " used: " + usedQuota.toNiceString());
}
return;
}
if (log.isDebugEnabled()) {
log.debug("Expiring tile page " + tilePage + " based on the global "