From d9271fc8e8f15780fba25f0eea68a9df3534911f Mon Sep 17 00:00:00 2001 From: Mark Rogers Date: Wed, 23 Jul 2014 16:24:56 +0000 Subject: [PATCH] Merged HEAD-BUG-FIX (5.0/Cloud) to HEAD (5.0/Cloud) 77193: Merged PLATFORM1 (5.0/Cloud) to HEAD-BUG-FIX (5.0/Cloud) 74588: Revert of R 74318 ACE-1996 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@78049 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- config/alfresco/cache-context.xml | 4 +-- config/alfresco/caches.properties | 9 ++++++ .../alfresco/repo/dictionary/TestModel.java | 21 ++++--------- .../repo/dictionary/DictionaryDAOTest.java | 24 ++++----------- .../dictionary/DictionaryLoadDAOTest.java | 24 ++++++++------- .../dictionary/RepoDictionaryDAOTest.java | 30 +++++++------------ .../repo/policy/MTPolicyComponentTest.java | 21 ++++--------- .../repo/policy/PolicyComponentTest.java | 21 ++++--------- 8 files changed, 54 insertions(+), 100 deletions(-) diff --git a/config/alfresco/cache-context.xml b/config/alfresco/cache-context.xml index fadfc0856a..bda3775e73 100644 --- a/config/alfresco/cache-context.xml +++ b/config/alfresco/cache-context.xml @@ -378,8 +378,8 @@ - - + + diff --git a/config/alfresco/caches.properties b/config/alfresco/caches.properties index 01b4c5afcf..995e376d1a 100644 --- a/config/alfresco/caches.properties +++ b/config/alfresco/caches.properties @@ -373,6 +373,15 @@ cache.messagesSharedCache.eviction-policy=LRU cache.messagesSharedCache.eviction-percentage=25 cache.messagesSharedCache.merge-policy=hz.ADD_NEW_ENTRY +cache.compiledModelsSharedCache.maxItems=1000 +cache.compiledModelsSharedCache.timeToLiveSeconds=0 +cache.compiledModelsSharedCache.maxIdleSeconds=0 +cache.compiledModelsSharedCache.cluster.type=invalidating +cache.compiledModelsSharedCache.backup-count=1 +cache.compiledModelsSharedCache.eviction-policy=LRU +cache.compiledModelsSharedCache.eviction-percentage=25 +cache.compiledModelsSharedCache.merge-policy=hz.ADD_NEW_ENTRY + cache.webScriptsRegistrySharedCache.maxItems=1000 cache.webScriptsRegistrySharedCache.timeToLiveSeconds=0 cache.webScriptsRegistrySharedCache.maxIdleSeconds=0 diff --git a/source/java/org/alfresco/repo/dictionary/TestModel.java b/source/java/org/alfresco/repo/dictionary/TestModel.java index 946e27017f..e775a8aa6b 100644 --- a/source/java/org/alfresco/repo/dictionary/TestModel.java +++ b/source/java/org/alfresco/repo/dictionary/TestModel.java @@ -20,14 +20,11 @@ package org.alfresco.repo.dictionary; import java.util.ArrayList; import java.util.List; -import java.util.concurrent.ThreadPoolExecutor; import org.alfresco.repo.cache.DefaultSimpleCache; import org.alfresco.repo.cache.SimpleCache; import org.alfresco.repo.tenant.SingleTServiceImpl; import org.alfresco.repo.tenant.TenantService; -import org.alfresco.util.ThreadPoolExecutorFactoryBean; -import org.alfresco.util.cache.DefaultAsynchronouslyRefreshedCacheRegistry; /** @@ -45,9 +42,8 @@ public class TestModel * TestModel [-h] [model filename]* *

* Returns 0 for success. - * @throws Exception */ - public static void main(String[] args) throws Exception + public static void main(String[] args) { if (args != null && args.length > 0 && args[0].equals("-h")) { @@ -86,7 +82,7 @@ public class TestModel DictionaryDAOImpl dictionaryDAO = new DictionaryDAOImpl(); dictionaryDAO.setTenantService(tenantService); - initDictionaryCaches(dictionaryDAO, tenantService); + initDictionaryCaches(dictionaryDAO); // bootstrap dao try @@ -113,16 +109,9 @@ public class TestModel } } - private static void initDictionaryCaches(DictionaryDAOImpl dictionaryDAO, TenantService tenantService) throws Exception + private static void initDictionaryCaches(DictionaryDAOImpl dictionaryDAO) { - CompiledModelsCache compiledModelsCache = new CompiledModelsCache(); - compiledModelsCache.setDictionaryDAO(dictionaryDAO); - compiledModelsCache.setTenantService(tenantService); - compiledModelsCache.setRegistry(new DefaultAsynchronouslyRefreshedCacheRegistry()); - ThreadPoolExecutorFactoryBean threadPoolfactory = new ThreadPoolExecutorFactoryBean(); - threadPoolfactory.afterPropertiesSet(); - compiledModelsCache.setThreadPoolExecutor((ThreadPoolExecutor) threadPoolfactory.getObject()); - dictionaryDAO.setDictionaryRegistryCache(compiledModelsCache); - dictionaryDAO.init(); + SimpleCache dictionaryCache = new DefaultSimpleCache(); + dictionaryDAO.setDictionaryRegistryCache(dictionaryCache); } } \ No newline at end of file diff --git a/source/test-java/org/alfresco/repo/dictionary/DictionaryDAOTest.java b/source/test-java/org/alfresco/repo/dictionary/DictionaryDAOTest.java index 8d4b2af831..9413d83d8a 100644 --- a/source/test-java/org/alfresco/repo/dictionary/DictionaryDAOTest.java +++ b/source/test-java/org/alfresco/repo/dictionary/DictionaryDAOTest.java @@ -23,7 +23,6 @@ import static org.junit.Assert.assertNull; import java.util.ArrayList; import java.util.List; -import java.util.concurrent.ThreadPoolExecutor; import org.alfresco.model.ContentModel; import org.alfresco.repo.cache.MemoryCache; @@ -34,10 +33,6 @@ import org.alfresco.repo.tenant.SingleTServiceImpl; import org.alfresco.repo.tenant.TenantService; import org.alfresco.repo.tenant.TenantUtil; import org.alfresco.repo.tenant.TenantUtil.TenantRunAsWork; -import org.alfresco.util.DynamicallySizedThreadPoolExecutor; -import org.alfresco.util.TraceableThreadFactory; -import org.alfresco.util.ThreadPoolExecutorFactoryBean; -import org.alfresco.util.cache.DefaultAsynchronouslyRefreshedCacheRegistry; import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.cmr.dictionary.TypeDefinition; import org.alfresco.service.namespace.QName; @@ -45,7 +40,6 @@ import org.junit.Before; import org.junit.Test; import org.springframework.extensions.surf.util.I18NUtil; - /** * * @author sglover @@ -70,7 +64,7 @@ public class DictionaryDAOTest this.dictionaryDAO = new DictionaryDAOImpl(); dictionaryDAO.setTenantService(tenantService); - initDictionaryCaches(dictionaryDAO, tenantService); + initDictionaryCaches(dictionaryDAO); new AuthenticationUtil().afterPropertiesSet(); @@ -93,27 +87,19 @@ public class DictionaryDAOTest service = component; } - private void initDictionaryCaches(DictionaryDAOImpl dictionaryDAO, TenantService tenantService) throws Exception + private void initDictionaryCaches(DictionaryDAOImpl dictionaryDAO) { - CompiledModelsCache compiledModelsCache = new CompiledModelsCache(); - compiledModelsCache.setDictionaryDAO(dictionaryDAO); - compiledModelsCache.setTenantService(tenantService); - compiledModelsCache.setRegistry(new DefaultAsynchronouslyRefreshedCacheRegistry()); - ThreadPoolExecutorFactoryBean threadPoolfactory = new ThreadPoolExecutorFactoryBean(); - threadPoolfactory.afterPropertiesSet(); - compiledModelsCache.setThreadPoolExecutor((ThreadPoolExecutor) threadPoolfactory.getObject()); - dictionaryDAO.setDictionaryRegistryCache(compiledModelsCache); - dictionaryDAO.init(); + dictionaryDAO.setDictionaryRegistryCache(new MemoryCache()); } @Test - public void testBootstrap() throws Exception + public void testBootstrap() { TenantService tenantService = new SingleTServiceImpl(); DictionaryDAOImpl dictionaryDAO = new DictionaryDAOImpl(); dictionaryDAO.setTenantService(tenantService); - initDictionaryCaches(dictionaryDAO, tenantService); + initDictionaryCaches(dictionaryDAO); DictionaryBootstrap bootstrap = new DictionaryBootstrap(); List bootstrapModels = new ArrayList(); diff --git a/source/test-java/org/alfresco/repo/dictionary/DictionaryLoadDAOTest.java b/source/test-java/org/alfresco/repo/dictionary/DictionaryLoadDAOTest.java index 29b84abf56..f27e6c47b5 100644 --- a/source/test-java/org/alfresco/repo/dictionary/DictionaryLoadDAOTest.java +++ b/source/test-java/org/alfresco/repo/dictionary/DictionaryLoadDAOTest.java @@ -113,18 +113,20 @@ public class DictionaryLoadDAOTest private void initDictionaryCaches(DictionaryDAOImpl dictionaryDAO, TenantService tenantService) throws Exception { - CompiledModelsCache compiledModelsCache = new CompiledModelsCache(); - compiledModelsCache.setDictionaryDAO(dictionaryDAO); - compiledModelsCache.setTenantService(tenantService); - compiledModelsCache.setRegistry(new DefaultAsynchronouslyRefreshedCacheRegistry()); - TraceableThreadFactory threadFactory = new TraceableThreadFactory(); - threadFactory.setThreadDaemon(true); - threadFactory.setThreadPriority(Thread.NORM_PRIORITY); + dictionaryDAO.setDictionaryRegistryCache(new MemoryCache()); - ThreadPoolExecutor threadPoolExecutor = new DynamicallySizedThreadPoolExecutor(20, 20, 90, TimeUnit.SECONDS, new LinkedBlockingQueue(), threadFactory, - new ThreadPoolExecutor.CallerRunsPolicy()); - compiledModelsCache.setThreadPoolExecutor(threadPoolExecutor); - dictionaryDAO.setDictionaryRegistryCache(compiledModelsCache); +// CompiledModelsCache compiledModelsCache = new CompiledModelsCache(); +// compiledModelsCache.setDictionaryDAO(dictionaryDAO); +// compiledModelsCache.setTenantService(tenantService); +// compiledModelsCache.setRegistry(new DefaultAsynchronouslyRefreshedCacheRegistry()); +// TraceableThreadFactory threadFactory = new TraceableThreadFactory(); +// threadFactory.setThreadDaemon(true); +// threadFactory.setThreadPriority(Thread.NORM_PRIORITY); +// +// ThreadPoolExecutor threadPoolExecutor = new DynamicallySizedThreadPoolExecutor(20, 20, 90, TimeUnit.SECONDS, new LinkedBlockingQueue(), threadFactory, +// new ThreadPoolExecutor.CallerRunsPolicy()); +// compiledModelsCache.setThreadPoolExecutor(threadPoolExecutor); +// dictionaryDAO.setDictionaryRegistryCache(compiledModelsCache); dictionaryDAO.init(); } diff --git a/source/test-java/org/alfresco/repo/dictionary/RepoDictionaryDAOTest.java b/source/test-java/org/alfresco/repo/dictionary/RepoDictionaryDAOTest.java index 6f9a05c203..7cf56efe41 100644 --- a/source/test-java/org/alfresco/repo/dictionary/RepoDictionaryDAOTest.java +++ b/source/test-java/org/alfresco/repo/dictionary/RepoDictionaryDAOTest.java @@ -26,7 +26,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.Map; -import java.util.concurrent.ThreadPoolExecutor; import junit.framework.TestCase; @@ -55,8 +54,6 @@ import org.alfresco.service.cmr.dictionary.PropertyDefinition; import org.alfresco.service.cmr.dictionary.TypeDefinition; import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; -import org.alfresco.util.ThreadPoolExecutorFactoryBean; -import org.alfresco.util.cache.DefaultAsynchronouslyRefreshedCacheRegistry; import org.springframework.extensions.surf.util.I18NUtil; @@ -71,7 +68,7 @@ public class RepoDictionaryDAOTest extends TestCase @Override - public void setUp() throws Exception + public void setUp() { // Registered the required constraints ConstraintRegistry constraintRegistry = ConstraintRegistry.getInstance(); @@ -92,7 +89,7 @@ public class RepoDictionaryDAOTest extends TestCase DictionaryDAOImpl dictionaryDAO = new DictionaryDAOImpl(); dictionaryDAO.setTenantService(tenantService); - initDictionaryCaches(dictionaryDAO, tenantService); + initDictionaryCaches(dictionaryDAO); // Populate with appropriate models DictionaryBootstrap bootstrap = new DictionaryBootstrap(); @@ -113,26 +110,19 @@ public class RepoDictionaryDAOTest extends TestCase service = component; } - private void initDictionaryCaches(DictionaryDAOImpl dictionaryDAO, TenantService tenantService) throws Exception + private void initDictionaryCaches(DictionaryDAOImpl dictionaryDAO) { - CompiledModelsCache compiledModelsCache = new CompiledModelsCache(); - compiledModelsCache.setDictionaryDAO(dictionaryDAO); - compiledModelsCache.setTenantService(tenantService); - compiledModelsCache.setRegistry(new DefaultAsynchronouslyRefreshedCacheRegistry()); - ThreadPoolExecutorFactoryBean threadPoolfactory = new ThreadPoolExecutorFactoryBean(); - threadPoolfactory.afterPropertiesSet(); - compiledModelsCache.setThreadPoolExecutor((ThreadPoolExecutor) threadPoolfactory.getObject()); - dictionaryDAO.setDictionaryRegistryCache(compiledModelsCache); - dictionaryDAO.init(); + SimpleCache dictionaryCache = new DefaultSimpleCache(11, getClass().getName() + ".dictionary"); + dictionaryDAO.setDictionaryRegistryCache(dictionaryCache); } - public void testBootstrap() throws Exception + public void testBootstrap() { TenantService tenantService = new SingleTServiceImpl(); DictionaryDAOImpl dictionaryDAO = new DictionaryDAOImpl(); dictionaryDAO.setTenantService(tenantService); - initDictionaryCaches(dictionaryDAO, tenantService); + initDictionaryCaches(dictionaryDAO); DictionaryBootstrap bootstrap = new DictionaryBootstrap(); List bootstrapModels = new ArrayList(); @@ -409,18 +399,18 @@ public class RepoDictionaryDAOTest extends TestCase assertTrue("Expected 'true' for timestamp propagation", childAssocDef.getPropagateTimestamps()); } - public void testADB159() throws Exception + public void testADB159() throws UnsupportedEncodingException { // source dictionary TenantService tenantService = new SingleTServiceImpl(); DictionaryDAOImpl dictionaryDAO = new DictionaryDAOImpl(); dictionaryDAO.setTenantService(tenantService); - initDictionaryCaches(dictionaryDAO, tenantService); + initDictionaryCaches(dictionaryDAO); // destination dictionary DictionaryDAOImpl dictionaryDAO2 = new DictionaryDAOImpl(); dictionaryDAO2.setTenantService(tenantService); - initDictionaryCaches(dictionaryDAO2, tenantService); + initDictionaryCaches(dictionaryDAO2); List models = new ArrayList(); models.add("alfresco/model/dictionaryModel.xml"); diff --git a/source/test-java/org/alfresco/repo/policy/MTPolicyComponentTest.java b/source/test-java/org/alfresco/repo/policy/MTPolicyComponentTest.java index dbe94d2548..53a38dd351 100644 --- a/source/test-java/org/alfresco/repo/policy/MTPolicyComponentTest.java +++ b/source/test-java/org/alfresco/repo/policy/MTPolicyComponentTest.java @@ -26,12 +26,10 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Date; import java.util.List; -import java.util.concurrent.ThreadPoolExecutor; import junit.framework.TestCase; import org.alfresco.repo.cache.MemoryCache; -import org.alfresco.repo.dictionary.CompiledModelsCache; import org.alfresco.repo.dictionary.DictionaryBootstrap; import org.alfresco.repo.dictionary.DictionaryComponent; import org.alfresco.repo.dictionary.DictionaryDAOImpl; @@ -40,8 +38,6 @@ import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.service.namespace.QName; -import org.alfresco.util.ThreadPoolExecutorFactoryBean; -import org.alfresco.util.cache.DefaultAsynchronouslyRefreshedCacheRegistry; /** * Policy Component Tests @@ -85,7 +81,7 @@ public class MTPolicyComponentTest extends TestCase DictionaryDAOImpl dictionaryDAO = new DictionaryDAOImpl(); dictionaryDAO.setTenantService(mockTenantService); - initDictionaryCaches(dictionaryDAO, mockTenantService); + initDictionaryCaches(dictionaryDAO); DictionaryBootstrap bootstrap = new DictionaryBootstrap(); List bootstrapModels = new ArrayList(); @@ -106,18 +102,11 @@ public class MTPolicyComponentTest extends TestCase policyComponent = x; } - @SuppressWarnings("unchecked") - private void initDictionaryCaches(DictionaryDAOImpl dictionaryDAO, TenantService tenantService) throws Exception + @SuppressWarnings({ "unchecked", "rawtypes" }) + private void initDictionaryCaches(DictionaryDAOImpl dictionaryDAO) { - CompiledModelsCache compiledModelsCache = new CompiledModelsCache(); - compiledModelsCache.setDictionaryDAO(dictionaryDAO); - compiledModelsCache.setTenantService(tenantService); - compiledModelsCache.setRegistry(new DefaultAsynchronouslyRefreshedCacheRegistry()); - ThreadPoolExecutorFactoryBean threadPoolfactory = new ThreadPoolExecutorFactoryBean(); - threadPoolfactory.afterPropertiesSet(); - compiledModelsCache.setThreadPoolExecutor((ThreadPoolExecutor) threadPoolfactory.getObject()); - dictionaryDAO.setDictionaryRegistryCache(compiledModelsCache); - dictionaryDAO.init(); + // note: unit tested here with null cache + dictionaryDAO.setDictionaryRegistryCache(new MemoryCache()); } public void testJavaBehaviour() diff --git a/source/test-java/org/alfresco/repo/policy/PolicyComponentTest.java b/source/test-java/org/alfresco/repo/policy/PolicyComponentTest.java index 8c18d41557..45371e5b54 100644 --- a/source/test-java/org/alfresco/repo/policy/PolicyComponentTest.java +++ b/source/test-java/org/alfresco/repo/policy/PolicyComponentTest.java @@ -21,20 +21,16 @@ package org.alfresco.repo.policy; import java.util.ArrayList; import java.util.Collection; import java.util.List; -import java.util.concurrent.ThreadPoolExecutor; import junit.framework.TestCase; import org.alfresco.repo.cache.MemoryCache; -import org.alfresco.repo.dictionary.CompiledModelsCache; import org.alfresco.repo.dictionary.DictionaryBootstrap; import org.alfresco.repo.dictionary.DictionaryComponent; import org.alfresco.repo.dictionary.DictionaryDAOImpl; import org.alfresco.repo.tenant.SingleTServiceImpl; import org.alfresco.repo.tenant.TenantService; import org.alfresco.service.namespace.QName; -import org.alfresco.util.ThreadPoolExecutorFactoryBean; -import org.alfresco.util.cache.DefaultAsynchronouslyRefreshedCacheRegistry; public class PolicyComponentTest extends TestCase @@ -62,7 +58,7 @@ public class PolicyComponentTest extends TestCase TenantService tenantService = new SingleTServiceImpl(); DictionaryDAOImpl dictionaryDAO = new DictionaryDAOImpl(); dictionaryDAO.setTenantService(tenantService); - initDictionaryCaches(dictionaryDAO, tenantService); + initDictionaryCaches(dictionaryDAO); DictionaryBootstrap bootstrap = new DictionaryBootstrap(); List bootstrapModels = new ArrayList(); @@ -81,18 +77,11 @@ public class PolicyComponentTest extends TestCase policyComponent = new PolicyComponentImpl(dictionary); } - @SuppressWarnings("unchecked") - private void initDictionaryCaches(DictionaryDAOImpl dictionaryDAO, TenantService tenantService) throws Exception + @SuppressWarnings({ "unchecked", "rawtypes" }) + private void initDictionaryCaches(DictionaryDAOImpl dictionaryDAO) { - CompiledModelsCache compiledModelsCache = new CompiledModelsCache(); - compiledModelsCache.setDictionaryDAO(dictionaryDAO); - compiledModelsCache.setTenantService(tenantService); - compiledModelsCache.setRegistry(new DefaultAsynchronouslyRefreshedCacheRegistry()); - ThreadPoolExecutorFactoryBean threadPoolfactory = new ThreadPoolExecutorFactoryBean(); - threadPoolfactory.afterPropertiesSet(); - compiledModelsCache.setThreadPoolExecutor((ThreadPoolExecutor) threadPoolfactory.getObject()); - dictionaryDAO.setDictionaryRegistryCache(compiledModelsCache); - dictionaryDAO.init(); + // note: unit tested here with null cache + dictionaryDAO.setDictionaryRegistryCache(new MemoryCache()); } public void testJavaBehaviour()