From 511af90d5c6e9344739a032fa41c04aacd0e52c1 Mon Sep 17 00:00:00 2001 From: Matt Ward Date: Mon, 1 Oct 2012 12:17:53 +0000 Subject: [PATCH] Merged BRANCHES/DEV/mward/clustering_p1 to HEAD: 41454: ALF-15881: Disabling clustering in community 41500: ALF-15883: Move configuration files 41503: ALF-15884: Move cluster package to enterprise repository project 41504: ALF-15884: Move cluster package to enterprise repository project 41519: ALF-15886: References/definition for "hazelcastInstanceFactory" must be in enterprise repo only 41523: ALF-15886: References/definition for "hazelcastInstanceFactory" must be in enterprise repo only 41525: ALF-15886: References/definition for "hazelcastInstanceFactory" must be in enterprise repo only 41527: ALF-15886: References/definition for "hazelcastInstanceFactory" must be in enterprise repo only 41530: ALF-15886: remove import for class no longer in project. 41532: ALF-15887: LockStoreFactoryImpl must be separated into community and enterprise versions 41535: ALF-15883: Move configuration files 41561: ALF-15886: factory class to create key fileserver config beans. 41578: ALF-15888: separate transactional and shared cache bean definitions. 41623: ALF-15888: first pass at DefaultSimpleCache implementation. 41646: ALF-15888: move ehcache-default.xml 41651: ALF-15888: update javadoc to reflect changes 41762: ALF-15888: improve cache test to prove that null values are stored correctly. 41812: ALF-15888: added new cache provider for use by hibernate: DefaultCacheProvider. 41830: ALF-15888: make DefaultSimpleCache BeanNameAware to help with debugging etc. 41831: ALF-15888: missing file from commit - adds enterprise override capability for hibernate-cfg.properties 41850: ALF-15888: move tickets cache to cache-context.xml 41857: ALF-15888: make RemoteAlfrescoTicketServiceImpl cache implementation agnostic. 41866: ALF-15888: extract caches from fileservers and web-client and provide enterprise overrides 41881: ALF-15888: replace use of EhCacheAdapter with DefaultSimpleCache and SimpleCache interface. 41884: ALF-15888: added DefaultSimpleCache configuration to CachingContentStore sample XML. 41885: ALF-15888: move EhCacheAdapter to new package. 41886: ALF-15888: correct absolute class names in config for EhCacheAdapter. 41892: ALF-15888: fix CachingContentStore tests. 41897: ALF-15888: move CacheTest and config to new package. 41898: ALF-15888: remove redundant directory 41899: ALF-15889: move EhCacheManagerFactoryBean to new package. 41902: ALF-15889: moved EhCacheTracerJob to new package. 41913: ALF-15889: move InternalEhCacheManagerFactoryBean to new package. 41916: ALF-15889: move AlfrescoCacheManagerPeerProviderFactory to new package. 41937: ALF-15889: decouple TransactionalCache from EhCache 41966: ALF-15889: decouple RetryingTransactionHelper from ehcache. 41989: ALF-15889: added ContextListener test. 41996: ALF-15889: moved cache test to its own class. 41998: ALF-15889: move ehcache jars. 41999: ALF-15889: modify .classpath to reflect jar moves. 42037: ALF-15889: update poms to reflect lib moves. 42038: ALF-15889: add eclipse library reference to enterprise projects. 42093: ALF-15916: moved core properties to enterprise 42114: ALF-15888: externalized cache sizes to repository.properties. 42127: ALF-16136: move re-indexing configuration 42140: ALF-16136: move cluster check property. 42186: ALF-15889: removing seemingly redundant test config file. 42187: ALF-15888: tidy up config changes. 42189: ALF-15888: cleanup config 42190: ALF-15888: config cleanup 42191: ALF-15888: config cleanup 42198: ALF-16136: restored lost property git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@42210 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- config/alfresco/application-context-core.xml | 2 +- config/alfresco/bootstrap-context.xml | 19 +- config/alfresco/cache-context.xml | 1159 ++--------------- config/alfresco/cluster-context.xml | 32 - config/alfresco/core-services-context.xml | 37 - .../alfresco/domain/hibernate-cfg.properties | 2 +- config/alfresco/ehcache-default.xml | 413 ------ .../caching-content-store-context.xml.sample | 24 +- .../ehcache-custom.xml.sample.cluster | 771 ----------- config/alfresco/hazelcast/hazelcast-ec2.xml | 169 --- config/alfresco/hazelcast/hazelcast-tcp.xml | 169 --- config/alfresco/hazelcast/hazelcast-udp.xml | 169 --- config/alfresco/hibernate-context.xml | 1 + .../remote-ticket-services-context.xml | 16 - config/alfresco/repository.properties | 92 +- config/alfresco/scheduled-jobs-context.xml | 23 - .../Search/lucene/index-recovery-context.xml | 99 +- .../default/file-servers-context.xml | 8 +- .../default/network-protocol-context.xml | 18 +- config/alfresco/tx-cache-context.xml | 629 +++++++++ config/alfresco/webdav-context.xml | 4 +- .../alfresco/test-hibernate-cfg.properties | 2 +- pom.xml | 5 - .../org/alfresco/RepositoryStartStopTest.java | 22 - .../filesys/config/ClusterConfigBean.java | 20 +- .../FileServerConfigurationFactory.java} | 17 +- .../config/ServerConfigurationBean.java | 10 +- ...frescoCacheManagerPeerProviderFactory.java | 77 -- .../org/alfresco/repo/cache/CacheTest.java | 1074 --------------- .../repo/cache/DefaultCacheProvider.java | 78 ++ .../repo/cache/DefaultSimpleCache.java | 126 ++ .../repo/cache/DefaultSimpleCacheTest.java | 157 +++ .../alfresco/repo/cache/EhCacheAdapter.java | 121 -- .../repo/cache/EhCacheManagerFactoryBean.java | 111 -- .../alfresco/repo/cache/EhCacheTracerJob.java | 250 ---- .../cache/HibernateSimpleCacheAdapter.java | 154 +++ .../InternalEhCacheManagerFactoryBean.java | 250 ---- .../repo/cache/TransactionalCache.java | 8 +- .../repo/cluster/BuildSafeTestSuite.java | 44 - .../repo/cluster/ClusterCheckEvent.java | 35 - .../alfresco/repo/cluster/ClusterChecker.java | 759 ----------- .../alfresco/repo/cluster/ClusterEvent.java | 37 - .../repo/cluster/ClusterMessageEvent.java | 50 - .../repo/cluster/ClusterNodeExistsEvent.java | 44 - .../cluster/ClusterNodePairStatusEvent.java | 61 - .../cluster/ClusterNodeStopTrackingEvent.java | 46 - .../repo/cluster/ClusterTestSuite.java | 43 - .../repo/cluster/ClusterValidateEvent.java | 42 - .../cluster/ClusterValidateResponseEvent.java | 50 - .../cluster/HazelcastConfigFactoryBean.java | 172 --- .../HazelcastConfigFactoryBeanTest.java | 69 - .../cluster/HazelcastInstanceFactory.java | 139 -- .../repo/cluster/HazelcastMessenger.java | 111 -- .../cluster/HazelcastMessengerFactory.java | 117 -- .../HazelcastMessengerFactoryTest.java | 87 -- .../repo/cluster/HazelcastMessengerTest.java | 79 -- .../alfresco/repo/cluster/HazelcastTest.java | 113 -- .../repo/cluster/MessageReceiver.java | 34 - .../org/alfresco/repo/cluster/Messenger.java | 43 - .../repo/cluster/MessengerFactory.java | 44 - .../cluster/MessengerFactoryProvider.java | 44 - .../repo/cluster/MessengerTestHelper.java | 130 -- .../alfresco/repo/cluster/NullMessenger.java | 68 - .../repo/content/RoutingContentStoreTest.java | 12 +- .../CachingContentStoreSpringTest.java | 24 +- .../dictionary/RepoDictionaryDAOTest.java | 22 +- .../alfresco/repo/dictionary/TestModel.java | 22 +- .../RemoteAlfrescoTicketServiceImpl.java | 8 +- .../RetryingTransactionHelper.java | 85 +- .../repo/webdav/LockStoreFactoryImpl.java | 69 - .../SimpleLockStoreFactory.java} | 13 +- .../cache-test/cache-test-config.xml | 41 - .../cache-test/cache-test-context.xml | 58 - .../cachingstore/test-context.xml | 14 +- .../cachingstore/test-std-quota-context.xml | 20 +- .../cluster-test/hazelcast-messenger-test.xml | 22 - .../cluster-test/placeholder-test.xml | 166 --- .../jbpm-test/test-hibernate-cfg.properties | 2 +- .../test-resources/jbpmresources/ehcache.xml | 48 - 79 files changed, 1471 insertions(+), 7954 deletions(-) delete mode 100644 config/alfresco/cluster-context.xml delete mode 100644 config/alfresco/ehcache-default.xml delete mode 100644 config/alfresco/extension/ehcache-custom.xml.sample.cluster delete mode 100644 config/alfresco/hazelcast/hazelcast-ec2.xml delete mode 100644 config/alfresco/hazelcast/hazelcast-tcp.xml delete mode 100644 config/alfresco/hazelcast/hazelcast-udp.xml create mode 100644 config/alfresco/tx-cache-context.xml rename source/java/org/alfresco/{repo/cluster/MessageSendingException.java => filesys/config/FileServerConfigurationFactory.java} (65%) delete mode 100644 source/java/org/alfresco/repo/cache/AlfrescoCacheManagerPeerProviderFactory.java delete mode 100644 source/java/org/alfresco/repo/cache/CacheTest.java create mode 100644 source/java/org/alfresco/repo/cache/DefaultCacheProvider.java create mode 100644 source/java/org/alfresco/repo/cache/DefaultSimpleCache.java create mode 100644 source/java/org/alfresco/repo/cache/DefaultSimpleCacheTest.java delete mode 100644 source/java/org/alfresco/repo/cache/EhCacheAdapter.java delete mode 100644 source/java/org/alfresco/repo/cache/EhCacheManagerFactoryBean.java delete mode 100644 source/java/org/alfresco/repo/cache/EhCacheTracerJob.java create mode 100644 source/java/org/alfresco/repo/cache/HibernateSimpleCacheAdapter.java delete mode 100644 source/java/org/alfresco/repo/cache/InternalEhCacheManagerFactoryBean.java delete mode 100644 source/java/org/alfresco/repo/cluster/BuildSafeTestSuite.java delete mode 100644 source/java/org/alfresco/repo/cluster/ClusterCheckEvent.java delete mode 100644 source/java/org/alfresco/repo/cluster/ClusterChecker.java delete mode 100644 source/java/org/alfresco/repo/cluster/ClusterEvent.java delete mode 100644 source/java/org/alfresco/repo/cluster/ClusterMessageEvent.java delete mode 100644 source/java/org/alfresco/repo/cluster/ClusterNodeExistsEvent.java delete mode 100644 source/java/org/alfresco/repo/cluster/ClusterNodePairStatusEvent.java delete mode 100644 source/java/org/alfresco/repo/cluster/ClusterNodeStopTrackingEvent.java delete mode 100644 source/java/org/alfresco/repo/cluster/ClusterTestSuite.java delete mode 100644 source/java/org/alfresco/repo/cluster/ClusterValidateEvent.java delete mode 100644 source/java/org/alfresco/repo/cluster/ClusterValidateResponseEvent.java delete mode 100644 source/java/org/alfresco/repo/cluster/HazelcastConfigFactoryBean.java delete mode 100644 source/java/org/alfresco/repo/cluster/HazelcastConfigFactoryBeanTest.java delete mode 100644 source/java/org/alfresco/repo/cluster/HazelcastInstanceFactory.java delete mode 100644 source/java/org/alfresco/repo/cluster/HazelcastMessenger.java delete mode 100644 source/java/org/alfresco/repo/cluster/HazelcastMessengerFactory.java delete mode 100644 source/java/org/alfresco/repo/cluster/HazelcastMessengerFactoryTest.java delete mode 100644 source/java/org/alfresco/repo/cluster/HazelcastMessengerTest.java delete mode 100644 source/java/org/alfresco/repo/cluster/HazelcastTest.java delete mode 100644 source/java/org/alfresco/repo/cluster/MessageReceiver.java delete mode 100644 source/java/org/alfresco/repo/cluster/Messenger.java delete mode 100644 source/java/org/alfresco/repo/cluster/MessengerFactory.java delete mode 100644 source/java/org/alfresco/repo/cluster/MessengerFactoryProvider.java delete mode 100644 source/java/org/alfresco/repo/cluster/MessengerTestHelper.java delete mode 100644 source/java/org/alfresco/repo/cluster/NullMessenger.java delete mode 100644 source/java/org/alfresco/repo/webdav/LockStoreFactoryImpl.java rename source/java/org/alfresco/repo/{cluster/ClusterMembershipListener.java => webdav/SimpleLockStoreFactory.java} (71%) delete mode 100644 source/test-resources/cache-test/cache-test-config.xml delete mode 100644 source/test-resources/cache-test/cache-test-context.xml delete mode 100644 source/test-resources/cluster-test/hazelcast-messenger-test.xml delete mode 100644 source/test-resources/cluster-test/placeholder-test.xml delete mode 100644 source/test-resources/jbpmresources/ehcache.xml diff --git a/config/alfresco/application-context-core.xml b/config/alfresco/application-context-core.xml index 32fc63545e..1f99d423cb 100644 --- a/config/alfresco/application-context-core.xml +++ b/config/alfresco/application-context-core.xml @@ -4,6 +4,7 @@ + @@ -43,7 +44,6 @@ - diff --git a/config/alfresco/bootstrap-context.xml b/config/alfresco/bootstrap-context.xml index e00aaeb44c..25d15389a2 100644 --- a/config/alfresco/bootstrap-context.xml +++ b/config/alfresco/bootstrap-context.xml @@ -176,23 +176,6 @@ - - - - - - - - - - - - - - - - - @@ -830,6 +813,8 @@ + + diff --git a/config/alfresco/cache-context.xml b/config/alfresco/cache-context.xml index d7f4d47bd8..9c7f937189 100644 --- a/config/alfresco/cache-context.xml +++ b/config/alfresco/cache-context.xml @@ -2,52 +2,22 @@ - - - - - - - - - - - - - - - - org.alfresco.cache.propertyValueCache - - + + - - - - - - - org.alfresco.cache.propertyValueTransactionalCache - - - - + --> + @@ -56,32 +26,8 @@ - - - - - - - - org.alfresco.cache.contentDataCache - - - - - - - - - - - - - org.alfresco.cache.contentDataTransactionalCache - - - - - + + @@ -90,31 +36,8 @@ - - - - - - - - org.alfresco.cache.immutableEntityCache - - - - - - - - - - - - - org.alfresco.cache.immutableEntityTransactionalCache - - - - + + @@ -123,61 +46,14 @@ - - - - - - - - org.alfresco.cache.node.rootNodesCache - - - - - - - - - - - - - org.alfresco.cache.node.rootNodesTransactionalCache - - - - - + + - - - - - - - - org.alfresco.cache.node.allRootNodesCache - - - - - - - - - - - - - org.alfresco.cache.node.allRootNodesTransactionalCache - - - - + + @@ -186,32 +62,8 @@ - - - - - - - - org.alfresco.cache.node.nodesCache - - - - - - - - - - - - - org.alfresco.cache.node.nodesTransactionalCache - - - - - + + @@ -220,31 +72,8 @@ - - - - - - - - org.alfresco.cache.node.aspectsCache - - - - - - - - - - - - - org.alfresco.cache.node.aspectsTransactionalCache - - - - + + @@ -253,64 +82,19 @@ - - - - - - - - org.alfresco.cache.node.propertiesCache - - - + + + - - - - - - - - org.alfresco.cache.node.propertiesTransactionalCache - - - - - - - - - - - - - - org.alfresco.cache.node.childByNameCache - - - - - - - - - - - - - org.alfresco.cache.node.childByNameTransactionalCache - - - - + + @@ -321,80 +105,20 @@ - - - - - - - - org.alfresco.nodeRulesTransactionalCache - - - - - - - - - - - - - - org.alfresco.cache.userToAuthorityCache - - - - - - - - - - - - - org.alfresco.userToAuthorityTransactionalCache - - - - + + - - - - - - - - org.alfresco.cache.authenticationCache - - - - - - - - - - - - - org.alfresco.authenticationTransactionalCache - - - 100 - + + @@ -403,32 +127,8 @@ - - - - - - - - org.alfresco.cache.authorityCache - - - - - - - - - - - - - org.alfresco.authorityTransactionalCache - - - - - + + @@ -437,32 +137,8 @@ - - - - - - - - org.alfresco.cache.authorityToChildAuthorityCache - - - - - - - - - - - - - org.alfresco.authorityToChildAuthorityTransactionalCache - - - - - + + @@ -471,31 +147,8 @@ - - - - - - - - org.alfresco.cache.zoneToAuthorityCache - - - - - - - - - - - - - org.alfresco.zoneToAuthorityTransactionalCache - - - - + + @@ -504,31 +157,8 @@ - - - - - - - - org.alfresco.cache.permissionsAccessCache - - - - - - - - - - - - - org.alfresco.permissionsAccessTransactionalCache - - - - + + @@ -537,31 +167,8 @@ - - - - - - - - org.alfresco.cache.readersCache - - - - - - - - - - - - - org.alfresco.readersTransactionalCache - - - - + + @@ -570,31 +177,8 @@ - - - - - - - - org.alfresco.cache.readersDeniedCache - - - - - - - - - - - - - org.alfresco.readersDeniedTransactionalCache - - - - + + @@ -604,31 +188,8 @@ - - - - - - - - org.alfresco.cache.nodeOwnerCache - - - - - - - - - - - - - org.alfresco.nodeOwnerTransactionalCache - - - - + + @@ -637,31 +198,8 @@ - - - - - - - - org.alfresco.cache.personCache - - - - - - - - - - - - - org.alfresco.personTransactionalCache - - - - + + @@ -670,17 +208,8 @@ - - - - - - - - org.alfresco.cache.ticketsCache - - - + + @@ -690,151 +219,30 @@ - - - - - - - - - - - org.alfresco.cache.avmStoreTransactionalCache - - - - - + - - - - - - - - org.alfresco.cache.avm.avmEntityCache - - - - - - - - - - - - - org.alfresco.cache.avmEntityTransactionalCache - - - - + + - - - - - - - - org.alfresco.cache.avm.avmVersionRootEntityCache - - - - - - - - - - - - - org.alfresco.cache.avmVersionRootEntityTransactionalCache - - - - + + - - - - - - - - org.alfresco.cache.avm.avmNodeCache - - - + + - - - - - - - - org.alfresco.cache.avmNodeTransactionalCache - - - - - - - - - - - - - - - org.alfresco.cache.avm.avmNodeAspectsCache - - - - - - - - - - - - - org.alfresco.cache.avmNodeAspectsTransactionalCache - - - - + + @@ -843,31 +251,8 @@ - - - - - - - - org.alfresco.repo.webservices.querySessionSharedCache - - - - - - - - - - - - - org.alfresco.repo.webservices.querySessionTransactionalCache - - - - + + @@ -877,31 +262,8 @@ - - - - - - - - org.alfresco.cache.aclCache - - - - - - - - - - - - - org.alfresco.aclTransactionalCache - - - - + + @@ -910,31 +272,8 @@ - - - - - - - - org.alfresco.cache.permissions.aclEntityCache - - - - - - - - - - - - - org.alfresco.cache.aclEntityTransactionalCache - - - - + + @@ -945,34 +284,6 @@ - - - - - - - - - - org.alfresco.cache.authorityEntityTransactionalCache - - - - - @@ -981,35 +292,7 @@ - - - - - - - - - - - org.alfresco.cache.permissionEntityTransactionalCache - - - - - + @@ -1017,89 +300,20 @@ - - - - - - - - org.alfresco.cache.resourceBundleBaseNamesCache - - - - - - - - - - - - - org.alfresco.resourceBundleBaseNamesTransactionalCache - - - - + + - - - - - - - - org.alfresco.cache.loadedResourceBundlesCache - - - - - - - - - - - - - org.alfresco.loadedResourceBundlesTransactionalCache - - - - + + - - - - - - - - org.alfresco.cache.messagesCache - - - - - - - - - - - - - org.alfresco.messagesTransactionalCache - - - - + + @@ -1109,60 +323,14 @@ - - - - - - - - org.alfresco.cache.compiledModelsCache - - - - - - - - - - - - - org.alfresco.compiledModelsTransactionalCache - - - - + + - - - - - - - - org.alfresco.cache.prefixesCache - - - - - - - - - - - - - org.alfresco.prefixesTransactionalCache - - - - + + @@ -1171,31 +339,8 @@ - - - - - - - - org.alfresco.cache.webScriptsRegistryCache - - - - - - - - - - - - - org.alfresco.webScriptsRegistryTransactionalCache - - - - + + @@ -1204,31 +349,8 @@ - - - - - - - - org.alfresco.cache.routingContentStoreCache - - - - - - - - - - - - - org.alfresco.routingContentStoreTransactionalCache - - - - + + @@ -1237,17 +359,8 @@ - - - - - - - - org.alfresco.cache.executingActionsCache - - - + + @@ -1256,31 +369,8 @@ - - - - - - - - org.alfresco.cache.tagscopeSummaryCache - - - - - - - - - - - - - org.alfresco.cache.tagscopeSummaryTransactionalCache - - - - + + @@ -1289,31 +379,8 @@ - - - - - - - - org.alfresco.cache.imapMessageCache - - - - - - - - - - - - - org.alfresco.cache.imapMessageTransactionalCache - - - - + + @@ -1322,32 +389,8 @@ - - - - - - - - org.alfresco.cache.tenantEntityCache - - - - - - - - - - - - - org.alfresco.tenantsTransactionalCache - - - - - + + @@ -1356,31 +399,21 @@ - - - - - - - - org.alfresco.cache.immutableSingletonCache - - - + + + + + + + - - - - - - - org.alfresco.cache.immutableSingletonTransactionalCache - - - - + + + + + diff --git a/config/alfresco/cluster-context.xml b/config/alfresco/cluster-context.xml deleted file mode 100644 index 41be670422..0000000000 --- a/config/alfresco/cluster-context.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - ${alfresco.cluster.name} - ${alfresco.hazelcast.password} - ${alfresco.hazelcast.specify.interface} - ${alfresco.hazelcast.bind.interface} - - - ${alfresco.hazelcast.tcp.config} - - - ${alfresco.hazelcast.ec2.accesskey} - ${alfresco.hazelcast.ec2.secretkey} - ${alfresco.hazelcast.ec2.region} - ${alfresco.hazelcast.ec2.securitygroup} - ${alfresco.hazelcast.ec2.tagkey} - ${alfresco.hazelcast.ec2.tagvalue} - - - - - - - - \ No newline at end of file diff --git a/config/alfresco/core-services-context.xml b/config/alfresco/core-services-context.xml index ff0aa7a6df..9d82237149 100644 --- a/config/alfresco/core-services-context.xml +++ b/config/alfresco/core-services-context.xml @@ -126,43 +126,6 @@ false - - - - - - ${alfresco.ehcache.rmi.hostname} - - - ${alfresco.ehcache.rmi.remoteObjectPort} - - - ${alfresco.ehcache.rmi.port} - - - ${alfresco.ehcache.rmi.socketTimeoutMillis} - - - ${alfresco.tcp.start_port} - - - ${alfresco.tcp.initial_hosts} - - - ${alfresco.tcp.port_range} - - - ${alfresco.udp.mcast_addr} - - - ${alfresco.udp.mcast_port} - - - ${alfresco.fping.shared.dir} - - - - diff --git a/config/alfresco/domain/hibernate-cfg.properties b/config/alfresco/domain/hibernate-cfg.properties index 5e7be7e961..205e518c22 100644 --- a/config/alfresco/domain/hibernate-cfg.properties +++ b/config/alfresco/domain/hibernate-cfg.properties @@ -11,7 +11,7 @@ hibernate.jdbc.use_streams_for_binary=true hibernate.show_sql=false hibernate.cache.use_query_cache=false hibernate.max_fetch_depth=10 -hibernate.cache.provider_class=org.alfresco.repo.cache.InternalEhCacheManagerFactoryBean +hibernate.cache.provider_class=org.alfresco.repo.cache.DefaultCacheProvider hibernate.cache.use_second_level_cache=true hibernate.default_batch_fetch_size=1 hibernate.jdbc.batch_size=32 diff --git a/config/alfresco/ehcache-default.xml b/config/alfresco/ehcache-default.xml deleted file mode 100644 index 235bfefd72..0000000000 --- a/config/alfresco/ehcache-default.xml +++ /dev/null @@ -1,413 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/config/alfresco/extension/caching-content-store-context.xml.sample b/config/alfresco/extension/caching-content-store-context.xml.sample index fc5dbeba06..511277d054 100644 --- a/config/alfresco/extension/caching-content-store-context.xml.sample +++ b/config/alfresco/extension/caching-content-store-context.xml.sample @@ -62,27 +62,9 @@ - - - - - - - - org.alfresco.cache.cachingContentStoreCache - - - - - - - - - - - - - + + + org.alfresco.repo.content.caching.cleanup.CachedContentCleanupJob diff --git a/config/alfresco/extension/ehcache-custom.xml.sample.cluster b/config/alfresco/extension/ehcache-custom.xml.sample.cluster deleted file mode 100644 index f45d4e2380..0000000000 --- a/config/alfresco/extension/ehcache-custom.xml.sample.cluster +++ /dev/null @@ -1,771 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/config/alfresco/hazelcast/hazelcast-ec2.xml b/config/alfresco/hazelcast/hazelcast-ec2.xml deleted file mode 100644 index 428c7b4880..0000000000 --- a/config/alfresco/hazelcast/hazelcast-ec2.xml +++ /dev/null @@ -1,169 +0,0 @@ - - - - ${alfresco.cluster.name} - ${alfresco.hazelcast.password} - - - 5701 - - - 224.2.2.3 - 54327 - - - 127.0.0.1 - - - ${alfresco.hazelcast.ec2.accesskey} - ${alfresco.hazelcast.ec2.secretkey} - - ${alfresco.hazelcast.ec2.region} - - ${alfresco.hazelcast.ec2.securitygroup} - ${alfresco.hazelcast.ec2.tagkey} - ${alfresco.hazelcast.ec2.tagvalue} - - - - ${alfresco.hazelcast.bind.interface} - - - - PBEWithMD5AndDES - - thesalt - - thepass - - 19 - - - - RSA/NONE/PKCS1PADDING - - thekeypass - - local - - JKS - - thestorepass - - keystore - - - - 16 - 64 - 60 - - - - 0 - - default - - - - 1 - - 0 - - 0 - - NONE - - 0 - - 25 - - hz.ADD_NEW_ENTRY - - - - - - - log4j - false - false - false - - \ No newline at end of file diff --git a/config/alfresco/hazelcast/hazelcast-tcp.xml b/config/alfresco/hazelcast/hazelcast-tcp.xml deleted file mode 100644 index af4efd2645..0000000000 --- a/config/alfresco/hazelcast/hazelcast-tcp.xml +++ /dev/null @@ -1,169 +0,0 @@ - - - - ${alfresco.cluster.name} - ${alfresco.hazelcast.password} - - - 5701 - - - 224.2.2.3 - 54327 - - - ${alfresco.hazelcast.tcp.config} - - - my-access-key - my-secret-key - - us-west-1 - - hazelcast-sg - type - hz-nodes - - - - ${alfresco.hazelcast.bind.interface} - - - - PBEWithMD5AndDES - - thesalt - - thepass - - 19 - - - - RSA/NONE/PKCS1PADDING - - thekeypass - - local - - JKS - - thestorepass - - keystore - - - - 16 - 64 - 60 - - - - 0 - - default - - - - 1 - - 0 - - 0 - - NONE - - 0 - - 25 - - hz.ADD_NEW_ENTRY - - - - - - - log4j - false - false - false - - \ No newline at end of file diff --git a/config/alfresco/hazelcast/hazelcast-udp.xml b/config/alfresco/hazelcast/hazelcast-udp.xml deleted file mode 100644 index 3544d69b66..0000000000 --- a/config/alfresco/hazelcast/hazelcast-udp.xml +++ /dev/null @@ -1,169 +0,0 @@ - - - - ${alfresco.cluster.name} - ${alfresco.hazelcast.password} - - - 5701 - - - 224.2.2.3 - 54327 - - - 127.0.0.1 - - - my-access-key - my-secret-key - - us-west-1 - - hazelcast-sg - type - hz-nodes - - - - ${alfresco.hazelcast.bind.interface} - - - - PBEWithMD5AndDES - - thesalt - - thepass - - 19 - - - - RSA/NONE/PKCS1PADDING - - thekeypass - - local - - JKS - - thestorepass - - keystore - - - - 16 - 64 - 60 - - - - 0 - - default - - - - 1 - - 0 - - 0 - - NONE - - 0 - - 25 - - hz.ADD_NEW_ENTRY - - - - - - - log4j - false - false - false - - \ No newline at end of file diff --git a/config/alfresco/hibernate-context.xml b/config/alfresco/hibernate-context.xml index b7122deeef..b8d13b7c5f 100644 --- a/config/alfresco/hibernate-context.xml +++ b/config/alfresco/hibernate-context.xml @@ -9,6 +9,7 @@ classpath:alfresco/domain/hibernate-cfg.properties + classpath*:alfresco/enterprise/cache/hibernate-cfg.properties diff --git a/config/alfresco/remote-ticket-services-context.xml b/config/alfresco/remote-ticket-services-context.xml index 2ae0695324..2277cc5757 100644 --- a/config/alfresco/remote-ticket-services-context.xml +++ b/config/alfresco/remote-ticket-services-context.xml @@ -86,20 +86,4 @@ - - - - - - - - - - - org.alfresco.cache.remote.auth.ticketCache - - - - - diff --git a/config/alfresco/repository.properties b/config/alfresco/repository.properties index 688e7f081d..a134ca5bc3 100644 --- a/config/alfresco/repository.properties +++ b/config/alfresco/repository.properties @@ -121,46 +121,6 @@ index.reindexMissingContent.cronExpression=* * * * * ? 2099 # Change the failure behaviour of the configuration checker system.bootstrap.config_check.strict=true -# The name of the cluster -# Leave this empty to disable cluster entry -alfresco.cluster.name= - -# Time to wait for a cluster node ping before marking the node as not alive (ms) -alfresco.clusterCheck.timeout=4000 - -# Hazelcast clustering configuration -# Password to join the cluster -alfresco.hazelcast.password=alfrescocluster -# Protocol used for member discovery (tcp, ec2, udp) -alfresco.hazelcast.protocol=tcp -# Location of the Hazelcast configuration file -alfresco.hazelcast.configLocation=classpath:alfresco/hazelcast/hazelcast-${alfresco.hazelcast.protocol}.xml -# XML elements to incorporate into Hazelcast config, in particular -# hostnames/IP addresses to use for membership discovery -alfresco.hazelcast.tcp.config= -# Whether to bind to a specific host interface -alfresco.hazelcast.specify.interface=false -# The interface to bind to, if enabled above. -alfresco.hazelcast.bind.interface= - -# Amazon Web Services - EC2 discovery -alfresco.hazelcast.ec2.accesskey=my-access-key -alfresco.hazelcast.ec2.secretkey=my-secret-key -alfresco.hazelcast.ec2.region=us-east-1 -# Only instances belonging to this group will be discovered, default will try all running instances -alfresco.hazelcast.ec2.securitygroup= -alfresco.hazelcast.ec2.tagkey=type -alfresco.hazelcast.ec2.tagvalue=hz-nodes - -# The EHCache RMI peer URL addresses to set in the ehcache-custom.xml file -# Use this property to set the hostname of the current server. -# This is only necessary if the cache peer URLs are generated with an invalid IP address for the local server. -alfresco.ehcache.rmi.hostname= -# Use this property to set the cache peer URL port. -alfresco.ehcache.rmi.remoteObjectPort=0 -alfresco.ehcache.rmi.port=0 -alfresco.ehcache.rmi.socketTimeoutMillis=5000 - # # How long should shutdown wait to complete normally before # taking stronger action and calling System.exit() @@ -998,10 +958,6 @@ system.content.caching.cacheOnInbound=true system.content.caching.maxDeleteWatchCount=1 # Clean up every day at 3 am system.content.caching.contentCleanup.cronExpression=0 0 3 * * ? -system.content.caching.timeToLiveSeconds=0 -system.content.caching.timeToIdleSeconds=86400 -system.content.caching.maxElementsInMemory=5000 -system.content.caching.maxElementsOnDisk=10000 system.content.caching.minFileAgeMillis=60000 system.content.caching.maxUsageMB=4096 # maxFileSizeMB - 0 means no max file size. @@ -1029,7 +985,55 @@ download.cleaner.maxAgeMins=60 # enable QuickShare - if false then the QuickShare-specific REST APIs will return 403 Forbidden system.quickshare.enabled=true +# +# Cache configuration +# +cache.propertyValueCache.maxItems=10000 +cache.contentDataSharedCache.maxItems=130000 +cache.immutableEntitySharedCache.maxItems=50000 +cache.node.rootNodesSharedCache.maxItems=1000 +cache.node.allRootNodesSharedCache.maxItems=1000 +cache.node.nodesSharedCache.maxItems=250000 +cache.node.aspectsSharedCache.maxItems=130000 +cache.node.propertiesSharedCache.maxItems=130000 +cache.node.parentAssocsSharedCache.maxItems=130000 +cache.node.childByNameSharedCache.maxItems=130000 +cache.userToAuthoritySharedCache.maxItems=5000 +cache.authenticationSharedCache.maxItems=5000 +cache.authoritySharedCache.maxItems=10000 +cache.authorityToChildAuthoritySharedCache.maxItems=40000 +cache.zoneToAuthoritySharedCache.maxItems=500 +cache.permissionsAccessSharedCache.maxItems=50000 +cache.readersSharedCache.maxItems=10000 +cache.readersDeniedSharedCache.maxItems=10000 +cache.nodeOwnerSharedCache.maxItems=40000 +cache.personSharedCache.maxItems=1000 +cache.ticketsCache.maxItems=1000 +cache.avmEntitySharedCache.maxItems=5000 +cache.avmVersionRootEntitySharedCache.maxItems=1000 +cache.avmNodeSharedCache.maxItems=5000 +cache.avmNodeAspectsSharedCache.maxItems=5000 +cache.webServicesQuerySessionSharedCache.maxItems=1000 +cache.aclSharedCache.maxItems=50000 +cache.aclEntitySharedCache.maxItems=50000 +cache.resourceBundleBaseNamesSharedCache.maxItems=1000 +cache.loadedResourceBundlesSharedCache.maxItems=1000 +cache.messagesSharedCache.maxItems=1000 +cache.compiledModelsSharedCache.maxItems=1000 +cache.prefixesSharedCache.maxItems=1000 +cache.webScriptsRegistrySharedCache.maxItems=1000 +cache.routingContentStoreSharedCache.maxItems=10000 +cache.executingActionsCache.maxItems=1000 +cache.tagscopeSummarySharedCache.maxItems=1000 +cache.imapMessageSharedCache.maxItems=2000 +cache.tenantEntitySharedCache.maxItems=1000 +cache.immutableSingletonSharedCache.maxItems=12000 +cache.remoteAlfrescoTicketService.ticketsCache.maxItems=1000 +cache.contentDiskDriver.fileInfoCache.maxItems=1000 +cache.globalConfigSharedCache.maxItems=1000 + # # Download Service Limits, in bytes # download.maxContentSize=2152852358 + diff --git a/config/alfresco/scheduled-jobs-context.xml b/config/alfresco/scheduled-jobs-context.xml index eafb4b93f6..8956d9ade7 100644 --- a/config/alfresco/scheduled-jobs-context.xml +++ b/config/alfresco/scheduled-jobs-context.xml @@ -104,29 +104,6 @@ 0 0 21 * * ? - - - - - - - org.alfresco.repo.cache.EhCacheTracerJob - - - - - - - 60 - - - 60 - - diff --git a/config/alfresco/subsystems/Search/lucene/index-recovery-context.xml b/config/alfresco/subsystems/Search/lucene/index-recovery-context.xml index 89f7efd08a..0f0069c80a 100644 --- a/config/alfresco/subsystems/Search/lucene/index-recovery-context.xml +++ b/config/alfresco/subsystems/Search/lucene/index-recovery-context.xml @@ -123,25 +123,23 @@ + + + org.alfresco.repo.node.index.IndexRecoveryJob + + + + + + + + + + + - - - - org.alfresco.repo.node.index.IndexRecoveryJob - - - - - - - - ${alfresco.cluster.name} - - - - - + @@ -166,25 +164,23 @@ + + + org.alfresco.repo.node.index.IndexRecoveryJob + + + + + + + + + + + - - - - org.alfresco.repo.node.index.IndexRecoveryJob - - - - - - - - ${alfresco.cluster.name} - - - - - + @@ -207,27 +203,25 @@ + + + org.alfresco.repo.node.index.IndexRecoveryJob + + + + + + + + + + + - - - - org.alfresco.repo.node.index.IndexRecoveryJob - - - - - - - - ${alfresco.cluster.name} - - - - - + @@ -235,4 +229,7 @@ ${index.reindexMissingContent.cronExpression} + + + \ No newline at end of file diff --git a/config/alfresco/subsystems/fileServers/default/file-servers-context.xml b/config/alfresco/subsystems/fileServers/default/file-servers-context.xml index 77f95e4d04..75d54b0cc5 100644 --- a/config/alfresco/subsystems/fileServers/default/file-servers-context.xml +++ b/config/alfresco/subsystems/fileServers/default/file-servers-context.xml @@ -3,7 +3,10 @@ "http://www.springframework.org/dtd/spring-beans.dtd"> - + @@ -287,8 +290,7 @@ - - + ${filesystem.cluster.debugFlags} diff --git a/config/alfresco/subsystems/fileServers/default/network-protocol-context.xml b/config/alfresco/subsystems/fileServers/default/network-protocol-context.xml index c0cc14b889..b4ef037096 100644 --- a/config/alfresco/subsystems/fileServers/default/network-protocol-context.xml +++ b/config/alfresco/subsystems/fileServers/default/network-protocol-context.xml @@ -111,20 +111,10 @@ - - - - - - - - org.alfresco.cache.filesys.fileInfo - - - - - - + + + + + + + + + + + + org.alfresco.cache.propertyValueTransactionalCache + + + + + + + + + + + + + + + org.alfresco.cache.contentDataTransactionalCache + + + + + + + + + + + + + + + + org.alfresco.cache.immutableEntityTransactionalCache + + + + + + + + + + + + + + + org.alfresco.cache.node.rootNodesTransactionalCache + + + + + + + + + + + + + + + + org.alfresco.cache.node.allRootNodesTransactionalCache + + + + + + + + + + + + + + + org.alfresco.cache.node.nodesTransactionalCache + + + + + + + + + + + + + + + + org.alfresco.cache.node.aspectsTransactionalCache + + + + + + + + + + + + + + + org.alfresco.cache.node.propertiesTransactionalCache + + + + + + + + + + + + + + + + org.alfresco.cache.node.childByNameTransactionalCache + + + + + + + + + + + + + + + org.alfresco.nodeRulesTransactionalCache + + + + + + + + + + + + + + + org.alfresco.userToAuthorityTransactionalCache + + + + + + + + + + + + + + + org.alfresco.authenticationTransactionalCache + + + 100 + + + + + + + + + + + + org.alfresco.authorityTransactionalCache + + + + + + + + + + + + + + + + org.alfresco.authorityToChildAuthorityTransactionalCache + + + + + + + + + + + + + + + + + org.alfresco.zoneToAuthorityTransactionalCache + + + + + + + + + + + + + + + + org.alfresco.permissionsAccessTransactionalCache + + + + + + + + + + + + + + + org.alfresco.readersTransactionalCache + + + + + + + + + + + + + + + org.alfresco.readersDeniedTransactionalCache + + + + + + + + + + + + + + + org.alfresco.nodeOwnerTransactionalCache + + + + + + + + + + + + + + + org.alfresco.personTransactionalCache + + + + + + + + + + + + + + + org.alfresco.cache.avmStoreTransactionalCache + + + + + + + + + + + + + + + org.alfresco.cache.avmEntityTransactionalCache + + + + + + + + + + + + + + + org.alfresco.cache.avmVersionRootEntityTransactionalCache + + + + + + + + + + + + + + + org.alfresco.cache.avmNodeTransactionalCache + + + + + + + + + + + + + + + org.alfresco.cache.avmNodeAspectsTransactionalCache + + + + + + + + + + + + + + + org.alfresco.repo.webservices.querySessionTransactionalCache + + + + + + + + + + + + + + + org.alfresco.aclTransactionalCache + + + + + + + + + + + + + + + org.alfresco.cache.aclEntityTransactionalCache + + + + + + + + + + + + + + + org.alfresco.cache.authorityEntityTransactionalCache + + + + + + + + + + + + + + + org.alfresco.cache.permissionEntityTransactionalCache + + + + + + + + + + + + + + + org.alfresco.resourceBundleBaseNamesTransactionalCache + + + + + + + + + + + + + + + org.alfresco.loadedResourceBundlesTransactionalCache + + + + + + + + + + + + + + + org.alfresco.messagesTransactionalCache + + + + + + + + + + + + + + + org.alfresco.compiledModelsTransactionalCache + + + + + + + + + + + + + + + org.alfresco.prefixesTransactionalCache + + + + + + + + + + + + + + + org.alfresco.webScriptsRegistryTransactionalCache + + + + + + + + + + + + + + + org.alfresco.routingContentStoreTransactionalCache + + + + + + + + + + + + + + + org.alfresco.cache.tagscopeSummaryTransactionalCache + + + + + + + + + + + + + + + org.alfresco.cache.imapMessageTransactionalCache + + + + + + + + + + + + + + + org.alfresco.tenantsTransactionalCache + + + + + + + + + + + + + + + + org.alfresco.cache.immutableSingletonTransactionalCache + + + + + + diff --git a/config/alfresco/webdav-context.xml b/config/alfresco/webdav-context.xml index 061241933c..5d938f577e 100644 --- a/config/alfresco/webdav-context.xml +++ b/config/alfresco/webdav-context.xml @@ -25,9 +25,7 @@ - - - + \ No newline at end of file diff --git a/config/test/alfresco/test-hibernate-cfg.properties b/config/test/alfresco/test-hibernate-cfg.properties index 5a45d7dc0d..795d8d0dad 100644 --- a/config/test/alfresco/test-hibernate-cfg.properties +++ b/config/test/alfresco/test-hibernate-cfg.properties @@ -11,7 +11,7 @@ hibernate.jdbc.use_streams_for_binary=true hibernate.show_sql=false hibernate.cache.use_query_cache=false hibernate.max_fetch_depth=10 -hibernate.cache.provider_class=org.alfresco.repo.cache.InternalEhCacheManagerFactoryBean +hibernate.cache.provider_class=org.alfresco.repo.cache.DefaultCacheProvider hibernate.cache.use_second_level_cache=true hibernate.default_batch_fetch_size=1 hibernate.jdbc.batch_size=32 diff --git a/pom.xml b/pom.xml index aee30bdd17..5cbea0c5cb 100644 --- a/pom.xml +++ b/pom.xml @@ -269,11 +269,6 @@ slf4j-log4j12 1.5.11 - - net.sf.ehcache - ehcache-core - 2.0.0 - org.beanshell bsh diff --git a/source/java/org/alfresco/RepositoryStartStopTest.java b/source/java/org/alfresco/RepositoryStartStopTest.java index ad09c8175c..9854de83d0 100644 --- a/source/java/org/alfresco/RepositoryStartStopTest.java +++ b/source/java/org/alfresco/RepositoryStartStopTest.java @@ -20,8 +20,6 @@ package org.alfresco; import java.lang.reflect.Field; -import net.sf.ehcache.CacheManager; - import org.alfresco.model.ContentModel; import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; @@ -82,17 +80,6 @@ public class RepositoryStartStopTest extends TestCase ); } - /** - * Checks that all our EHCache instances have been shutdown - */ - public static void assertAllCachesShutdown() throws Exception { - assertEquals( - "All Caches should have been shut down, but some remained", - 0, - CacheManager.ALL_CACHE_MANAGERS.size() - ); - } - private ApplicationContext getMinimalContext() { ApplicationContextHelper.setUseLazyLoading(false); ApplicationContextHelper.setNoAutoStart(true); @@ -124,7 +111,6 @@ public class RepositoryStartStopTest extends TestCase ApplicationContextHelper.closeApplicationContext(); assertNoCachedApplicationContext(); - assertAllCachesShutdown(); } /** @@ -145,7 +131,6 @@ public class RepositoryStartStopTest extends TestCase // Close it down ApplicationContextHelper.closeApplicationContext(); assertNoCachedApplicationContext(); - assertAllCachesShutdown(); // Re-open it, we get a fresh copy ApplicationContext ctx2 = getMinimalContext(); @@ -160,7 +145,6 @@ public class RepositoryStartStopTest extends TestCase // And finally close it ApplicationContextHelper.closeApplicationContext(); assertNoCachedApplicationContext(); - assertAllCachesShutdown(); } /** @@ -181,7 +165,6 @@ public class RepositoryStartStopTest extends TestCase // Close it down ApplicationContextHelper.closeApplicationContext(); assertNoCachedApplicationContext(); - assertAllCachesShutdown(); // Re-open it, we get a fresh copy ApplicationContext ctx2 = getFullContext(); @@ -198,7 +181,6 @@ public class RepositoryStartStopTest extends TestCase // And finally close it ApplicationContextHelper.closeApplicationContext(); assertNoCachedApplicationContext(); - assertAllCachesShutdown(); } /** @@ -219,7 +201,6 @@ public class RepositoryStartStopTest extends TestCase // Close ApplicationContextHelper.closeApplicationContext(); assertNoCachedApplicationContext(); - assertAllCachesShutdown(); // Now open the full one @@ -235,7 +216,6 @@ public class RepositoryStartStopTest extends TestCase // Close it ApplicationContextHelper.closeApplicationContext(); assertNoCachedApplicationContext(); - assertAllCachesShutdown(); // Back to the minimal one @@ -246,7 +226,6 @@ public class RepositoryStartStopTest extends TestCase // Close ApplicationContextHelper.closeApplicationContext(); assertNoCachedApplicationContext(); - assertAllCachesShutdown(); // And finally we want the full one again @@ -257,7 +236,6 @@ public class RepositoryStartStopTest extends TestCase // Close and we're done ApplicationContextHelper.closeApplicationContext(); assertNoCachedApplicationContext(); - assertAllCachesShutdown(); } public void doTestBasicWriteOperations(ApplicationContext ctx) throws Exception diff --git a/source/java/org/alfresco/filesys/config/ClusterConfigBean.java b/source/java/org/alfresco/filesys/config/ClusterConfigBean.java index fbec2926a0..74254a72ac 100644 --- a/source/java/org/alfresco/filesys/config/ClusterConfigBean.java +++ b/source/java/org/alfresco/filesys/config/ClusterConfigBean.java @@ -18,8 +18,6 @@ */ package org.alfresco.filesys.config; -import org.alfresco.repo.cluster.HazelcastInstanceFactory; - /** * The Class ClusterConfigBean. * @@ -28,29 +26,19 @@ import org.alfresco.repo.cluster.HazelcastInstanceFactory; */ public class ClusterConfigBean { - private HazelcastInstanceFactory hazelcastInstanceFactory; private String debugFlags; private int nearCacheTimeout; - - - public void setHazelcastInstanceFactory(HazelcastInstanceFactory hazelcastInstanceFactory) - { - this.hazelcastInstanceFactory = hazelcastInstanceFactory; - } - - public HazelcastInstanceFactory getHazelcastInstanceFactory() - { - return this.hazelcastInstanceFactory; - } public boolean getClusterEnabled() { - return hazelcastInstanceFactory.isClusteringEnabled(); + // No clustering support in community edition. + return false; } public String getClusterName() { - return hazelcastInstanceFactory.getClusterName(); + // No clustering support in community edition. + return null; } public void setDebugFlags(String debugFlags) diff --git a/source/java/org/alfresco/repo/cluster/MessageSendingException.java b/source/java/org/alfresco/filesys/config/FileServerConfigurationFactory.java similarity index 65% rename from source/java/org/alfresco/repo/cluster/MessageSendingException.java rename to source/java/org/alfresco/filesys/config/FileServerConfigurationFactory.java index 60d34a3174..cbd4f22c26 100644 --- a/source/java/org/alfresco/repo/cluster/MessageSendingException.java +++ b/source/java/org/alfresco/filesys/config/FileServerConfigurationFactory.java @@ -16,19 +16,22 @@ * You should have received a copy of the GNU Lesser General Public License * along with Alfresco. If not, see . */ -package org.alfresco.repo.cluster; +package org.alfresco.filesys.config; /** - * Thrown when unable to send a message using a {@link Messenger}. + * Factory to provide community versions of key fileserver configuration beans. * * @author Matt Ward */ -public class MessageSendingException extends RuntimeException +public class FileServerConfigurationFactory { - private static final long serialVersionUID = 1L; - - public MessageSendingException(Throwable e) + public ServerConfigurationBean createFileServerConfiguration() { - super("Unable to send message", e); + return new ServerConfigurationBean(); + } + + public ClusterConfigBean createClusterConfigBean() + { + return new ClusterConfigBean(); } } diff --git a/source/java/org/alfresco/filesys/config/ServerConfigurationBean.java b/source/java/org/alfresco/filesys/config/ServerConfigurationBean.java index d261b9096b..42b71e51f1 100644 --- a/source/java/org/alfresco/filesys/config/ServerConfigurationBean.java +++ b/source/java/org/alfresco/filesys/config/ServerConfigurationBean.java @@ -82,12 +82,10 @@ import org.alfresco.jlan.util.MemorySize; import org.alfresco.jlan.util.Platform; import org.alfresco.jlan.util.StringList; import org.alfresco.jlan.util.X64; -import org.alfresco.repo.cluster.HazelcastInstanceFactory; import org.alfresco.repo.management.subsystems.ActivateableBean; import org.springframework.beans.factory.DisposableBean; import org.springframework.extensions.config.element.GenericConfigElement; -import com.hazelcast.core.HazelcastInstance; /** * Alfresco File Server Configuration Bean Class @@ -112,7 +110,7 @@ public class ServerConfigurationBean extends AbstractServerConfigurationBean imp private CoreServerConfigBean coreServerConfigBean; private ThreadRequestPool threadPool; - private ClusterConfigBean clusterConfigBean; + protected ClusterConfigBean clusterConfigBean; /** * Default constructor @@ -2320,11 +2318,7 @@ public class ServerConfigurationBean extends AbstractServerConfigurationBean imp } // Create a ClusterConfigSection and attach it to 'this'. - ClusterConfigSection clusterConf = new ClusterConfigSection(this); - HazelcastInstanceFactory hazelcastInstanceFactory = clusterConfigBean.getHazelcastInstanceFactory(); - // Clustering is enabled, so we can safely request the hazelcast instance. - HazelcastInstance hazelcast = hazelcastInstanceFactory.getInstance(); - clusterConf.setHazelcastInstance(hazelcast); + ClusterConfigSection clusterConf = new ClusterConfigSection(this); } diff --git a/source/java/org/alfresco/repo/cache/AlfrescoCacheManagerPeerProviderFactory.java b/source/java/org/alfresco/repo/cache/AlfrescoCacheManagerPeerProviderFactory.java deleted file mode 100644 index 6f6e74ef7a..0000000000 --- a/source/java/org/alfresco/repo/cache/AlfrescoCacheManagerPeerProviderFactory.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (C) 2005-2010 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.repo.cache; - -import java.util.Properties; - -import net.sf.ehcache.CacheManager; -import net.sf.ehcache.distribution.CacheManagerPeerProvider; -import net.sf.ehcache.distribution.CacheManagerPeerProviderFactory; -import net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Alfresco's CacheManagerPeerProviderFactory that defers to the community or - * enterprise factories. - * - * @author Derek Hulley - * @since 3.1 - */ -public class AlfrescoCacheManagerPeerProviderFactory extends CacheManagerPeerProviderFactory -{ - private static Log logger = LogFactory.getLog(AlfrescoCacheManagerPeerProviderFactory.class); - - @Override - public CacheManagerPeerProvider createCachePeerProvider(CacheManager cacheManager, Properties properties) - { - CacheManagerPeerProviderFactory factory = null; - try - { - @SuppressWarnings("unchecked") - Class clazz = Class.forName("org.alfresco.enterprise.repo.cache.cluster.RMICacheManagerPeerProvider$Factory"); - factory = (CacheManagerPeerProviderFactory) clazz.newInstance(); - } - catch (ClassNotFoundException e) - { - // Entirely expected if the Enterprise-level code is not present - } - catch (Throwable e) - { - logger.error("Failed to instantiate RMICacheManagerPeerProvider factory.", e); - } - finally - { - if (factory == null) - { - // Use EHCache's default implementation - factory = new RMICacheManagerPeerProviderFactory(); - } - } - - if (logger.isDebugEnabled()) - { - logger.debug("Using peer provider factory: " + factory.getClass().getName()); - } - - return factory.createCachePeerProvider(cacheManager, properties); - } - -} diff --git a/source/java/org/alfresco/repo/cache/CacheTest.java b/source/java/org/alfresco/repo/cache/CacheTest.java deleted file mode 100644 index ab634d6a23..0000000000 --- a/source/java/org/alfresco/repo/cache/CacheTest.java +++ /dev/null @@ -1,1074 +0,0 @@ -/* - * Copyright (C) 2005-2010 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.repo.cache; - -import java.sql.SQLException; -import java.util.Collection; - -import javax.transaction.Status; -import javax.transaction.UserTransaction; - -import junit.framework.TestCase; -import net.sf.ehcache.CacheManager; - -import org.alfresco.repo.transaction.AlfrescoTransactionSupport; -import org.alfresco.repo.transaction.RetryingTransactionHelper; -import org.alfresco.repo.transaction.AlfrescoTransactionSupport.TxnReadState; -import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; -import org.alfresco.repo.transaction.TransactionListenerAdapter; -import org.alfresco.service.ServiceRegistry; -import org.alfresco.service.transaction.TransactionService; -import org.alfresco.util.ApplicationContextHelper; -import org.apache.commons.lang.mutable.MutableLong; -import org.springframework.context.ApplicationContext; - -/** - * @see org.alfresco.repo.cache.EhCacheAdapter - * - * @author Derek Hulley - */ -public class CacheTest extends TestCase -{ - private static ApplicationContext ctx = ApplicationContextHelper.getApplicationContext( - new String[] { - "classpath:cache-test/cache-test-context.xml", - ApplicationContextHelper.CONFIG_LOCATIONS[0]}); - - private ServiceRegistry serviceRegistry; - private SimpleCache standaloneCache; - private SimpleCache backingCache; - private TransactionalCache transactionalCache; - private SimpleCache objectCache; - - @SuppressWarnings("unchecked") - @Override - public void setUp() throws Exception - { - if (AlfrescoTransactionSupport.getTransactionReadState() != TxnReadState.TXN_NONE) - { - fail("A transaction is still running"); - } - - serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY); - standaloneCache = (SimpleCache) ctx.getBean("ehCache1"); - backingCache = (SimpleCache) ctx.getBean("backingCache"); - transactionalCache = (TransactionalCache) ctx.getBean("transactionalCache"); - objectCache = (SimpleCache) ctx.getBean("objectCache"); - - // Make sure that the backing cache is empty - backingCache.clear(); - - // Make the cache mutable (default) - transactionalCache.setMutable(true); - transactionalCache.setAllowEqualsChecks(false); - } - - @Override - public void tearDown() - { - serviceRegistry = null; - standaloneCache = null; - backingCache = null; - transactionalCache = null; - } - - public void testSetUp() throws Exception - { - CacheManager cacheManager = (CacheManager) ctx.getBean("testEHCacheManager"); - assertNotNull(cacheManager); - CacheManager cacheManagerCheck = (CacheManager) ctx.getBean("testEHCacheManager"); - assertTrue(cacheManager == cacheManagerCheck); - - assertNotNull(serviceRegistry); - assertNotNull(backingCache); - assertNotNull(standaloneCache); - assertNotNull(transactionalCache); - assertNotNull(objectCache); - } - - public void testObjectCache() throws Exception - { - objectCache.put("A", this); - Object obj = objectCache.get("A"); - assertTrue("Object not cached properly", this == obj); - } - - public void testEhcacheAdaptors() throws Exception - { - backingCache.put("A", "AAA"); - assertNull("Second cache should not have first's present", standaloneCache.get("A")); - - assertEquals("AAA", backingCache.get("A")); - - Collection keys = backingCache.getKeys(); - assertEquals("Backing cache didn't return correct number of keys", 1, keys.size()); - - backingCache.remove("A"); - assertNull(backingCache.get("A")); - } - - public void testTransactionalCacheNoTxn() throws Exception - { - String key = "B"; - String value = "BBB"; - // no transaction - do a put - transactionalCache.put(key, value); - // check that the value appears in the backing cache, backingCache - assertEquals("Backing cache not used for put when no transaction present", value, backingCache.get(key)); - - // remove the value from the backing cache and check that it is removed from the transaction cache - backingCache.remove(key); - assertNull("Backing cache not used for removed when no transaction present", transactionalCache.get(key)); - - // add value into backing cache - backingCache.put(key, value); - // remove it from the transactional cache - transactionalCache.remove(key); - // check that it is gone from the backing cache - assertNull("Non-transactional remove didn't go to backing cache", backingCache.get(key)); - } - - private static final String NEW_GLOBAL_ONE = "new_global_one"; - private static final String NEW_GLOBAL_TWO = "new_global_two"; - private static final String NEW_GLOBAL_THREE = "new_global_three"; - private static final String UPDATE_TXN_THREE = "updated_txn_three"; - private static final String UPDATE_TXN_FOUR = "updated_txn_four"; - - public void testRollbackCleanup() throws Exception - { - TransactionService transactionService = serviceRegistry.getTransactionService(); - RetryingTransactionHelper txnHelper = transactionService.getRetryingTransactionHelper(); - - // Add items to the global cache - backingCache.put(NEW_GLOBAL_ONE, NEW_GLOBAL_ONE); - - RetryingTransactionCallback callback = new RetryingTransactionCallback() - { - private int throwCount = 0; - public Object execute() throws Throwable - { - transactionalCache.put(NEW_GLOBAL_TWO, NEW_GLOBAL_TWO); - transactionalCache.remove(NEW_GLOBAL_ONE); - - String key = "B"; - String value = "BBB"; - // no transaction - do a put - transactionalCache.put(key, value); - // Blow up - if (throwCount < 5) - { - throwCount++; - throw new SQLException("Dummy"); - } - else - { - throw new Exception("Fail"); - } - } - }; - try - { - txnHelper.doInTransaction(callback); - } - catch (Exception e) - { - // Expected - } - - assertFalse("Remove not done after rollback", transactionalCache.contains(NEW_GLOBAL_ONE)); - assertFalse("Update happened after rollback", transactionalCache.contains(NEW_GLOBAL_TWO)); - } - - public void testTransactionalCacheWithSingleTxn() throws Throwable - { - // add item to global cache - backingCache.put(NEW_GLOBAL_ONE, NEW_GLOBAL_ONE); - backingCache.put(NEW_GLOBAL_TWO, NEW_GLOBAL_TWO); - backingCache.put(NEW_GLOBAL_THREE, NEW_GLOBAL_THREE); - - TransactionService transactionService = serviceRegistry.getTransactionService(); - UserTransaction txn = transactionService.getUserTransaction(); - try - { - // begin a transaction - txn.begin(); - - // remove 1 from the cache - transactionalCache.remove(NEW_GLOBAL_ONE); - assertFalse("Item was not removed from txn cache", transactionalCache.contains(NEW_GLOBAL_ONE)); - assertNull("Get didn't return null", transactionalCache.get(NEW_GLOBAL_ONE)); - assertTrue("Item was removed from backing cache", backingCache.contains(NEW_GLOBAL_ONE)); - - // read 2 from the cache - assertEquals("Item not read from backing cache", NEW_GLOBAL_TWO, transactionalCache.get(NEW_GLOBAL_TWO)); - // Change the backing cache - backingCache.put(NEW_GLOBAL_TWO, NEW_GLOBAL_TWO + "-updated"); - // Ensure read-committed - assertEquals("Read-committed not preserved", NEW_GLOBAL_TWO, transactionalCache.get(NEW_GLOBAL_TWO)); - - // update 3 in the cache - transactionalCache.put(UPDATE_TXN_THREE, "XXX"); - assertEquals("Item not updated in txn cache", "XXX", transactionalCache.get(UPDATE_TXN_THREE)); - assertFalse( - "Item was put into backing cache", - backingCache.contains(UPDATE_TXN_THREE)); - - // check that the keys collection is correct - Collection transactionalKeys = transactionalCache.getKeys(); - assertFalse("Transactionally removed item found in keys", transactionalKeys.contains(NEW_GLOBAL_ONE)); - assertTrue("Transactionally added item not found in keys", transactionalKeys.contains(UPDATE_TXN_THREE)); - - // Register a post-commit cache reader to make sure that nothing blows up if the cache is hit in post-commit - PostCommitCacheReader listenerReader = new PostCommitCacheReader(transactionalCache, UPDATE_TXN_THREE); - AlfrescoTransactionSupport.bindListener(listenerReader); - - // Register a post-commit cache reader to make sure that nothing blows up if the cache is hit in post-commit - PostCommitCacheWriter listenerWriter = new PostCommitCacheWriter(transactionalCache, UPDATE_TXN_FOUR, "FOUR"); - AlfrescoTransactionSupport.bindListener(listenerWriter); - - // commit the transaction - txn.commit(); - - // Check the post-commit stressers - if (listenerReader.e != null) - { - throw listenerReader.e; - } - if (listenerWriter.e != null) - { - throw listenerWriter.e; - } - - // check that backing cache was updated with the in-transaction changes - assertFalse("Item was not removed from backing cache", backingCache.contains(NEW_GLOBAL_ONE)); - assertNull("Item could still be fetched from backing cache", backingCache.get(NEW_GLOBAL_ONE)); - assertEquals("Item not updated in backing cache", "XXX", backingCache.get(UPDATE_TXN_THREE)); - - // Check that the transactional cache serves get requests - assertEquals("Transactional cache must serve post-commit get requests", "XXX", - transactionalCache.get(UPDATE_TXN_THREE)); - } - catch (Throwable e) - { - if (txn.getStatus() == Status.STATUS_ACTIVE) - { - txn.rollback(); - } - throw e; - } - } - - /** - * This transaction listener attempts to read from the cache in the afterCommit phase. Technically the - * transaction has finished, but the transaction resources are still available. - * - * @author Derek Hulley - * @since 2.1 - */ - private class PostCommitCacheReader extends TransactionListenerAdapter - { - private final SimpleCache transactionalCache; - private final String key; - private Throwable e; - private PostCommitCacheReader(SimpleCache transactionalCache, String key) - { - this.transactionalCache = transactionalCache; - this.key = key; - } - @Override - public void afterCommit() - { - try - { - transactionalCache.get(key); - } - catch (Throwable e) - { - this.e = e; - return; - } - } - } - - /** - * This transaction listener attempts to write to the cache in the afterCommit phase. Technically the - * transaction has finished, but the transaction resources are still available. - * - * @author Derek Hulley - * @since 2.1 - */ - private class PostCommitCacheWriter extends TransactionListenerAdapter - { - private final SimpleCache transactionalCache; - private final String key; - private final Object value; - private Throwable e; - private PostCommitCacheWriter(SimpleCache transactionalCache, String key, Object value) - { - this.transactionalCache = transactionalCache; - this.key = key; - this.value = value; - } - @Override - public void afterCommit() - { - try - { - transactionalCache.put(key, value); - transactionalCache.remove(key); - transactionalCache.clear(); - } - catch (Throwable e) - { - this.e = e; - return; - } - } - } - - public void testTransactionalCacheDisableSharedCaches() throws Throwable - { - // add item to global cache - backingCache.put(NEW_GLOBAL_ONE, NEW_GLOBAL_ONE); - backingCache.put(NEW_GLOBAL_TWO, NEW_GLOBAL_TWO); - backingCache.put(NEW_GLOBAL_THREE, NEW_GLOBAL_THREE); - - TransactionService transactionService = serviceRegistry.getTransactionService(); - UserTransaction txn = transactionService.getUserTransaction(); - try - { - // begin a transaction - txn.begin(); - - // Go directly past ALL shared caches - transactionalCache.setDisableSharedCacheReadForTransaction(true); - - // Try to get results in shared caches - assertNull("Read of mutable shared cache MUST NOT use backing cache", transactionalCache.get(NEW_GLOBAL_ONE)); - assertNull("Value should not be in any cache", transactionalCache.get(UPDATE_TXN_THREE)); - - // Update the transactional caches - transactionalCache.put(NEW_GLOBAL_TWO, "An update"); - transactionalCache.put(UPDATE_TXN_THREE, UPDATE_TXN_THREE); - - // Try to get results in shared caches - assertNull("Read of mutable shared cache MUST NOT use backing cache", transactionalCache.get(NEW_GLOBAL_ONE)); - assertEquals("Value should be in transactional cache", "An update", transactionalCache.get(NEW_GLOBAL_TWO)); - assertEquals("Value should be in transactional cache", UPDATE_TXN_THREE, transactionalCache.get(UPDATE_TXN_THREE)); - - txn.commit(); - - // Now check that values were not written through for any caches - assertEquals("Out-of-txn read must return shared value", NEW_GLOBAL_ONE, transactionalCache.get(NEW_GLOBAL_ONE)); - assertNull("Value should be removed from shared cache", transactionalCache.get(NEW_GLOBAL_TWO)); - assertEquals("New values must be written to shared cache", UPDATE_TXN_THREE, transactionalCache.get(UPDATE_TXN_THREE)); - } - catch (Throwable e) - { - if (txn.getStatus() == Status.STATUS_ACTIVE) - { - txn.rollback(); - } - throw e; - } - } - - /** - * Preloads the cache, then performs a simultaneous addition of N new values and - * removal of the N preloaded values. - * - * @param cache - * @param objectCount - * @return Returns the time it took in nanoseconds. - */ - public long runPerformanceTestOnCache(SimpleCache cache, int objectCount) - { - // preload - for (int i = 0; i < objectCount; i++) - { - String key = Integer.toString(i); - Integer value = new Integer(i); - cache.put(key, value); - } - - // start timer - long start = System.nanoTime(); - for (int i = 0; i < objectCount; i++) - { - String key = Integer.toString(i); - cache.remove(key); - // add a new value - key = Integer.toString(i + objectCount); - Integer value = new Integer(i + objectCount); - cache.put(key, value); - } - // stop - long stop = System.nanoTime(); - - return (stop - start); - } - - /** - * Tests a straight Ehcache adapter against a transactional cache both in and out - * of a transaction. This is done repeatedly, pushing the count up. - */ - public void testPerformance() throws Exception - { - for (int i = 0; i < 6; i++) - { - int count = (int) Math.pow(10D, (double)i); - - // test standalone - long timePlain = runPerformanceTestOnCache(standaloneCache, count); - - // do transactional cache in a transaction - TransactionService transactionService = serviceRegistry.getTransactionService(); - UserTransaction txn = transactionService.getUserTransaction(); - txn.begin(); - long timeTxn = runPerformanceTestOnCache(transactionalCache, count); - long commitStart = System.nanoTime(); - txn.commit(); - long commitEnd = System.nanoTime(); - long commitTime = (commitEnd - commitStart); - // add this to the cache's performance overhead - timeTxn += commitTime; - - // report - System.out.println("Cache performance test: \n" + - " count: " + count + "\n" + - " direct: " + timePlain/((long)count) + " ns\\count \n" + - " transaction: " + timeTxn/((long)count) + " ns\\count"); - } - } - - /** - * Time how long it takes to create and complete a whole lot of transactions - */ - public void testInitializationPerformance() throws Exception - { - TransactionService transactionService = serviceRegistry.getTransactionService(); - long start = System.nanoTime(); - int count = 10000; - for (int i = 0; i < count; i++) - { - UserTransaction txn = transactionService.getUserTransaction(); - try - { - txn.begin(); - transactionalCache.contains("A"); - } - finally - { - try { txn.rollback(); } catch (Throwable ee) {ee.printStackTrace();} - } - } - long end = System.nanoTime(); - - // report - System.out.println( - "Cache initialization performance test: \n" + - " count: " + count + "\n" + - " transaction: " + (end-start)/((long)count) + " ns\\count"); - } - - /** - * @see #testPerformance() - */ - public static void main(String ... args) - { - try - { - CacheTest test = new CacheTest(); - test.setUp(); - System.out.println("Press any key to run initialization test ..."); - System.in.read(); - test.testInitializationPerformance(); - System.out.println("Press any key to run performance test ..."); - System.in.read(); - test.testPerformance(); - System.out.println("Press any key to shutdown ..."); - System.in.read(); - test.tearDown(); - } - catch (Throwable e) - { - e.printStackTrace(); - } - finally - { - ApplicationContextHelper.closeApplicationContext(); - } - } - - /** - * Starts off with a null in the backing cache and adds a value to the - * transactional cache. There should be no problem with this. - */ - public void testNullValue() throws Throwable - { - TransactionService transactionService = serviceRegistry.getTransactionService(); - UserTransaction txn = transactionService.getUserTransaction(); - - txn.begin(); - - backingCache.put("A", null); - transactionalCache.put("A", "AAA"); - - try - { - txn.commit(); - } - catch (Throwable e) - { - try {txn.rollback();} catch (Throwable ee) {} - throw e; - } - } - - /** - * Add 50K objects into the transactional cache and checks that the first object added - * has been discarded. - */ - public void testMaxSizeOverrun() throws Exception - { - TransactionService transactionService = serviceRegistry.getTransactionService(); - UserTransaction txn = transactionService.getUserTransaction(); - try - { - txn.begin(); - - Object startValue = new Integer(-1); - String startKey = startValue.toString(); - transactionalCache.put(startKey, startValue); - - assertEquals("The start value isn't correct", startValue, transactionalCache.get(startKey)); - - for (int i = 0; i < 205000; i++) - { - Object value = Integer.valueOf(i); - String key = value.toString(); - transactionalCache.put(key, value); - } - - // Is the start value here? - Object checkStartValue = transactionalCache.get(startKey); - // Now, the cache should no longer contain the first value - assertNull("The start value didn't drop out of the cache", checkStartValue); - - txn.commit(); - } - finally - { - try { txn.rollback(); } catch (Throwable ee) {} - } - } - - /** Execute the callback and ensure that the backing cache is left with the expected value */ - private void executeAndCheck( - RetryingTransactionCallback callback, - boolean readOnly, - String key, - Object expectedValue) throws Throwable - { - TransactionService transactionService = serviceRegistry.getTransactionService(); - UserTransaction txn = transactionService.getUserTransaction(readOnly); - try - { - txn.begin(); - callback.execute(); - txn.commit(); - } - finally - { - try { txn.rollback(); } catch (Throwable ee) {} - } - Object actualValue = backingCache.get(key); - assertEquals("Backing cache value was not correct", expectedValue, actualValue); - - // Clear the backing cache to ensure that subsequent tests don't run into existing data - backingCache.clear(); - } - - private static final String COMMON_KEY = "A"; - private static final MutableLong VALUE_ONE_A = new MutableLong(1L); - private static final MutableLong VALUE_ONE_B = new MutableLong(1L); - private static final MutableLong VALUE_TWO_A = new MutableLong(2L); - /** - *
    - *
  • Add to the transaction cache
  • - *
  • Add to the backing cache
  • - *
  • Commit
  • - *
- */ - public void testConcurrentAddAgainstAdd()throws Throwable - { - RetryingTransactionCallback callback = new RetryingTransactionCallback() - { - public Object execute() throws Throwable - { - transactionalCache.put(COMMON_KEY, VALUE_ONE_A); - backingCache.put(COMMON_KEY, VALUE_ONE_B); - return null; - } - }; - transactionalCache.setAllowEqualsChecks(false); - transactionalCache.setMutable(true); - executeAndCheck(callback, false, COMMON_KEY, null); // Mutable: Pessimistic removal - executeAndCheck(callback, true, COMMON_KEY, null); // Mutable: Pessimistic removal - transactionalCache.setMutable(false); - executeAndCheck(callback, false, COMMON_KEY, VALUE_ONE_B); // Immutable: Assume backing cache is correct - executeAndCheck(callback, true, COMMON_KEY, VALUE_ONE_B); // Immutable: Assume backing cache is correct - - transactionalCache.setAllowEqualsChecks(true); - transactionalCache.setMutable(true); - executeAndCheck(callback, false, COMMON_KEY, VALUE_ONE_B); // Mutable: Shared cache value checked - executeAndCheck(callback, true, COMMON_KEY, VALUE_ONE_B); // Mutable: Shared cache value checked - transactionalCache.setMutable(false); - executeAndCheck(callback, false, COMMON_KEY, VALUE_ONE_B); // Immutable: Assume backing cache is correct - executeAndCheck(callback, true, COMMON_KEY, VALUE_ONE_B); // Immutable: Assume backing cache is correct - } - /** - *
    - *
  • Add to the transaction cache
  • - *
  • Add to the backing cache
  • - *
  • Commit
  • - *
- */ - public void testConcurrentAddAgainstAddSame()throws Throwable - { - RetryingTransactionCallback callback = new RetryingTransactionCallback() - { - public Object execute() throws Throwable - { - transactionalCache.put(COMMON_KEY, VALUE_ONE_A); - backingCache.put(COMMON_KEY, VALUE_ONE_A); - return null; - } - }; - transactionalCache.setAllowEqualsChecks(false); - transactionalCache.setMutable(true); - executeAndCheck(callback, false, COMMON_KEY, VALUE_ONE_A); // Mutable: Object handle is match - executeAndCheck(callback, true, COMMON_KEY, VALUE_ONE_A); // Mutable: Object handle is match - transactionalCache.setMutable(false); - executeAndCheck(callback, false, COMMON_KEY, VALUE_ONE_A); // Immutable: Object handle is match - executeAndCheck(callback, true, COMMON_KEY, VALUE_ONE_A); // Immutable: Object handle is match - - transactionalCache.setAllowEqualsChecks(true); - transactionalCache.setMutable(true); - executeAndCheck(callback, false, COMMON_KEY, VALUE_ONE_A); // Mutable: Object handle is match - executeAndCheck(callback, true, COMMON_KEY, VALUE_ONE_A); // Mutable: Object handle is match - transactionalCache.setMutable(false); - executeAndCheck(callback, false, COMMON_KEY, VALUE_ONE_A); // Immutable: Object handle is match - executeAndCheck(callback, true, COMMON_KEY, VALUE_ONE_A); // Immutable: Object handle is match - } - /** - *
    - *
  • Add to the transaction cache
  • - *
  • Clear the backing cache
  • - *
  • Commit
  • - *
- */ - public void testConcurrentAddAgainstClear()throws Throwable - { - RetryingTransactionCallback callback = new RetryingTransactionCallback() - { - public Object execute() throws Throwable - { - transactionalCache.put(COMMON_KEY, VALUE_ONE_A); - backingCache.clear(); - return null; - } - }; - transactionalCache.setAllowEqualsChecks(false); - transactionalCache.setMutable(true); - executeAndCheck(callback, false, COMMON_KEY, VALUE_ONE_A); // Mutable: Add back to backing cache - executeAndCheck(callback, true, COMMON_KEY, VALUE_ONE_A); // Mutable: Add back to backing cache - transactionalCache.setMutable(false); - executeAndCheck(callback, false, COMMON_KEY, VALUE_ONE_A); // Immutable: Add back to backing cache - executeAndCheck(callback, true, COMMON_KEY, VALUE_ONE_A); // Immutable: Add back to backing cache - - transactionalCache.setAllowEqualsChecks(true); - transactionalCache.setMutable(true); - executeAndCheck(callback, false, COMMON_KEY, VALUE_ONE_A); // Mutable: Add back to backing cache - executeAndCheck(callback, true, COMMON_KEY, VALUE_ONE_A); // Mutable: Add back to backing cache - transactionalCache.setMutable(false); - executeAndCheck(callback, false, COMMON_KEY, VALUE_ONE_A); // Immutable: Add back to backing cache - executeAndCheck(callback, true, COMMON_KEY, VALUE_ONE_A); // Immutable: Add back to backing cache - } - /** - *
    - *
  • Add to the backing cache
  • - *
  • Update the transactional cache
  • - *
  • Update the backing cache
  • - *
  • Commit
  • - *
- */ - public void testConcurrentUpdateAgainstUpdate()throws Throwable - { - RetryingTransactionCallback callback = new RetryingTransactionCallback() - { - public Object execute() throws Throwable - { - backingCache.put(COMMON_KEY, VALUE_ONE_A); - transactionalCache.put(COMMON_KEY, VALUE_ONE_B); - backingCache.put(COMMON_KEY, VALUE_TWO_A); - return null; - } - }; - transactionalCache.setAllowEqualsChecks(false); - transactionalCache.setMutable(true); - executeAndCheck(callback, false, COMMON_KEY, null); // Mutable: Pessimistic removal - executeAndCheck(callback, true, COMMON_KEY, null); // Mutable: Pessimistic removal - transactionalCache.setMutable(false); - executeAndCheck(callback, false, COMMON_KEY, VALUE_TWO_A); // Immutable: Assume backing cache is correct - executeAndCheck(callback, true, COMMON_KEY, VALUE_TWO_A); // Immutable: Assume backing cache is correct - - transactionalCache.setAllowEqualsChecks(true); - transactionalCache.setMutable(true); - executeAndCheck(callback, false, COMMON_KEY, null); // Mutable: Shared cache value checked failed - executeAndCheck(callback, true, COMMON_KEY, null); // Mutable: Shared cache value checked failed - transactionalCache.setMutable(false); - executeAndCheck(callback, false, COMMON_KEY, VALUE_TWO_A); // Immutable: Assume backing cache is correct - executeAndCheck(callback, true, COMMON_KEY, VALUE_TWO_A); // Immutable: Assume backing cache is correct - } - /** - *
    - *
  • Add to the backing cache
  • - *
  • Update the transactional cache
  • - *
  • Update the backing cache with a null value
  • - *
  • Commit
  • - *
- */ - public void testConcurrentUpdateAgainstUpdateNull()throws Throwable - { - RetryingTransactionCallback callback = new RetryingTransactionCallback() - { - public Object execute() throws Throwable - { - backingCache.put(COMMON_KEY, VALUE_ONE_A); - transactionalCache.put(COMMON_KEY, VALUE_ONE_B); - backingCache.put(COMMON_KEY, null); - return null; - } - }; - transactionalCache.setAllowEqualsChecks(false); - transactionalCache.setMutable(true); - executeAndCheck(callback, false, COMMON_KEY, null); // Mutable: Pessimistic removal - executeAndCheck(callback, true, COMMON_KEY, null); // Mutable: Pessimistic removal - transactionalCache.setMutable(false); - executeAndCheck(callback, false, COMMON_KEY, VALUE_ONE_B); // Immutable: Add back to backing cache - executeAndCheck(callback, true, COMMON_KEY, VALUE_ONE_B); // Immutable: Add back to backing cache - - transactionalCache.setAllowEqualsChecks(true); - transactionalCache.setMutable(true); - executeAndCheck(callback, false, COMMON_KEY, null); // Mutable: Pessimistic removal - executeAndCheck(callback, true, COMMON_KEY, null); // Mutable: Pessimistic removal - transactionalCache.setMutable(false); - executeAndCheck(callback, false, COMMON_KEY, VALUE_ONE_B); // Immutable: Add back to backing cache - executeAndCheck(callback, true, COMMON_KEY, VALUE_ONE_B); // Immutable: Add back to backing cache - } - /** - *
    - *
  • Add to the backing cache
  • - *
  • Update the transactional cache with a null value
  • - *
  • Update the backing cache
  • - *
  • Commit
  • - *
- */ - public void testConcurrentUpdateNullAgainstUpdate()throws Throwable - { - RetryingTransactionCallback callback = new RetryingTransactionCallback() - { - public Object execute() throws Throwable - { - backingCache.put(COMMON_KEY, VALUE_ONE_A); - transactionalCache.put(COMMON_KEY, null); - backingCache.put(COMMON_KEY, VALUE_ONE_B); - return null; - } - }; - transactionalCache.setAllowEqualsChecks(false); - transactionalCache.setMutable(true); - executeAndCheck(callback, false, COMMON_KEY, null); // Mutable: Pessimistic removal - executeAndCheck(callback, true, COMMON_KEY, null); // Mutable: Pessimistic removal - transactionalCache.setMutable(false); - executeAndCheck(callback, false, COMMON_KEY, VALUE_ONE_B); // Immutable: Assume backing cache is correct - executeAndCheck(callback, true, COMMON_KEY, VALUE_ONE_B); // Immutable: Assume backing cache is correct - - transactionalCache.setAllowEqualsChecks(true); - transactionalCache.setMutable(true); - executeAndCheck(callback, false, COMMON_KEY, null); // Mutable: Pessimistic removal - executeAndCheck(callback, true, COMMON_KEY, null); // Mutable: Pessimistic removal - transactionalCache.setMutable(false); - executeAndCheck(callback, false, COMMON_KEY, VALUE_ONE_B); // Immutable: Assume backing cache is correct - executeAndCheck(callback, true, COMMON_KEY, VALUE_ONE_B); // Immutable: Assume backing cache is correct - } - /** - *
    - *
  • Add to the backing cache
  • - *
  • Update the transactional cache
  • - *
  • Remove from the backing cache
  • - *
  • Commit
  • - *
- */ - public void testConcurrentUpdateAgainstRemove()throws Throwable - { - RetryingTransactionCallback callback = new RetryingTransactionCallback() - { - public Object execute() throws Throwable - { - backingCache.put(COMMON_KEY, VALUE_ONE_A); - transactionalCache.put(COMMON_KEY, VALUE_ONE_B); - backingCache.remove(COMMON_KEY); - return null; - } - }; - transactionalCache.setAllowEqualsChecks(false); - transactionalCache.setMutable(true); - executeAndCheck(callback, false, COMMON_KEY, null); // Mutable: Pessimistic removal - executeAndCheck(callback, true, COMMON_KEY, null); // Mutable: Pessimistic removal - transactionalCache.setMutable(false); - executeAndCheck(callback, false, COMMON_KEY, VALUE_ONE_B); // Immutable: Add back to backing cache - executeAndCheck(callback, true, COMMON_KEY, VALUE_ONE_B); // Immutable: Add back to backing cache - - transactionalCache.setAllowEqualsChecks(true); - transactionalCache.setMutable(true); - executeAndCheck(callback, false, COMMON_KEY, null); // Mutable: Pessimistic removal - executeAndCheck(callback, true, COMMON_KEY, null); // Mutable: Pessimistic removal - transactionalCache.setMutable(false); - executeAndCheck(callback, false, COMMON_KEY, VALUE_ONE_B); // Immutable: Add back to backing cache - executeAndCheck(callback, true, COMMON_KEY, VALUE_ONE_B); // Immutable: Add back to backing cache - } - /** - *
    - *
  • Add to the backing cache
  • - *
  • Update the transactional cache
  • - *
  • Clear the backing cache
  • - *
  • Commit
  • - *
- */ - public void testConcurrentUpdateAgainstClear()throws Throwable - { - RetryingTransactionCallback callback = new RetryingTransactionCallback() - { - public Object execute() throws Throwable - { - backingCache.put(COMMON_KEY, VALUE_ONE_A); - transactionalCache.put(COMMON_KEY, VALUE_ONE_B); - backingCache.clear(); - return null; - } - }; - transactionalCache.setAllowEqualsChecks(false); - transactionalCache.setMutable(true); - executeAndCheck(callback, false, COMMON_KEY, null); // Mutable: Pessimistic removal - executeAndCheck(callback, true, COMMON_KEY, null); // Mutable: Pessimistic removal - transactionalCache.setMutable(false); - executeAndCheck(callback, false, COMMON_KEY, VALUE_ONE_B); // Immutable: Add back to backing cache - executeAndCheck(callback, true, COMMON_KEY, VALUE_ONE_B); // Immutable: Add back to backing cache - - transactionalCache.setAllowEqualsChecks(true); - transactionalCache.setMutable(true); - executeAndCheck(callback, false, COMMON_KEY, null); // Mutable: Pessimistic removal - executeAndCheck(callback, true, COMMON_KEY, null); // Mutable: Pessimistic removal - transactionalCache.setMutable(false); - executeAndCheck(callback, false, COMMON_KEY, VALUE_ONE_B); // Immutable: Add back to backing cache - executeAndCheck(callback, true, COMMON_KEY, VALUE_ONE_B); // Immutable: Add back to backing cache - } - /** - *
    - *
  • Remove from the backing cache
  • - *
  • Remove from the transactional cache
  • - *
  • Add to the backing cache
  • - *
  • Commit
  • - *
- */ - public void testConcurrentRemoveAgainstUpdate_NoPreExisting()throws Throwable - { - RetryingTransactionCallback callback = new RetryingTransactionCallback() - { - public Object execute() throws Throwable - { - backingCache.remove(COMMON_KEY); - transactionalCache.remove(COMMON_KEY); - backingCache.put(COMMON_KEY, VALUE_ONE_B); - return null; - } - }; - transactionalCache.setAllowEqualsChecks(false); - transactionalCache.setMutable(true); - executeAndCheck(callback, false, COMMON_KEY, null); // Mutable: Pessimistic removal - executeAndCheck(callback, true, COMMON_KEY, null); // Mutable: Pessimistic removal - transactionalCache.setMutable(false); - executeAndCheck(callback, false, COMMON_KEY, null); // Immutable: Remove from backing cache - executeAndCheck(callback, true, COMMON_KEY, null); // Immutable: Remove from backing cache - - transactionalCache.setAllowEqualsChecks(true); - transactionalCache.setMutable(true); - executeAndCheck(callback, false, COMMON_KEY, null); // Mutable: Pessimistic removal - executeAndCheck(callback, true, COMMON_KEY, null); // Mutable: Pessimistic removal - transactionalCache.setMutable(false); - executeAndCheck(callback, false, COMMON_KEY, null); // Immutable: Remove from backing cache - executeAndCheck(callback, true, COMMON_KEY, null); // Immutable: Remove from backing cache - } - /** - *
    - *
  • Remove from the backing cache
  • - *
  • Add to the transactional cache
  • - *
  • Add to the backing cache
  • - *
  • Commit
  • - *
- */ - public void testConcurrentAddAgainstAdd_NoPreExisting()throws Throwable - { - RetryingTransactionCallback callback = new RetryingTransactionCallback() - { - public Object execute() throws Throwable - { - backingCache.remove(COMMON_KEY); - transactionalCache.put(COMMON_KEY, VALUE_ONE_A); - backingCache.put(COMMON_KEY, VALUE_ONE_B); - return null; - } - }; - transactionalCache.setAllowEqualsChecks(false); - transactionalCache.setMutable(true); - executeAndCheck(callback, false, COMMON_KEY, null); // Mutable: Pessimistic removal - executeAndCheck(callback, true, COMMON_KEY, null); // Mutable: Pessimistic removal - transactionalCache.setMutable(false); - executeAndCheck(callback, false, COMMON_KEY, VALUE_ONE_B); // Immutable: Assume backing cache is correct - executeAndCheck(callback, true, COMMON_KEY, VALUE_ONE_B); // Immutable: Assume backing cache is correct - - transactionalCache.setAllowEqualsChecks(true); - transactionalCache.setMutable(true); - executeAndCheck(callback, false, COMMON_KEY, VALUE_ONE_B); // Mutable: Shared cache value checked - executeAndCheck(callback, true, COMMON_KEY, VALUE_ONE_B); // Mutable: Shared cache value checked - transactionalCache.setMutable(false); - executeAndCheck(callback, false, COMMON_KEY, VALUE_ONE_B); // Immutable: Assume backing cache is correct - executeAndCheck(callback, true, COMMON_KEY, VALUE_ONE_B); // Immutable: Assume backing cache is correct - } - /** - *
    - *
  • Add to the backing cache
  • - *
  • Remove from the transactional cache
  • - *
  • Add to the backing cache
  • - *
  • Commit
  • - *
- */ - public void testConcurrentRemoveAgainstUpdate_PreExisting()throws Throwable - { - RetryingTransactionCallback callback = new RetryingTransactionCallback() - { - public Object execute() throws Throwable - { - backingCache.put(COMMON_KEY, VALUE_ONE_A); - transactionalCache.remove(COMMON_KEY); - backingCache.put(COMMON_KEY, VALUE_ONE_B); - return null; - } - }; - transactionalCache.setAllowEqualsChecks(false); - transactionalCache.setMutable(true); - executeAndCheck(callback, false, COMMON_KEY, null); // Mutable: Pessimistic removal - executeAndCheck(callback, true, COMMON_KEY, null); // Mutable: Pessimistic removal - transactionalCache.setMutable(false); - executeAndCheck(callback, false, COMMON_KEY, null); // Immutable: Remove from backing cache - executeAndCheck(callback, true, COMMON_KEY, null); // Immutable: Remove from backing cache - - transactionalCache.setAllowEqualsChecks(true); - transactionalCache.setMutable(true); - executeAndCheck(callback, false, COMMON_KEY, null); // Mutable: Pessimistic removal - executeAndCheck(callback, true, COMMON_KEY, null); // Mutable: Pessimistic removal - transactionalCache.setMutable(false); - executeAndCheck(callback, false, COMMON_KEY, null); // Immutable: Remove from backing cache - executeAndCheck(callback, true, COMMON_KEY, null); // Immutable: Remove from backing cache - } - /** - *
    - *
  • Add to the backing cache
  • - *
  • Remove from the transactional cache
  • - *
  • Remove from the backing cache
  • - *
  • Commit
  • - *
- */ - public void testConcurrentRemoveAgainstRemove()throws Throwable - { - RetryingTransactionCallback callback = new RetryingTransactionCallback() - { - public Object execute() throws Throwable - { - backingCache.put(COMMON_KEY, VALUE_ONE_A); - transactionalCache.remove(COMMON_KEY); - backingCache.remove(COMMON_KEY); - return null; - } - }; - transactionalCache.setAllowEqualsChecks(false); - transactionalCache.setMutable(true); - executeAndCheck(callback, false, COMMON_KEY, null); // Mutable: Remove from backing cache - executeAndCheck(callback, true, COMMON_KEY, null); // Mutable: Remove from backing cache - transactionalCache.setMutable(false); - executeAndCheck(callback, false, COMMON_KEY, null); // Immutable: Remove from backing cache - executeAndCheck(callback, true, COMMON_KEY, null); // Immutable: Remove from backing cache - - transactionalCache.setAllowEqualsChecks(true); - transactionalCache.setMutable(true); - executeAndCheck(callback, false, COMMON_KEY, null); // Mutable: Remove from backing cache - executeAndCheck(callback, true, COMMON_KEY, null); // Mutable: Remove from backing cache - transactionalCache.setMutable(false); - executeAndCheck(callback, false, COMMON_KEY, null); // Immutable: Remove from backing cache - executeAndCheck(callback, true, COMMON_KEY, null); // Immutable: Remove from backing cache - } - /** - *
    - *
  • Add to the backing cache
  • - *
  • Remove from the transactional cache
  • - *
  • Clear the backing cache
  • - *
  • Commit
  • - *
- */ - public void testConcurrentRemoveAgainstClear()throws Throwable - { - RetryingTransactionCallback callback = new RetryingTransactionCallback() - { - public Object execute() throws Throwable - { - backingCache.put(COMMON_KEY, VALUE_ONE_A); - transactionalCache.remove(COMMON_KEY); - backingCache.clear(); - return null; - } - }; - transactionalCache.setAllowEqualsChecks(false); - transactionalCache.setMutable(true); - executeAndCheck(callback, false, COMMON_KEY, null); // Mutable: Nothing to do - executeAndCheck(callback, true, COMMON_KEY, null); // Mutable: Nothing to do - transactionalCache.setMutable(false); - executeAndCheck(callback, false, COMMON_KEY, null); // Immutable: Nothing to do - executeAndCheck(callback, true, COMMON_KEY, null); // Immutable: Nothing to do - - transactionalCache.setAllowEqualsChecks(true); - transactionalCache.setMutable(true); - executeAndCheck(callback, false, COMMON_KEY, null); // Mutable: Nothing to do - executeAndCheck(callback, true, COMMON_KEY, null); // Mutable: Nothing to do - transactionalCache.setMutable(false); - executeAndCheck(callback, false, COMMON_KEY, null); // Immutable: Nothing to do - executeAndCheck(callback, true, COMMON_KEY, null); // Immutable: Nothing to do - } -} diff --git a/source/java/org/alfresco/repo/cache/DefaultCacheProvider.java b/source/java/org/alfresco/repo/cache/DefaultCacheProvider.java new file mode 100644 index 0000000000..3242cedc30 --- /dev/null +++ b/source/java/org/alfresco/repo/cache/DefaultCacheProvider.java @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2005-2012 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.repo.cache; + +import java.io.Serializable; +import java.util.Properties; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.hibernate.cache.Cache; +import org.hibernate.cache.CacheException; +import org.hibernate.cache.CacheProvider; +import org.hibernate.cache.Timestamper; + +/** + * A simple {@link CacheProvider} that allows Hibernate to create {@link DefaultSimpleCache} + * based caches. + * + * @author Matt Ward + */ +public class DefaultCacheProvider implements CacheProvider +{ + private final static Log log = LogFactory.getLog(DefaultCacheProvider.class); + // TODO: setup in spring (SystemPropertiesSetterBean) + private int defaultMaxItems = 500; + + @Override + public Cache buildCache(String regionName, Properties properties) throws CacheException + { + if (log.isDebugEnabled()) + { + log.debug("building cache for regionName=" + regionName + ", with properties: " + properties); + } + DefaultSimpleCache cache = new DefaultSimpleCache(); + cache.setMaxItems(defaultMaxItems); + Cache hibCache = new HibernateSimpleCacheAdapter(cache, regionName); + return hibCache; + } + + @Override + public long nextTimestamp() + { + return Timestamper.next(); + } + + @Override + public void start(Properties properties) throws CacheException + { + } + + @Override + public void stop() + { + } + + @Override + public boolean isMinimalPutsEnabledByDefault() + { + return false; + } + +} diff --git a/source/java/org/alfresco/repo/cache/DefaultSimpleCache.java b/source/java/org/alfresco/repo/cache/DefaultSimpleCache.java new file mode 100644 index 0000000000..948d0ef641 --- /dev/null +++ b/source/java/org/alfresco/repo/cache/DefaultSimpleCache.java @@ -0,0 +1,126 @@ +/* + * Copyright (C) 2005-2012 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.repo.cache; + +import java.io.Serializable; +import java.util.Collection; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Map.Entry; + +import org.springframework.beans.factory.BeanNameAware; + +/** + * {@link SimpleCache} implementation backed by a {@link LinkedHashMap}. + * + * @author Matt Ward + */ +public final class DefaultSimpleCache + implements SimpleCache, BeanNameAware +{ + private final Map map; + private int maxItems = 0; + private String cacheName; + + public DefaultSimpleCache() + { + // Create a LinkedHashMap with accessOrder true, i.e. iteration order + // will be least recently accessed first. Eviction policy will therefore be LRU. + // The map will have a bounded size determined by the maxItems member variable. + map = (Map) Collections.synchronizedMap(new LinkedHashMap(16, 0.75f, true) { + private static final long serialVersionUID = 1L; + @Override + protected boolean removeEldestEntry(Entry eldest) + { + return maxItems > 0 && size() > maxItems; + } + }); + } + + @Override + public boolean contains(K key) + { + return map.containsKey(key); + } + + @Override + public Collection getKeys() + { + return map.keySet(); + } + + @Override + public V get(K key) + { + return map.get(key); + } + + @Override + public void put(K key, V value) + { + map.put(key, value); + } + + @Override + public void remove(K key) + { + map.remove(key); + } + + @Override + public void clear() + { + map.clear(); + } + + @Override + public String toString() + { + return "DefaultSimpleCache[maxItems=" + maxItems + ", cacheName=" + cacheName + "]"; + } + + /** + * Sets the maximum number of items that the cache will hold. Setting + * this value will cause the cache to be emptied. A value of zero + * will allow the cache to grow unbounded. + * + * @param maxItems + */ + public void setMaxItems(int maxItems) + { + synchronized(map) + { + map.clear(); + this.maxItems = maxItems; + } + } + + /** + * Since there are many cache instances, it is useful to be able to associate + * a name with each one. + * + * @param cacheName Set automatically by Spring, but can be set manually if required. + */ + @Override + public void setBeanName(String cacheName) + { + this.cacheName = cacheName; + } +} diff --git a/source/java/org/alfresco/repo/cache/DefaultSimpleCacheTest.java b/source/java/org/alfresco/repo/cache/DefaultSimpleCacheTest.java new file mode 100644 index 0000000000..7f6dd7171e --- /dev/null +++ b/source/java/org/alfresco/repo/cache/DefaultSimpleCacheTest.java @@ -0,0 +1,157 @@ +/* + * Copyright (C) 2005-2012 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.repo.cache; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + +import java.util.Iterator; + +import org.junit.Before; +import org.junit.Test; + +/** + * Tests for the DefaultSimpleCache class. + * + * @author Matt Ward + */ +public class DefaultSimpleCacheTest +{ + private DefaultSimpleCache cache; + + @Before + public void setUp() + { + cache = new DefaultSimpleCache(); + } + + @Test + public void unboundedSizeCache() + { + cache.put(1, "1"); + cache.put(2, "2"); + cache.put(3, "3"); + cache.put(4, "4"); + cache.put(5, "5"); + + assertEquals("1", cache.get(1)); + assertEquals("2", cache.get(2)); + assertEquals("3", cache.get(3)); + assertEquals("4", cache.get(4)); + assertEquals("5", cache.get(5)); + } + + @Test + public void boundedSizeCache() + { + // We'll only keep the LAST 3 items + cache.setMaxItems(3); + + cache.put(1, "1"); + cache.put(2, "2"); + cache.put(3, "3"); + cache.put(4, "4"); + cache.put(5, "5"); + + // Lost the first item + assertNull(cache.get(1)); + assertFalse(cache.contains(1)); + + // Lost the second item + assertNull(cache.get(2)); + assertFalse(cache.contains(2)); + + // Last three are still present + assertEquals("3", cache.get(3)); + assertEquals("4", cache.get(4)); + assertEquals("5", cache.get(5)); + } + + @Test + public void canStoreNullValues() + { + cache.put(2, null); + assertEquals(null, cache.get(2)); + // Check that the key has an entry against it. + assertTrue(cache.contains(2)); + + // Ensure that a key that has not been assigned is discernable + // from a key that has been assigned a null value. + assertEquals(null, cache.get(4)); + assertFalse(cache.contains(4)); + } + + @Test + public void canRemoveItems() + { + cache.put(1, "hello"); + cache.put(2, "world"); + assertEquals("hello", cache.get(1)); + assertEquals("world", cache.get(2)); + + cache.remove(2); + assertEquals("hello", cache.get(1)); + assertEquals(null, cache.get(2)); + assertEquals(false, cache.contains(2)); + } + + @Test + public void canClearItems() + { + cache.put(1, "hello"); + cache.put(2, "world"); + assertEquals("hello", cache.get(1)); + assertEquals("world", cache.get(2)); + + cache.clear(); + + assertEquals(null, cache.get(1)); + assertEquals(false, cache.contains(1)); + assertEquals(null, cache.get(2)); + assertEquals(false, cache.contains(2)); + } + + @Test + public void canGetKeys() + { + cache.put(3, "blue"); + cache.put(12, "red"); + cache.put(43, "olive"); + + Iterator it = cache.getKeys().iterator(); + assertEquals(3, it.next().intValue()); + assertEquals(12, it.next().intValue()); + assertEquals(43, it.next().intValue()); + assertFalse("There should be no more keys.", it.hasNext()); + } + + @Test + public void clearUponSetMaxItems() + { + cache.put(1, "1"); + assertTrue(cache.contains(1)); + + cache.setMaxItems(10); + + // The item should have gone. + assertFalse(cache.contains(1)); + } +} diff --git a/source/java/org/alfresco/repo/cache/EhCacheAdapter.java b/source/java/org/alfresco/repo/cache/EhCacheAdapter.java deleted file mode 100644 index 5586ed7dad..0000000000 --- a/source/java/org/alfresco/repo/cache/EhCacheAdapter.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (C) 2005-2010 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.repo.cache; - -import java.io.Serializable; -import java.util.Collection; - -import net.sf.ehcache.Cache; -import net.sf.ehcache.CacheException; -import net.sf.ehcache.Element; - -import org.alfresco.error.AlfrescoRuntimeException; - -/** - * A thin adapter for Ehcache support. - *

- * Thread-safety is taken care of by the underlying Ehcache - * instance. - * - * @see org.springframework.cache.ehcache.EhCacheFactoryBean - * @see org.springframework.cache.ehcache.EhCacheManagerFactoryBean - * - * @author Derek Hulley - */ -public class EhCacheAdapter - implements SimpleCache -{ - private net.sf.ehcache.Cache cache; - - public EhCacheAdapter() - { - } - - /** - * @param cache the backing Ehcache instance - */ - public void setCache(Cache cache) - { - this.cache = cache; - } - - public boolean contains(K key) - { - try - { - return (cache.getQuiet(key) != null); - } - catch (CacheException e) - { - throw new AlfrescoRuntimeException("contains failed", e); - } - } - - @SuppressWarnings("unchecked") - public Collection getKeys() - { - return cache.getKeys(); - } - - @SuppressWarnings("unchecked") - public V get(K key) - { - try - { - Element element = cache.get(key); - if (element != null) - { - return (V) element.getObjectValue(); - } - else - { - return null; - } - } - catch (IllegalStateException ie) - { - throw new AlfrescoRuntimeException("Failed to get from EhCache as state invalid: \n" + - " state: " + cache.getStatus() + "\n" + - " key: " + key, - ie); - } - catch (CacheException e) - { - throw new AlfrescoRuntimeException("Failed to get from EhCache: \n" + - " key: " + key, - e); - } - } - - public void put(K key, V value) - { - Element element = new Element(key, value); - cache.put(element); - } - - public void remove(K key) - { - cache.remove(key); - } - - public void clear() - { - cache.removeAll(); - } -} diff --git a/source/java/org/alfresco/repo/cache/EhCacheManagerFactoryBean.java b/source/java/org/alfresco/repo/cache/EhCacheManagerFactoryBean.java deleted file mode 100644 index c4b2114749..0000000000 --- a/source/java/org/alfresco/repo/cache/EhCacheManagerFactoryBean.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (C) 2005-2010 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.repo.cache; - -import java.io.IOException; -import java.net.URL; - -import net.sf.ehcache.CacheException; -import net.sf.ehcache.CacheManager; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.util.PropertyCheck; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import org.springframework.beans.factory.DisposableBean; -import org.springframework.beans.factory.FactoryBean; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.core.io.Resource; - -/** - * This is virtually a copy of the Springframework version, with the exception - * that it uses the newer constructors for the EHCacheManager - * instances. - * - * @author Derek Hulley - */ -public class EhCacheManagerFactoryBean implements FactoryBean, InitializingBean, DisposableBean -{ - static - { - // https://jira.terracotta.org/jira/browse/EHC-652 - // Force old-style LruMemoryStore - // System.setProperty("net.sf.ehcache.use.classic.lru", "true"); - } - - protected final Log logger = LogFactory.getLog(EhCacheManagerFactoryBean.class); - - private Resource configLocation; - private CacheManager cacheManager; - - /** - * - * @param configLocation a resource location using the file: or classpath: prefix - */ - public void setConfigLocation(Resource configLocation) - { - this.configLocation = configLocation; - } - - public void afterPropertiesSet() throws IOException, CacheException - { - PropertyCheck.mandatory(this, "configLocation", configLocation); - - // Double-check the config location or EHCache will throw an NPE - try - { - URL configUrl = this.configLocation.getURL(); - logger.info("Initializing EHCache CacheManager using URL: " + configLocation); - this.cacheManager = new CacheManager(configUrl); - } - catch (IOException e) - { - throw new AlfrescoRuntimeException("Unabled to read EHCache configuration file at " + configLocation, e); - } - } - - public Object getObject() - { - return this.cacheManager; - } - - @SuppressWarnings("unchecked") - public Class getObjectType() - { - return (this.cacheManager != null ? this.cacheManager.getClass() : CacheManager.class); - } - - public boolean isSingleton() - { - return true; - } - - public void destroy() - { - logger.info("Shutting down EHCache CacheManager"); - if(logger.isDebugEnabled()) { - String[] caches = this.cacheManager.getCacheNames(); - for(String cache : caches) { - logger.debug("Shutting down EHCache instance " + cache); - } - } - this.cacheManager.shutdown(); - } -} diff --git a/source/java/org/alfresco/repo/cache/EhCacheTracerJob.java b/source/java/org/alfresco/repo/cache/EhCacheTracerJob.java deleted file mode 100644 index 6a71c6b163..0000000000 --- a/source/java/org/alfresco/repo/cache/EhCacheTracerJob.java +++ /dev/null @@ -1,250 +0,0 @@ -/* - * Copyright (C) 2005-2010 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.repo.cache; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.ObjectOutputStream; -import java.io.Serializable; -import java.util.List; - -import net.sf.ehcache.Cache; -import net.sf.ehcache.CacheException; -import net.sf.ehcache.CacheManager; -import net.sf.ehcache.Element; -import net.sf.ehcache.Status; -import net.sf.ehcache.statistics.LiveCacheStatistics; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.quartz.Job; -import org.quartz.JobExecutionContext; -import org.quartz.JobExecutionException; - -/** - * Analyzes the size of EHCache caches used. - *

- * To activate this class, call the {@link #init()} method. - * - * @author Derek Hulley - */ -public class EhCacheTracerJob implements Job -{ - private static Log logger = LogFactory.getLog(EhCacheTracerJob.class); - - private CacheManager cacheManager; - - /** - * Set the cache manager to analyze. The default cache manager will be analyzed - * if this property is not set. - * - * @param cacheManager optional cache manager to analyze - */ - public void setCacheManager(CacheManager cacheManager) - { - this.cacheManager = cacheManager; - } - - public void execute(JobExecutionContext context) throws JobExecutionException - { - try - { - execute(); - } - catch (Throwable e) - { - logger.error("Exception during execution of job", e); - } - } - - private void execute() throws Exception - { - if (cacheManager == null) - { - cacheManager = InternalEhCacheManagerFactoryBean.getInstance(); - } - - long maxHeapSize = Runtime.getRuntime().maxMemory(); - long allCachesTotalSize = 0L; - double estimatedMaxSize = 0L; - // get all the caches - String[] cacheNames = cacheManager.getCacheNames(); - logger.debug("Dumping EHCache info:"); - boolean analyzeAll = true; - for (String cacheName : cacheNames) - { - Cache cache = cacheManager.getCache(cacheName); - //cache.getCacheEventNotificationService(). -// cache.registerCacheUsageListener(cacheUsageListener) - if (cache == null) // perhaps a temporary cache - { - continue; - } - Log cacheLogger = LogFactory.getLog(this.getClass().getName() + "." + cacheName); - // log each cache to its own logger - // dump - if (cacheLogger.isDebugEnabled()) - { - CacheAnalysis analysis = new CacheAnalysis(cache); - cacheLogger.debug(analysis); - // get the size - allCachesTotalSize += analysis.getSize(); - double cacheEstimatedMaxSize = analysis.getEstimatedMaxSize(); - estimatedMaxSize += (Double.isNaN(cacheEstimatedMaxSize) || Double.isInfinite(cacheEstimatedMaxSize)) - ? 0.0 - : cacheEstimatedMaxSize; - } - else - { - analyzeAll = false; - } - } - if (analyzeAll) - { - // check the size - double sizePercentage = (double)allCachesTotalSize / (double)maxHeapSize * 100.0; - double maxSizePercentage = estimatedMaxSize / (double)maxHeapSize * 100.0; - String msg = String.format( - "EHCaches currently consume %5.2f MB or %3.2f percent of system VM size. \n" + - "The estimated maximum size is %5.2f MB or %3.2f percent of system VM size.", - (double)allCachesTotalSize / 1024.0 / 1024.0, - sizePercentage, - estimatedMaxSize / 1024.0 / 1024.0, - maxSizePercentage); - logger.debug(msg); - } - } - - private static class CacheAnalysis - { - private Cache cache; - private long size = 0L; - double sizeMB; - long maxSize; - long currentSize; - long hitCount; - long missCount; - double percentageFull; - double estMaxSize; - - public CacheAnalysis(Cache cache) throws CacheException - { - this.cache = cache; - if (this.cache.getStatus().equals(Status.STATUS_ALIVE)) - { - try - { - calculateSize(); - } - catch (Throwable e) - { - // just ignore - } - } - } - - public synchronized long getSize() - { - return size; - } - - public synchronized double getEstimatedMaxSize() - { - return estMaxSize; - } - - @SuppressWarnings("unchecked") - private synchronized void calculateSize() throws CacheException - { - // calculate the cache deep size - EHCache 1.1 is always returning 0L - List keys = cache.getKeys(); - // only count a maximum of 1000 entities - int count = 0; - for (Serializable key : keys) - { - Element element = cache.get(key); - size += getSize(element); - count++; - if (count >= 50) - { - break; - } - } - - // the size must be multiplied by the ratio of the count to actual size - size = count > 0 ? (long) ((double)size * ((double)keys.size()/(double)count)) : 0L; - - sizeMB = (double)size/1024.0/1024.0; - LiveCacheStatistics statistics = cache.getLiveCacheStatistics(); - maxSize = cache.getCacheConfiguration().getMaxElementsInMemory(); - currentSize = cache.getMemoryStoreSize(); - hitCount = statistics.getCacheHitCount(); - missCount = statistics.getCacheMissCount(); - percentageFull = (double)currentSize / (double)maxSize * 100.0; - estMaxSize = size / (double) currentSize * (double) maxSize; - } - - private long getSize(Serializable obj) - { - ByteArrayOutputStream bout = new ByteArrayOutputStream(1024); - ObjectOutputStream oos = null; - try - { - oos = new ObjectOutputStream(bout); - oos.writeObject(obj); - return bout.size(); - } - catch (IOException e) - { - logger.warn("Deep size calculation failed for cache: \n" + cache); - return 0L; - } - finally - { - try { oos.close(); } catch (IOException e) {} - } - } - - public String toString() - { - double sizeMB = (double)getSize()/1024.0/1024.0; - LiveCacheStatistics statistics = cache.getLiveCacheStatistics(); - long maxSize = cache.getCacheConfiguration().getMaxElementsInMemory(); - long currentSize = cache.getMemoryStoreSize(); - long hitCount = statistics.getCacheHitCount(); - long totalMissCount = statistics.getCacheMissCount() + statistics.getCacheMissCountExpired(); - double hitRatio = (double)hitCount / (double)(totalMissCount + hitCount) * 100.0; - double percentageFull = (double)currentSize / (double)maxSize * 100.0; - double estMaxSize = sizeMB / (double) currentSize * (double) maxSize; - - StringBuilder sb = new StringBuilder(512); - sb.append("\n") - .append("===> EHCache: ").append(cache).append("\n") - .append(" Hit Ratio: ").append(String.format("%10.2f percent ", hitRatio )) - .append(" | Hit Count: ").append(String.format("%10d hits ", hitCount )) - .append(" | Miss Count: ").append(String.format("%10d misses ", totalMissCount )).append("\n") - .append(" Deep Size: ").append(String.format("%10.2f MB ", sizeMB )) - .append(" | Current Count: ").append(String.format("%10d entries ", currentSize )).append("\n") - .append(" Percentage used: ").append(String.format("%10.2f percent", percentageFull)) - .append(" | Max Count: ").append(String.format("%10d entries ", maxSize )).append("\n") - .append(" Estimated maximum size: ").append(String.format("%10.2f MB ", estMaxSize )); - return sb.toString(); - } - } -} diff --git a/source/java/org/alfresco/repo/cache/HibernateSimpleCacheAdapter.java b/source/java/org/alfresco/repo/cache/HibernateSimpleCacheAdapter.java new file mode 100644 index 0000000000..2717b61860 --- /dev/null +++ b/source/java/org/alfresco/repo/cache/HibernateSimpleCacheAdapter.java @@ -0,0 +1,154 @@ +/* + * Copyright (C) 2005-2012 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.repo.cache; + +import java.io.Serializable; +import java.util.Map; + +import org.hibernate.cache.Cache; +import org.hibernate.cache.CacheException; +import org.hibernate.cache.Timestamper; + +/** + * Adapts a {@link SimpleCache} instance for use as a Hibernate {@link Cache}. + * + * @author Matt Ward + */ +public class HibernateSimpleCacheAdapter implements Cache +{ + private final SimpleCache cache; + private final String regionName; + + /** + * Adapt a + * @param cache + * @param regionName + */ + public HibernateSimpleCacheAdapter(SimpleCache cache, String regionName) + { + this.cache = cache; + this.regionName = regionName; + } + + @Override + public Object read(Object key) throws CacheException + { + return cache.get(serializable(key)); + } + + @Override + public Object get(Object key) throws CacheException + { + return cache.get(serializable(key)); + } + + @Override + public void put(Object key, Object value) throws CacheException + { + cache.put(serializable(key), value); + } + + @Override + public void update(Object key, Object value) throws CacheException + { + cache.put(serializable(key), value); + } + + @Override + public void remove(Object key) throws CacheException + { + cache.remove(serializable(key)); + } + + @Override + public void clear() throws CacheException + { + cache.clear(); + } + + @Override + public void destroy() throws CacheException + { + // NoOp + } + + @Override + public void lock(Object key) throws CacheException + { + // NoOp + } + + @Override + public void unlock(Object key) throws CacheException + { + // NoOp + } + + @Override + public long nextTimestamp() + { + return Timestamper.next(); + } + + @Override + public int getTimeout() + { + return Timestamper.ONE_MS * 60000; // 1 minute + } + + @Override + public String getRegionName() + { + return regionName; + } + + @Override + public long getSizeInMemory() + { + return -1; + } + + @Override + public long getElementCountInMemory() + { + return -1; + } + + @Override + public long getElementCountOnDisk() + { + return 0; + } + + @Override + public Map toMap() + { + throw new UnsupportedOperationException(); + } + + private Serializable serializable(Object obj) + { + if (!(obj instanceof Serializable)) + { + throw new IllegalArgumentException("Object is not Serializable, class=" + obj.getClass().getName()); + } + return (Serializable) obj; + } + +} diff --git a/source/java/org/alfresco/repo/cache/InternalEhCacheManagerFactoryBean.java b/source/java/org/alfresco/repo/cache/InternalEhCacheManagerFactoryBean.java deleted file mode 100644 index a2cf2fc0c8..0000000000 --- a/source/java/org/alfresco/repo/cache/InternalEhCacheManagerFactoryBean.java +++ /dev/null @@ -1,250 +0,0 @@ -/* - * Copyright (C) 2005-2010 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.repo.cache; - -import java.io.FileNotFoundException; -import java.net.URL; -import java.util.Properties; - -import net.sf.ehcache.CacheManager; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.hibernate.cache.Cache; -import org.hibernate.cache.CacheException; -import org.hibernate.cache.CacheProvider; -import org.hibernate.cache.EhCache; -import org.hibernate.cache.EhCacheProvider; -import org.hibernate.cache.Timestamper; -import org.springframework.beans.factory.FactoryBean; -import org.springframework.util.ResourceUtils; - -/** - * Alfresco-specific cache manager factory. - *

- * The purpose of this bean is to provide a common point from which the system-wide - * EHCache CacheManager singleton is created. Hibernate and Spring - * will all pick up the same CacheManager instance. It then becomes - * possible to initialise this instance in whichever way we require, provided it - * is done in a well-known (non-configurable) way. - *

- * For Alfresco purposes, there are two files that are looked for: - *

    - *
  • classpath:alfresco/extension/ehcache-custom.xml, which will take precedence
  • - *
  • classpath:alfresco/ehcache-default.xml, which is the default shipped with Alfresco
  • - *
- *

- * The EHCache static singleton instance is used but ensuring that all access to the - * instance goes through the required initialization code first. - *

- * TODO: Provide mixing of config so that cache definitions in the custom file override - * those in the default file - * - * @see #getInstance() - * - * @author Derek Hulley - */ -public class InternalEhCacheManagerFactoryBean implements FactoryBean, CacheProvider -{ - static - { - // https://jira.terracotta.org/jira/browse/EHC-652 - // Force old-style LruMemoryStore - // System.setProperty("net.sf.ehcache.use.classic.lru", "true"); - } - - public static final String CUSTOM_CONFIGURATION_FILE = "classpath:alfresco/extension/ehcache-custom.xml"; - public static final String DEFAULT_CONFIGURATION_FILE = "classpath:alfresco/ehcache-default.xml"; - - private static Log logger = LogFactory.getLog(InternalEhCacheManagerFactoryBean.class); - - /** keep track of the singleton status to avoid work */ - private static boolean initialized; - /** the CacheManager */ - private static CacheManager cacheManager; - /** used to ensure that the existing Hibernate logic is maintained */ - private static EhCacheProvider hibernateEhCacheProvider = new EhCacheProvider(); - - /** - * Default constructor required by Hibernate. In fact, we anticipate several - * instances of this class to be created. - */ - public InternalEhCacheManagerFactoryBean() - { - } - - /** - * News up the singleton cache manager according to the rules set out - * in the class comments. - */ - private static synchronized void initCacheManager() - { - if (initialized) - { - return; - } - try - { - boolean defaultLocation = false; - try - { - URL configUrl = ResourceUtils.getURL(CUSTOM_CONFIGURATION_FILE); - InternalEhCacheManagerFactoryBean.cacheManager = CacheManager.create(configUrl); - } - catch (FileNotFoundException e) - { - // try the alfresco default - URL configUrl = ResourceUtils.getURL(DEFAULT_CONFIGURATION_FILE); - if (configUrl == null) - { - throw new AlfrescoRuntimeException("Missing default cache config: " + DEFAULT_CONFIGURATION_FILE); - } - InternalEhCacheManagerFactoryBean.cacheManager = new CacheManager(configUrl); - defaultLocation = true; - } - // done - if (logger.isDebugEnabled()) - { - logger.debug("Created EHCache CacheManager instance: \n" + - " configuration: " + (defaultLocation ? DEFAULT_CONFIGURATION_FILE : CUSTOM_CONFIGURATION_FILE)); - } - initialized = true; - } - catch (Throwable e) - { - throw new AlfrescoRuntimeException("EHCache configuration failed", e); - } - } - - /** - * @return Returns the properly initialized instance for Alfresco internal use - * - * @see #initCacheManager() - */ - public static CacheManager getInstance() - { - if (!InternalEhCacheManagerFactoryBean.initialized) - { - InternalEhCacheManagerFactoryBean.initCacheManager(); - } - return InternalEhCacheManagerFactoryBean.cacheManager; - } - - public Cache buildCache(String regionName, Properties properties) throws CacheException - { - CacheManager manager = InternalEhCacheManagerFactoryBean.getInstance(); - try - { - net.sf.ehcache.Cache cache = manager.getCache(regionName); - if (cache == null) - { - logger.info("Using default cache configuration: " + regionName); - manager.addCache(regionName); - cache = manager.getCache(regionName); - logger.debug("Started EHCache region: " + regionName); - } - return new EhCache(cache); - } - catch (net.sf.ehcache.CacheException e) - { - throw new CacheException(e); - } - } - - /** - * @see #hibernateEhCacheProvider - */ - public boolean isMinimalPutsEnabledByDefault() - { - return false; - } - - /** - * @see #hibernateEhCacheProvider - */ - public long nextTimestamp() - { - return Timestamper.next(); - } - - /** - * @see #initCacheManager() - */ - public void start(Properties properties) throws CacheException - { - InternalEhCacheManagerFactoryBean.initCacheManager(); - } - - /** - * @see #initCacheManager() - */ - public void stop() - { - // TODO: Does this port over different Locales? - // Better to override DbPersistenceServiceFactory#close to put a marker on the thread. - if (Thread.currentThread().getName().contains("Finalizer")) - { - // Probably JBPM's finalizer code ... we rely on Spring context calls rather - return; - } - - synchronized (getClass()) - { - if(logger.isDebugEnabled()) { - String[] caches = InternalEhCacheManagerFactoryBean.getInstance().getCacheNames(); - for(String regionName : caches) { - logger.debug("Stopped EHCache region: " + regionName); - } - } - - if (initialized) // Avoid re-initialization if it has already been shut down - { - InternalEhCacheManagerFactoryBean.getInstance().shutdown(); - initialized = false; - } - } - } - - /** - * @return Returns the singleton cache manager - * - * @see #initCacheManager() - */ - public CacheManager getObject() throws Exception - { - return InternalEhCacheManagerFactoryBean.getInstance(); - } - - /** - * @return Returns the singleton cache manager type - */ - public Class getObjectType() - { - return CacheManager.class; - } - - /** - * @return Returns true always - */ - public boolean isSingleton() - { - return true; - } -} diff --git a/source/java/org/alfresco/repo/cache/TransactionalCache.java b/source/java/org/alfresco/repo/cache/TransactionalCache.java index 69d4747259..534ca57d57 100644 --- a/source/java/org/alfresco/repo/cache/TransactionalCache.java +++ b/source/java/org/alfresco/repo/cache/TransactionalCache.java @@ -25,8 +25,6 @@ import java.util.LinkedHashMap; import java.util.Map; import java.util.Set; -import net.sf.ehcache.CacheException; - import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.repo.tenant.TenantService; import org.alfresco.repo.tenant.TenantUtil; @@ -734,7 +732,7 @@ public class TransactionalCache logger.debug("Pre-commit called for " + keys.size() + " values."); } } - catch (CacheException e) + catch (Throwable e) { throw new AlfrescoRuntimeException("Failed to transfer updates to shared cache", e); } @@ -795,7 +793,7 @@ public class TransactionalCache logger.debug("Post-commit called for " + keys.size() + " values."); } } - catch (CacheException e) + catch (Throwable e) { throw new AlfrescoRuntimeException("Failed to transfer updates to shared cache", e); } @@ -837,7 +835,7 @@ public class TransactionalCache } } } - catch (CacheException e) + catch (Throwable e) { throw new AlfrescoRuntimeException("Failed to transfer updates to shared cache", e); } diff --git a/source/java/org/alfresco/repo/cluster/BuildSafeTestSuite.java b/source/java/org/alfresco/repo/cluster/BuildSafeTestSuite.java deleted file mode 100644 index b922fa0974..0000000000 --- a/source/java/org/alfresco/repo/cluster/BuildSafeTestSuite.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2005-2012 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.repo.cluster; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - -/** - * Test suite for org.alfresco.repo.cluster tests, but excluding - * tests which are known to fail in the CI environment (Bamboo). - *

- * These tests are still useful in the desktop development environment however, - * so are kept for this reason. {@link ClusterTestSuite} runs all the tests in this - * suite, plus the offending tests. - * - * @author Matt Ward - */ -@RunWith(Suite.class) -@SuiteClasses({ - org.alfresco.repo.cluster.HazelcastConfigFactoryBeanTest.class, - org.alfresco.repo.cluster.HazelcastMessengerFactoryTest.class, - org.alfresco.repo.cluster.HazelcastMessengerTest.class -}) -public class BuildSafeTestSuite -{ - // Annotations specify the suite. -} diff --git a/source/java/org/alfresco/repo/cluster/ClusterCheckEvent.java b/source/java/org/alfresco/repo/cluster/ClusterCheckEvent.java deleted file mode 100644 index 7d75bc7c6a..0000000000 --- a/source/java/org/alfresco/repo/cluster/ClusterCheckEvent.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2005-2012 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.repo.cluster; - -/** - * - * @since Odin - * - */ -public class ClusterCheckEvent extends ClusterMessageEvent -{ - private static final long serialVersionUID = -4633842466757526069L; - - public ClusterCheckEvent(ClusterChecker clusterChecker, String sourceId, String targetId) - { - super(clusterChecker, sourceId, targetId); - } - -} diff --git a/source/java/org/alfresco/repo/cluster/ClusterChecker.java b/source/java/org/alfresco/repo/cluster/ClusterChecker.java deleted file mode 100644 index 7bbe410402..0000000000 --- a/source/java/org/alfresco/repo/cluster/ClusterChecker.java +++ /dev/null @@ -1,759 +0,0 @@ -/* - * Copyright (C) 2005-2012 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.repo.cluster; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.Serializable; -import java.net.InetAddress; -import java.net.UnknownHostException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.Timer; -import java.util.TimerTask; -import java.util.concurrent.ConcurrentHashMap; - -import org.alfresco.repo.lock.JobLockService; -import org.alfresco.repo.lock.LockAcquisitionException; -import org.alfresco.repo.security.authentication.AuthenticationException; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; -import org.alfresco.service.cmr.security.AuthenticationService; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.alfresco.service.transaction.TransactionService; -import org.alfresco.util.EqualsHelper; -import org.alfresco.util.GUID; -import org.alfresco.util.TempFileProvider; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.beans.BeansException; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextAware; -import org.springframework.context.ApplicationEvent; - -/** - * Checks that the cluster is working. - * - * @since Odin - * - */ -public class ClusterChecker implements MessageReceiver, ApplicationContextAware -{ - private static final Log logger = LogFactory.getLog(ClusterChecker.class); - private static final String TmpFile = ".clusterChecker"; - private static final QName LOCK = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "ClusterChecker"); - - /* - * WORKING: is synced with other nodes in the cluster - * NOTWORKING: is alive but not synced with other nodes in the cluster - * UNKNOWN: status is unknown (could be in the middle of checking) - * CHECKING: still waiting for cluster check response - */ - public static enum NodeStatus - { - WORKING, NOTWORKING, TIMEOUT, UNKNOWN; - }; - - // time to wait for a cluster node to respond - private int timeout = 4000; // ms - - private ApplicationContext applicationContext; - private AuthenticationService authenticationService; - private TransactionService transactionService; - private MessengerFactory messengerFactory; - private JobLockService jobLockService; - - private Messenger messenger; - - private Timer timer = new Timer(); - - // cluster nodes that this node knows about - private Map nodeInfo = new ConcurrentHashMap(); - - // unique id for this cluster node - private String id = null; - - public ClusterChecker() throws FileNotFoundException, IOException, ClassNotFoundException - { - this.id = buildId(); - } - - private String buildId() throws FileNotFoundException, IOException, ClassNotFoundException - { - // we need an immutable unique id for the cluster node - String guid = null; - - File systemTmpDir = TempFileProvider.getSystemTempDir(); - File tmpFile = new File(systemTmpDir, TmpFile); - - // persist the id locally - if(!tmpFile.exists()) - { - guid = GUID.generate(); - tmpFile.createNewFile(); - ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(tmpFile)); - out.writeObject(guid); - out.close(); - } - else - { - ObjectInputStream in = new ObjectInputStream(new FileInputStream(tmpFile)); - guid = (String)in.readObject(); - in.close(); - } - - return guid; - } - - /** - * Attempts to get the lock. If the lock couldn't be taken, then null is returned. - * - * @return Returns the lock token or null - */ - private String getLock(long time) - { - try - { - return jobLockService.getLock(LOCK, time); - } - catch (LockAcquisitionException e) - { - return null; - } - } - - public void init() - { - this.messenger = messengerFactory.createMessenger(getClass().getName(), true); - messenger.setReceiver(this); - } - - public void shutdown() - { - cancelTimer(); - } - - public void setTimeout(int timeout) - { - this.timeout = timeout; - } - - public void setJobLockService(JobLockService jobLockService) - { - this.jobLockService = jobLockService; - } - - public void setTransactionService(TransactionService transactionService) - { - this.transactionService = transactionService; - } - - public void setAuthenticationService(AuthenticationService authenticationService) - { - this.authenticationService = authenticationService; - } - - public void setMessengerFactory(MessengerFactory messengerFactory) - { - this.messengerFactory = messengerFactory; - } - - private void cancelTimer() - { - timer.cancel(); - } - - private NodeInfo registerNode(String id) - { - NodeInfo info = new NodeInfo(id); - nodeInfo.put(id, info); - return info; - } - - private void checkCluster() - { - // set the status of any currently tracked to 'checking' - for(NodeInfo info : nodeInfo.values()) - { - info.setChecking(true); - } - - // Authenticate and get a ticket. This will be used to validate that the other nodes in the cluster are - // 'working' i.e. their caches are updating in the cluster. - try - { - AuthenticationUtil.pushAuthentication(); - AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName()); - String ticket = authenticationService.getCurrentTicket(); - messenger.send(new ClusterValidateEvent(this, ticket, id, null)); - } - catch(AuthenticationException e) - { - logger.warn("Unable to check cluster, authentication failed", e); - return; - } - finally - { - AuthenticationUtil.popAuthentication(); - } - - // A timer to mark nodes still in the checking state as not alive after a timeout. - timer.schedule(new TimerTask() - { - @Override - public void run() - { - for(NodeInfo info : nodeInfo.values()) - { - List timedOut = info.timeoutNodes(); - for(String nodeId : timedOut) - { - nodePairStatusChange(info.getId(), nodeId, NodeStatus.TIMEOUT); - } - } - } - }, timeout); - } - - private void nodePairStatusChange(String sourceNodeId, String targetNodeId, NodeStatus status) - { - publishEvent(new ClusterNodePairStatusEvent(this, sourceNodeId, targetNodeId, status)); - } - - private void nodeFound(String nodeId) - { - publishEvent(new ClusterNodeExistsEvent(this, nodeId)); - } - - private String getAddress() - { - try - { - return InetAddress.getLocalHost().getHostName(); - } - catch(UnknownHostException e) - { - return "Unknown"; - } - } - - private void publishEvent(ApplicationEvent event) - { - applicationContext.publishEvent(event); - } - - private void handleValidationEvent(ClusterValidateEvent validateEvent) - { - String sourceId = validateEvent.getSourceId(); - String ticket = validateEvent.getTicket(); - - // try to validate the ticket generated by the source node - boolean ticketValid = true; - try - { - AuthenticationUtil.pushAuthentication(); - authenticationService.validate(ticket); - if(!authenticationService.getCurrentUserName().equals(AuthenticationUtil.getAdminUserName())) - { - ticketValid = false; - } - } - catch(AuthenticationException e) - { - ticketValid = false; - } - finally - { - AuthenticationUtil.popAuthentication(); - } - - messenger.send(new ClusterValidateResponseEvent(this, getAddress(), sourceId, id, ticketValid)); - } - - private void handleValidationResponse(ClusterValidateResponseEvent validateResponseEvent) - { - String sourceId = validateResponseEvent.getSourceId(); - String targetId = validateResponseEvent.getTargetId(); - String address = validateResponseEvent.getAddress(); // target address - - NodeInfo source = getNodeInfo(sourceId); - boolean newSourceNode = false; - if(source == null) - { - source = registerNode(sourceId); - newSourceNode = true; - } - - // update the target's address, if it isn't known already - boolean newTargetNode = false; - NodeInfo remote = getNodeInfo(targetId); - if(remote == null) - { - remote = registerNode(targetId); - newTargetNode = true; - } - remote.setAddress(address); - - // update source node's view of the target's status - boolean ticketValid = validateResponseEvent.isTicketValid(); - NodeStatus newTargetStatus = ticketValid ? NodeStatus.WORKING : NodeStatus.NOTWORKING; - source.setStatus(targetId, newTargetStatus); - - if(newSourceNode) - { - nodeFound(sourceId); - } - - if(newTargetNode) - { - nodeFound(targetId); - } - - if(!sourceId.equals(targetId) && newTargetStatus != NodeStatus.UNKNOWN) - { - nodePairStatusChange(sourceId, targetId, newTargetStatus); - } - } - - public boolean isConnected() - { - return messenger.isConnected(); - } - - public boolean isClusterActive() - { - return messengerFactory.isClusterActive(); - } - - public Map getNodeInfo() - { - return Collections.unmodifiableMap(nodeInfo); - } - - public NodeInfo getNodeInfo(String nodeId) - { - return nodeInfo.get(nodeId); - } - - public String getId() - { - return id; - } - - public void check() - { - // Take out a lock to prevent more than one check at a time - RetryingTransactionCallback txnWork = new RetryingTransactionCallback() - { - public String execute() throws Exception - { - String lockToken = getLock(timeout + 1000); - return lockToken; - } - }; - - final String lockToken = transactionService.getRetryingTransactionHelper().doInTransaction(txnWork, false, true); - if(lockToken == null) - { - logger.warn("Can't get lock. Assume multiple cluster checkers ..."); - return; - } - - // Kick off the check by broadcasting the initiating event to each node in the cluster - if (messenger.isConnected()) - { - messenger.send(new ClusterCheckEvent(this, id, null)); - } - - // A timer to release the lock after a timeout - timer.schedule(new TimerTask() - { - @Override - public void run() - { - jobLockService.releaseLock(lockToken, LOCK); - } - }, timeout); - } - - public List getPeers(String nodeId) - { - NodeInfo nodeInfo = getNodeInfo(nodeId); - Map peersInfo = nodeInfo.getPeersInfo(); - - List ret = new ArrayList(); - for(String peerId : peersInfo.keySet()) - { - if(peerId.equals(nodeId)) - { - continue; - } - NodeInfo peerInfo = getNodeInfo(peerId); - NodeStatus peerStatus = peersInfo.get(peerId).getNodeStatus(); - String peerAddress = peerInfo.getAddress(); - ret.add(new PeerNodeInfo(peerId, peerAddress, peerStatus)); - } - - return ret; - } - - public void stopChecking(String nodeId) - { - if(nodeInfo.containsKey(nodeId)) - { - nodeInfo.remove(nodeId); - } - for(NodeInfo node : nodeInfo.values()) - { - node.stopChecking(nodeId); - } - publishEvent(new ClusterNodeStopTrackingEvent(this, nodeId)); - } - - @Override - public void onReceive(ClusterMessageEvent event) - { - if (event == null) - { - return; - } - - if(event instanceof ClusterCheckEvent) - { - checkCluster(); - } - else if(event instanceof ClusterValidateEvent) - { - // handle validation request from another node - handleValidationEvent((ClusterValidateEvent)event); - } - else if(event instanceof ClusterValidateResponseEvent) - { - // handle response to a validation request - handleValidationResponse((ClusterValidateResponseEvent)event); - } - } - - public Set> getNonWorkingNodePairs() - { - Set> nonWorkingPairs = new HashSet>(); - - for(NodeInfo node : nodeInfo.values()) - { - // a cluster node is regarded as working only if every other node agrees - // notes that for a 2 node cluster with one node down, the other node will still be regarded - // as not working because there are no other nodes to counter the non-working node. - nonWorkingPairs.addAll(node.getNonWorkingPeers()); - } - - return nonWorkingPairs; - } - - @Override - public void setApplicationContext(ApplicationContext applicationContext) throws BeansException - { - this.applicationContext = applicationContext; - } - - // Records information on a peer i.e. whether it is being checked and its status - private static class PeerStatus - { - private boolean checking; - private NodeStatus nodeStatus; - - public PeerStatus() - { - this.checking = false; - this.nodeStatus = NodeStatus.UNKNOWN; - } - - public boolean isChecking() - { - return checking; - } - - void setChecking(boolean checking) - { - this.checking = checking; - } - - public NodeStatus getNodeStatus() - { - return nodeStatus; - } - - void setNodeStatus(NodeStatus nodeStatus) - { - this.nodeStatus = nodeStatus; - } - } - - public static class PeerNodeInfo - { - private String peerId; - private String peerAddress; - private NodeStatus peerStatus; - - public PeerNodeInfo(String peerId, String peerAddress, NodeStatus peerStatus) { - super(); - this.peerId = peerId; - this.peerAddress = peerAddress; - this.peerStatus = peerStatus; - } - - public String getPeerId() - { - return peerId; - } - - public String getPeerAddress() - { - return peerAddress; - } - - public NodeStatus getPeerStatus() - { - return peerStatus; - } - } - - // Information pertaining to a cluster node and its peers - public static class NodeInfo - { - private String id; - private String address; - private Map nodeInfos = new ConcurrentHashMap(5); - - public NodeInfo(String id) - { - super(); - this.id = id; - } - - public String getId() - { - return id; - } - - public String getAddress() - { - return address; - } - - void setAddress(String address) - { - this.address = address; - } - - void setStatus(String targetId, NodeStatus status) - { - PeerStatus peerStatus = getStatus(targetId, true); - peerStatus.setChecking(false); - peerStatus.setNodeStatus(status); - } - - void stopChecking(String nodeId) - { - nodeInfos.remove(nodeId); - } - - public Map getPeersInfo() - { - return Collections.unmodifiableMap(nodeInfos); - } - - public PeerStatus getStatus(String nodeId) - { - return getStatus(nodeId, false); - } - - public PeerStatus getStatus(String nodeId, boolean create) - { - PeerStatus peerStatus = nodeInfos.get(nodeId); - if(peerStatus == null) - { - peerStatus = new PeerStatus(); - nodeInfos.put(nodeId, peerStatus); - } - return peerStatus; - } - - void setChecking(boolean checking) - { - for(String nodeId : nodeInfos.keySet()) - { - setChecking(nodeId, checking); - } - } - - void setChecking(String nodeId, boolean checking) - { - PeerStatus status = getStatus(nodeId, true); - status.setChecking(checking); - } - - void setStatuses(NodeStatus status) - { - for(String nodeId : nodeInfos.keySet()) - { - setStatus(nodeId, status); - } - } - - List timeoutNodes() - { - List timedOut = new ArrayList(); - - for(String nodeId : nodeInfos.keySet()) - { - if(getStatus(nodeId).isChecking()) - { - setStatus(nodeId, NodeStatus.TIMEOUT); - timedOut.add(nodeId); - } - } - - return timedOut; - } - - public Set> getNonWorkingPeers() - { - Set> nonWorkingPeers = new HashSet>(); - for(String nodeId : nodeInfos.keySet()) - { - if(!getId().equals(nodeId) && getStatus(nodeId).getNodeStatus() != NodeStatus.WORKING) - { - nonWorkingPeers.add(new UnorderedPair(getId(), nodeId)); - } - } - - return nonWorkingPeers; - } - - public boolean equals(Object other) - { - if (this == other) - { - return true; - } - - if(!(other instanceof NodeInfo)) - { - return false; - } - - NodeInfo nodeInfo = (NodeInfo)other; - return EqualsHelper.nullSafeEquals(getId(), nodeInfo.getId()); - } - } - - public static class UnorderedPair implements Serializable - { - private static final long serialVersionUID = -8947346745086237616L; - - @SuppressWarnings({ "unchecked", "rawtypes" }) - public static final UnorderedPair NULL_PAIR = new UnorderedPair(null, null); - - @SuppressWarnings("unchecked") - public static final UnorderedPair nullPair() - { - return NULL_PAIR; - } - - /** - * The first member of the pair. - */ - private T first; - - /** - * The second member of the pair. - */ - private T second; - - /** - * Make a new one. - * - * @param first The first member. - * @param second The second member. - */ - public UnorderedPair(T first, T second) - { - this.first = first; - this.second = second; - } - - /** - * Get the first member of the tuple. - * @return The first member. - */ - public final T getFirst() - { - return first; - } - - /** - * Get the second member of the tuple. - * @return The second member. - */ - public final T getSecond() - { - return second; - } - - @Override - public boolean equals(Object other) - { - if (this == other) - { - return true; - } - if (other == null || !(other instanceof UnorderedPair)) - { - return false; - } - UnorderedPair o = (UnorderedPair)other; - return EqualsHelper.nullSafeEquals(this.first, o.first) && - EqualsHelper.nullSafeEquals(this.second, o.second) || - EqualsHelper.nullSafeEquals(this.first, o.second) && - EqualsHelper.nullSafeEquals(this.second, o.first); - } - - @Override - public int hashCode() - { - return (first == null ? 0 : first.hashCode()) + (second == null ? 0 : second.hashCode()); - } - - @Override - public String toString() - { - return "(" + first + ", " + second + ")"; - } - } -} \ No newline at end of file diff --git a/source/java/org/alfresco/repo/cluster/ClusterEvent.java b/source/java/org/alfresco/repo/cluster/ClusterEvent.java deleted file mode 100644 index f33448228e..0000000000 --- a/source/java/org/alfresco/repo/cluster/ClusterEvent.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2005-2012 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.repo.cluster; - -import org.springframework.context.ApplicationEvent; - -/** - * - * @since Odin - * - */ -public class ClusterEvent extends ApplicationEvent -{ - private static final long serialVersionUID = 7481373845772903712L; - - public ClusterEvent(ClusterChecker clusterChecker) - { - super(clusterChecker); - } - -} diff --git a/source/java/org/alfresco/repo/cluster/ClusterMessageEvent.java b/source/java/org/alfresco/repo/cluster/ClusterMessageEvent.java deleted file mode 100644 index 0c15bcf48d..0000000000 --- a/source/java/org/alfresco/repo/cluster/ClusterMessageEvent.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2005-2012 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.repo.cluster; - -/** - * - * @since Odin - * - */ -public class ClusterMessageEvent extends ClusterEvent -{ - private static final long serialVersionUID = -8677530378696271077L; - - private String sourceId; - private String targetId; - - public ClusterMessageEvent(ClusterChecker clusterChecker, String sourceId, String targetId) - { - super(clusterChecker); - this.sourceId = sourceId; - this.targetId = targetId; - } - - public String getSourceId() - { - return sourceId; - } - - public String getTargetId() - { - return targetId; - } - -} diff --git a/source/java/org/alfresco/repo/cluster/ClusterNodeExistsEvent.java b/source/java/org/alfresco/repo/cluster/ClusterNodeExistsEvent.java deleted file mode 100644 index db2bd59850..0000000000 --- a/source/java/org/alfresco/repo/cluster/ClusterNodeExistsEvent.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2005-2012 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.repo.cluster; - -/** - * - * @since Odin - * - */ -public class ClusterNodeExistsEvent extends ClusterEvent -{ - private static final long serialVersionUID = -9060051914186153663L; - public static final String NOTIFICATION_TYPE = "Cluster Node Found"; - - private String nodeId; - - public ClusterNodeExistsEvent(ClusterChecker clusterChecker, String nodeId) - { - super(clusterChecker); - this.nodeId = nodeId; - } - - public String getNodeId() - { - return nodeId; - } - -} diff --git a/source/java/org/alfresco/repo/cluster/ClusterNodePairStatusEvent.java b/source/java/org/alfresco/repo/cluster/ClusterNodePairStatusEvent.java deleted file mode 100644 index 9541796ec5..0000000000 --- a/source/java/org/alfresco/repo/cluster/ClusterNodePairStatusEvent.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (C) 2005-2012 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.repo.cluster; - -import org.alfresco.repo.cluster.ClusterChecker.NodeStatus; - -/** - * - * @Odin - * - */ -public class ClusterNodePairStatusEvent extends ClusterEvent -{ - private static final long serialVersionUID = -4045195741687097066L; - public static final String NOTIFICATION_TYPE = "Cluster Node Pair Status"; - - private String sourceNodeId; - private String targetNodeId; - private NodeStatus status; - - public ClusterNodePairStatusEvent(ClusterChecker clusterChecker, String sourceNodeId, String targetNodeId, NodeStatus status) - { - super(clusterChecker); - this.sourceNodeId = sourceNodeId; - this.targetNodeId = targetNodeId; - this.status = status; - - } - - public String getSourceNodeId() - { - return sourceNodeId; - } - - public String getTargetNodeId() - { - return targetNodeId; - } - - public NodeStatus getStatus() - { - return status; - } - -} \ No newline at end of file diff --git a/source/java/org/alfresco/repo/cluster/ClusterNodeStopTrackingEvent.java b/source/java/org/alfresco/repo/cluster/ClusterNodeStopTrackingEvent.java deleted file mode 100644 index f6415e0452..0000000000 --- a/source/java/org/alfresco/repo/cluster/ClusterNodeStopTrackingEvent.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2005-2012 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.repo.cluster; - -/** - * - * @since Odin - * - */ -public class ClusterNodeStopTrackingEvent extends ClusterEvent -{ - private static final long serialVersionUID = -116885933025872510L; - - public static final String NOTIFICATION_TYPE = "Cluster Node Stop Tracking"; - - private String nodeId; - - public ClusterNodeStopTrackingEvent(ClusterChecker clusterChecker, String nodeId) - { - super(clusterChecker); - this.nodeId = nodeId; - - } - - public String getNodeId() - { - return nodeId; - } - -} diff --git a/source/java/org/alfresco/repo/cluster/ClusterTestSuite.java b/source/java/org/alfresco/repo/cluster/ClusterTestSuite.java deleted file mode 100644 index 502fba17a9..0000000000 --- a/source/java/org/alfresco/repo/cluster/ClusterTestSuite.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2005-2012 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.repo.cluster; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - -/** - * Test suite for the org.alfresco.repo.cluster package. - *

- * This includes tests which will fail on the build servers - - * do not include this suite in the CI build targets. - * - * @author Matt Ward - */ -@RunWith(Suite.class) -@SuiteClasses({ - // Run the standard tests - org.alfresco.repo.cluster.BuildSafeTestSuite.class, - - // Additionally run these tests that cannot be run on the build servers. - org.alfresco.repo.cluster.HazelcastTest.class -}) -public class ClusterTestSuite -{ -} diff --git a/source/java/org/alfresco/repo/cluster/ClusterValidateEvent.java b/source/java/org/alfresco/repo/cluster/ClusterValidateEvent.java deleted file mode 100644 index 7899bf4d4c..0000000000 --- a/source/java/org/alfresco/repo/cluster/ClusterValidateEvent.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2005-2012 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.repo.cluster; - -/** - * - * @since Odin - * - */ -public class ClusterValidateEvent extends ClusterMessageEvent -{ - private static final long serialVersionUID = -8091460189522981871L; - - private String ticket; - - public ClusterValidateEvent(ClusterChecker clusterChecker, String ticket, String sourceId, String targetId) - { - super(clusterChecker, sourceId, targetId); - this.ticket = ticket; - } - - public String getTicket() - { - return ticket; - } -} diff --git a/source/java/org/alfresco/repo/cluster/ClusterValidateResponseEvent.java b/source/java/org/alfresco/repo/cluster/ClusterValidateResponseEvent.java deleted file mode 100644 index 577032c648..0000000000 --- a/source/java/org/alfresco/repo/cluster/ClusterValidateResponseEvent.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2005-2012 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.repo.cluster; - -/** - * - * @since Odin - * - */ -public class ClusterValidateResponseEvent extends ClusterMessageEvent -{ - private static final long serialVersionUID = -813956714769487998L; - - private String address; - private boolean ticketValid; - - public ClusterValidateResponseEvent(ClusterChecker clusterChecker, String address, String sourceId, String targetId, boolean ticketValid) - { - super(clusterChecker, sourceId, targetId); - this.address = address; - this.ticketValid = ticketValid; - } - - public String getAddress() - { - return address; - } - - public boolean isTicketValid() - { - return ticketValid; - } - -} diff --git a/source/java/org/alfresco/repo/cluster/HazelcastConfigFactoryBean.java b/source/java/org/alfresco/repo/cluster/HazelcastConfigFactoryBean.java deleted file mode 100644 index 405535583c..0000000000 --- a/source/java/org/alfresco/repo/cluster/HazelcastConfigFactoryBean.java +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright (C) 2005-2012 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.repo.cluster; - -import java.io.IOException; -import java.io.InputStream; -import java.io.StringWriter; -import java.util.Properties; -import java.util.regex.Pattern; - -import org.apache.commons.io.IOUtils; -import org.springframework.beans.factory.FactoryBean; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.core.io.Resource; - -import com.hazelcast.config.Config; -import com.hazelcast.config.InMemoryXmlConfig; - -/** - * FactoryBean used to create Hazelcast {@link Config} objects. A configuration file is supplied - * in the form of a Spring {@link Resource} and a set of {@link Properties} can also be provided. The - * XML file is processed so that property placeholders of the form ${property.name} are substitued for - * the corresponding property value before the XML is parsed into the Hazelcast configuration object. - * - * @author Matt Ward - */ -public class HazelcastConfigFactoryBean implements InitializingBean, FactoryBean -{ - private static final String PLACEHOLDER_END = "}"; - private static final String PLACEHOLDER_START = "${"; - private Resource configFile; - private Config config; - private Properties properties; - - - /** - * Set the Hazelcast XML configuration file to use. This will be merged with the supplied - * Properties and parsed to produce a final {@link Config} object. - * @param configFile the configFile to set - */ - public void setConfigFile(Resource configFile) - { - this.configFile = configFile; - } - - /** - * Used to supply the set of Properties that the configuration file can reference. - * - * @param properties the properties to set - */ - public void setProperties(Properties properties) - { - this.properties = properties; - } - - /** - * Spring {@link InitializingBean} lifecycle method. Substitutes property placeholders for their - * corresponding values and creates a {@link Config Hazelcast configuration} with the post-processed - * XML file - ready for the {@link #getObject()} factory method to be used to retrieve it. - */ - @Override - public void afterPropertiesSet() throws Exception - { - if (configFile == null) - { - throw new IllegalArgumentException("No configuration file specified."); - } - if (properties == null) - { - properties = new Properties(); - } - - // These configXML strings will be large and are therefore intended - // to be thrown away. We only want to keep the final Config object. - String rawConfigXML = getConfigFileContents(); - String configXML = substituteProperties(rawConfigXML); - config = new InMemoryXmlConfig(configXML); - } - - /** - * For the method parameter text, replaces all occurrences of placeholders having - * the form ${property.name} with the value of the property having the key "property.name". The - * properties are supplied using {@link #setProperties(Properties)}. - * - * @param text The String to apply property substitutions to. - * @return String after substitutions have been applied. - */ - private String substituteProperties(String text) - { - for (String propName : properties.stringPropertyNames()) - { - String propValue = properties.getProperty(propName); - String quotedPropName = Pattern.quote(PLACEHOLDER_START + propName + PLACEHOLDER_END); - text = text.replaceAll(quotedPropName, propValue); - } - - return text; - } - - /** - * Opens the configFile {@link Resource} and reads the contents into a String. - * - * @return the contents of the configFile resource. - */ - private String getConfigFileContents() - { - StringWriter writer = new StringWriter(); - InputStream inputStream = null; - try - { - inputStream = configFile.getInputStream(); - IOUtils.copy(inputStream, writer, "UTF-8"); - return writer.toString(); - } - catch (IOException e) - { - throw new RuntimeException("Couldn't read configuration: " + configFile, e); - } - finally - { - try - { - if (inputStream != null) - { - inputStream.close(); - } - } - catch (IOException e) - { - throw new RuntimeException("Couldn't close stream", e); - } - } - } - - /** - * FactoryBean's factory method. Returns the config with the property key/value - * substitutions in place. - */ - @Override - public Config getObject() throws Exception - { - return config; - } - - @Override - public Class getObjectType() - { - return Config.class; - } - - @Override - public boolean isSingleton() - { - return true; - } -} diff --git a/source/java/org/alfresco/repo/cluster/HazelcastConfigFactoryBeanTest.java b/source/java/org/alfresco/repo/cluster/HazelcastConfigFactoryBeanTest.java deleted file mode 100644 index 5a897852cf..0000000000 --- a/source/java/org/alfresco/repo/cluster/HazelcastConfigFactoryBeanTest.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (C) 2005-2012 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.repo.cluster; - -import static org.junit.Assert.assertEquals; - -import java.util.Properties; - -import org.junit.Before; -import org.junit.Test; -import org.springframework.core.io.ClassPathResource; -import org.springframework.core.io.Resource; - -import com.hazelcast.config.Config; - -/** - * Tests for the HazelcastConfigFactoryBean class. - * - * @author Matt Ward - */ -public class HazelcastConfigFactoryBeanTest -{ - private HazelcastConfigFactoryBean configFactory; - private Resource resource; - private Properties properties; - - @Before - public void setUp() throws Exception - { - configFactory = new HazelcastConfigFactoryBean(); - resource = new ClassPathResource("cluster-test/placeholder-test.xml"); - configFactory.setConfigFile(resource); - - properties = new Properties(); - properties.setProperty("alfresco.hazelcast.password", "let-me-in"); - properties.setProperty("alfresco.cluster.name", "cluster-name"); - configFactory.setProperties(properties); - - // Trigger the spring post-bean creation lifecycle method - configFactory.afterPropertiesSet(); - } - - - @Test - public void testConfigHasNewPropertyValues() throws Exception - { - // Invoke the factory method. - Config config = configFactory.getObject(); - - assertEquals("let-me-in", config.getGroupConfig().getPassword()); - assertEquals("cluster-name", config.getGroupConfig().getName()); - } -} diff --git a/source/java/org/alfresco/repo/cluster/HazelcastInstanceFactory.java b/source/java/org/alfresco/repo/cluster/HazelcastInstanceFactory.java deleted file mode 100644 index feb88886aa..0000000000 --- a/source/java/org/alfresco/repo/cluster/HazelcastInstanceFactory.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright (C) 2005-2012 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.repo.cluster; - -import java.util.concurrent.locks.ReentrantReadWriteLock; - -import org.alfresco.util.PropertyCheck; - -import com.hazelcast.config.Config; -import com.hazelcast.core.Hazelcast; -import com.hazelcast.core.HazelcastInstance; - -/** - * Provides a way of lazily creating HazelcastInstances for a given configuration. - * The HazelcastInstance will not be created until {@link #getInstance()} is called. - *

- * An intermediary class such as this is required in order to avoid starting - * Hazelcast instances when clustering is not configured/required. Otherwise - * simply by defining a HazelcastInstance bean clustering would spring into life. - *

- * Please note this class provides non-static access deliberately, and should be - * injected into any clients that require its services. - * - * @author Matt Ward - */ -public class HazelcastInstanceFactory -{ - private Config config; - private HazelcastInstance hazelcastInstance; - /** Guards {@link #config} and {@link #hazelcastInstance} */ - private ReentrantReadWriteLock rwLock = new ReentrantReadWriteLock(); - - public HazelcastInstance getInstance() - { - rwLock.readLock().lock(); - try - { - if (hazelcastInstance != null) - { - return hazelcastInstance; - } - } - finally - { - rwLock.readLock().unlock(); - } - - // hazelcastInstance is null, so create it. - rwLock.writeLock().lock(); - try - { - // Double check condition hasn't changed in between locks. - if (hazelcastInstance == null) - { - hazelcastInstance = Hazelcast.newHazelcastInstance(config); - } - return hazelcastInstance; - } - finally - { - rwLock.writeLock().unlock(); - } - } - - /** - * Checks whether hazelcast has been given a valid cluster name. If so, - * then clustering is considered enabled. This condition should be checked - * before calling {@link #getInstance()}. - * - * @return true if clustering is enabled, false otherwise. - */ - public boolean isClusteringEnabled() - { - rwLock.readLock().lock(); - try - { - String clusterName = config.getGroupConfig().getName(); - return (PropertyCheck.isValidPropertyString(clusterName)); - } - finally - { - rwLock.readLock().unlock(); - } - } - - /** - * Retrieve the name of the cluster for the configuration used by this factory. - * - * @return String - the cluster name. - */ - public String getClusterName() - { - rwLock.readLock().lock(); - try - { - String clusterName = config.getGroupConfig().getName(); - return clusterName; - } - finally - { - rwLock.readLock().unlock(); - } - } - - /** - * Sets the Hazelcast configuration that will be used by this factory when - * creating the HazelcastInstance. - * - * @param config Hazelcast configuration - */ - public void setConfig(Config config) - { - rwLock.writeLock().lock(); - try - { - this.config = config; - } - finally - { - rwLock.writeLock().unlock(); - } - } -} diff --git a/source/java/org/alfresco/repo/cluster/HazelcastMessenger.java b/source/java/org/alfresco/repo/cluster/HazelcastMessenger.java deleted file mode 100644 index 0a3d540304..0000000000 --- a/source/java/org/alfresco/repo/cluster/HazelcastMessenger.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (C) 2005-2012 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ - -package org.alfresco.repo.cluster; - -import java.io.Serializable; - -import org.apache.commons.lang.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import com.hazelcast.core.ITopic; -import com.hazelcast.core.MessageListener; - -/** - * Hazelcast-based implementation of the {@link Messenger} interface. - * - * @see HazelcastMessengerFactory - * @author Matt Ward - */ -public class HazelcastMessenger implements Messenger, MessageListener -{ - private ITopic topic; - private MessageReceiver receiverDelegate; - private String address; - private final static Log logger = LogFactory.getLog(HazelcastMessenger.class); - - /** - * @param topic - */ - public HazelcastMessenger(ITopic topic, String address) - { - this.topic = topic; - this.address = address; - } - - - @Override - public void send(T message) - { - if (logger.isTraceEnabled()) - { - String digest = StringUtils.abbreviate(message.toString(), 50); - logger.trace("Sending [source: " + address + "]: " + digest); - } - topic.publish(message); - } - - @Override - public void setReceiver(MessageReceiver receiver) - { - // Install a delegate to ready to handle incoming messages. - receiverDelegate = receiver; - // Start receiving messages. - topic.addMessageListener(this); - } - - @Override - public void onMessage(T message) - { - if (logger.isTraceEnabled()) - { - String digest = StringUtils.abbreviate(message.toString(), 50); - logger.trace("Received [destination: " + address + "] (delegating to receiver): " + digest); - } - receiverDelegate.onReceive(message); - } - - @Override - public boolean isConnected() - { - return true; - } - - protected ITopic getTopic() - { - return topic; - } - - - @Override - public String getAddress() - { - return address; - } - - - @Override - public String toString() - { - return "HazelcastMessenger[connected=" + isConnected() + - ", topic=" + getTopic() + - ", address=" + getAddress() + "]"; - } -} diff --git a/source/java/org/alfresco/repo/cluster/HazelcastMessengerFactory.java b/source/java/org/alfresco/repo/cluster/HazelcastMessengerFactory.java deleted file mode 100644 index 9ba93ac6dd..0000000000 --- a/source/java/org/alfresco/repo/cluster/HazelcastMessengerFactory.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (C) 2005-2012 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ - -package org.alfresco.repo.cluster; - -import java.io.Serializable; -import java.util.Set; - -import com.hazelcast.core.HazelcastInstance; -import com.hazelcast.core.ITopic; -import com.hazelcast.core.Member; -import com.hazelcast.core.MembershipEvent; -import com.hazelcast.core.MembershipListener; - -/** - * Hazelcast-based implementation of the {@link MessengerFactory} interface. - * The factory must be configured with a {@link HazelcastInstance} - which - * is the underlying factory for {@link ITopic} creation. - * - * @author Matt Ward - */ -public class HazelcastMessengerFactory implements MessengerFactory -{ - private HazelcastInstanceFactory hazelcastInstanceFactory; - - @Override - public Messenger createMessenger(String appRegion) - { - return createMessenger(appRegion, false); - } - - @Override - public Messenger createMessenger(String appRegion, boolean acceptLocalMessages) - { - if (!isClusterActive()) - { - return new NullMessenger(); - } - // Clustering is enabled, create a messenger. - HazelcastInstance hazelcast = hazelcastInstanceFactory.getInstance(); - ITopic topic = hazelcast.getTopic(appRegion); - String address = hazelcast.getCluster().getLocalMember().getInetSocketAddress().toString(); - return new HazelcastMessenger(topic, address); - } - - /** - * Provide the messenger factory with a means to obtain a HazelcastInstance. - * - * @param hazelcastInstanceFactory - */ - public void setHazelcastInstanceFactory(HazelcastInstanceFactory hazelcastInstanceFactory) - { - this.hazelcastInstanceFactory = hazelcastInstanceFactory; - } - - @Override - public boolean isClusterActive() - { - return hazelcastInstanceFactory.isClusteringEnabled(); - } - - @Override - public void addMembershipListener(final ClusterMembershipListener listener) - { - if (isClusterActive()) - { - HazelcastInstance hazelcast = hazelcastInstanceFactory.getInstance(); - hazelcast.getCluster().addMembershipListener(new MembershipListener() - { - @Override - public void memberRemoved(MembershipEvent e) - { - listener.memberLeft(member(e), cluster(e)); - } - - @Override - public void memberAdded(MembershipEvent e) - { - listener.memberJoined(member(e), cluster(e)); - } - - private String member(MembershipEvent e) - { - return e.getMember().getInetSocketAddress().toString(); - } - - private String[] cluster(MembershipEvent e) - { - Set members = e.getCluster().getMembers(); - String[] cluster = new String[members.size()]; - int i = 0; - for (Member m : members) - { - cluster[i++] = m.getInetSocketAddress().toString(); - } - return cluster; - } - }); - } - } -} diff --git a/source/java/org/alfresco/repo/cluster/HazelcastMessengerFactoryTest.java b/source/java/org/alfresco/repo/cluster/HazelcastMessengerFactoryTest.java deleted file mode 100644 index 84e5d02e80..0000000000 --- a/source/java/org/alfresco/repo/cluster/HazelcastMessengerFactoryTest.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (C) 2005-2012 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ - -package org.alfresco.repo.cluster; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertSame; -import static org.mockito.Mockito.when; - -import java.net.InetSocketAddress; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; - -import com.hazelcast.core.Cluster; -import com.hazelcast.core.HazelcastInstance; -import com.hazelcast.core.ITopic; -import com.hazelcast.core.Member; - - -/** - * Tests for the HazelcastMessengerFactory class. - * - * @author Matt Ward - */ -@RunWith(MockitoJUnitRunner.class) -public class HazelcastMessengerFactoryTest -{ - private HazelcastMessengerFactory factory; - private @Mock HazelcastInstance hazelcast; - private @Mock Member member; - private @Mock Cluster cluster; - private @Mock ITopic topic; - private @Mock HazelcastInstanceFactory hazelcastInstanceFactory; - - @Before - public void setUp() - { - factory = new HazelcastMessengerFactory(); - factory.setHazelcastInstanceFactory(hazelcastInstanceFactory); - - when(hazelcastInstanceFactory.isClusteringEnabled()).thenReturn(true); - when(hazelcastInstanceFactory.getInstance()).thenReturn(hazelcast); - } - - @Test - public void topicWrappedInMessenger() - { - when(hazelcast.getTopic("app-region")).thenReturn(topic); - when(hazelcast.getCluster()).thenReturn(cluster); - when(cluster.getLocalMember()).thenReturn(member); - when(member.getInetSocketAddress()).thenReturn(InetSocketAddress.createUnresolved("a-host-name", 1234)); - - Messenger messenger = factory.createMessenger("app-region"); - - assertSame(topic, ((HazelcastMessenger) messenger).getTopic()); - assertEquals("a-host-name:1234", messenger.getAddress()); - } - - @Test - public void canCheckClusterIsActive() - { - assertEquals(true, factory.isClusterActive()); - - when(hazelcastInstanceFactory.isClusteringEnabled()).thenReturn(false); - assertEquals(false, factory.isClusterActive()); - } -} diff --git a/source/java/org/alfresco/repo/cluster/HazelcastMessengerTest.java b/source/java/org/alfresco/repo/cluster/HazelcastMessengerTest.java deleted file mode 100644 index 5ef3fd1ca3..0000000000 --- a/source/java/org/alfresco/repo/cluster/HazelcastMessengerTest.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (C) 2005-2012 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ - -package org.alfresco.repo.cluster; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.verify; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; - -import com.hazelcast.core.ITopic; - -/** - * Tests for the HazelcastMessenger class. - * - * @author Matt Ward - */ -@RunWith(MockitoJUnitRunner.class) -public class HazelcastMessengerTest -{ - private @Mock ITopic topic; - private HazelcastMessenger messenger; - private String receivedMsg; - - @Before - public void setUp() - { - messenger = new HazelcastMessenger(topic, "address"); - receivedMsg = null; - } - - @Test - public void canSendMessage() - { - messenger.send("Test string"); - verify(topic).publish("Test string"); - } - - @Test - public void canReceiveMessage() - { - messenger.setReceiver(new MessageReceiver() - { - @Override - public void onReceive(String message) - { - receivedMsg = new String(message); - } - }); - - // Hazelcast will call the onMessage method... - messenger.onMessage("Hazelcast is sending a message."); - - // setReceiver() should have resulted in a listener being registered with the topic. - verify(topic).addMessageListener(messenger); - - assertEquals("Hazelcast is sending a message.", receivedMsg); - } -} diff --git a/source/java/org/alfresco/repo/cluster/HazelcastTest.java b/source/java/org/alfresco/repo/cluster/HazelcastTest.java deleted file mode 100644 index d161152711..0000000000 --- a/source/java/org/alfresco/repo/cluster/HazelcastTest.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright (C) 2005-2012 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ - -package org.alfresco.repo.cluster; - - -import org.alfresco.repo.cluster.MessengerTestHelper.TestMessageReceiver; -import org.alfresco.util.ApplicationContextHelper; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.springframework.context.ApplicationContext; - -import com.hazelcast.core.Hazelcast; -import com.hazelcast.core.HazelcastInstance; -import com.hazelcast.core.ITopic; -import com.hazelcast.core.MessageListener; - -/** - * Tests for Hazelcast implementations of {@link Messenger} and related classes. - * These are integration tests and configured through a Spring test context file. - * - * @author Matt Ward - */ -public class HazelcastTest implements MessageListener -{ - private static ApplicationContext ctx; - private MessengerTestHelper helper; - private HazelcastInstanceFactory hiFactory; - private HazelcastInstance hi; - - @BeforeClass - public static void setUpClass() - { - ctx = ApplicationContextHelper. - getApplicationContext(new String[] { "cluster-test/hazelcast-messenger-test.xml" }); - } - - @AfterClass - public static void tearDownClass() - { - ApplicationContextHelper.closeApplicationContext(); - Hazelcast.shutdownAll(); - } - - @Before - public void setUp() - { - helper = new MessengerTestHelper(); - hiFactory = ctx.getBean(HazelcastInstanceFactory.class); - hi = hiFactory.getInstance(); - } - - - @Test - public void canSendWithHazelcastMessengerFactory() throws InterruptedException - { - ITopic topic = hi.getTopic("testregion"); - - topic.addMessageListener(this); - - MessengerFactory messengerFactory = (MessengerFactory) ctx.getBean("messengerFactory"); - Messenger messenger = messengerFactory.createMessenger("testregion"); - messenger.send("Full test including spring."); - - helper.checkMessageReceivedWas("Full test including spring."); - } - - @Ignore("Behaviour not yet implemented.") - @Test - public void messengerWillNotReceiveMessagesFromSelf() throws InterruptedException - { - MessengerFactory messengerFactory = (MessengerFactory) ctx.getBean("messengerFactory"); - Messenger m1 = messengerFactory.createMessenger("testregion"); - TestMessageReceiver r1 = new TestMessageReceiver(); - m1.setReceiver(r1); - - ITopic topic2 = hi.getTopic("testregion"); - String address2 = hi.getCluster().getLocalMember().getInetSocketAddress().toString(); - Messenger m2 = new HazelcastMessenger(topic2, address2); - TestMessageReceiver r2 = new TestMessageReceiver(); - m2.setReceiver(r2); - - m1.send("This should be received by r2 but not r1"); - - r2.helper.checkMessageReceivedWas("This should be received by r2 but not r1"); - r1.helper.checkNoMessageReceived(); - } - - @Override - public void onMessage(String message) - { - helper.setReceivedMsg(message); - } -} diff --git a/source/java/org/alfresco/repo/cluster/MessageReceiver.java b/source/java/org/alfresco/repo/cluster/MessageReceiver.java deleted file mode 100644 index 474c4adac6..0000000000 --- a/source/java/org/alfresco/repo/cluster/MessageReceiver.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2005-2012 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ - -package org.alfresco.repo.cluster; - -import java.io.Serializable; - -/** - * Implement this interface and supply to a {@link Messenger} using - * {@link Messenger#setReceiver(MessageReceiver)} in order to receive - * messages from other {@link Messenger}s. - * - * @author Matt Ward - */ -public interface MessageReceiver -{ - void onReceive(T message); -} diff --git a/source/java/org/alfresco/repo/cluster/Messenger.java b/source/java/org/alfresco/repo/cluster/Messenger.java deleted file mode 100644 index 465e112278..0000000000 --- a/source/java/org/alfresco/repo/cluster/Messenger.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2005-2012 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ - -package org.alfresco.repo.cluster; - -import java.io.Serializable; - -/** - * Provides facilities for peer-to-peer messaging within a cluster. This interface - * is intended to act as a facade, allowing the actual implementation (e.g. Hazelcast) - * to be decoupled as much as possible from the Alfresco code base. - *

- * Instances of this class are parameterised with the type of message payload - * to send and receive. - * - * @author Matt Ward - */ -public interface Messenger -{ - void send(T message); - - void setReceiver(MessageReceiver receiver); - - boolean isConnected(); - - String getAddress(); -} diff --git a/source/java/org/alfresco/repo/cluster/MessengerFactory.java b/source/java/org/alfresco/repo/cluster/MessengerFactory.java deleted file mode 100644 index fc39ddfa7d..0000000000 --- a/source/java/org/alfresco/repo/cluster/MessengerFactory.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2005-2012 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ - -package org.alfresco.repo.cluster; - -import java.io.Serializable; - -/** - * Factory class responsible for creating instances of {@link Messenger} class. - * - * @author Matt Ward - */ -public interface MessengerFactory -{ - /** A catch-all for unknown application regions. */ - public static final String APP_REGION_DEFAULT = "DEFAULT"; - - /** The application region used by the EHCache heartbeat implementation. */ - public static final String APP_REGION_EHCACHE_HEARTBEAT = "EHCACHE_HEARTBEAT"; - - Messenger createMessenger(String appRegion); - - Messenger createMessenger(String appRegion, boolean acceptLocalMessages); - - boolean isClusterActive(); - - void addMembershipListener(ClusterMembershipListener membershipListener); -} diff --git a/source/java/org/alfresco/repo/cluster/MessengerFactoryProvider.java b/source/java/org/alfresco/repo/cluster/MessengerFactoryProvider.java deleted file mode 100644 index 3bc3630757..0000000000 --- a/source/java/org/alfresco/repo/cluster/MessengerFactoryProvider.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2005-2012 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.repo.cluster; - -/** - * Static container for MessengerFactory. This allows code to obtain the correct - * {@link MessengerFactory} implementation where dependency injection is not available. - * - * @author Matt Ward - */ -public class MessengerFactoryProvider -{ - private static MessengerFactory instance; - - public void setInstance(MessengerFactory messengerFactory) - { - instance = messengerFactory; - } - - public static MessengerFactory getInstance() - { - if (instance == null) - { - throw new IllegalStateException("MessengerFactory instance not configured yet."); - } - return instance; - } -} diff --git a/source/java/org/alfresco/repo/cluster/MessengerTestHelper.java b/source/java/org/alfresco/repo/cluster/MessengerTestHelper.java deleted file mode 100644 index cdab15a0d4..0000000000 --- a/source/java/org/alfresco/repo/cluster/MessengerTestHelper.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (C) 2005-2012 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ - -package org.alfresco.repo.cluster; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.*; - -/** - * Helper class for testing Messenger related code. - * - * @author Matt Ward - */ -public class MessengerTestHelper -{ - private String receivedMsg; - private final static int SLEEP_MILLIS = 50; - private static final int MAX_TRIES = 30; - - - public MessengerTestHelper() - { - setReceivedMsg(null); - } - - /** - * Try to avoid intermitten test failures by trying multiple times. Hopefully the messge - * will have been received after the very first sleep, but in a slow environment it may take longer. - * This also allows the sleep time to be lower - rather than waiting for say 50 ms, we can try 10 times - * at 5 ms - with a chance that we can return after the initial 5 ms. - * - * @param expectedMsg - * @throws InterruptedException - */ - public void checkMessageReceivedWas(String expectedMsg) - { - int tries = 0; - - while (tries < MAX_TRIES) - { - try - { - Thread.sleep(SLEEP_MILLIS); - } - catch (InterruptedException e) - { - // Carry on - e.printStackTrace(); - } - if (getReceivedMsg() != null) - { - assertEquals(expectedMsg, getReceivedMsg()); - return; - } - tries++; - } - fail("No message received, tried " + tries + - " times, sleeping " + SLEEP_MILLIS + "ms each time."); - } - - /** - * Assert that no message was received in the given period. - */ - public void checkNoMessageReceived() - { - int tries = 0; - - while (tries < MAX_TRIES) - { - try - { - Thread.sleep(SLEEP_MILLIS); - } - catch (InterruptedException e) - { - // Carry on - e.printStackTrace(); - } - if (getReceivedMsg() != null) - { - fail("Message received but should NOT have been. Message was: " + getReceivedMsg()); - } - tries++; - } - } - - /** - * @return the receivedMsg - */ - public String getReceivedMsg() - { - return this.receivedMsg; - } - - /** - * @param receivedMsg the receivedMsg to set - */ - public void setReceivedMsg(String receivedMsg) - { - this.receivedMsg = receivedMsg; - } - - - public static class TestMessageReceiver implements MessageReceiver - { - MessengerTestHelper helper = new MessengerTestHelper(); - - @Override - public void onReceive(String message) - { - helper.setReceivedMsg(message); - } - } -} diff --git a/source/java/org/alfresco/repo/cluster/NullMessenger.java b/source/java/org/alfresco/repo/cluster/NullMessenger.java deleted file mode 100644 index 55b63587aa..0000000000 --- a/source/java/org/alfresco/repo/cluster/NullMessenger.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2005-2012 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.repo.cluster; - -import java.io.Serializable; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * A do-nothing implementation of the {@link Messenger} interface. - * - * @author Matt Ward - */ -public class NullMessenger implements Messenger -{ - private static final Log logger = LogFactory.getLog(NullMessenger.class); - - @Override - public void send(T message) - { - if (logger.isDebugEnabled()) - { - logger.debug("Throwing away message: " + message); - } - } - - @Override - public void setReceiver(MessageReceiver receiver) - { - if (logger.isDebugEnabled()) - { - logger.debug("Throwing away receiver: " + receiver); - } - } - - @Override - public boolean isConnected() - { - return false; - } - - @Override - public String getAddress() - { - if (logger.isDebugEnabled()) - { - logger.debug("getAddress() always returns loopback address: 127.0.0.1"); - } - return "127.0.0.1"; - } -} diff --git a/source/java/org/alfresco/repo/content/RoutingContentStoreTest.java b/source/java/org/alfresco/repo/content/RoutingContentStoreTest.java index 2f9a66b6c6..4bf5444845 100644 --- a/source/java/org/alfresco/repo/content/RoutingContentStoreTest.java +++ b/source/java/org/alfresco/repo/content/RoutingContentStoreTest.java @@ -24,10 +24,8 @@ import java.util.Collections; import java.util.Date; import java.util.List; -import net.sf.ehcache.Cache; -import net.sf.ehcache.CacheManager; - -import org.alfresco.repo.cache.EhCacheAdapter; +import org.alfresco.repo.cache.DefaultSimpleCache; +import org.alfresco.repo.cache.SimpleCache; import org.alfresco.repo.content.filestore.FileContentStore; import org.alfresco.service.cmr.repository.ContentIOException; import org.alfresco.service.cmr.repository.ContentReader; @@ -158,11 +156,7 @@ public class RoutingContentStoreTest extends AbstractWritableContentStoreTest { this.stores.add(store); } - Cache ehCache = new Cache("RandomRoutingContentStore", 50, false, true, 0L, 0L); - CacheManager cacheManager = new CacheManager(); - cacheManager.addCache(ehCache); - EhCacheAdapter, ContentStore> cache = new EhCacheAdapter, ContentStore>(); - cache.setCache(ehCache); + SimpleCache, ContentStore> cache = new DefaultSimpleCache, ContentStore>(); super.setStoresCache(cache); } diff --git a/source/java/org/alfresco/repo/content/caching/CachingContentStoreSpringTest.java b/source/java/org/alfresco/repo/content/caching/CachingContentStoreSpringTest.java index fe8a5158aa..54dfb157c7 100644 --- a/source/java/org/alfresco/repo/content/caching/CachingContentStoreSpringTest.java +++ b/source/java/org/alfresco/repo/content/caching/CachingContentStoreSpringTest.java @@ -20,9 +20,8 @@ package org.alfresco.repo.content.caching; import java.io.File; -import net.sf.ehcache.CacheManager; - -import org.alfresco.repo.cache.EhCacheAdapter; +import org.alfresco.repo.cache.DefaultSimpleCache; +import org.alfresco.repo.cache.SimpleCache; import org.alfresco.repo.content.AbstractWritableContentStoreTest; import org.alfresco.repo.content.ContentContext; import org.alfresco.repo.content.ContentStore; @@ -42,8 +41,6 @@ import org.junit.runner.RunWith; @RunWith(JUnit38ClassRunner.class) public class CachingContentStoreSpringTest extends AbstractWritableContentStoreTest { - private static final String EHCACHE_NAME = "cache.test.cachingContentStoreCache"; - private static final int T24_HOURS = 86400; private CachingContentStore store; private FileContentStore backingStore; private ContentCacheImpl cache; @@ -67,22 +64,9 @@ public class CachingContentStoreSpringTest extends AbstractWritableContentStoreT store = new CachingContentStore(backingStore, cache, false); } - private EhCacheAdapter createMemoryStore() + private SimpleCache createMemoryStore() { - CacheManager manager = CacheManager.getInstance(); - - // Create the cache if it hasn't already been created. - if (!manager.cacheExists(EHCACHE_NAME)) - { - net.sf.ehcache.Cache memoryOnlyCache = - new net.sf.ehcache.Cache(EHCACHE_NAME, 50, false, false, T24_HOURS, T24_HOURS); - - manager.addCache(memoryOnlyCache); - } - - EhCacheAdapter memoryStore = new EhCacheAdapter(); - memoryStore.setCache(manager.getCache(EHCACHE_NAME)); - + SimpleCache memoryStore = new DefaultSimpleCache(); return memoryStore; } diff --git a/source/java/org/alfresco/repo/dictionary/RepoDictionaryDAOTest.java b/source/java/org/alfresco/repo/dictionary/RepoDictionaryDAOTest.java index acfe5d9a1b..c8590c58d8 100644 --- a/source/java/org/alfresco/repo/dictionary/RepoDictionaryDAOTest.java +++ b/source/java/org/alfresco/repo/dictionary/RepoDictionaryDAOTest.java @@ -28,11 +28,11 @@ import java.util.List; import java.util.Map; import junit.framework.TestCase; -import net.sf.ehcache.Cache; -import net.sf.ehcache.CacheManager; import org.alfresco.model.ContentModel; -import org.alfresco.repo.cache.EhCacheAdapter; +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; @@ -116,25 +116,13 @@ public class RepoDictionaryDAOTest extends TestCase private void initDictionaryCaches(DictionaryDAOImpl dictionaryDAO) { - CacheManager cacheManager = new CacheManager(); - - Cache dictionaryEhCache = new Cache("dictionaryCache", 50, false, true, 0L, 0L); - cacheManager.addCache(dictionaryEhCache); - EhCacheAdapter dictionaryCache = new EhCacheAdapter(); - dictionaryCache.setCache(dictionaryEhCache); - + SimpleCache dictionaryCache = new DefaultSimpleCache(); dictionaryDAO.setDictionaryRegistryCache(dictionaryCache); } private void initNamespaceCaches(NamespaceDAOImpl namespaceDAO) { - CacheManager cacheManager = new CacheManager(); - - Cache namespaceEhCache = new Cache("namespaceCache", 50, false, true, 0L, 0L); - cacheManager.addCache(namespaceEhCache); - EhCacheAdapter namespaceCache = new EhCacheAdapter(); - namespaceCache.setCache(namespaceEhCache); - + SimpleCache namespaceCache = new NullCache(); namespaceDAO.setNamespaceRegistryCache(namespaceCache); } diff --git a/source/java/org/alfresco/repo/dictionary/TestModel.java b/source/java/org/alfresco/repo/dictionary/TestModel.java index 5eeab22062..f8c7211dc5 100644 --- a/source/java/org/alfresco/repo/dictionary/TestModel.java +++ b/source/java/org/alfresco/repo/dictionary/TestModel.java @@ -21,10 +21,8 @@ package org.alfresco.repo.dictionary; import java.util.ArrayList; import java.util.List; -import net.sf.ehcache.Cache; -import net.sf.ehcache.CacheManager; - -import org.alfresco.repo.cache.EhCacheAdapter; +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; @@ -120,25 +118,13 @@ public class TestModel private static void initDictionaryCaches(DictionaryDAOImpl dictionaryDAO) { - CacheManager cacheManager = new CacheManager(); - - Cache dictionaryEhCache = new Cache("dictionaryCache", 50, false, true, 0L, 0L); - cacheManager.addCache(dictionaryEhCache); - EhCacheAdapter dictionaryCache = new EhCacheAdapter(); - dictionaryCache.setCache(dictionaryEhCache); - + SimpleCache dictionaryCache = new DefaultSimpleCache(); dictionaryDAO.setDictionaryRegistryCache(dictionaryCache); } private static void initNamespaceCaches(NamespaceDAOImpl namespaceDAO) { - CacheManager cacheManager = new CacheManager(); - - Cache namespaceEhCache = new Cache("namespaceCache", 50, false, true, 0L, 0L); - cacheManager.addCache(namespaceEhCache); - EhCacheAdapter namespaceCache = new EhCacheAdapter(); - namespaceCache.setCache(namespaceEhCache); - + SimpleCache namespaceCache = new DefaultSimpleCache(); namespaceDAO.setNamespaceRegistryCache(namespaceCache); } } \ No newline at end of file diff --git a/source/java/org/alfresco/repo/remoteticket/RemoteAlfrescoTicketServiceImpl.java b/source/java/org/alfresco/repo/remoteticket/RemoteAlfrescoTicketServiceImpl.java index 836b336e68..14fc9064e0 100644 --- a/source/java/org/alfresco/repo/remoteticket/RemoteAlfrescoTicketServiceImpl.java +++ b/source/java/org/alfresco/repo/remoteticket/RemoteAlfrescoTicketServiceImpl.java @@ -23,7 +23,7 @@ import java.util.HashMap; import java.util.Map; import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.repo.cache.EhCacheAdapter; +import org.alfresco.repo.cache.SimpleCache; import org.alfresco.repo.remotecredentials.PasswordCredentialsInfoImpl; import org.alfresco.repo.security.authentication.AuthenticationException; import org.alfresco.repo.transaction.RetryingTransactionHelper; @@ -67,7 +67,7 @@ public class RemoteAlfrescoTicketServiceImpl implements RemoteAlfrescoTicketServ private RetryingTransactionHelper retryingTransactionHelper; private RemoteCredentialsService remoteCredentialsService; private RemoteConnectorService remoteConnectorService; - private EhCacheAdapter ticketsCache; + private SimpleCache ticketsCache; private Map remoteSystemsUrls = new HashMap(); private Map> remoteSystemsReqHeaders = new HashMap>(); @@ -89,9 +89,9 @@ public class RemoteAlfrescoTicketServiceImpl implements RemoteAlfrescoTicketServ } /** - * Sets the EhCache to be used to cache remote tickets in + * Sets the SimpleCache to be used to cache remote tickets in */ - public void setTicketsCache(EhCacheAdapter ticketsCache) + public void setTicketsCache(SimpleCache ticketsCache) { this.ticketsCache = ticketsCache; } diff --git a/source/java/org/alfresco/repo/transaction/RetryingTransactionHelper.java b/source/java/org/alfresco/repo/transaction/RetryingTransactionHelper.java index 49197b2bbf..c1f0b1714a 100644 --- a/source/java/org/alfresco/repo/transaction/RetryingTransactionHelper.java +++ b/source/java/org/alfresco/repo/transaction/RetryingTransactionHelper.java @@ -21,6 +21,9 @@ package org.alfresco.repo.transaction; import java.lang.reflect.Method; import java.sql.BatchUpdateException; import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; import java.util.LinkedList; import java.util.List; import java.util.Random; @@ -31,8 +34,6 @@ import javax.transaction.RollbackException; import javax.transaction.Status; import javax.transaction.UserTransaction; -import net.sf.ehcache.distribution.RemoteCacheException; - import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.error.ExceptionStackUtil; import org.alfresco.repo.security.permissions.AccessDeniedException; @@ -89,24 +90,68 @@ public class RetryingTransactionHelper public static final Class[] RETRY_EXCEPTIONS; static { - RETRY_EXCEPTIONS = new Class[] { - ConcurrencyFailureException.class, - DeadlockLoserDataAccessException.class, - StaleObjectStateException.class, - JdbcUpdateAffectedIncorrectNumberOfRowsException.class, // Similar to StaleObjectState - LockAcquisitionException.class, - ConstraintViolationException.class, - UncategorizedSQLException.class, - SQLException.class, - BatchUpdateException.class, - DataIntegrityViolationException.class, - StaleStateException.class, - TooManyResultsException.class, // Expected one result but found multiple (bad key alert) - ObjectNotFoundException.class, - CacheException.class, // Usually a cache replication issue - RemoteCacheException.class, // A cache replication issue - SQLGrammarException.class // Actually specific to MS SQL Server 2005 - we check for this - }; + Class[] coreClasses = new Class[] { + ConcurrencyFailureException.class, + DeadlockLoserDataAccessException.class, + StaleObjectStateException.class, + JdbcUpdateAffectedIncorrectNumberOfRowsException.class, // Similar to StaleObjectState + LockAcquisitionException.class, + ConstraintViolationException.class, + UncategorizedSQLException.class, + SQLException.class, + BatchUpdateException.class, + DataIntegrityViolationException.class, + StaleStateException.class, + TooManyResultsException.class, // Expected one result but found multiple (bad key alert) + ObjectNotFoundException.class, + CacheException.class, // Usually a cache replication issue + SQLGrammarException.class // Actually specific to MS SQL Server 2005 - we check for this + }; + + List> retryExceptions = new ArrayList>(); + // Add core classes to the list. + retryExceptions.addAll(Arrays.asList(coreClasses)); + // Add enterprise-specific classes to the list + retryExceptions.addAll(enterpriseRetryExceptions()); + + RETRY_EXCEPTIONS = retryExceptions.toArray(new Class[] {}); + } + + /** + * Use reflection to load a list of enterprise-specific exception classes to add to the + * core list specified in this class. + *

+ * This is used to decouple this class from enterprise-specific libraries. + * + * @return List of enterprise exception classes or empty list if not available. + */ + private static List> enterpriseRetryExceptions() + { + List> retryExceptions = null; + try + { + Class c = Class.forName("org.alfresco.enterprise.repo.transaction.RetryExceptions"); + retryExceptions = (List>) c.newInstance(); + } + catch (ClassNotFoundException error) + { + // It's ok not to have the enterprise class available. + } + catch (InstantiationException error) + { + throw new AlfrescoRuntimeException("Unable to instantiate enterprise RetryExceptions."); + } + catch (IllegalAccessException error) + { + throw new AlfrescoRuntimeException("Unable to instantiate enterprise RetryExceptions."); + } + + // If no enterprise class found then create an empty list. + if (retryExceptions == null) + { + retryExceptions = Collections.emptyList(); + } + return retryExceptions; } /** diff --git a/source/java/org/alfresco/repo/webdav/LockStoreFactoryImpl.java b/source/java/org/alfresco/repo/webdav/LockStoreFactoryImpl.java deleted file mode 100644 index ea15b79aa1..0000000000 --- a/source/java/org/alfresco/repo/webdav/LockStoreFactoryImpl.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (C) 2005-2012 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.repo.webdav; - -import java.util.concurrent.ConcurrentMap; - -import org.alfresco.repo.cluster.HazelcastInstanceFactory; -import org.alfresco.service.cmr.repository.NodeRef; - -import com.hazelcast.core.HazelcastInstance; - - -/** - * Default implementation of the {@link LockStoreFactory} interface. Creates {@link LockStore}s - * backed by a Hazelcast distributed Map if clustering is enabled, - * otherwise it creates a non-clustered {@link SimpleLockStore}. - * - * @see LockStoreFactory - * @see LockStoreImpl - * @author Matt Ward - */ -public class LockStoreFactoryImpl implements LockStoreFactory -{ - private static final String HAZELCAST_MAP_NAME = "webdav-locks"; - private HazelcastInstanceFactory hazelcastInstanceFactory; - - /** - * This method should be used sparingly and the created {@link LockStore}s should be - * retained (this factory does not cache instances of them). - */ - @Override - public synchronized LockStore createLockStore() - { - if (!hazelcastInstanceFactory.isClusteringEnabled()) - { - return new SimpleLockStore(); - } - else - { - HazelcastInstance instance = hazelcastInstanceFactory.getInstance(); - ConcurrentMap map = instance.getMap(HAZELCAST_MAP_NAME); - return new LockStoreImpl(map); - } - } - - /** - * @param hazelcastInstanceFactory the factory that will create a HazelcastInstance if required. - */ - public synchronized void setHazelcastInstanceFactory(HazelcastInstanceFactory hazelcastInstanceFactory) - { - this.hazelcastInstanceFactory = hazelcastInstanceFactory; - } -} diff --git a/source/java/org/alfresco/repo/cluster/ClusterMembershipListener.java b/source/java/org/alfresco/repo/webdav/SimpleLockStoreFactory.java similarity index 71% rename from source/java/org/alfresco/repo/cluster/ClusterMembershipListener.java rename to source/java/org/alfresco/repo/webdav/SimpleLockStoreFactory.java index 2341986774..c38c42337e 100644 --- a/source/java/org/alfresco/repo/cluster/ClusterMembershipListener.java +++ b/source/java/org/alfresco/repo/webdav/SimpleLockStoreFactory.java @@ -16,15 +16,18 @@ * You should have received a copy of the GNU Lesser General Public License * along with Alfresco. If not, see . */ -package org.alfresco.repo.cluster; +package org.alfresco.repo.webdav; /** - * Implementing classes can react to members joining or leaving the cluster. + * LockStoreFactory that always returns a new {@link SimpleLockStore} instance. * * @author Matt Ward */ -public interface ClusterMembershipListener +public class SimpleLockStoreFactory implements LockStoreFactory { - void memberJoined(String member, String[] cluster); - void memberLeft(String member, String[] cluster); + @Override + public LockStore createLockStore() + { + return new SimpleLockStore(); + } } diff --git a/source/test-resources/cache-test/cache-test-config.xml b/source/test-resources/cache-test/cache-test-config.xml deleted file mode 100644 index a8a1a4192b..0000000000 --- a/source/test-resources/cache-test/cache-test-config.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/source/test-resources/cache-test/cache-test-context.xml b/source/test-resources/cache-test/cache-test-context.xml deleted file mode 100644 index 6744de122c..0000000000 --- a/source/test-resources/cache-test/cache-test-context.xml +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - - classpath:cache-test/cache-test-config.xml - - - - - - - - - - - cache1 - - - - - - - - - - - - - backingCache - - - - - - - - transactionalCache - 200000 - - - - - - - - - - objectCache - - - - - - \ No newline at end of file diff --git a/source/test-resources/cachingstore/test-context.xml b/source/test-resources/cachingstore/test-context.xml index 6e06be347f..017f14f380 100644 --- a/source/test-resources/cachingstore/test-context.xml +++ b/source/test-resources/cachingstore/test-context.xml @@ -5,19 +5,7 @@ - - - - - - - - org.alfresco.cache.cachingContentStoreCache - - - - - + diff --git a/source/test-resources/cachingstore/test-std-quota-context.xml b/source/test-resources/cachingstore/test-std-quota-context.xml index 07580f16fd..9111463219 100644 --- a/source/test-resources/cachingstore/test-std-quota-context.xml +++ b/source/test-resources/cachingstore/test-std-quota-context.xml @@ -35,24 +35,8 @@ - - - - - - - - org.alfresco.cache.cachingContentStoreCache - - - - - - - - - - + + diff --git a/source/test-resources/cluster-test/hazelcast-messenger-test.xml b/source/test-resources/cluster-test/hazelcast-messenger-test.xml deleted file mode 100644 index b7c391e185..0000000000 --- a/source/test-resources/cluster-test/hazelcast-messenger-test.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - test_hazelcast_cluster - test_hazelcast_cluster_password - - - - - - - - diff --git a/source/test-resources/cluster-test/placeholder-test.xml b/source/test-resources/cluster-test/placeholder-test.xml deleted file mode 100644 index 9bbcaab1a7..0000000000 --- a/source/test-resources/cluster-test/placeholder-test.xml +++ /dev/null @@ -1,166 +0,0 @@ - - - - - ${alfresco.cluster.name} - ${alfresco.hazelcast.password} - - - 5701 - - - 224.2.2.3 - 54327 - - - 127.0.0.1 - - - my-access-key - my-secret-key - - us-west-1 - - hazelcast-sg - type - hz-nodes - - - - 10.10.1.* - - - - PBEWithMD5AndDES - - thesalt - - thepass - - 19 - - - - RSA/NONE/PKCS1PADDING - - thekeypass - - local - - JKS - - thestorepass - - keystore - - - - 16 - 64 - 60 - - - - 0 - - default - - - - 1 - - 0 - - 0 - - NONE - - 0 - - 25 - - hz.ADD_NEW_ENTRY - - - - - - \ No newline at end of file diff --git a/source/test-resources/jbpm-test/test-hibernate-cfg.properties b/source/test-resources/jbpm-test/test-hibernate-cfg.properties index 5a45d7dc0d..795d8d0dad 100644 --- a/source/test-resources/jbpm-test/test-hibernate-cfg.properties +++ b/source/test-resources/jbpm-test/test-hibernate-cfg.properties @@ -11,7 +11,7 @@ hibernate.jdbc.use_streams_for_binary=true hibernate.show_sql=false hibernate.cache.use_query_cache=false hibernate.max_fetch_depth=10 -hibernate.cache.provider_class=org.alfresco.repo.cache.InternalEhCacheManagerFactoryBean +hibernate.cache.provider_class=org.alfresco.repo.cache.DefaultCacheProvider hibernate.cache.use_second_level_cache=true hibernate.default_batch_fetch_size=1 hibernate.jdbc.batch_size=32 diff --git a/source/test-resources/jbpmresources/ehcache.xml b/source/test-resources/jbpmresources/ehcache.xml deleted file mode 100644 index 663cdef302..0000000000 --- a/source/test-resources/jbpmresources/ehcache.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - \ No newline at end of file