diff --git a/config/alfresco/cache-context.xml b/config/alfresco/cache-context.xml index bda3775e73..fadfc0856a 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 0f30f4d465..995e376d1a 100644 --- a/config/alfresco/caches.properties +++ b/config/alfresco/caches.properties @@ -364,7 +364,7 @@ cache.loadedResourceBundlesSharedCache.eviction-percentage=25 cache.loadedResourceBundlesSharedCache.merge-policy=hz.ADD_NEW_ENTRY cache.messagesSharedCache.tx.maxItems=1000 -cache.messagesSharedCache.maxItems=250 +cache.messagesSharedCache.maxItems=1000 cache.messagesSharedCache.timeToLiveSeconds=0 cache.messagesSharedCache.maxIdleSeconds=0 cache.messagesSharedCache.cluster.type=invalidating diff --git a/source/java/org/alfresco/repo/dictionary/TestModel.java b/source/java/org/alfresco/repo/dictionary/TestModel.java index f8c7211dc5..40f4132697 100644 --- a/source/java/org/alfresco/repo/dictionary/TestModel.java +++ b/source/java/org/alfresco/repo/dictionary/TestModel.java @@ -20,13 +20,15 @@ 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.dictionary.DictionaryDAOImpl.DictionaryRegistry; import org.alfresco.repo.dictionary.NamespaceDAOImpl.NamespaceRegistry; import org.alfresco.repo.tenant.SingleTServiceImpl; import org.alfresco.repo.tenant.TenantService; +import org.alfresco.util.ThreadPoolExecutorFactoryBean; +import org.alfresco.util.cache.DefaultAsynchronouslyRefreshedCacheRegistry; /** @@ -44,8 +46,9 @@ public class TestModel * TestModel [-h] [model filename]* *

* Returns 0 for success. + * @throws Exception */ - public static void main(String[] args) + public static void main(String[] args) throws Exception { if (args != null && args.length > 0 && args[0].equals("-h")) { @@ -89,7 +92,7 @@ public class TestModel DictionaryDAOImpl dictionaryDAO = new DictionaryDAOImpl(namespaceDAO); dictionaryDAO.setTenantService(tenantService); - initDictionaryCaches(dictionaryDAO); + initDictionaryCaches(dictionaryDAO, tenantService); // bootstrap dao try @@ -116,15 +119,23 @@ public class TestModel } } - private static void initDictionaryCaches(DictionaryDAOImpl dictionaryDAO) + private static void initDictionaryCaches(DictionaryDAOImpl dictionaryDAO, TenantService tenantService) throws Exception { - SimpleCache dictionaryCache = new DefaultSimpleCache(); - dictionaryDAO.setDictionaryRegistryCache(dictionaryCache); + 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(); } private static void initNamespaceCaches(NamespaceDAOImpl namespaceDAO) { SimpleCache namespaceCache = new DefaultSimpleCache(); namespaceDAO.setNamespaceRegistryCache(namespaceCache); + namespaceDAO.init(); } } \ No newline at end of file diff --git a/source/test-java/org/alfresco/repo/dictionary/RepoDictionaryDAOTest.java b/source/test-java/org/alfresco/repo/dictionary/RepoDictionaryDAOTest.java index 9c52b32187..68c8583c78 100644 --- a/source/test-java/org/alfresco/repo/dictionary/RepoDictionaryDAOTest.java +++ b/source/test-java/org/alfresco/repo/dictionary/RepoDictionaryDAOTest.java @@ -26,14 +26,13 @@ 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; import org.alfresco.model.ContentModel; import org.alfresco.repo.cache.DefaultSimpleCache; -import org.alfresco.repo.cache.NullCache; import org.alfresco.repo.cache.SimpleCache; -import org.alfresco.repo.dictionary.DictionaryDAOImpl.DictionaryRegistry; import org.alfresco.repo.dictionary.NamespaceDAOImpl.NamespaceRegistry; import org.alfresco.repo.dictionary.constraint.AbstractConstraint; import org.alfresco.repo.dictionary.constraint.ConstraintRegistry; @@ -57,6 +56,8 @@ 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 +72,7 @@ public class RepoDictionaryDAOTest extends TestCase @Override - public void setUp() + public void setUp() throws Exception { // Registered the required constraints ConstraintRegistry constraintRegistry = ConstraintRegistry.getInstance(); @@ -95,7 +96,7 @@ public class RepoDictionaryDAOTest extends TestCase DictionaryDAOImpl dictionaryDAO = new DictionaryDAOImpl(namespaceDAO); dictionaryDAO.setTenantService(tenantService); - initDictionaryCaches(dictionaryDAO); + initDictionaryCaches(dictionaryDAO, tenantService); // Populate with appropriate models DictionaryBootstrap bootstrap = new DictionaryBootstrap(); @@ -116,20 +117,28 @@ public class RepoDictionaryDAOTest extends TestCase service = component; } - private void initDictionaryCaches(DictionaryDAOImpl dictionaryDAO) + private void initDictionaryCaches(DictionaryDAOImpl dictionaryDAO, TenantService tenantService) throws Exception { - SimpleCache dictionaryCache = new DefaultSimpleCache(11, getClass().getName() + ".dictionary"); - dictionaryDAO.setDictionaryRegistryCache(dictionaryCache); + 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(); } private void initNamespaceCaches(NamespaceDAOImpl namespaceDAO) { SimpleCache namespaceCache = new DefaultSimpleCache(11, getClass().getName() + ".namespace"); namespaceDAO.setNamespaceRegistryCache(namespaceCache); + namespaceDAO.init(); } - public void testBootstrap() + public void testBootstrap() throws Exception { TenantService tenantService = new SingleTServiceImpl(); NamespaceDAOImpl namespaceDAO = new NamespaceDAOImpl(); @@ -138,7 +147,7 @@ public class RepoDictionaryDAOTest extends TestCase DictionaryDAOImpl dictionaryDAO = new DictionaryDAOImpl(namespaceDAO); dictionaryDAO.setTenantService(tenantService); - initDictionaryCaches(dictionaryDAO); + initDictionaryCaches(dictionaryDAO, tenantService); DictionaryBootstrap bootstrap = new DictionaryBootstrap(); List bootstrapModels = new ArrayList(); @@ -415,7 +424,7 @@ public class RepoDictionaryDAOTest extends TestCase assertTrue("Expected 'true' for timestamp propagation", childAssocDef.getPropagateTimestamps()); } - public void testADB159() throws UnsupportedEncodingException + public void testADB159() throws Exception { // source dictionary TenantService tenantService = new SingleTServiceImpl(); @@ -424,7 +433,7 @@ public class RepoDictionaryDAOTest extends TestCase initNamespaceCaches(namespaceDAO); DictionaryDAOImpl dictionaryDAO = new DictionaryDAOImpl(namespaceDAO); dictionaryDAO.setTenantService(tenantService); - initDictionaryCaches(dictionaryDAO); + initDictionaryCaches(dictionaryDAO, tenantService); // destination dictionary NamespaceDAOImpl namespaceDAO2 = new NamespaceDAOImpl(); @@ -432,7 +441,7 @@ public class RepoDictionaryDAOTest extends TestCase initNamespaceCaches(namespaceDAO2); DictionaryDAOImpl dictionaryDAO2 = new DictionaryDAOImpl(namespaceDAO2); dictionaryDAO2.setTenantService(tenantService); - initDictionaryCaches(dictionaryDAO2); + initDictionaryCaches(dictionaryDAO2, tenantService); 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 467fa4ae93..05e2bf91a1 100644 --- a/source/test-java/org/alfresco/repo/policy/MTPolicyComponentTest.java +++ b/source/test-java/org/alfresco/repo/policy/MTPolicyComponentTest.java @@ -23,10 +23,12 @@ import java.util.Collection; import java.util.Date; import java.util.List; import java.util.Map; +import java.util.concurrent.ThreadPoolExecutor; import junit.framework.TestCase; import org.alfresco.repo.cache.NullCache; +import org.alfresco.repo.dictionary.CompiledModelsCache; import org.alfresco.repo.dictionary.CompiledModel; import org.alfresco.repo.dictionary.DictionaryBootstrap; import org.alfresco.repo.dictionary.DictionaryComponent; @@ -38,6 +40,9 @@ 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; + import static org.mockito.Matchers.any; import static org.mockito.Mockito.mock; @@ -88,7 +93,7 @@ public class MTPolicyComponentTest extends TestCase initNamespaceCaches(namespaceDAO); DictionaryDAOImpl dictionaryDAO = new DictionaryDAOImpl(namespaceDAO); dictionaryDAO.setTenantService(mockTenantService); - initDictionaryCaches(dictionaryDAO); + initDictionaryCaches(dictionaryDAO, mockTenantService); DictionaryBootstrap bootstrap = new DictionaryBootstrap(); List bootstrapModels = new ArrayList(); @@ -110,10 +115,17 @@ public class MTPolicyComponentTest extends TestCase } @SuppressWarnings("unchecked") - private void initDictionaryCaches(DictionaryDAOImpl dictionaryDAO) + private void initDictionaryCaches(DictionaryDAOImpl dictionaryDAO, TenantService tenantService) throws Exception { - // note: unit tested here with null cache - dictionaryDAO.setDictionaryRegistryCache(new NullCache()); + 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(); } @SuppressWarnings("unchecked") @@ -121,6 +133,7 @@ public class MTPolicyComponentTest extends TestCase { // note: unit tested here with null cache namespaceDAO.setNamespaceRegistryCache(new NullCache()); + namespaceDAO.init(); } 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 3ecaf01825..6fd6c24e16 100644 --- a/source/test-java/org/alfresco/repo/policy/PolicyComponentTest.java +++ b/source/test-java/org/alfresco/repo/policy/PolicyComponentTest.java @@ -21,10 +21,12 @@ 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.NullCache; +import org.alfresco.repo.dictionary.CompiledModelsCache; import org.alfresco.repo.dictionary.DictionaryBootstrap; import org.alfresco.repo.dictionary.DictionaryComponent; import org.alfresco.repo.dictionary.DictionaryDAOImpl; @@ -32,6 +34,8 @@ import org.alfresco.repo.dictionary.NamespaceDAOImpl; 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 +66,7 @@ public class PolicyComponentTest extends TestCase initNamespaceCaches(namespaceDAO); DictionaryDAOImpl dictionaryDAO = new DictionaryDAOImpl(namespaceDAO); dictionaryDAO.setTenantService(tenantService); - initDictionaryCaches(dictionaryDAO); + initDictionaryCaches(dictionaryDAO, tenantService); DictionaryBootstrap bootstrap = new DictionaryBootstrap(); List bootstrapModels = new ArrayList(); @@ -82,10 +86,17 @@ public class PolicyComponentTest extends TestCase } @SuppressWarnings("unchecked") - private void initDictionaryCaches(DictionaryDAOImpl dictionaryDAO) + private void initDictionaryCaches(DictionaryDAOImpl dictionaryDAO, TenantService tenantService) throws Exception { - // note: unit tested here with null cache - dictionaryDAO.setDictionaryRegistryCache(new NullCache()); + 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(); } @SuppressWarnings("unchecked") @@ -93,6 +104,7 @@ public class PolicyComponentTest extends TestCase { // note: unit tested here with null cache namespaceDAO.setNamespaceRegistryCache(new NullCache()); + namespaceDAO.init(); } public void testJavaBehaviour()