From 8c6c739a5e0f7d06e8a277a084ccfd34b8c22a41 Mon Sep 17 00:00:00 2001 From: Alan Davis Date: Mon, 2 Feb 2015 10:05:36 +0000 Subject: [PATCH] Merged HEAD-BUG-FIX (5.1/Cloud) to HEAD (5.1/Cloud) 95693: Merged 5.0.N (5.0.1) to HEAD-BUG-FIX (5.1/Cloud) 94442: Merged V4.2-BUG-FIX (4.2.5) to 5.0.N (5.0.1) 94393: Merged DEV (4.2.5) to V4.2-BUG-FIX (4.2.5) 94233: MNT-12802: CachingContentStore Quota & Performance Made the quota thresholds configurable. Introduced a property to configure a gap between normal cleanups. Changed cachingContentStoreCache configuration. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@95698 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- config/alfresco/caches.properties | 4 +-- .../caching-content-store-context.xml.sample | 5 ++++ config/alfresco/repository.properties | 10 +++++++ .../caching/quota/StandardQuotaStrategy.java | 28 ++++++++++++++++++- 4 files changed, 44 insertions(+), 3 deletions(-) diff --git a/config/alfresco/caches.properties b/config/alfresco/caches.properties index feaf3cdf72..df2d59134c 100644 --- a/config/alfresco/caches.properties +++ b/config/alfresco/caches.properties @@ -591,8 +591,8 @@ cache.samlTrustEngineSharedCache.readBackupData=${caches.readBackupData} # Caching content store, see caching-content-store-context.xml.sample* cache.cachingContentStoreCache.maxItems=5000 -cache.cachingContentStoreCache.timeToLiveSeconds=0 -cache.cachingContentStoreCache.maxIdleSeconds=86400 +cache.cachingContentStoreCache.timeToLiveSeconds=86400 +cache.cachingContentStoreCache.maxIdleSeconds=14400 cache.cachingContentStoreCache.cluster.type=local cache.cachingContentStoreCache.backup-count=${caches.backupCount} cache.cachingContentStoreCache.eviction-policy=LRU diff --git a/config/alfresco/extension/caching-content-store-context.xml.sample b/config/alfresco/extension/caching-content-store-context.xml.sample index 3c7480282b..415e1b5316 100644 --- a/config/alfresco/extension/caching-content-store-context.xml.sample +++ b/config/alfresco/extension/caching-content-store-context.xml.sample @@ -54,6 +54,11 @@ + + + + + diff --git a/config/alfresco/repository.properties b/config/alfresco/repository.properties index 46363484ad..48fef29dfc 100644 --- a/config/alfresco/repository.properties +++ b/config/alfresco/repository.properties @@ -935,6 +935,16 @@ system.content.caching.minFileAgeMillis=60000 system.content.caching.maxUsageMB=4096 # maxFileSizeMB - 0 means no max file size. system.content.caching.maxFileSizeMB=0 +# 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. +system.content.caching.panicThresholdPct=90 +# 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. +system.content.caching.cleanThresholdPct=80 +# An aggressive cleaner is run till the targetUsagePct (default 70%) of maxUsageBytes is achieved +system.content.caching.targetUsagePct=70 +# Threshold in seconds indicating a minimal gap between normal cleanup starts +system.content.caching.normalCleanThresholdSec=0 mybatis.useLocalCaches=false diff --git a/source/java/org/alfresco/repo/content/caching/quota/StandardQuotaStrategy.java b/source/java/org/alfresco/repo/content/caching/quota/StandardQuotaStrategy.java index bf5c35eb04..9c0bdea77a 100644 --- a/source/java/org/alfresco/repo/content/caching/quota/StandardQuotaStrategy.java +++ b/source/java/org/alfresco/repo/content/caching/quota/StandardQuotaStrategy.java @@ -62,7 +62,10 @@ public class StandardQuotaStrategy implements QuotaManagerStrategy, UsageTracker private int cleanThresholdPct = 80; private int targetUsagePct = 70; private long maxUsageBytes = 0; + /* Threshold in seconds indicating a minimal gap between normal cleanup starts */ + private long normalCleanThresholdSec = 0; private AtomicLong currentUsageBytes = new AtomicLong(0); + private AtomicLong lastCleanupStart = new AtomicLong(0); private CachedContentCleaner cleaner; private ContentCacheImpl cache; // impl specific functionality required private int maxFileSizeMB = 0; @@ -89,6 +92,8 @@ public class StandardQuotaStrategy implements QuotaManagerStrategy, UsageTracker } loadDiskUsage(); + // Set the time to start the normal clean + lastCleanupStart.set(System.currentTimeMillis() - normalCleanThresholdSec); // Run the cleaner thread so that it can update the disk usage more accurately. signalCleanerStart("quota (init)"); } @@ -226,7 +231,19 @@ public class StandardQuotaStrategy implements QuotaManagerStrategy, UsageTracker } else { - cleaner.execute(reason); + long timePassedFromLastClean = System.currentTimeMillis() - lastCleanupStart.get(); + if (timePassedFromLastClean < normalCleanThresholdSec * 1000) + { + if (log.isDebugEnabled()) + { + log.debug("Skipping a normal clean as it is too soon. The last cleanup was run " + timePassedFromLastClean/1000f + " seconds ago."); + } + } + else + { + lastCleanupStart.set(System.currentTimeMillis()); + cleaner.execute(reason); + } } } @@ -294,7 +311,16 @@ public class StandardQuotaStrategy implements QuotaManagerStrategy, UsageTracker this.cleanThresholdPct = cleanThresholdPct; } + public void setTargetUsagePct(int targetUsagePct) + { + this.targetUsagePct = targetUsagePct; + } + public void setNormalCleanThresholdSec(long normalCleanThresholdSec) + { + this.normalCleanThresholdSec = normalCleanThresholdSec; + } + @Required public void setCache(ContentCacheImpl cache) {