continue;
}
final LayerQuota definedQuotaForLayer = quotaConfig.layerQuota(layerName);
final ExpirationPolicy policy = definedQuotaForLayer.getExpirationPolicyName();
final Quota quota = definedQuotaForLayer.getQuota();
final Quota usedQuota = monitor.getUsedQuotaByLayerName(layerName);
Quota excedent = usedQuota.difference(quota);
if (excedent.getBytes().compareTo(BigInteger.ZERO) > 0) {
log.info("Layer '" + layerName + "' exceeds its quota of " + quota.toNiceString()
+ " by " + excedent.toNiceString() + ". Currently used: "
+ usedQuota.toNiceString() + ". Clean up task will be performed"
+ " using expiration policy " + policy);
Set<String> layerNames = Collections.singleton(layerName);
QuotaResolver quotaResolver;
quotaResolver = monitor.newLayerQuotaResolver(layerName);
LayerQuotaEnforcementTask task;
task = new LayerQuotaEnforcementTask(layerNames, quotaResolver, monitor);
Future<Object> future = this.cleanUpExecutorService.submit(task);
perLayerRunningCleanUps.put(layerName, future);
}
}
if (globallyManagedLayerNames.size() > 0) {
ExpirationPolicy globalExpirationPolicy = quotaConfig.getGlobalExpirationPolicyName();
if (globalExpirationPolicy == null) {
return;
}
final Quota globalQuota = quotaConfig.getGlobalQuota();
if (globalQuota == null) {
log.info("There's not a global disk quota configured. The following layers "
+ "will not be checked for excess of disk usage: "
+ globallyManagedLayerNames);
return;
}
if (globalCleanUpTask != null && !globalCleanUpTask.isDone()) {
log.debug("Global cache quota enforcement task still running, avoiding issueing a new one...");
return;
}
Quota globalUsedQuota = monitor.getGloballyUsedQuota();
Quota excedent = globalUsedQuota.difference(globalQuota);
if (excedent.getBytes().compareTo(BigInteger.ZERO) > 0) {
log.info("Submitting global cache quota enforcement task");
LayerQuotaEnforcementTask task;
QuotaResolver quotaResolver = monitor.newGlobalQuotaResolver();
task = new LayerQuotaEnforcementTask(globallyManagedLayerNames, quotaResolver,