Index: rctags/ehcache-2.10.8.0.7/README.txt =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/README.txt (revision 11085) +++ rctags/ehcache-2.10.8.0.7/README.txt (revision 0) @@ -1,18 +0,0 @@ -1. To compile: - %> mvn install -DskipTests - -Note: the final Ehcache jar is found under ehcache/target - - -2. To build Ehcache distribution kit: - - %> cd distribution - - %> mvn package (build without an embedded Terracotta kit, lean and mean Ehcache kit) - - %> mvn package -Dtc-kit-url=http://url/to/teracotta.tar.gz (built with Terracotta kit, offical distribution kit) - -3. To deploy Maven central repo (via Sonatype) - - %> mvn clean deploy -P sign-artifacts,deploy-sonatype -DskipTests - \ No newline at end of file Index: rctags/ehcache-2.10.8.0.7/management-ehcache-impl/management-ehcache-impl-v1/pom.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/management-ehcache-impl/management-ehcache-impl-v1/pom.xml (revision 11085) +++ rctags/ehcache-2.10.8.0.7/management-ehcache-impl/management-ehcache-impl-v1/pom.xml (revision 0) @@ -1,113 +0,0 @@ - - - 4.0.0 - - - net.sf.ehcache - management-ehcache-impl-parent - 2.10.8.0.7 - .. - - - management-ehcache-impl-v1 - management-ehcache-impl-v1 - A product library integrating with ehcache to construct the relevant management resource entities V1 - - - - net.sf.ehcache - management-ehcache-v1 - ${project.version} - - - net.sf.ehcache - management-ehcache-common - ${project.version} - - - org.terracotta - management-core-resources - ${management-core.version} - test-jar - test - - - net.sf.ehcache.internal - ehcache-core - ${project.version} - provided - - - gf-40 - gf.javax.servlet-api - - - org.easymock - easymock - test - - - org.eclipse.jetty - jetty-servlet - test - - - org.mockito - mockito-core - test - - - org.powermock - powermock-api-easymock - test - - - org.powermock - powermock-module-junit4 - test - - - org.hamcrest - hamcrest-all - 1.3 - test - - - net.sf.ehcache.internal - ehcache-core - test-jar - ${project.version} - test - - - - - - - org.apache.maven.plugins - maven-jar-plugin - - - - - - - terracotta-snapshots - http://www.terracotta.org/download/reflector/snapshots - - - terracotta-releases - http://www.terracotta.org/download/reflector/releases - - - - - terracotta-snapshots - http://www.terracotta.org/download/reflector/snapshots - - - terracotta-releases - http://www.terracotta.org/download/reflector/releases - - - Index: rctags/ehcache-2.10.8.0.7/ehcache-core/pom.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/pom.xml (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/pom.xml (revision 0) @@ -1,617 +0,0 @@ - - - 4.0.0 - - - net.sf.ehcache - ehcache-root - 2.10.8.0.7 - - - net.sf.ehcache.internal - ehcache-core - jar - - ehcache-core - Internal ehcache-core module. This artifact is not meant to be used directly - - - Ehcache - UTF-8 - UTF-8 - 5 - src/test/java - src/test/resources - ehcache - false - - -Xmx64m - - - - - - org.slf4j - slf4j-api - - - org.terracotta.internal - statistics - - - - - javax.servlet - javax.servlet-api - - - org.hibernate - hibernate-core - - - javax.transaction - jta - - - net.sf.ehcache - sizeof-agent - - - - - org.slf4j - slf4j-jdk14 - - - org.codehaus.btm - btm - - - net.sf.hibernate - hibernate - - - org.hamcrest - hamcrest-core - - - org.hamcrest - hamcrest-library - - - junit - junit - - - dom4j - dom4j - - - javassist - javassist - - - org.hibernate - hibernate-ehcache - - - - commons-logging - commons-logging - - - org.apache.derby - derby - - - org.mockito - mockito-core - - - com.sun.xsom - xsom - - - org.beanshell - bsh - - - - - - - src/main/resources - true - - - ${project.build.directory}/generated-resources - false - - - ${basedir}/${testDir} - - - ${basedir}/src/main/config/jcache - - - ${basedir}/${testResources} - - - - - - org.apache.maven.plugins - maven-jar-plugin - - - test-jar - - test-jar - - - - - - org.terracotta - maven-forge-plugin - - - build-info - generate-resources - - buildinfo - - - ${basedir}/.. - - - - - - - - - org.terracotta - maven-forge-plugin - - pertest - ${tests.supplemental.args} ${tests.max.heap.size} - false - false - true - plain - false - - true - ${net.sf.ehcache.speedAdjustmentFactor} - ${project.build.directory} - true - - - net.sf.ehcache:sizeof-agent - - - - - - default-test - - - **/*$* - **/*PerfTest.java - **/*PerfTest*.java - **/Abstract*Test.java - - - - - integration-test-execution - integration-test - - test - - - ${checkshort} - false - - **/*$* - - - **/IT*.java - **/*IT.java - **/*ITCase.java - - ${tests.supplemental.args} -Xms512m -Xmx512m - - - - - - - org.apache.maven.plugins - maven-checkstyle-plugin - - - verify - - checkstyle - - - - - ${basedir}/checkstyle/checkstyle.xml - ${basedir}/checkstyle/suppressions.xml - ${basedir}/checkstyle/ClassHeader.txt - ${skipCheckstyle} - false - false - true - true - true - false - true - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - generate-resources - copy-agent-jar-to-resources - - copy-dependencies - - - * - sizeof-agent - ${project.build.directory}/generated-resources/net/sf/ehcache/pool/sizeof/ - true - true - - - - - - org.codehaus.mojo - rmic-maven-plugin - - - rmi-compilation - compile - - rmic - - - - **/RMICachePeer.class - - ${project.build.outputDirectory} - - - - - - - - - - org.eclipse.m2e - lifecycle-mapping - 1.0.0 - - - - - - org.codehaus.mojo - xml-maven-plugin - [1.0,) - - transform - - - - - - - - - org.apache.maven.plugins - maven-dependency-plugin - [1.0,) - - copy-dependencies - - - - - - - - - org.codehaus.gmaven - gmaven-plugin - [1.3,) - - execute - - - - - - - - - org.codehaus.mojo - rmic-maven-plugin - [1.1,) - - rmic - - - - - - - - - org.apache.maven.plugins - maven-checkstyle-plugin - [2.7,) - - checkstyle - - - - - - - - - - - - - - - - - skip-ehcache-core-deploy - - true - - - - staging - - - - org.apache.maven.plugins - maven-gpg-plugin - - - sign-artifacts - deploy - - sign - - - - - - - - - perfTests - - - - org.terracotta - maven-forge-plugin - - - - default-test - - ${tests.supplemental.args} -Xmx512m - - **/*PerfTest.java - **/*PerfTest*.java - - - **/*$* - **/Abstract*Test.java - - - - - - - - - - - buildnumber-git - - - - org.codehaus.mojo - buildnumber-maven-plugin - 1.0-beta-3 - - - generate-resources - - create - - - - - false - false - {0,date,yyyy-MM-dd_HH-mm}_{1} - - timestamp - ${user.name} - - - - - - - - - - no-interruptible-io-solaris - - - java.vendor - Sun Microsystems Inc. - - - - -XX:-UseVMInterruptibleIO - - - - enable-system-gc-jrockit - - - java.vm.name - Oracle JRockit(R) - - - - -XXfullSystemGC -Xverbose:systemgc - - - - ibmj9 - - - java.vm.name - IBM J9 VM - - - - -Xenableexplicitgc - -Xmx256m - - - - - - test-nonstopcache - - - - org.terracotta - maven-forge-plugin - - - **/nonstop/*Test.java - - - **/*$* - - - - java.awt.headless - true - - - - - - - - - - - fast - - true - - - - - - - - terracotta-snapshots - http://www.terracotta.org/download/reflector/snapshots - - false - - - true - - - - - terracotta-releases - http://www.terracotta.org/download/reflector/releases - - true - - - false - - - - - - jboss-releases - http://repository.jboss.org/nexus/content/groups/public-jboss - - true - - - false - - - - - - Java.net Maven 2 - http://download.java.net/maven/2 - - true - - - false - - - - - - - terracotta-snapshots - http://www.terracotta.org/download/reflector/snapshots - - false - - - true - - - - terracotta-releases - http://www.terracotta.org/download/reflector/releases - - true - - - false - - - - - - Index: rctags/ehcache-2.10.8.0.7/ehcache/pom.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache/pom.xml (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache/pom.xml (revision 0) @@ -1,443 +0,0 @@ - - - 4.0.0 - - - net.sf.ehcache - ehcache-root - 2.10.8.0.7 - .. - - - ehcache - jar - ehcache - Ehcache is an open source, standards-based cache used to boost performance, - offload the database and simplify scalability. Ehcache is robust, proven and full-featured and - this has made it the most widely-used Java-based cache. - - - - The Apache Software License, Version 2.0 - src/assemble/EHCACHE-CORE-LICENSE.txt - - - http://ehcache.org - - - - ${project.artifactId}-${project.version}-distribution - ${project.build.directory}/${kit.name} - ${project.build.directory}/tmp/terracotta - 1.4 - false - true - - - - - - net.sf.ehcache.internal - ehcache-terracotta-bootstrap - ${project.version} - - - net.sf.ehcache.internal - ehcache-rest-agent - ${project.version} - - - net.sf.ehcache.internal - ehcache-core - ${project.version} - - - net.sf.ehcache.internal - ehcache-scheduled-refresh - ${project.version} - - - net.sf.ehcache.internal - ehcache-search-parser - ${project.version} - - - junit - junit - test - - - org.terracotta - product-upgradability-testing-utils - 0.9.2 - test - - - org.codehaus.btm - btm - 2.1.3 - test - - - org.quartz-scheduler - quartz - 2.2.1 - test - - - org.slf4j - slf4j-jdk14 - ${slf4j.version} - test - - - - - - - ${basedir}/src/main/resources - true - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - copy-TIMs - - org.terracotta.modules - ${project.build.outputDirectory}/META-INF/terracotta/TIMs - **/META-INF/maven/**,**/license.txt,**/thirdpartylicenses.txt - - process-resources - - copy-dependencies - - - - - - org.terracotta - maven-forge-plugin - - - create-manifest - package - - manifest - - - ${basedir}/.. - ${project.build.directory}/MANIFEST.MF - - Apache Software License, Version 2.0 - Supported - ${project.artifactId} - ${project.description} - - - - - enforce-dependencies - - enforceDependencies - - verify - - net.sf.ehcache.internal - ehcache-core - ${project.version} - - - - - - - - - - org.eclipse.m2e - lifecycle-mapping - 1.0.0 - - - - - - org.apache.maven.plugins - maven-dependency-plugin - [2.6,) - - list - - - - - - - - - - - - - - - - - devmode - - - devmode - true - - true - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - list-dependencies - - ${project.build.outputDirectory}/META-INF/devmode/${project.groupId}/${project.artifactId}/dependencies.txt - - - list - - compile - - - - - - - - - fullmode - - - devmode - false - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.9 - - - create-javadoc - prepare-package - - jar - - - - - org.hibernate - hibernate-core - ${hibernate-core.version} - - - ${skipJavadoc} - true - 128m - 512 - true -
ehcache]]>
- ${project.name} ${project.version} API - ${project.name} ${project.version} API - Copyright 2001-{currentYear}, Terracotta, Inc. - ${basedir}/src/main/java/net/sf/ehcache/overview.html - true - - net.sf.ehcache.internal:ehcache-core - -
-
-
-
- - - org.apache.maven.plugins - maven-shade-plugin - - record-shader - true - true - - - net.sf.ehcache.internal:* - org.terracotta.internal:statistics - com.terracotta:clustered-entity-management - - - - - *:* - - META-INF/maven/com.terracotta/** - META-INF/maven/net.sf.ehcache.internal/** - META-INF/maven/org.terracotta.internal/** - **/license.txt - **/thirdpartylicenses.txt - META-INF/*.SF - META-INF/*.DSA - META-INF/*.RSA - **/LICENSE - **/LICENSE.txt - **/NOTICE - **/NOTICE.txt - **/ASL2.0 - **/DEPENDENCIES - - - - true - ${project.build.directory}/dependency-reduced-pom.xml - - - MANIFEST.MF - - - META-INF/MANIFEST.MF - ${project.build.directory}/MANIFEST.MF - - - - - - shade-jar - package - - shade - - - - - - org.apache.maven.plugins - maven-antrun-plugin - 1.7 - - - unpack-jar-for-bundling - package - - run - - - - - - - - - - - org.apache.felix - maven-bundle-plugin - 2.3.7 - - ${project.build.directory} - - bitronix.tm;resolution:=optional, - bitronix.tm.resource.ehcache;resolution:=optional, - com.atomikos.*;resolution:=optional, - com.atomikos.icatch.jta;resolution:=optional, - weblogic.transaction;resolution:=optional, - javax.transaction;resolution:=optional, - javax.servlet;resolution:=optional, - javax.net.ssl;resolution:=optional, - javax.activation;resolution:=optional, - javax.xml.stream;resolution:=optional, - javax.xml.transform.sax;resolution:=optional, - javax.xml.transform.dom;resolution:=optional, - javax.xml.transform.stream;resolution:=optional, - org.hibernate.*;resolution:=optional, - org.terracotta.toolkit.*;resolution:=optional, - org.quartz.*;resolution:=optional, - org.terracotta.quartz.*;resolution:=optional, - !sun.misc,* - - net.sf.ehcache.* - org.terracotta.* - JavaSE-1.6 - - *;scope=provided|runtime - - - - generate-osgi-headers - package - - manifest - - - - - - org.codehaus.gmaven - gmaven-plugin - ${gmaven-plugin.version} - - - repackage-jar - package - - execute - - - - def jarFile = new File(project.build.directory, "${project.artifactId}-${project.version}.jar") - ant.copy(file: new File(project.build.directory, "dependency-reduced-pom.xml"), - tofile: new File(project.build.outputDirectory, "META-INF/maven/${project.groupId}/${project.artifactId}/pom.xml")) - ant.jar(destfile: jarFile, basedir: new File(project.build.outputDirectory).getAbsolutePath(), manifest: new File(project.build.directory, "MANIFEST.MF")) - - - - - -
-
-
-
- - - - terracotta-snapshots - http://www.terracotta.org/download/reflector/snapshots - - - - terracotta-releases - http://www.terracotta.org/download/reflector/releases - - - - - - terracotta-snapshots - http://www.terracotta.org/download/reflector/snapshots - - - terracotta-releases - http://www.terracotta.org/download/reflector/releases - - - - - JIRA - https://jira.terracotta.org/jira/browse/EHC - - -
Index: rctags/ehcache-2.10.8.0.7/pom.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/pom.xml (revision 11085) +++ rctags/ehcache-2.10.8.0.7/pom.xml (revision 0) @@ -1,509 +0,0 @@ - - - 4.0.0 - - - net.sf.ehcache - ehcache-parent - 2.22 - - - - ehcache-root - net.sf.ehcache - ehcache-root - pom - 2.10.8.0.7 - - - scm:svn:https://svn.terracotta.org/repo/ehcache/trunk/ehcache - - - - 1.7.25 - 1.0.1 - 1.4 - 2.15 - 1.17 - 2.1.9 - 0.10.0 - 1.0.2 - 2.2.3 - 9.4.11.v20180605 - 3.5.1-Final - - - - ehcache-core - terracotta - ehcache - management-ehcache-v1 - management-ehcache-v2 - management-ehcache-impl - ehcache-scheduled-refresh - ehcache-search-parser - - - - - - - org.slf4j - slf4j-api - ${slf4j.version} - - - org.terracotta.internal - statistics - ${statistics.version} - - - org.terracotta - management-core-resources - ${management-core.version} - - - com.terracotta - clustered-entity-management - ${clustered-entity-management.version} - - - org.eclipse.jetty - jetty-servlet - ${jetty.version} - - - javax.servlet - javax.servlet-api - - - - - - gf-40 - gf.javax.servlet-api - 3.1.0 - - - - - org.terracotta.toolkit - terracotta-toolkit-api-internal - ${terracotta-toolkit-api-internal.version} - provided - - - javax.servlet - javax.servlet-api - 3.1.0 - provided - - - org.hibernate - hibernate-core - ${hibernate-core.version} - provided - - - javax.transaction - jta - 1.1 - provided - - - net.sf.ehcache - sizeof-agent - 1.0.1 - provided - - - - - org.slf4j - slf4j-jdk14 - ${slf4j.version} - test - - - org.codehaus.btm - btm - 2.1.3 - test - - - net.sf.hibernate - hibernate - 2.1.8 - test - - - org.hamcrest - hamcrest-core - 1.3 - test - - - org.hamcrest - hamcrest-library - 1.3 - test - - - junit - junit - 4.11 - test - - - dom4j - dom4j - 1.6.1 - test - - - javassist - javassist - 3.4.GA - test - - - org.hibernate - hibernate-ehcache - 3.3.2.GA - test - - - ehcache - net.sf.ehcache - - - - - commons-logging - commons-logging - 1.1.1 - test - - - org.apache.derby - derby - 10.5.3.0_1 - test - - - org.mockito - mockito-core - 1.9.0 - test - - - com.sun.xsom - xsom - 20100725 - test - - - org.beanshell - bsh - 1.3.0 - test - - - org.quartz-scheduler - quartz - ${quartz.version} - - - org.easymock - easymock - 3.0 - test - - - org.powermock - powermock-api-easymock - 1.4.10 - test - - - org.powermock - powermock-module-junit4 - 1.4.10 - test - - - - - - - - - org.apache.maven.plugins - maven-jar-plugin - 2.3.2 - - - - true - - - - - - org.apache.maven.plugins - maven-surefire-plugin - ${surefire.version} - - true - - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.8.1 - - - org.apache.maven.plugins - maven-checkstyle-plugin - 2.9.1 - - - org.apache.maven.plugins - maven-dependency-plugin - 2.8 - - - org.codehaus.mojo - build-helper-maven-plugin - 1.7 - - - org.apache.maven.plugins - maven-antrun-plugin - 1.3 - - - org.terracotta - maven-forge-plugin - ${maven-forge-plugin.version} - - -Djava.net.preferIPv4Stack=true - - - - org.apache.maven.plugins - maven-shade-plugin - 2.3 - - - org.terracotta.maven.plugins - terracotta-shader - 1.2 - - - - - org.codehaus.gmaven - gmaven-plugin - ${gmaven-plugin.version} - - - org.codehaus.mojo - rmic-maven-plugin - 1.1 - - - - org.eclipse.m2e - lifecycle-mapping - 1.0.0 - - - - - - org.codehaus.mojo - javacc-maven-plugin - [2.6,) - - javacc - - - - - - - - - - - - - - - org.terracotta - maven-forge-plugin - - - generateBuildInfoFile - generate-resources - - buildinfo - - - true - ${project.build.outputDirectory} - - - - default-test - test - - test - - - - - - - - - - system-tests - - system-tests - - - - dist - - distribution - - - - - - check-short - - true - true - - - - - org.reflections - reflections-maven - 0.9.9-RC1 - - org.reflections.scanners.TypeAnnotationsScanner - ${project.build.directory}/reflections.xml - true - true - - - - - reflections - - process-test-classes - - - - - org.terracotta - maven-forge-plugin - - true - org.terracotta.test.categories.CheckShorts - - - java.awt.headless - true - - - - - - - - - - deploy-terracotta - - - - - org.sonatype.plugins - nexus-staging-maven-plugin - 1.6.1 - true - - - http://nexus.terracotta.eur.ad.sag - - terracotta-nexus-staging - ${skipDeploy} - - - - - - - org.sonatype.plugins - nexus-staging-maven-plugin - - - - - - - deploy-sonatype - - - sonatype-nexus-staging - http://oss.sonatype.org/service/local/staging/deploy/maven2 - - - sonatype-nexus-snapshots - https://oss.sonatype.org/content/repositories/snapshots - - - - - - - - terracotta-nexus-staging - Terracotta Nexus Staging Repository - ${terracotta-nexus-staging-url} - - - terracotta-os-snapshots - false - Terracotta OS Snapshots Repository - ${terracotta-os-snapshots-url} - - - - - - terracotta-snapshots - http://www.terracotta.org/download/reflector/snapshots - - - terracotta-releases - http://www.terracotta.org/download/reflector/releases - - - - - - terracotta-snapshots - http://www.terracotta.org/download/reflector/snapshots - - - terracotta-releases - http://www.terracotta.org/download/reflector/releases - - - Index: rctags/ehcache-2.10.8.0.7/TestCategories.properties =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/TestCategories.properties (revision 11085) +++ rctags/ehcache-2.10.8.0.7/TestCategories.properties (revision 0) @@ -1,328 +0,0 @@ -net.sf.ehcache.AutoVersioningElementTest=production -net.sf.ehcache.CacheClassicLruMemoryStoreTest=production -net.sf.ehcache.CacheCopyOnRwPoolTest=production -net.sf.ehcache.CacheCopyOnRwReplaceRemoveTest=production -net.sf.ehcache.CacheExceptionTest=production -net.sf.ehcache.CacheManagerTest=production -net.sf.ehcache.CachePinningTest=production -net.sf.ehcache.CachePoolPinningTest=production -net.sf.ehcache.CacheTest=production -net.sf.ehcache.ChrisCachePerformanceTest=production -net.sf.ehcache.ClockMemoryStoreTest=production -net.sf.ehcache.DiskStoreTest=production -net.sf.ehcache.DynamicCacheConfigurationTest=production -net.sf.ehcache.ElementTest=production -net.sf.ehcache.ExplicitMaxInMemoryTest=production -net.sf.ehcache.InfiniteCapacityCacheTest=production -net.sf.ehcache.MemoryStoreTester=production -net.sf.ehcache.OverflowCacheTest=production -net.sf.ehcache.PoolCacheManagerTest=production -net.sf.ehcache.RecalculateSizeTest=production -net.sf.ehcache.SameCacheManagerNameTest=production -net.sf.ehcache.StatisticsTest=production -net.sf.ehcache.TerracottaIntegrationTest=production -net.sf.ehcache.XACacheTest=production -net.sf.ehcache.concurrent.ConcurrencyUtilTest=production -net.sf.ehcache.concurrent.ConcurrentCacheMethodsTest=production -net.sf.ehcache.config.CacheConfigConflictTest=production -net.sf.ehcache.config.CacheConfigurationListenerTest=production -net.sf.ehcache.config.CacheConfigurationTest=production -net.sf.ehcache.config.CacheWriterConfigurationTest=production -net.sf.ehcache.config.CoherenceModeConfigTest=production -net.sf.ehcache.config.ConfigurationFactoryTest=production -net.sf.ehcache.config.ConfigurationHelperTest=production -net.sf.ehcache.config.DefaultCacheOptionalTest=production -net.sf.ehcache.config.DynamicCacheConfigurationValidityTest=production -net.sf.ehcache.config.InvalidConfigTest=production -net.sf.ehcache.config.MemoryUnitTest=production -net.sf.ehcache.config.SchemaValidationTest=production -net.sf.ehcache.config.StorageStrategyConfigTest=production -net.sf.ehcache.config.generator.AllConfigurationGeneratedTest=production -net.sf.ehcache.config.generator.ConfigurationGeneratedParsesTest=production -net.sf.ehcache.config.generator.DecoratedCacheConfigTest=production -net.sf.ehcache.config.nonstop.NonStopConfigTest=production -net.sf.ehcache.config.nonstop.NonstopInheritsDefaultConfigTest=production -net.sf.ehcache.constructs.CacheDecoratorFactoryTest=production -net.sf.ehcache.constructs.DecoratorNoNameTest=production -net.sf.ehcache.constructs.DefaultCacheDecoratorFactoryTest=production -net.sf.ehcache.constructs.blocking.BlockingCacheTest=production -net.sf.ehcache.constructs.blocking.SelfPopulatingCacheTest=production -net.sf.ehcache.constructs.blocking.UpdatingSelfPopulatingCacheTest=production -net.sf.ehcache.constructs.locking.ExplicitLockApiTest=production -net.sf.ehcache.constructs.nonstop.BasicNonstopTest=production -net.sf.ehcache.constructs.nonstop.ExecutorServiceTest=production -net.sf.ehcache.constructs.nonstop.NonStopThreadDestroyedTest=production -net.sf.ehcache.constructs.nonstop.NonstopTestUtil=production -net.sf.ehcache.constructs.nonstop.TimeoutOnRejoinTest=production -net.sf.ehcache.distribution.EventMessageTest=production -net.sf.ehcache.distribution.ManualRMIPeerProviderTest=production -net.sf.ehcache.distribution.MulticastRMIPeerProviderTest=production -net.sf.ehcache.distribution.PayloadUtilTest=production -net.sf.ehcache.distribution.RMIBootstrapCacheLoaderTest=production -net.sf.ehcache.distribution.RMICacheManagerPeerListenerTest=production -net.sf.ehcache.distribution.RMICacheManagerPeerTest=production -net.sf.ehcache.distribution.RMICacheReplicatorTest=production -net.sf.ehcache.distribution.RMICacheReplicatorWithLargePayloadTest=production -net.sf.ehcache.distribution.RMIDistributedCacheTest=production -net.sf.ehcache.distribution.ShutdownRMICacheManagerPeerListenerTestImpl=production -net.sf.ehcache.event.BulkOpsEventListenerTest=production -net.sf.ehcache.event.CacheEventListenerTest=production -net.sf.ehcache.event.CacheManagerEventListenerTest=production -net.sf.ehcache.event.EvictionListenerTest=production -net.sf.ehcache.event.ProgrammaticallyCreatedCacheEventListenerTest=production -net.sf.ehcache.event.TestCacheManagerEventListenerFactory=production -net.sf.ehcache.exceptionhandler.CacheExceptionHandlerTest=production -net.sf.ehcache.extension.CacheExtensionTest=production -net.sf.ehcache.extension.TestCacheExtension=production -net.sf.ehcache.extension.TestCacheExtensionFactory=production -net.sf.ehcache.hibernate.EhCacheRegionFactoryTest=production -net.sf.ehcache.hibernate.HibernateAPIUsageTest=production -net.sf.ehcache.hibernate.HibernateCacheTest=production -net.sf.ehcache.hibernate.management.impl.EhcacheStatsImplTest=production -net.sf.ehcache.loader.CacheLoaderTest=production -net.sf.ehcache.loader.CompositeLoaderTest=production -net.sf.ehcache.management.ManagementServiceTest=production -net.sf.ehcache.management.ResourceClassLoaderTest=production -net.sf.ehcache.management.sampled.MBeanRegistrationProviderTest=production -net.sf.ehcache.pool.PoolableStoresTest=production -net.sf.ehcache.pool.TwinCachesTest=production -net.sf.ehcache.pool.sizeof.AgentLoaderRaceTest=production -net.sf.ehcache.pool.sizeof.AgentLoaderSystemPropTest=production -net.sf.ehcache.pool.sizeof.AgentLoaderTest=production -net.sf.ehcache.pool.sizeof.FilteredSizeOfTest=production -net.sf.ehcache.pool.sizeof.ObjectGraphWalkerTest=production -net.sf.ehcache.pool.sizeof.SizeOfTest=production -net.sf.ehcache.pool.sizeof.filter.AnnotationProxyFactoryTest=production -net.sf.ehcache.search.BasicSearchTest=production -net.sf.ehcache.search.QueryExamplesTest=production -net.sf.ehcache.search.SearchTestUtil=production -net.sf.ehcache.search.TestAttributeExtractor=production -net.sf.ehcache.search.TransactionalSearchTest=production -net.sf.ehcache.search.attribute.JavaBeanAttributeExtractorTest=production -net.sf.ehcache.search.attribute.ReflectionAttributeExtractorTest=production -net.sf.ehcache.servermaplocalcache.ServerMapLocalCacheTest=production -net.sf.ehcache.statistics.CacheUsageListenerTest=production -net.sf.ehcache.statistics.DisabledCacheStatisticsTest=production -net.sf.ehcache.statistics.LiveCacheStatisticsTest=production -net.sf.ehcache.store.CacheKeySetTest=production -net.sf.ehcache.store.DiskBackedMemoryStoreTest=production -net.sf.ehcache.store.DiskStoreBootstrapCacheLoaderFactoryTest=production -net.sf.ehcache.store.ElementIdAssigningStoreTest=production -net.sf.ehcache.store.FifoMemoryStoreTest=production -net.sf.ehcache.store.InitialCapacityTest=production -net.sf.ehcache.store.LruClassicMemoryStoreTest=production -net.sf.ehcache.store.LruMemoryStoreTest=production -net.sf.ehcache.store.MemoryOnlyStoreTest=production -net.sf.ehcache.store.MemoryStorePinningTest=production -net.sf.ehcache.store.MemoryStorePoolingTest=production -net.sf.ehcache.store.OffheapStoreInOssTest=production -net.sf.ehcache.store.PoolableMemoryStoreTest=production -net.sf.ehcache.store.XATransactionalStoreTest=production -net.sf.ehcache.store.chm.SelectableConcurrentHashMapTest=production -net.sf.ehcache.store.compound.PartialSerializationCopyStrategyTest=production -net.sf.ehcache.store.compound.TCCLReadWriteSerializationCopyStrategyTest=production -net.sf.ehcache.store.disk.DiskBackMemoryStoreTest=production -net.sf.ehcache.store.disk.DiskStorePoolingTest=production -net.sf.ehcache.store.disk.DiskStoreTest=production -net.sf.ehcache.store.disk.ods.FileAllocationTreeTest=production -net.sf.ehcache.terracotta.BasicRejoinTest=production -net.sf.ehcache.terracotta.BootstrapCacheTest=quarantined -net.sf.ehcache.terracotta.EventReplicationTest=production -net.sf.ehcache.terracotta.KeySnapshotterTest=production -net.sf.ehcache.terracotta.RejoinEventSequenceTest=production -net.sf.ehcache.terracotta.RotatingSnapshotFileTest=production -net.sf.ehcache.terracotta.StorageStrategyInvalidConfigurationTest=production -net.sf.ehcache.terracotta.TerracottaBootstrapCacheLoaderTest=production -net.sf.ehcache.terracotta.TerracottaUnitTesting=production -net.sf.ehcache.terracotta.TerracottaWithLocalOffHeapTest=production -net.sf.ehcache.terracotta.TestRejoinStore=production -net.sf.ehcache.transaction.SoftLockPinningTest=production -net.sf.ehcache.transaction.local.LocalTransactionSizeOfTest=production -net.sf.ehcache.transaction.local.LocalTransactionTest=production -net.sf.ehcache.transaction.xa.TwoPCTest=production -net.sf.ehcache.transaction.xa.XAThreadPoolTest=production -net.sf.ehcache.transaction.xa.XATransactionSizeOfTest=production -net.sf.ehcache.transaction.xa.XATransactionTest=production -net.sf.ehcache.util.LargeCollectionTest=production -net.sf.ehcache.util.MemoryEfficientByteArrayOutputStreamTest=production -net.sf.ehcache.util.MemorySizeParserTest=production -net.sf.ehcache.util.ProductInfoTest=production -net.sf.ehcache.util.SlewClockTest=production -net.sf.ehcache.util.SmokeTests=production -net.sf.ehcache.util.TimestamperTest=production -net.sf.ehcache.util.UpdateCheckerTest=production -net.sf.ehcache.util.WeakIdentityConcurrentMapTest=production -net.sf.ehcache.writer.CacheWriterTest=production -net.sf.ehcache.writer.CoalesceKeysFilterTest=production -net.sf.ehcache.writer.TestCacheWriter=production -net.sf.ehcache.writer.TestCacheWriterException=production -net.sf.ehcache.writer.TestCacheWriterFactory=production -net.sf.ehcache.writer.TestCacheWriterRetries=production -net.sf.ehcache.writer.TestCacheWriterSlow=production -org.terracotta.ehcache.tests.BasicAtomikosXATest=quarantined -org.terracotta.ehcache.tests.BasicBTMXATest=quarantined -org.terracotta.ehcache.tests.BasicStandaloneCacheAndServerTopologyTest=production -org.terracotta.ehcache.tests.BasicStandaloneCacheTest=production -org.terracotta.ehcache.tests.BasicWriteBehindTest=quarantined -org.terracotta.ehcache.tests.CacheBlockingQueueTest=quarantined -org.terracotta.ehcache.tests.CacheConsistencyTest=production -org.terracotta.ehcache.tests.CacheLocksTest=quarantined -org.terracotta.ehcache.tests.CacheWriterBTMXATest=quarantined -org.terracotta.ehcache.tests.ClusterCacheEventsRejoinEnabledTest=quarantined -org.terracotta.ehcache.tests.ClusterEventsRejoinEnabledTest=quarantined -org.terracotta.ehcache.tests.ClusterEventsTest=production -org.terracotta.ehcache.tests.ClusteredCacheRemovalTest=quarantined -org.terracotta.ehcache.tests.CoalescingWriteBehindTest=quarantined -org.terracotta.ehcache.tests.CompressedCacheTest=production -org.terracotta.ehcache.tests.ConcurrencyValueTest=quarantined -org.terracotta.ehcache.tests.CopyOnWriteTest=production -org.terracotta.ehcache.tests.DoubleConfigStandaloneCacheTest=production -org.terracotta.ehcache.tests.EmbeddedConfigNamespaceStandaloneCacheTest=production -org.terracotta.ehcache.tests.EmbeddedConfigStandaloneCacheTest=production -org.terracotta.ehcache.tests.EmbeddedEhcacheJarTest=production -org.terracotta.ehcache.tests.EmbeddedEhcacheJarTestClient=production -org.terracotta.ehcache.tests.ExpiryListenerTest=production -org.terracotta.ehcache.tests.ExplicitlyUnclusteredStandaloneCacheTest=production -org.terracotta.ehcache.tests.ExpressShutdownTest=production -org.terracotta.ehcache.tests.GetKeysSerializedCacheTest=production -org.terracotta.ehcache.tests.HibernateExpressShutdownTest=production -org.terracotta.ehcache.tests.LocalTxTest=production -org.terracotta.ehcache.tests.MemoryStoreEvictionPolicyTest=production -org.terracotta.ehcache.tests.MixedCacheTest=production -org.terracotta.ehcache.tests.NamelessCacheManagerStandaloneCacheTest=production -org.terracotta.ehcache.tests.NoTcConfigStandaloneCacheTest=production -org.terracotta.ehcache.tests.OtherClassLoaderEventTest=production -org.terracotta.ehcache.tests.OtherClassloaderCacheTest=production -org.terracotta.ehcache.tests.OverflowToDiskStandaloneCacheTest=production -org.terracotta.ehcache.tests.SerializationWriteBehindTest=production -org.terracotta.ehcache.tests.SerializedArrayCacheTest=production -org.terracotta.ehcache.tests.SuspendResumeAtomikosXATest=production -org.terracotta.ehcache.tests.SuspendResumeBTMXATest=production -org.terracotta.ehcache.tests.SynchronousWriteBehindTest=production -org.terracotta.ehcache.tests.SystemPropTcConfigTest=production -org.terracotta.ehcache.tests.ThreadLocalTest=production -org.terracotta.ehcache.tests.TwoResourceAtomikosXATest=production -org.terracotta.ehcache.tests.TwoResourceBTMXATest=production -org.terracotta.ehcache.tests.TwoResourceSuspendResumeAtomikosXATest=production -org.terracotta.ehcache.tests.TwoResourceSuspendResumeBTMXATest=production -org.terracotta.ehcache.tests.UrlConfigStandaloneCacheTest=production -org.terracotta.ehcache.tests.XAResourceTest=production -org.terracotta.ehcache.tests.coherence.CacheCoherenceExpressTest=quarantined -org.terracotta.ehcache.tests.coherence.IncoherentNodesTest=quarantined -org.terracotta.ehcache.tests.coherence.RestartingL1ExpressTest=quarantined -org.terracotta.ehcache.tests.container.BasicContainerJTATest=production -org.terracotta.ehcache.tests.container.BasicContainerTest=production -org.terracotta.ehcache.tests.container.BasicJTATestServlet=production -org.terracotta.ehcache.tests.container.BasicTestServlet=production -org.terracotta.ehcache.tests.container.EARContainerTest=production -org.terracotta.ehcache.tests.container.TwoResourceContainerJTATest=production -org.terracotta.ehcache.tests.container.TwoResourceJTATestServlet=production -org.terracotta.ehcache.tests.container.hibernate.BaseClusteredRegionFactoryTest=production -org.terracotta.ehcache.tests.container.hibernate.BaseClusteredRegionFactoryTestServlet=production -org.terracotta.ehcache.tests.container.hibernate.nontransactional.EhCacheClusteredHibernateCacheTest=production -org.terracotta.ehcache.tests.container.hibernate.nontransactional.EmptySecondLevelCacheEntryTest=production -org.terracotta.ehcache.tests.container.hibernate.nontransactional.KeyDeserializationSecondLevelCacheEntryTest=production -org.terracotta.ehcache.tests.container.hibernate.nontransactional.KeyDeserializationSecondLevelCacheEntryTestServlet=production -org.terracotta.ehcache.tests.container.hibernate.nontransactional.NonEternalSecondLevelCacheTest=production -org.terracotta.ehcache.tests.container.hibernate.nontransactional.NonEternalSecondLevelCacheTestServlet=production -org.terracotta.ehcache.tests.container.hibernate.nontransactional.NonTransactionalCacheTest=production -org.terracotta.ehcache.tests.container.hibernate.nontransactional.QueryCacheInvalidationTest=production -org.terracotta.ehcache.tests.loader.LoaderTest=production -org.terracotta.ehcache.tests.servermap.BasicServerMapExpressCacheTest=production -org.terracotta.ehcache.tests.servermap.BasicServerMapExpressTestHelper=production -org.terracotta.ehcache.tests.servermap.CacheSizeTest=production -org.terracotta.ehcache.tests.servermap.LockGCNotFlushingEntriesTest=production -org.terracotta.ehcache.tests.servermap.LockGCNotFlushingEntriesTestClient=production -org.terracotta.ehcache.tests.servermap.ServerMapCapacityEvictionExpressTest=production -org.terracotta.ehcache.tests.servermap.ServerMapCapacityEvictionExpressTestClient=production -org.terracotta.ehcache.tests.servermap.ServerMapClearExpressTest=production -org.terracotta.ehcache.tests.servermap.ServerMapClearExpressTestClient1=production -org.terracotta.ehcache.tests.servermap.ServerMapClearExpressTestClient2=production -org.terracotta.ehcache.tests.servermap.ServerMapClearTestHelper=production -org.terracotta.ehcache.tests.servermap.ServerMapElementTTIExpressTest=production -org.terracotta.ehcache.tests.servermap.ServerMapElementTTIExpressTestClient=production -org.terracotta.ehcache.tests.servermap.ServerMapElementTTLExpressTest=production -org.terracotta.ehcache.tests.servermap.ServerMapElementTTLExpressTestClient=production -org.terracotta.ehcache.tests.servermap.ServerMapL1CapacityEvictionExpressTest=production -org.terracotta.ehcache.tests.servermap.ServerMapL1CapacityEvictionExpressTestClient=production -org.terracotta.ehcache.tests.servermap.ServerMapL1CapacityExpirationExpressTest=production -org.terracotta.ehcache.tests.servermap.ServerMapL1CapacityExpirationExpressTestClient=production -org.terracotta.ehcache.tests.servermap.ServerMapL1EvictionOffHeapDestroyExpressTest=production -org.terracotta.ehcache.tests.servermap.ServerMapL1EvictionOffHeapDestroyExpressTestClient=production -org.terracotta.ehcache.tests.servermap.ServerMapL2EvictionReachesL1Test=production -org.terracotta.ehcache.tests.servermap.ServerMapL2EvictionReachesL1TestClient=production -org.terracotta.ehcache.tests.servermap.ServerMapL2EvictionReachesOneL1Test=production -org.terracotta.ehcache.tests.servermap.ServerMapL2EvictionReachesOneL1TestClient=production -org.terracotta.ehcache.tests.servermap.ServerMapLocalSizeTest=production -org.terracotta.ehcache.tests.servermap.ServerMapTTIExpressTest=production -org.terracotta.ehcache.tests.servermap.ServerMapTTIExpressTestClient=production -org.terracotta.ehcache.tests.servermap.ServerMapTTLExpressTest=production -org.terracotta.ehcache.tests.servermap.ServerMapTTLExpressTestClient=production -org.terracotta.modules.ehcache.LocalVMResourcesTestUtil=production -org.terracotta.modules.ehcache.bulkops.BulkOpsBasicSerializationSanityTest=production -org.terracotta.modules.ehcache.bulkops.BulkOpsExplictLockingTest=production -org.terracotta.modules.ehcache.bulkops.BulkOpsGenericSanityTest=production -org.terracotta.modules.ehcache.bulkops.GetAllCustomMapTest=production -org.terracotta.modules.ehcache.bulkops.GetAllNonLiteralTest=production -org.terracotta.modules.ehcache.bulkops.GetAllTest=production -org.terracotta.modules.ehcache.cluster.CacheClusterTest=production -org.terracotta.modules.ehcache.cluster.ClusterTopologyListenerTest=production -org.terracotta.modules.ehcache.cluster.FailoverDuringPassiveSyncTest=production -org.terracotta.modules.ehcache.cluster.FailoverToOutOfSyncPassivesTest=production -org.terracotta.modules.ehcache.coherence.CacheCoherenceTest=production -org.terracotta.modules.ehcache.coherence.CacheCoherenceTestL1Client=production -org.terracotta.modules.ehcache.coherence.GetSizeTest=production -org.terracotta.modules.ehcache.coherence.NoLocksCreatedEventualTest=production -org.terracotta.modules.ehcache.coherence.NoLocksCreatedTest=production -org.terracotta.modules.ehcache.event.ClusterTopologyTest=production -org.terracotta.modules.ehcache.event.ClusteredEventsAllTest=production -org.terracotta.modules.ehcache.event.ClusteredEventsEvictionExpiryTest=production -org.terracotta.modules.ehcache.event.ClusteredEventsLocalTest=production -org.terracotta.modules.ehcache.event.ClusteredEventsRemoteTest=production -org.terracotta.modules.ehcache.event.ClusteredEventsSerializationTest=production -org.terracotta.modules.ehcache.l1bm.L1BMCacheManagerRecreateTest=production -org.terracotta.modules.ehcache.l1bm.L1BMCacheStatisticsTest=production -org.terracotta.modules.ehcache.l1bm.L1BMDynamicConfigurationTest=production -org.terracotta.modules.ehcache.l1bm.L1BMOnHeapActivePassiveSanityTest=production -org.terracotta.modules.ehcache.l1bm.L1BMOnHeapBasicSanityTestApp=production -org.terracotta.modules.ehcache.l1bm.L1BMOnHeapReadWriteTest=production -org.terracotta.modules.ehcache.l1bm.L1BMOnHeapSanityTest=production -org.terracotta.modules.ehcache.l1bm.L1BMOnHeapWithTTISanityTest=production -org.terracotta.modules.ehcache.l1bm.L1BMOnHeapWithTTLSanityTest=production -org.terracotta.modules.ehcache.l1bm.L1BMUpdateInvalidatedEntryTest=production -org.terracotta.modules.ehcache.store.BasicCacheSyncWriteTest=production -org.terracotta.modules.ehcache.store.BasicCacheTest=production -org.terracotta.modules.ehcache.store.BlockingCacheTest=production -org.terracotta.modules.ehcache.store.CachePinningTest=production -org.terracotta.modules.ehcache.store.ClassicIsInvalidTest=production -org.terracotta.modules.ehcache.store.ConcurrentCacheMethodsTest=production -org.terracotta.modules.ehcache.store.CopyOnReadTest=production -org.terracotta.modules.ehcache.store.DCV2ConfigurationChangePropagationTest=production -org.terracotta.modules.ehcache.store.DynamicCacheConfigurationTest=production -org.terracotta.modules.ehcache.store.EvictionListenerTest=production -org.terracotta.modules.ehcache.store.ExpirationListenerTest=production -org.terracotta.modules.ehcache.store.GetKeysSerializedCacheTest=production -org.terracotta.modules.ehcache.store.InlineExpirationTest=production -org.terracotta.modules.ehcache.store.LocalBufferedMapTest=production -org.terracotta.modules.ehcache.store.LocalReadsGetKeysTest=production -org.terracotta.modules.ehcache.store.NoCacheWithMaxBytesLocalDiskTest=production -org.terracotta.modules.ehcache.store.PinnedCacheTest=production -org.terracotta.modules.ehcache.store.PrimitiveClassTest=production -org.terracotta.modules.ehcache.store.ProgrammaticCacheTest=production -org.terracotta.modules.ehcache.store.ProgrammaticConfigTest=production -org.terracotta.modules.ehcache.store.SampledStatisticTimerTest=production -org.terracotta.modules.ehcache.store.SerializedCacheCopyOnReadTest=production -org.terracotta.modules.ehcache.store.SerializedCacheTest=production -org.terracotta.modules.ehcache.store.ServerMapBasicCacheTest=production -org.terracotta.modules.ehcache.store.SimpleVersionTest=production -org.terracotta.modules.ehcache.store.StorageStrategyNotSupportedTest=production -org.terracotta.modules.ehcache.store.TTICacheTest=production -org.terracotta.modules.ehcache.store.TTLCacheTest=production -org.terracotta.modules.ehcache.store.TotalCapacityTest=production -org.terracotta.modules.ehcache.store.backend.BulkLoadInternalKeyRepresentationExposedTest=production -org.terracotta.modules.ehcache.writebehind.AsyncWriteBehindTest=production -org.terracotta.modules.ehcache.writebehind.BasicWriteBehindTest=production -org.terracotta.modules.ehcache.writebehind.CacheSeparationWriteBehindTest=production -org.terracotta.modules.ehcache.writebehind.CoalescingWriteBehindTest=production -org.terracotta.modules.ehcache.writebehind.RemovingCacheWriteBehindTest=production -org.terracotta.modules.ehcache.writebehind.SerializationWriteBehindTest=production Index: rctags/ehcache-2.10.8.0.7/distribution/pom.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/distribution/pom.xml (revision 11085) +++ rctags/ehcache-2.10.8.0.7/distribution/pom.xml (revision 0) @@ -1,298 +0,0 @@ - - - 4.0.0 - - - net.sf.ehcache - ehcache-root - 2.10.8.0.7 - - - ehcache-kit - pom - ehcache-kit - - project to build distribution kit - - - colorcache - events - - - - ehcache - ${productName}-${project.version} - ${kitFolder}-distribution - ${project.build.directory}/${kitFolder} - ${project.build.directory}/tmp/terracotta - - - - - net.sf.ehcache - ehcache - ${project.version} - provided - - - org.slf4j - slf4j-api - provided - - - org.slf4j - slf4j-jdk14 - provided - - - - - - includeJavadoc - - - !skipJavadoc - - - - - net.sf.ehcache - ehcache - ${project.version} - javadoc - provided - - - - - - - - - com.github.goldin - copy-maven-plugin - 0.2.3.8 - - false - - - - {{ new File( project.build.directory, "${kitFolder}" ).isDirectory() }} - ${root.dir} - - **/** - - true - true - - - - ${root.dir} - ${basedir}/src/main/assembly/root - true - true - - - - ${root.dir} - ${basedir}/../ehcache-core/src/main/config - true - - - - ${root.dir}/src - - - net.sf.ehcache - ehcache - sources - - - true - - - - false - ${root.dir}/javadoc - - - net.sf.ehcache - ehcache - javadoc - - - true - - - - {{ new File(project.properties['terracotta.kit.path']).isDirectory() }} - ${root.dir}/samples - - - net.sf.ehcache.examples - events - ${project.version} - distribution - tar.gz - - - net.sf.ehcache.examples - colorcache - ${project.version} - distribution - tar.gz - - - true - - - - {{ new File(project.properties['terracotta.kit.path']).isDirectory() }} - ${root.dir}/terracotta - ${terracotta.kit.path} - - **/ehcache/** - **/quartz/** - **/sessions/** - - true - - - {{ new File(project.properties['terracotta.kit.path']).isDirectory() }} - ${root.dir}/samples - ${terracotta.kit.path}/ehcache/samples - true - - - {{ new File(project.properties['terracotta.kit.path']).isDirectory() }} - ${root.dir}/samples/colorcache/bin - ${basedir}/src/main/assembly - - relative-paths.* - - - - {{ new File(project.properties['terracotta.kit.path']).isDirectory() }} - ${root.dir}/samples/events/bin - ${basedir}/src/main/assembly - - relative-paths.* - - - - - - - package-with-no-tc - package - - copy - - - - - - - org.terracotta - maven-forge-plugin - - - package-lib - package - - copy-dependencies - - - ${root.dir}/lib - false - - net.sf.ehcache:ehcache:${project.version} - org.slf4j:slf4j-api:${slf4j.version} - org.slf4j:slf4j-jdk14:${slf4j.version} - - - - - - - org.codehaus.gmaven - gmaven-plugin - - - create-tarball - package - - execute - - - - def srcdir = new File(project.basedir, "target/${kitFolder}") - def destFile = new File(project.basedir, "target/${tarballName}.tar.gz") - ant.tar(destfile: "${destFile}", longfile: "gnu", compression: "gzip") { - tarfileset(dir: "${srcdir}", prefix: "${kitFolder}", excludes: "**/bin/**,**/lib/**,**/*.sh,**/*.bat") - tarfileset(dir: "${srcdir}", prefix: "${kitFolder}", includes: "**/bin/**,**/lib/**,**/*.sh,**/*.bat", filemode: "755") - } - - - - - - - org.codehaus.mojo - build-helper-maven-plugin - 1.5 - - - attach-distribution - package - - attach-artifact - - - - - ${project.build.directory}/${tarballName}.tar.gz - tar.gz - distribution - - - - - - - - - - - - terracotta-snapshots - http://www.terracotta.org/download/reflector/snapshots - - - terracotta-releases - http://www.terracotta.org/download/reflector/releases - - - - - - terracotta-snapshots - http://www.terracotta.org/download/reflector/snapshots - - - terracotta-releases - http://www.terracotta.org/download/reflector/releases - - - evgenyg.artifactoryonline.com - http://evgenyg.artifactoryonline.com/evgenyg/repo/ - - true - - - false - - - - - Index: rctags/ehcache-2.10.8.0.7/terracotta/pom.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/terracotta/pom.xml (revision 11085) +++ rctags/ehcache-2.10.8.0.7/terracotta/pom.xml (revision 0) @@ -1,74 +0,0 @@ - - - 4.0.0 - - - net.sf.ehcache - ehcache-root - 2.10.8.0.7 - - - net.sf.ehcache.internal - ehcache-terracotta-root - ehcache-terracotta-root - pom - - - bootstrap - - - - - terracotta-snapshots - http://www.terracotta.org/download/reflector/snapshots - - false - - - true - - - - terracotta-releases - http://www.terracotta.org/download/reflector/releases - - true - - - false - - - - - - - terracotta-snapshots - http://www.terracotta.org/download/reflector/snapshots - - false - - - true - - - - terracotta-releases - http://www.terracotta.org/download/reflector/releases - - true - - - false - - - - - - - deploy-sonatype - - true - - - - Index: rctags/ehcache-2.10.8.0.7/system-tests/pom.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/system-tests/pom.xml (revision 11085) +++ rctags/ehcache-2.10.8.0.7/system-tests/pom.xml (revision 0) @@ -1,325 +0,0 @@ - - 4.0.0 - - org.terracotta - system-tests-parent - 4.3.8.0.8 - - - net.sf.ehcache.internal - ehcache-terracotta-system-tests - 2.10.8.0.7 - ehcache-terracotta-system-tests - System tests for ehcache-terracotta - - 512m - 1024m - -XX:MaxPermSize=512m - true - true - 10.10.1.1 - 2.2.3 - 1.7.7 - 1.5 - - - - org.terracotta - terracotta - ${terracotta.core.version} - - - gf-40 - gf.javax.servlet-api - - - - - net.sf.ehcache - ehcache - ${project.version} - test - - - net.sf.ehcache - management-ehcache-v1 - ${project.version} - test - - - net.sf.ehcache - management-ehcache-v2 - ${project.version} - test - - - org.slf4j - slf4j-simple - ${slf4j.version} - - - org.terracotta - terracotta-toolkit-runtime - ${terracotta.core.version} - test - - - asm - asm - 3.2 - test - - - org.hibernate - hibernate-core - 3.3.2.GA - test - - - javassist - javassist - 3.8.0.GA - test - - - org.apache.derby - derby - ${derby.version} - test - - - org.apache.derby - derbynet - ${derby.version} - test - - - org.apache.derby - derbyclient - ${derby.version} - test - - - javax.transaction - jta - 1.1 - test - - - org.codehaus.btm - btm - 2.1.3 - test - - - org.apache.geronimo.specs - geronimo-jta_1.0.1B_spec - 1.0.1 - test - - - com.atomikos - transactions-jta - 3.8.0 - test - - - org.mockito - mockito-all - - - - - org.ow2.jotm - jotm-core - 2.1.9 - test - - - org.terracotta.test - container-test-framework - - - org.quartz-scheduler - quartz - ${quartz.version} - - - com.jayway.restassured - rest-assured - 1.8.1 - - - org.codehaus.groovy - groovy - - - org.hamcrest - * - - - com.fasterxml.jackson.core - jackson-databind - - - test - - - org.codehaus.groovy - groovy-all - 2.1.2 - test - - - net.sf.ehcache.test - hibernate-ehcache-bundle - ${osgi-test-tool.version} - - - org.terracotta.test - osgi-test-utils - ${osgi-test-tool.version} - - - - - - org.apache.maven.plugins - maven-jar-plugin - - - test-jar - - test-jar - - - - - - org.apache.servicemix.tooling - depends-maven-plugin - 1.2 - - - generate-depends-file - - generate-depends-file - - - - - - - - - org.eclipse.m2e - lifecycle-mapping - 1.0.0 - - - - - - org.apache.maven.plugins - maven-checkstyle-plugin - [2.8,) - - checkstyle - - - - - - - - - - - - - - - - include-container-tests - - - appserver - - - - - - org.terracotta - maven-forge-plugin - - - **/container/**/*Test.java - - - - - - - - no-appserver-tests - - - appserver - no-appserver - - - - - - org.terracotta - maven-forge-plugin - - -Xmx768m - -XX:MaxPermSize=128m - - **/*Test.java - - - - - - - - deploy-sonatype - - true - - - - - - terracotta-snapshots - http://www.terracotta.org/download/reflector/snapshots - - - terracotta-releases - http://www.terracotta.org/download/reflector/releases - - - jboss - JBoss Repository - https://repository.jboss.org/nexus/content/repositories/public/ - - true - - - false - - - - - - terracotta-snapshots - http://www.terracotta.org/download/reflector/snapshots - - - terracotta-releases - http://www.terracotta.org/download/reflector/releases - - - Index: rctags/ehcache-2.10.8.0.7/management-ehcache-v2/pom.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/management-ehcache-v2/pom.xml (revision 11085) +++ rctags/ehcache-2.10.8.0.7/management-ehcache-v2/pom.xml (revision 0) @@ -1,72 +0,0 @@ - - - 4.0.0 - - - net.sf.ehcache - ehcache-root - 2.10.8.0.7 - .. - - - management-ehcache-v2 - management-ehcache-v2 - A library defining the ehcache management resource services and resource entities, version 2 - - - - org.terracotta - management-common-resources-v2 - ${management-core.version} - - - - - junit - junit - test - - - org.easymock - easymock - test - - - net.sf.ehcache.internal - ehcache-core - test-jar - ${project.version} - test - - - - - - - org.apache.maven.plugins - maven-jar-plugin - - - - - - - terracotta-snapshots - http://www.terracotta.org/download/reflector/snapshots - - - terracotta-releases - http://www.terracotta.org/download/reflector/releases - - - - - terracotta-snapshots - http://www.terracotta.org/download/reflector/snapshots - - - terracotta-releases - http://www.terracotta.org/download/reflector/releases - - - Index: rctags/ehcache-2.10.8.0.7/management-ehcache-impl/pom.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/management-ehcache-impl/pom.xml (revision 11085) +++ rctags/ehcache-2.10.8.0.7/management-ehcache-impl/pom.xml (revision 0) @@ -1,43 +0,0 @@ - - - 4.0.0 - - - net.sf.ehcache - ehcache-root - 2.10.8.0.7 - .. - - - management-ehcache-impl-parent - management-ehcache-impl-parent - pom - - - management-ehcache-impl-v1 - management-ehcache-impl-v2 - management-ehcache-common - ehcache-rest-agent - - - - - terracotta-snapshots - http://www.terracotta.org/download/reflector/snapshots - - - terracotta-releases - http://www.terracotta.org/download/reflector/releases - - - - - terracotta-snapshots - http://www.terracotta.org/download/reflector/snapshots - - - terracotta-releases - http://www.terracotta.org/download/reflector/releases - - - Index: rctags/ehcache-2.10.8.0.7/third-party.txt =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/third-party.txt (revision 11085) +++ rctags/ehcache-2.10.8.0.7/third-party.txt (revision 0) @@ -1,5 +0,0 @@ -This project depends on repackaged GlassFish libraries. -They can be identified by their groupId starting with gf-*. - -The source code for these libraries can be found at https://svn.java.net/svn/glassfish~svn/. -Otherwise contact to get the source code for these libraries. \ No newline at end of file Index: rctags/ehcache-2.10.8.0.7/management-ehcache-impl/ehcache-rest-agent/pom.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/management-ehcache-impl/ehcache-rest-agent/pom.xml (revision 11085) +++ rctags/ehcache-2.10.8.0.7/management-ehcache-impl/ehcache-rest-agent/pom.xml (revision 0) @@ -1,249 +0,0 @@ - - - 4.0.0 - - - net.sf.ehcache - management-ehcache-impl-parent - 2.10.8.0.7 - .. - - - net.sf.ehcache.internal - ehcache-rest-agent - ehcache-rest-agent - - Ehcache REST implementation - - - rest-management-private-classpath - .class_terracotta - true - false - - - - - net.sf.ehcache - management-ehcache-impl-v1 - ${project.version} - - - net.sf.ehcache - management-ehcache-impl-v2 - ${project.version} - - - gf-40 - gf.javax.servlet-api - 3.1.0 - - - org.eclipse.jetty - jetty-servlet - - - javax.xml.bind - jaxb-api - 2.3.0 - - - - - - - org.apache.maven.plugins - maven-jar-plugin - - - - - - - org.eclipse.m2e - lifecycle-mapping - 1.0.0 - - - - - - org.apache.maven.plugins - maven-dependency-plugin - [2.6,) - - list - - - - - - - - - - - - - - - - - devmode - - - devmode - true - - true - - - - .class - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - list-dependencies - - ${project.build.outputDirectory}/META-INF/devmode/${project.groupId}/${project.artifactId}/dependencies.txt - - - list - - compile - - - - - - org.apache.maven.plugins - maven-shade-plugin - - reduced-pom-only-shader - ${project.build.directory}/dependency-reduced-pom.xml - true - true - false - false - - - - org.slf4j:* - - - - - - package - - shade - - - - - - - - - - fullmode - - - devmode - false - - - - - - org.apache.maven.plugins - maven-shade-plugin - - record-shader - ${project.build.directory}/dependency-reduced-pom.xml - true - true - false - true - - - - org.slf4j:* - - - - - *:* - - META-INF/*.SF - META-INF/*.DSA - META-INF/*.RSA - - - - - - - - - - package - - shade - - - - - - org.codehaus.gmaven - gmaven-plugin - - - fix-content - package - - execute - - - - ${basedir}/src/scripts - - - import Util - Util.packageAgentJar(project) - - - - - - - - - - - - - terracotta-snapshots - http://www.terracotta.org/download/reflector/snapshots - - - terracotta-releases - http://www.terracotta.org/download/reflector/releases - - - - - terracotta-snapshots - http://www.terracotta.org/download/reflector/snapshots - - - terracotta-releases - http://www.terracotta.org/download/reflector/releases - - - Index: rctags/ehcache-2.10.8.0.7/distribution/events/pom.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/distribution/events/pom.xml (revision 11085) +++ rctags/ehcache-2.10.8.0.7/distribution/events/pom.xml (revision 0) @@ -1,299 +0,0 @@ - - 4.0.0 - - org.terracotta.forge - forge-parent - 4.0 - - - net.sf.ehcache.examples - events - 2.10.8.0.7 - events - war - Clustered Ehcache Terracotta as second level cache for Hibernate - - 2.1.0 - 4.3.8.0.8 - 1.1.116 - 9.4.11.v20180605 - 1.1 - true - - - - org.slf4j - slf4j-api - 1.7.25 - - - org.apache.logging.log4j - log4j-slf4j-impl - 2.11.2 - - - javassist - javassist - 3.8.0.GA - - - h2 - ${h2.version} - com.h2database - - - net.sf.ehcache - ehcache - ${project.version} - - - org.terracotta - terracotta-toolkit-runtime - ${terracotta.version} - - - commons-logging - commons-logging - 1.1 - compile - - - log4j - log4j - - - logkit - logkit - - - avalon-framework - avalon-framework - - - javax.servlet - servlet-api - - - - - gf-40 - gf.javax.servlet-api - 3.1.0 - - - org.hibernate - hibernate-core - 3.3.1.GA - - - org.slf4j - slf4j-api - - - javax.transaction - jta - - - - - gf-3122 - gf.javax.transaction - 1.1 - - - - ${project.name} - - - maven-assembly-plugin - 2.3 - - ${project.name} - - src/assemble/distribution.xml - - gnu - - - - package - - single - - - - - - maven-jetty-plugin - ${jetty.version} - org.mortbay.jetty - - ${name} - STOP - - - - hibernate3-maven-plugin - 2.1 - org.codehaus.mojo - - - target/classes/hibernate3hbm2ddl.properties - target/classes/hibernate.cfg.xml - true - true - schema.sql - - - - - com.h2database - h2 - ${h2.version} - - - - - org.terracotta.maven.plugins - tc-maven-plugin - ${tc-maven-plugin.version} - - - org.terracotta - terracotta - ${terracotta.version} - - - - - - - - start-h2 - - - - org.codehaus.mojo - exec-maven-plugin - ${exec-maven-plugin.version} - - org.h2.tools.Server - - -tcp - -tcpAllowOthers - - - - - - - - stop-h2 - - - - org.codehaus.mojo - exec-maven-plugin - ${exec-maven-plugin.version} - - org.h2.tools.Server - - -tcpShutdown - tcp://localhost:9092 - - - - - - - - 9081 - - - - maven-jetty-plugin - ${jetty.version} - org.mortbay.jetty - - - - jetty.port - 9081 - - - 9981 - - - - - - - 9082 - - - - maven-jetty-plugin - ${jetty.version} - org.mortbay.jetty - - - - jetty.port - 9082 - - - 9982 - - - - - - - sag-deps - - - sag-deps - true - - - - - - - org.terracotta - maven-forge-plugin - - - com.softwareag.ibit.tools.util - finder - 3.0 - compile - - - - - - - - - - - terracotta-snapshots - http://www.terracotta.org/download/reflector/snapshots - - - terracotta-releases - http://www.terracotta.org/download/reflector/releases - - - - - terracotta-snapshots - http://www.terracotta.org/download/reflector/snapshots - - - terracotta-releases - http://www.terracotta.org/download/reflector/releases - - - Index: rctags/ehcache-2.10.8.0.7/management-ehcache-impl/management-ehcache-impl-v2/pom.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/management-ehcache-impl/management-ehcache-impl-v2/pom.xml (revision 11085) +++ rctags/ehcache-2.10.8.0.7/management-ehcache-impl/management-ehcache-impl-v2/pom.xml (revision 0) @@ -1,136 +0,0 @@ - - - 4.0.0 - - - net.sf.ehcache - management-ehcache-impl-parent - 2.10.8.0.7 - .. - - - management-ehcache-impl-v2 - management-ehcache-impl-v2 - A product library integrating with ehcache to construct the relevant management resource entities V1 - - - - net.sf.ehcache - management-ehcache-v2 - ${project.version} - - - net.sf.ehcache - management-ehcache-common - ${project.version} - - - org.terracotta - management-core-resources - ${management-core.version} - test-jar - test - - - net.sf.ehcache.internal - ehcache-core - ${project.version} - provided - - - net.sf.ehcache.internal - ehcache-terracotta-bootstrap - ${project.version} - provided - - - org.terracotta.toolkit - terracotta-toolkit-api - 2.5 - provided - - - org.terracotta.toolkit - terracotta-toolkit-api-internal - provided - - - gf-40 - gf.javax.servlet-api - - - org.easymock - easymock - test - - - org.eclipse.jetty - jetty-servlet - test - - - org.mockito - mockito-core - test - - - org.powermock - powermock-api-easymock - test - - - org.powermock - powermock-module-junit4 - test - - - org.hamcrest - hamcrest-all - 1.3 - test - - - commons-io - commons-io - 2.6 - test - - - net.sf.ehcache.internal - ehcache-core - test-jar - ${project.version} - test - - - - - - - org.apache.maven.plugins - maven-jar-plugin - - - - - - - terracotta-snapshots - http://www.terracotta.org/download/reflector/snapshots - - - terracotta-releases - http://www.terracotta.org/download/reflector/releases - - - - - terracotta-snapshots - http://www.terracotta.org/download/reflector/snapshots - - - terracotta-releases - http://www.terracotta.org/download/reflector/releases - - - Index: rctags/ehcache-2.10.8.0.7/distribution/colorcache/pom.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/distribution/colorcache/pom.xml (revision 11085) +++ rctags/ehcache-2.10.8.0.7/distribution/colorcache/pom.xml (revision 0) @@ -1,178 +0,0 @@ - - 4.0.0 - - org.terracotta.forge - forge-parent - 4.0 - - - net.sf.ehcache.examples - colorcache - 2.10.8.0.7 - colorcache - war - Clustered Ehcache sample with Terracotta - - 2.1.0 - 4.3.8.0.8 - true - - - ${project.name} - - - maven-assembly-plugin - 2.3 - - ${project.name} - - src/assemble/distribution.xml - - gnu - - - - package - - single - - - - - - maven-jetty-plugin - 9.4.11.v20180605 - org.eclipse.jetty - - ${project.name} - STOP - - - - org.terracotta.maven.plugins - tc-maven-plugin - ${tc-maven-plugin.version} - - - org.terracotta - terracotta - ${terracotta.version} - - - - - - - - net.sf.ehcache - ehcache - ${project.version} - - - org.terracotta - terracotta-toolkit-runtime - ${terracotta.version} - - - gf-40 - gf.javax.servlet-api - 3.1.0 - - - org.slf4j - slf4j-jdk14 - 1.7.25 - - - - - 9081 - - - - maven-jetty-plugin - 6.1.15 - org.mortbay.jetty - - - - jetty.port - 9081 - - - 9981 - - - - - - - 9082 - - - - maven-jetty-plugin - 6.1.15 - org.mortbay.jetty - - - - jetty.port - 9082 - - - 9982 - - - - - - - sag-deps - - - sag-deps - true - - - - - - - org.terracotta - maven-forge-plugin - - - com.softwareag.ibit.tools.util - finder - 3.0 - compile - - - - - - - - - - - terracotta-snapshots - http://www.terracotta.org/download/reflector/snapshots - - - terracotta-releases - http://www.terracotta.org/download/reflector/releases - - - - - terracotta-snapshots - http://www.terracotta.org/download/reflector/snapshots - - - terracotta-releases - http://www.terracotta.org/download/reflector/releases - - - Index: rctags/ehcache-2.10.8.0.7/ehcache-scheduled-refresh/pom.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-scheduled-refresh/pom.xml (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-scheduled-refresh/pom.xml (revision 0) @@ -1,46 +0,0 @@ - - - 4.0.0 - - - net.sf.ehcache - ehcache-root - 2.10.8.0.7 - .. - - - ehcache-scheduled-refresh - net.sf.ehcache.internal - ehcache-scheduled-refresh - Ehcache functionality for Scheduled Refresh; uses the Quartz Job Scheduler - - - - net.sf.ehcache.internal - ehcache-core - ${project.version} - - - org.quartz-scheduler - quartz - provided - - - org.slf4j - slf4j-jdk14 - provided - - - junit - junit - test - - - net.sf.ehcache.internal - ehcache-core - test-jar - ${project.version} - test - - - Index: rctags/ehcache-2.10.8.0.7/management-ehcache-v1/pom.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/management-ehcache-v1/pom.xml (revision 11085) +++ rctags/ehcache-2.10.8.0.7/management-ehcache-v1/pom.xml (revision 0) @@ -1,72 +0,0 @@ - - - 4.0.0 - - - net.sf.ehcache - ehcache-root - 2.10.8.0.7 - .. - - - management-ehcache-v1 - management-ehcache-v1 - A library defining the ehcache management resource services and resource entities, version 1 - - - - org.terracotta - management-common-resources-v1 - ${management-core.version} - - - - - junit - junit - test - - - org.easymock - easymock - test - - - net.sf.ehcache.internal - ehcache-core - test-jar - ${project.version} - test - - - - - - - org.apache.maven.plugins - maven-jar-plugin - - - - - - - terracotta-snapshots - http://www.terracotta.org/download/reflector/snapshots - - - terracotta-releases - http://www.terracotta.org/download/reflector/releases - - - - - terracotta-snapshots - http://www.terracotta.org/download/reflector/snapshots - - - terracotta-releases - http://www.terracotta.org/download/reflector/releases - - - Index: rctags/ehcache-2.10.8.0.7/terracotta/bootstrap/pom.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/terracotta/bootstrap/pom.xml (revision 11085) +++ rctags/ehcache-2.10.8.0.7/terracotta/bootstrap/pom.xml (revision 0) @@ -1,82 +0,0 @@ - - - 4.0.0 - - - net.sf.ehcache.internal - ehcache-terracotta-root - 2.10.8.0.7 - - - ehcache-terracotta-bootstrap - ehcache-terracotta-bootstrap - jar - - - false - - - - - net.sf.ehcache.internal - ehcache-core - ${project.version} - provided - - - org.terracotta.toolkit - terracotta-toolkit-api-internal - - - com.terracotta - clustered-entity-management - - - org.mockito - mockito-core - test - - - junit - junit - test - - - net.sf.ehcache.internal - ehcache-core - test-jar - ${project.version} - test - - - - - - terracotta-snapshots - http://www.terracotta.org/download/reflector/snapshots - - - terracotta-releases - http://www.terracotta.org/download/reflector/releases - - - - - terracotta-snapshots - http://www.terracotta.org/download/reflector/snapshots - - - terracotta-releases - http://www.terracotta.org/download/reflector/releases - - - - - - deploy-sonatype - - true - - - - Index: rctags/ehcache-2.10.8.0.7/management-ehcache-impl/management-ehcache-common/pom.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/management-ehcache-impl/management-ehcache-common/pom.xml (revision 11085) +++ rctags/ehcache-2.10.8.0.7/management-ehcache-impl/management-ehcache-common/pom.xml (revision 0) @@ -1,101 +0,0 @@ - - - 4.0.0 - - - net.sf.ehcache - management-ehcache-impl-parent - 2.10.8.0.7 - .. - - - management-ehcache-common - management-ehcache-common - A common library shared between different management-ehcache implementation versions - - - false - - - - - org.terracotta - management-core-resources - - - net.sf.ehcache.internal - ehcache-core - ${project.version} - provided - - - gf-40 - gf.javax.servlet-api - - - org.eclipse.jetty - jetty-servlet - - - junit - junit - test - - - commons-io - commons-io - 2.6 - test - - - org.easymock - easymock - test - - - org.mockito - mockito-core - test - - - org.powermock - powermock-api-easymock - test - - - org.powermock - powermock-module-junit4 - test - - - - - - - org.apache.maven.plugins - maven-jar-plugin - - - - - - - terracotta-snapshots - http://www.terracotta.org/download/reflector/snapshots - - - terracotta-releases - http://www.terracotta.org/download/reflector/releases - - - - - terracotta-snapshots - http://www.terracotta.org/download/reflector/snapshots - - - terracotta-releases - http://www.terracotta.org/download/reflector/releases - - - Index: rctags/ehcache-2.10.8.0.7/ehcache-search-parser/pom.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-search-parser/pom.xml (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-search-parser/pom.xml (revision 0) @@ -1,53 +0,0 @@ - - - 4.0.0 - - net.sf.ehcache - ehcache-root - 2.10.8.0.7 - .. - - - net.sf.ehcache.internal - ehcache-search-parser - ehcache-search-parser - A parser for Big Memory Structured Query Language. - - - - - org.codehaus.mojo - javacc-maven-plugin - 2.6 - - - javacc - - javacc - - - - - - - - - - net.sf.ehcache.internal - ehcache-core - ${project.version} - - - junit - junit - test - - - net.sf.ehcache.internal - ehcache-core - test-jar - ${project.version} - test - - - Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/hibernate/strategy/EhcacheAccessStrategyFactory.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/hibernate/strategy/EhcacheAccessStrategyFactory.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/hibernate/strategy/EhcacheAccessStrategyFactory.java (revision 0) @@ -1,53 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.sf.ehcache.hibernate.strategy; - -import net.sf.ehcache.hibernate.regions.EhcacheCollectionRegion; -import net.sf.ehcache.hibernate.regions.EhcacheEntityRegion; - -import org.hibernate.cache.access.AccessType; -import org.hibernate.cache.access.CollectionRegionAccessStrategy; -import org.hibernate.cache.access.EntityRegionAccessStrategy; - -/** - * Factory to create {@link EntityRegionAccessStrategy} - * - * @author Abhishek Sanoujam - * - */ -public interface EhcacheAccessStrategyFactory { - - /** - * Create {@link EntityRegionAccessStrategy} for the input {@link EhcacheEntityRegion} and {@link AccessType} - * - * @param entityRegion - * @param accessType - * @return the created {@link EntityRegionAccessStrategy} - */ - public EntityRegionAccessStrategy createEntityRegionAccessStrategy(EhcacheEntityRegion entityRegion, AccessType accessType); - - /** - * Create {@link CollectionRegionAccessStrategy} for the input {@link EhcacheCollectionRegion} and {@link AccessType} - * - * @param collectionRegion - * @param accessType - * @return the created {@link CollectionRegionAccessStrategy} - */ - public CollectionRegionAccessStrategy createCollectionRegionAccessStrategy(EhcacheCollectionRegion collectionRegion, - AccessType accessType); - -} Index: rctags/ehcache-2.10.8.0.7/system-tests/src/test/resources/net/sf/ehcache/osgi/PhoneNumber.hbm.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/system-tests/src/test/resources/net/sf/ehcache/osgi/PhoneNumber.hbm.xml (revision 11085) +++ rctags/ehcache-2.10.8.0.7/system-tests/src/test/resources/net/sf/ehcache/osgi/PhoneNumber.hbm.xml (revision 0) @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/CacheOperationOutcomes.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/CacheOperationOutcomes.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/CacheOperationOutcomes.java (revision 0) @@ -1,191 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.sf.ehcache; - -/** - * Interface containing cache operation outcome enums. - * - * @author cschanck - */ -public interface CacheOperationOutcomes { - - /** - * Outcomes for cache Get operations. - * - * @author cschanck - */ - enum GetOutcome { - /** hit. */ - HIT, - /** miss expired. */ - MISS_EXPIRED, - /** miss not found. */ - MISS_NOT_FOUND - }; - - /** - * The outcomes for Put Outcomes. - */ - enum PutOutcome { - /** added. */ - ADDED, - /** updated. */ - UPDATED, - - /** ignored. */ - IGNORED - }; - - /** - * The outcomes for remove operations. - */ - enum RemoveOutcome { - /** success. */ - SUCCESS - }; - - /** - * The outcomes for GetAll operations. - */ - enum GetAllOutcome { - /** all miss. */ - ALL_MISS, - /** all hit. */ - ALL_HIT, - /** partial. */ - PARTIAL - }; - - /** - * The outcomes for GetAll operations. - */ - enum PutAllOutcome { - - /** The ignored. */ - IGNORED, - /** The completed. */ - COMPLETED - }; - - /** - * The outcomes for GetAll operations. - */ - enum RemoveAllOutcome { - - /** The ignored. */ - IGNORED, - /** The completed. */ - COMPLETED - }; - - /** - * The outcomes for the store search operation. - */ - enum SearchOutcome { - /** success. */ - SUCCESS, - /** exception. */ - EXCEPTION - }; - - /** - * The eviction outcomes. - */ - enum EvictionOutcome { - /** success. */ - SUCCESS - }; - - /** - * The expiration outcomes. - */ - enum ExpiredOutcome { - /** success. */ - SUCCESS, - /** The failure. */ - FAILURE - }; - - /** - * Cluster event operation outcomes. - * - * @author cschanck - * - */ - public static enum ClusterEventOutcomes { - - /** offline. */ - OFFLINE, - - /** online. */ - ONLINE, - - /** rejoin. */ - REJOINED - }; - - /** - * The Enum NonStopOperationOutcomes. - */ - public static enum NonStopOperationOutcomes { - - /** The success. */ - SUCCESS, - - /** failure */ - FAILURE, - - /** The rejoin driven timeout */ - REJOIN_TIMEOUT, - - /** The timeout. */ - TIMEOUT; - } - - enum ReplaceOneArgOutcome { - /** replaced */ - SUCCESS, - - /** not found */ - FAILURE, - } - - enum ReplaceTwoArgOutcome { - /** replaced */ - SUCCESS, - - /** not found */ - FAILURE, - } - - enum PutIfAbsentOutcome { - /** put into cache */ - SUCCESS, - - /** already exisits; not put into cache */ - FAILURE, - } - - enum RemoveElementOutcome { - /** element removed from cache */ - SUCCESS, - - /** not found */ - FAILURE, - } - -} Index: rctags/ehcache-2.10.8.0.7/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/writebehind/operations/DeleteAsyncOperation.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/writebehind/operations/DeleteAsyncOperation.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/writebehind/operations/DeleteAsyncOperation.java (revision 0) @@ -1,54 +0,0 @@ -/* - * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved. - */ -package org.terracotta.modules.ehcache.writebehind.operations; - -import net.sf.ehcache.CacheEntry; -import net.sf.ehcache.Element; -import net.sf.ehcache.writer.CacheWriter; -import net.sf.ehcache.writer.writebehind.operations.SingleOperationType; - -public class DeleteAsyncOperation implements SingleAsyncOperation { - - private static final long serialVersionUID = -5780204454577869853L; - - private final Object keySnapshot; - private final Element elementSnapshot; - private final long creationTime; - - public DeleteAsyncOperation(Object keySnapshot, Element elementSnapshot) { - this(keySnapshot, elementSnapshot, System.currentTimeMillis()); - } - - public DeleteAsyncOperation(Object keySnapshot, Element elementSnapshot, long creationTime) { - this.keySnapshot = keySnapshot; - this.elementSnapshot = elementSnapshot; - this.creationTime = creationTime; - } - - @Override - public void performSingleOperation(CacheWriter cacheWriter) { - cacheWriter.delete(new CacheEntry(getKey(), getElement())); - } - - @Override - public Object getKey() { - return keySnapshot; - } - - @Override - public Element getElement() { - return elementSnapshot; - } - - @Override - public long getCreationTime() { - return creationTime; - } - - @Override - public void throwAwayElement(CacheWriter cacheWriter, RuntimeException e) { - cacheWriter.throwAway(elementSnapshot, SingleOperationType.DELETE, e); - } - -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/store/CopyingBruteForceSource.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/store/CopyingBruteForceSource.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/store/CopyingBruteForceSource.java (revision 0) @@ -1,103 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.sf.ehcache.store; - -import net.sf.ehcache.Element; -import net.sf.ehcache.config.Searchable; - -import java.util.Iterator; - -/** - * A {@link BruteForceSource} that wraps another one and deals with copy for read of {@link Element}s. - * - * @author ljacomet - */ -class CopyingBruteForceSource implements BruteForceSource { - - private final BruteForceSource delegate; - private final CopyStrategyHandler copyStrategyHandler; - - /** - * Construct this CopyingBruteForceSource with the given delegate and the {@link CopyStrategyHandler} to use. - * - * @param delegate the delegate BruteForceSource - * @param copyStrategyHandler the copy strategy handler - */ - CopyingBruteForceSource(BruteForceSource delegate, CopyStrategyHandler copyStrategyHandler) { - this.delegate = delegate; - this.copyStrategyHandler = copyStrategyHandler; - } - - @Override - public Iterable elements() { - return new CopyingIterable(delegate.elements(), copyStrategyHandler); - } - - @Override - public Searchable getSearchable() { - return delegate.getSearchable(); - } - - @Override - public Element transformForIndexing(Element element) { - return copyStrategyHandler.copyElementForReadIfNeeded(element); - } - - /** - * Wrapping Iterable holding the delegate Iterable and the {@link CopyStrategyHandler} - */ - private static class CopyingIterable implements Iterable { - private final Iterable elements; - private final CopyStrategyHandler copyStrategyHandler; - - public CopyingIterable(Iterable elements, CopyStrategyHandler copyStrategyHandler) { - this.elements = elements; - this.copyStrategyHandler = copyStrategyHandler; - } - - @Override - public Iterator iterator() { - return new CopyingIterator(elements.iterator()); - } - - /** - * Wrapping Iterator responsible of doing the copy on read - */ - private class CopyingIterator implements Iterator { - private final Iterator delegate; - - public CopyingIterator(Iterator delegate) { - this.delegate = delegate; - } - - @Override - public boolean hasNext() { - return delegate.hasNext(); - } - - @Override - public Element next() { - return copyStrategyHandler.copyElementForReadIfNeeded(delegate.next()); - } - - @Override - public void remove() { - delegate.remove(); - } - } - } -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/statistics/beans/LongBeanProxy.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/statistics/beans/LongBeanProxy.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/statistics/beans/LongBeanProxy.java (revision 0) @@ -1,57 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.sf.ehcache.statistics.beans; - -/** - * An implementation of a Long attribute proxy. - * - * @author cschanck - */ -public class LongBeanProxy extends AttributeProxy { - - /** The val. */ - private long val = 0; - - /** - * Instantiates a new long bean proxy. - * - * @param name the name - * @param description the description - * @param isRead the is read - * @param isWrite the is write - */ - public LongBeanProxy(String name, String description, boolean isRead, boolean isWrite) { - super(Long.class, name, description, isRead, isWrite); - } - - /* (non-Javadoc) - * @see net.sf.ehcache.statistics.beans.AttributeProxy#get(java.lang.String) - */ - @Override - public Long get(String name) { - return val; - } - - /* (non-Javadoc) - * @see net.sf.ehcache.statistics.beans.AttributeProxy#set(java.lang.String, java.lang.Object) - */ - @Override - public void set(String name, Long t) { - val = t.longValue(); - } - -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/constructs/DefaultCacheDecoratorFactoryTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/constructs/DefaultCacheDecoratorFactoryTest.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/constructs/DefaultCacheDecoratorFactoryTest.java (revision 0) @@ -1,86 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.sf.ehcache.constructs; - -import java.util.Arrays; -import java.util.List; - -import junit.framework.TestCase; -import net.sf.ehcache.CacheManager; -import net.sf.ehcache.constructs.MockDecoratorFactory.MockDecoratorFactoryCache; - -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.terracotta.test.categories.CheckShorts; - -/** - * @author Abhishek Sanoujam - */ -@Category(CheckShorts.class) -public class DefaultCacheDecoratorFactoryTest extends TestCase { - - private static final Logger LOG = LoggerFactory.getLogger(DefaultCacheDecoratorFactoryTest.class); - - private static final String EHCACHE_DEFAULT_DECORATOR_TEST_XML = "/ehcache-default-decorator-test.xml"; - - @Test - public void testCacheDecoratorFactory() { - CacheManager cacheManager = new CacheManager(getClass().getResourceAsStream(EHCACHE_DEFAULT_DECORATOR_TEST_XML)); - List cacheNames = Arrays.asList(cacheManager.getCacheNames()); - LOG.info("" + cacheNames); - - assertEquals(7, cacheNames.size()); - - assertTrue(cacheNames.contains("noDecoratorCache")); - assertTrue(cacheNames.contains("noDecoratorCache-defaultDecoratorOne")); - assertTrue(cacheNames.contains("noDecoratorCache-defaultDecoratorTwo")); - assertTrue(cacheNames.contains("oneDecoratorCache")); - assertTrue(cacheNames.contains("oneDecoratorCacheFirst")); - assertTrue(cacheNames.contains("oneDecoratorCache-defaultDecoratorOne")); - assertTrue(cacheNames.contains("oneDecoratorCache-defaultDecoratorTwo")); - - cacheManager.shutdown(); - - } - - @Test - public void testCacheDecoratorFactoryProperties() { - CacheManager cacheManager = new CacheManager(getClass().getResourceAsStream(EHCACHE_DEFAULT_DECORATOR_TEST_XML)); - List cacheNames = Arrays.asList(cacheManager.getCacheNames()); - assertEquals(7, cacheNames.size()); - - MockDecoratorFactoryCache cache = (MockDecoratorFactoryCache) cacheManager.getEhcache("noDecoratorCache-defaultDecoratorOne"); - assertEquals("defaultDecoratorOne", cache.getProperties().getProperty("someKey")); - - cache = (MockDecoratorFactoryCache) cacheManager.getEhcache("noDecoratorCache-defaultDecoratorTwo"); - assertEquals("defaultDecoratorTwo", cache.getProperties().getProperty("someKey")); - - cache = (MockDecoratorFactoryCache) cacheManager.getEhcache("oneDecoratorCache-defaultDecoratorOne"); - assertEquals("defaultDecoratorOne", cache.getProperties().getProperty("someKey")); - - cache = (MockDecoratorFactoryCache) cacheManager.getEhcache("oneDecoratorCache-defaultDecoratorTwo"); - assertEquals("defaultDecoratorTwo", cache.getProperties().getProperty("someKey")); - - cache = (MockDecoratorFactoryCache) cacheManager.getEhcache("oneDecoratorCacheFirst"); - assertEquals("oneFirst", cache.getProperties().getProperty("someKey")); - - cacheManager.shutdown(); - - } -} Index: rctags/ehcache-2.10.8.0.7/ehcache-scheduled-refresh/src/test/java/net/sf/ehcache/constructs/scheduledrefresh/OddCacheLoader.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-scheduled-refresh/src/test/java/net/sf/ehcache/constructs/scheduledrefresh/OddCacheLoader.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-scheduled-refresh/src/test/java/net/sf/ehcache/constructs/scheduledrefresh/OddCacheLoader.java (revision 0) @@ -1,9 +0,0 @@ -package net.sf.ehcache.constructs.scheduledrefresh; - -public class OddCacheLoader extends IncrementingCacheLoader { - - public OddCacheLoader() { - super(false, 10000); - } - -} \ No newline at end of file Index: rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/ehcache/tests/ClientBase.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/ehcache/tests/ClientBase.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/ehcache/tests/ClientBase.java (revision 0) @@ -1,162 +0,0 @@ -/* - * [ * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved. - */ -package org.terracotta.ehcache.tests; - -import net.sf.ehcache.Cache; -import net.sf.ehcache.CacheManager; -import net.sf.ehcache.Element; -import net.sf.ehcache.config.Configuration; -import net.sf.ehcache.config.ConfigurationFactory; -import net.sf.ehcache.config.TimeoutBehaviorConfiguration; -import net.sf.ehcache.constructs.nonstop.NonStopCacheException; - -import org.terracotta.modules.ehcache.ToolkitClientAccessor; -import org.terracotta.tests.base.AbstractClientBase; -import org.terracotta.toolkit.Toolkit; -import org.terracotta.toolkit.ToolkitFactory; -import org.terracotta.toolkit.ToolkitInstantiationException; -import org.terracotta.toolkit.concurrent.ToolkitBarrier; -import org.terracotta.toolkit.internal.ToolkitInternal; - -import java.io.InputStream; -import java.util.concurrent.BrokenBarrierException; -import java.util.concurrent.TimeUnit; - -public abstract class ClientBase extends AbstractClientBase { - - private final String name; - protected CacheManager cacheManager; - private ToolkitBarrier barrier; - private Toolkit toolkit; - - public ClientBase(String[] args) { - this("test", args); - } - - public ClientBase(String cacheName, String args[]) { - super(args); - this.name = cacheName; - } - - @Override - public void doTest() throws Throwable { - setupCacheManager(); - if (isStandaloneCfg()) { - runTest(getCache(), null); - } else { - runTest(getCache(), getClusteringToolkit()); - } - } - - protected boolean isStandaloneCfg() { - return getTestControlMbean().isStandAloneTest(); - } - - protected synchronized final ToolkitBarrier getBarrierForAllClients() { - if (barrier == null) { - barrier = getClusteringToolkit().getBarrier("barrier with all clients", getParticipantCount()); - } - return barrier; - } - - protected final int waitForAllClients() throws InterruptedException, BrokenBarrierException { - if (isStandaloneCfg()) return 0; - return getBarrierForAllClients().await(); - } - - protected void setupCacheManager() { - Configuration config = ConfigurationFactory.parseConfiguration(getEhcacheXmlAsStream()); - - ClassLoader loader = getCacheManagerClassLoader(); - if (loader != null) { - config.setClassLoader(loader); - } - cacheManager = CacheManager.create(config); - } - - protected ClassLoader getCacheManagerClassLoader() { - return null; - } - - protected InputStream getEhcacheXmlAsStream() { - return Client1.class.getResourceAsStream("/ehcache-config.xml"); - } - - protected Cache getCache() { - return cacheManager.getCache(name); - } - - protected CacheManager getCacheManager() { - return cacheManager; - } - - protected synchronized Toolkit getClusteringToolkit() { - if (toolkit == null) { - toolkit = createToolkit(); - } - return toolkit; - } - - protected Toolkit createToolkit() { - try { - return ToolkitFactory.createToolkit(getTerracottaTypeSubType() + getTerracottaUrl()); - } catch (ToolkitInstantiationException e) { - throw new RuntimeException(e); - } - } - - protected String getTerracottaTypeSubType() { - return "toolkit:terracotta://"; - } - - public synchronized void clearTerracottaClient() { - cacheManager = null; - barrier = null; - toolkit = null; - } - - protected abstract void runTest(Cache cache, Toolkit myToolkit) throws Throwable; - - /** - * MNK-5309 : Since this method can be called for caches with timeout behavior other than EXCEPTION, we temporarily - * change the timeout behavior to EXCEPTION during this method and revert it back while exiting. - */ - public void waitUntilCacheInitialized(Cache cache) throws InterruptedException { - TimeoutBehaviorConfiguration actualTimeoutBehavior = cache.getCacheConfiguration().getTerracottaConfiguration() - .getNonstopConfiguration().getTimeoutBehavior(); - try { - TimeoutBehaviorConfiguration clone = (TimeoutBehaviorConfiguration) actualTimeoutBehavior.clone(); - clone.setType("exception"); - cache.getCacheConfiguration().getTerracottaConfiguration().getNonstopConfiguration().addTimeoutBehavior(clone); - } catch (CloneNotSupportedException re) { - throw new RuntimeException(re); - } - - while (true) { - try { - debug("===== Waiting for cache " + cache.getName() + " to be initialized ====="); - cache.put(new Element("key", "value")); - cache.remove("key"); - cache.getCacheConfiguration().getTerracottaConfiguration().getNonstopConfiguration() - .addTimeoutBehavior(actualTimeoutBehavior); - return; - } catch (NonStopCacheException e) { - TimeUnit.SECONDS.sleep(1L); - } - } - } - - public void waitForAllCurrentTransactionsToComplete(Cache cache) { - // Only do waitFor All Txn for Clustered Caches - if (cache.getCacheConfiguration().isTerracottaClustered()) { - Toolkit internalToolkit = ToolkitClientAccessor.getInternalToolkitClient(cache); - waitForAllCurrentTransactionsToComplete(internalToolkit); - } - } - - public void waitForAllCurrentTransactionsToComplete(Toolkit toolkitParam) { - ((ToolkitInternal) toolkitParam).waitUntilAllTransactionsComplete(); - } - -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/event/RegisteredEventListenersTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/event/RegisteredEventListenersTest.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/event/RegisteredEventListenersTest.java (revision 0) @@ -1,141 +0,0 @@ -package net.sf.ehcache.event; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.emptyIterable; -import static org.hamcrest.core.Is.is; -import static org.hamcrest.core.IsCollectionContaining.hasItem; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import java.util.Collection; - -import net.sf.ehcache.CacheStoreHelper; -import net.sf.ehcache.Ehcache; -import net.sf.ehcache.Status; -import net.sf.ehcache.distribution.CacheReplicator; -import net.sf.ehcache.store.TerracottaStore; - -import org.hamcrest.Matcher; -import org.junit.Test; - -/** - * @author twu - * @author adahanne - * @author cschanck - * - * orderedListeners are only accessed through package scope methods : - * that seems to indicate those orderedListeners were designed for a feature that never was fully implemented - * (in this case it was made for ingenius we suppose) -- do we get rid of this field ? - * - * there are several assertions, verifications to make when testing each of the classes (register / unresgister listeners) ; - * we chose to write 1 test per "behavior" : - * for example, when testing the registerListener methods, - * we wrote a test to verify notifyEventListenersChangedIfNecessary was called - * and a test to verify the hasReplicators was in sync with the CacheEventListener - * - * testDeliverRemoteScopeAll() : can we mock an Enum, such as NotificationScope, to change one of its methods : shouldDeliver - * We can, unsing Powermock, that its support through IDEs does not seem to be ideal - * a better approach would be to use a seam, extracting listenerWrapper.getScope().shouldDeliver(remoteEvent) in a seam method - * and overriding it extending the class under test - * - * We ommitted the return value of registerListener and unregisterListener - * - * - */ -public class RegisteredEventListenersTest { - private RegisteredEventListeners createRegisteredEventListeners(TerracottaStore store) { - Ehcache cache = mock(Ehcache.class); - when(cache.getStatus()).thenReturn(Status.STATUS_ALIVE); - CacheStoreHelper cacheStoreHelper = mock(CacheStoreHelper.class); - when(cacheStoreHelper.getStore()).thenReturn(store); - return new RegisteredEventListeners(cache, cacheStoreHelper); - } - - @Test - public void testDetectRegisterCacheReplicator() { - RegisteredEventListeners registeredEventListeners = createRegisteredEventListeners(null); - - CacheEventListener listener = mock(CacheReplicator.class); - registeredEventListeners.registerListener(listener); - assertThat(registeredEventListeners.hasCacheReplicators(), is(true)); - } - - @Test - public void testDetectRegisterNonCacheReplicator() { - RegisteredEventListeners registeredEventListeners = createRegisteredEventListeners(null); - - CacheEventListener listener = mock(CacheEventListener.class); - registeredEventListeners.registerListener(listener); - assertThat(registeredEventListeners.hasCacheReplicators(), is(false)); - } - - @Test - public void testCanRegisterListener() { - RegisteredEventListeners registeredEventListeners = createRegisteredEventListeners(null); - - CacheEventListener listener = mock(CacheEventListener.class); - - boolean registerListener = registeredEventListeners.registerListener(listener); - assertTrue(registerListener); - assertThat(registeredEventListeners.getCacheEventListeners(), hasItem(listener)); - } - - @Test - public void testCanUnregisterListener() throws Exception { - RegisteredEventListeners registeredEventListeners = createRegisteredEventListeners(null); - CacheEventListener listener = mock(CacheEventListener.class); - - registeredEventListeners.registerListener(listener); - boolean unregisterListener = registeredEventListeners.unregisterListener(listener); - assertTrue(unregisterListener); - - assertThat((Collection) registeredEventListeners.getCacheEventListeners(), (Matcher) emptyIterable()); - } - - @Test - public void testCacheReplicatorAccounting() throws Exception { - RegisteredEventListeners registeredEventListeners = createRegisteredEventListeners(null); - - CacheEventListener listener1 = mock(CacheEventListener.class); - CacheEventListener listener2 = mock(CacheEventListener.class); - CacheEventListener replicator1 = mock(CacheReplicator.class); - CacheEventListener replicator2 = mock(CacheReplicator.class); - - registeredEventListeners.registerListener(listener1); - registeredEventListeners.registerListener(listener2); - registeredEventListeners.registerListener(replicator1); - registeredEventListeners.registerListener(replicator2); - assertThat(registeredEventListeners.hasCacheReplicators(), is(true)); - - registeredEventListeners.unregisterListener(replicator1); - assertThat(registeredEventListeners.hasCacheReplicators(), is(true)); - - registeredEventListeners.unregisterListener(replicator2); - assertThat(registeredEventListeners.hasCacheReplicators(), is(false)); - } - - @Test - public void testNotifyTerracottaStoreOfListenerChangeOnRegister() throws Exception { - TerracottaStore store = mock(TerracottaStore.class); - RegisteredEventListeners registeredEventListeners = createRegisteredEventListeners(store); - CacheEventListener listener = mock(CacheEventListener.class); - - registeredEventListeners.registerListener(listener); - verify(store).notifyCacheEventListenersChanged(); - } - - @Test - public void testNotifyTerracottaStoreOfListenerChangeOnUnregister() throws Exception { - TerracottaStore store = mock(TerracottaStore.class); - RegisteredEventListeners registeredEventListeners = createRegisteredEventListeners(store); - - CacheEventListener listener = mock(CacheEventListener.class); - - registeredEventListeners.registerListener(listener); - registeredEventListeners.unregisterListener(listener); - verify(store, times(2)).notifyCacheEventListenersChanged(); - } -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/pool/sizeof/filter/AnnotationSizeOfFilter.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/pool/sizeof/filter/AnnotationSizeOfFilter.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/pool/sizeof/filter/AnnotationSizeOfFilter.java (revision 0) @@ -1,132 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.sf.ehcache.pool.sizeof.filter; - -import net.sf.ehcache.pool.sizeof.annotations.IgnoreSizeOf; -import java.lang.reflect.AnnotatedElement; -import java.lang.reflect.Field; -import java.util.Collection; -import java.util.Iterator; -import java.lang.annotation.Annotation; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import java.util.regex.PatternSyntaxException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * A Filter that will filter fields, based on the {@link IgnoreSizeOf} annotation - * - * @author Chris Dennis - */ -public final class AnnotationSizeOfFilter implements SizeOfFilter { - - - private static final String IGNORE_SIZE_OF_VM_ARGUMENT = "net.sf.ehcache.pool.sizeof.ignore.pattern"; - - private static final Logger LOG = LoggerFactory.getLogger(AnnotationSizeOfFilter.class.getName()); - - //default is *cache.*IgnoreSizeOf - private static final String IGNORE_SIZE_OF_DEFAULT_REGEXP = "^.*cache\\..*IgnoreSizeOf$"; - private static final Pattern IGNORE_SIZE_OF_PATTERN; - - static { - String ignoreSizeOfRegexpVMArg = System.getProperty(IGNORE_SIZE_OF_VM_ARGUMENT); - String ignoreSizeOfRegexp = ignoreSizeOfRegexpVMArg != null ? ignoreSizeOfRegexpVMArg : IGNORE_SIZE_OF_DEFAULT_REGEXP; - Pattern localPattern; - try { - localPattern = Pattern.compile(ignoreSizeOfRegexp); - LOG.info("Using regular expression provided through VM argument " - + IGNORE_SIZE_OF_VM_ARGUMENT - + " for IgnoreSizeOf annotation : " - + ignoreSizeOfRegexp); - } catch (PatternSyntaxException e) { - throw new IllegalArgumentException("Invalid regular expression provided through VM argument " - + IGNORE_SIZE_OF_VM_ARGUMENT - + " : \n" - + e.getMessage() - + "\n using default regular expression for IgnoreSizeOf annotation : " - + IGNORE_SIZE_OF_DEFAULT_REGEXP); - } - IGNORE_SIZE_OF_PATTERN = localPattern; - } - - /** - * {@inheritDoc} - */ - public Collection filterFields(Class klazz, Collection fields) { - for (Iterator it = fields.iterator(); it.hasNext();) { - - Field field = it.next(); - IgnoreSizeOf annotationOnField = getAnnotationOn(field, IgnoreSizeOf.class, IGNORE_SIZE_OF_PATTERN); - if (annotationOnField != null) { - it.remove(); - } - } - return fields; - } - - /** - * {@inheritDoc} - */ - public boolean filterClass(Class klazz) { - boolean classAnnotated = isAnnotationPresentOrInherited(klazz); - Package pack = klazz.getPackage(); - IgnoreSizeOf annotationOnPackage = pack == null ? null : getAnnotationOn(pack, IgnoreSizeOf.class, IGNORE_SIZE_OF_PATTERN); - boolean packageAnnotated = annotationOnPackage != null; - return !classAnnotated && !packageAnnotated; - } - - private boolean isAnnotationPresentOrInherited(final Class instanceKlazz) { - Class klazz = instanceKlazz; - while (klazz != null) { - IgnoreSizeOf annotationOnClass = getAnnotationOn(klazz, IgnoreSizeOf.class, IGNORE_SIZE_OF_PATTERN); - if (annotationOnClass != null && (klazz == instanceKlazz || annotationOnClass.inherited())) { - return true; - } - klazz = klazz.getSuperclass(); - } - return false; - } - - private boolean validateCustomAnnotationPattern(String canonicalName, Pattern matchingAnnotationPattern) { - Matcher matcher = matchingAnnotationPattern.matcher(canonicalName); - - boolean found = matcher.matches(); - if (found) { - LOG.debug(canonicalName + " matched IgnoreSizeOf annotation pattern " + IGNORE_SIZE_OF_PATTERN); - } - return found; - } - - //EHC-938 : looking for all types of IgnoreSizeOf annotations - private T getAnnotationOn(AnnotatedElement element, Class referenceAnnotation, Pattern matchingAnnotationPattern) { - T matchingAnnotation = null; - Annotation[] annotations = element.getAnnotations(); - for (Annotation annotation : annotations) { - if (validateCustomAnnotationPattern(annotation.annotationType().getName(), matchingAnnotationPattern)) { - if (matchingAnnotation != null) { - throw new IllegalStateException("You are not allowed to use more than one @" + referenceAnnotation.getName() - + " annotations for the same element : " - + element.toString()); - } - matchingAnnotation = AnnotationProxyFactory.getAnnotationProxy(annotation, referenceAnnotation); - } - } - return matchingAnnotation; - } -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/pool/sizeof/filter/annotations/ReferenceAnnotation.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/pool/sizeof/filter/annotations/ReferenceAnnotation.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/pool/sizeof/filter/annotations/ReferenceAnnotation.java (revision 0) @@ -1,35 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.sf.ehcache.pool.sizeof.filter.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.FIELD, ElementType.TYPE, ElementType.PACKAGE }) -public @interface ReferenceAnnotation { - String version() default "hello"; - boolean deprecated() default false; - int differentReturnType() default 5; - String[] things(); - Class aClass() default String.class; - ExampleEnum anEnum() default ExampleEnum.ONE; - Deprecated anAnnotation() default @Deprecated; - -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/resources/ehcache-storage-strategy.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/resources/ehcache-storage-strategy.xml (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/resources/ehcache-storage-strategy.xml (revision 0) @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - - - - - Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/distribution/RMISynchronousCacheReplicator.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/distribution/RMISynchronousCacheReplicator.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/distribution/RMISynchronousCacheReplicator.java (revision 0) @@ -1,388 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.sf.ehcache.distribution; - -import net.sf.ehcache.CacheException; -import net.sf.ehcache.Ehcache; -import net.sf.ehcache.Element; -import net.sf.ehcache.Status; - -import java.io.Serializable; -import java.util.List; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Listens to {@link net.sf.ehcache.CacheManager} and {@link net.sf.ehcache.Cache} events and propagates those to - * {@link CachePeer} peers of the Cache. - * - * @author Greg Luck - * @version $Id: RMISynchronousCacheReplicator.java 10789 2018-04-26 02:08:13Z adahanne $ - */ -public class RMISynchronousCacheReplicator implements CacheReplicator { - - private static final Logger LOG = LoggerFactory.getLogger(RMISynchronousCacheReplicator.class.getName()); - - - /** - * The status of the replicator. Only replicates when STATUS_ALIVE - */ - protected Status status; - - /** - * Whether to replicate puts. - */ - protected final boolean replicatePuts; - - /** - * Whether a put should replicated by copy or by invalidation, (a remove). - *

- * By copy is best when the entry is expensive to produce. By invalidation is best when - * we are really trying to force other caches to sync back to a canonical source like a database. - * An example of a latter usage would be a read/write cache being used in Hibernate. - *

- * This setting only has effect if #replicateUpdates is true. - */ - protected boolean replicatePutsViaCopy; - - /** - * Whether to replicate updates. - */ - protected final boolean replicateUpdates; - - /** - * Whether an update (a put) should be by copy or by invalidation, (a remove). - *

- * By copy is best when the entry is expensive to produce. By invalidation is best when - * we are really trying to force other caches to sync back to a canonical source like a database. - * An example of a latter usage would be a read/write cache being used in Hibernate. - *

- * This setting only has effect if #replicateUpdates is true. - */ - protected final boolean replicateUpdatesViaCopy; - /** - * Whether to replicate removes - */ - protected final boolean replicateRemovals; - - /** - * Constructor for internal and subclass use - * - * @param replicatePuts - * @param replicateUpdates - * @param replicateUpdatesViaCopy - * @param replicateRemovals - */ - public RMISynchronousCacheReplicator( - boolean replicatePuts, - boolean replicatePutsViaCopy, - boolean replicateUpdates, - boolean replicateUpdatesViaCopy, - boolean replicateRemovals) { - this.replicatePuts = replicatePuts; - this.replicatePutsViaCopy = replicatePutsViaCopy; - this.replicateUpdates = replicateUpdates; - this.replicateUpdatesViaCopy = replicateUpdatesViaCopy; - this.replicateRemovals = replicateRemovals; - status = Status.STATUS_ALIVE; - } - - /** - * Called immediately after an element has been put into the cache. The {@link net.sf.ehcache.Cache#put(net.sf.ehcache.Element)} method - * will block until this method returns. - *

- * Implementers may wish to have access to the Element's fields, including value, so the element is provided. - * Implementers should be careful not to modify the element. The effect of any modifications is undefined. - * - * @param cache the cache emitting the notification - * @param element the element which was just put into the cache. - */ - public void notifyElementPut(final Ehcache cache, final Element element) throws CacheException { - if (notAlive()) { - return; - } - - if (!replicatePuts) { - return; - } - - if (!element.isSerializable()) { - if (LOG.isWarnEnabled()) { - LOG.warn("Object with key " + element.getObjectKey() + " is not Serializable and cannot be replicated"); - } - return; - } - - if (replicatePutsViaCopy) { - replicatePutNotification(cache, element); - } else { - replicateRemovalNotification(cache, (Serializable) element.getObjectKey()); - } - } - - /** - * Does the actual RMI remote call. - *

- * If a Throwable occurs a SEVERE log message will be logged, but attempts to replicate to the other - * peers will continue. - */ - protected static void replicatePutNotification(Ehcache cache, Element element) throws RemoteCacheException { - List cachePeers = listRemoteCachePeers(cache); - for (Object cachePeer1 : cachePeers) { - CachePeer cachePeer = (CachePeer) cachePeer1; - try { - cachePeer.put(element); - } catch (Throwable t) { - LOG.error("Exception on replication of putNotification. " + t.getMessage() + ". Continuing...", t); - } - } - } - - - /** - * Called immediately after an element has been put into the cache and the element already - * existed in the cache. This is thus an update. - *

- * The {@link net.sf.ehcache.Cache#put(net.sf.ehcache.Element)} method - * will block until this method returns. - *

- * Implementers may wish to have access to the Element's fields, including value, so the element is provided. - * Implementers should be careful not to modify the element. The effect of any modifications is undefined. - * - * @param cache the cache emitting the notification - * @param element the element which was just put into the cache. - */ - public void notifyElementUpdated(final Ehcache cache, final Element element) throws CacheException { - if (notAlive()) { - return; - } - if (!replicateUpdates) { - return; - } - - if (replicateUpdatesViaCopy) { - if (!element.isSerializable()) { - if (LOG.isWarnEnabled()) { - LOG.warn("Object with key " + element.getObjectKey() - + " is not Serializable and cannot be updated via copy"); - } - return; - } - - replicatePutNotification(cache, element); - } else { - if (!element.isKeySerializable()) { - if (LOG.isWarnEnabled()) { - LOG.warn("Key " + element.getObjectKey() + " is not Serializable and cannot be replicated."); - } - return; - } - - replicateRemovalNotification(cache, (Serializable) element.getObjectKey()); - } - } - - /** - * Called immediately after an attempt to remove an element. The remove method will block until - * this method returns. - *

- * This notification is received regardless of whether the cache had an element matching - * the removal key or not. If an element was removed, the element is passed to this method, - * otherwise a synthetic element, with only the key set is passed in. - *

- * - * @param cache the cache emitting the notification - * @param element the element just deleted, or a synthetic element with just the key set if - * no element was removed.param element just deleted - */ - public void notifyElementRemoved(final Ehcache cache, final Element element) throws CacheException { - if (notAlive()) { - return; - } - - if (!replicateRemovals) { - return; - } - - if (!element.isKeySerializable()) { - if (LOG.isWarnEnabled()) { - LOG.warn("Key " + element.getObjectKey() + " is not Serializable and cannot be replicated."); - } - return; - } - - replicateRemovalNotification(cache, (Serializable) element.getObjectKey()); - } - - /** - * Does the actual RMI remote call. - *

- * If a Throwable occurs a SEVERE log message will be logged, but attempts to replicate to the other - * peers will continue. - */ - protected static void replicateRemovalNotification(Ehcache cache, Serializable key) throws RemoteCacheException { - List cachePeers = listRemoteCachePeers(cache); - for (Object cachePeer1 : cachePeers) { - CachePeer cachePeer = (CachePeer) cachePeer1; - try { - cachePeer.remove(key); - } catch (Throwable t) { - LOG.error("Exception on replication of removeNotification. " + t.getMessage() + ". Continuing...", t); - } - } - } - - - /** - * {@inheritDoc} - *

- * This implementation does not propagate expiries. It does not need to do anything because the element will - * expire in the remote cache at the same time. If the remote peer is not configured the same way they should - * not be in an cache cluster. - */ - public final void notifyElementExpired(final Ehcache cache, final Element element) { - /*do not propagate expiries. The element should expire in the remote cache at the same time, thus - preseerving coherency. - */ - } - - /** - * Called immediately after an element is evicted from the cache. Evicted in this sense - * means evicted from one store and not moved to another, so that it exists nowhere in the - * local cache. - *

- * In a sense the Element has been removed from the cache, but it is different, - * thus the separate notification. - *

- * This replicator does not propagate these events - * - * @param cache the cache emitting the notification - * @param element the element that has just been evicted - */ - public void notifyElementEvicted(final Ehcache cache, final Element element) { - /** - * do not notify these - */ - } - - - /** - * Called during {@link net.sf.ehcache.Ehcache#removeAll()} to indicate that the all - * elements have been removed from the cache in a bulk operation. The usual - * {@link #notifyElementRemoved(net.sf.ehcache.Ehcache,net.sf.ehcache.Element)} - * is not called. - *

- * This notification exists because clearing a cache is a special case. It is often - * not practical to serially process notifications where potentially millions of elements - * have been bulk deleted. - * - * @param cache the cache emitting the notification - */ - public void notifyRemoveAll(final Ehcache cache) { - if (notAlive()) { - return; - } - - if (!replicateRemovals) { - return; - } - - replicateRemoveAllNotification(cache); - } - - /** - * Does the actual RMI remote call. - * - * If a Throwable occurs a SEVERE log message will be logged, but attempts to replicate to the other - * peers will continue. - * - */ - protected void replicateRemoveAllNotification(Ehcache cache) { - List cachePeers = listRemoteCachePeers(cache); - for (Object cachePeer1 : cachePeers) { - CachePeer cachePeer = (CachePeer) cachePeer1; - try { - cachePeer.removeAll(); - } catch (Throwable t) { - LOG.error("Exception on replication of removeAllNotification. " + t.getMessage() + ". Continuing...", t); - } - } - } - - /** - * Package protected List of cache peers - * - * @param cache - * @return a list of {@link CachePeer} peers for the given cache, excluding the local peer. - */ - static List listRemoteCachePeers(Ehcache cache) { - CacheManagerPeerProvider provider = cache.getCacheManager().getCacheManagerPeerProvider("RMI"); - return provider.listRemoteCachePeers(cache); - } - - - /** - * @return whether update is through copy or invalidate - */ - public final boolean isReplicateUpdatesViaCopy() { - return replicateUpdatesViaCopy; - } - - /** - * Asserts that the replicator is active. - * - * @return true if the status is not STATUS_ALIVE - */ - public final boolean notAlive() { - return !alive(); - } - - /** - * Checks that the replicator is is STATUS_ALIVE. - */ - public final boolean alive() { - if (status == null) { - return false; - } else { - return (status.equals(Status.STATUS_ALIVE)); - } - } - - /** - * Give the replicator a chance to cleanup and free resources when no longer needed - */ - public void dispose() { - status = Status.STATUS_SHUTDOWN; - } - - /** - * Creates a clone of this listener. This method will only be called by ehcache before a cache is initialized. - *

- * This may not be possible for listeners after they have been initialized. Implementations should throw - * CloneNotSupportedException if they do not support clone. - * - * @return a clone - * @throws CloneNotSupportedException if the listener could not be cloned. - */ - public Object clone() throws CloneNotSupportedException { - //shutup checkstyle - super.clone(); - return new RMISynchronousCacheReplicator(replicatePuts, replicatePutsViaCopy, replicateUpdates, - replicateUpdatesViaCopy, replicateRemovals); - } -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/transaction/local/LocalTransactionContext.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/transaction/local/LocalTransactionContext.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/transaction/local/LocalTransactionContext.java (revision 0) @@ -1,313 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package net.sf.ehcache.transaction.local; - -import net.sf.ehcache.transaction.SoftLock; -import net.sf.ehcache.transaction.TransactionException; -import net.sf.ehcache.transaction.TransactionID; -import net.sf.ehcache.transaction.TransactionIDFactory; -import net.sf.ehcache.transaction.TransactionTimeoutException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.TimeUnit; - -import static java.util.concurrent.TimeUnit.MILLISECONDS; - -/** - * A local transaction's thread context - * - * @author Ludovic Orban - */ -public class LocalTransactionContext { - - private static final Logger LOG = LoggerFactory.getLogger(LocalTransactionContext.class.getName()); - - private boolean rollbackOnly; - private final long expirationTimestamp; - private final TransactionIDFactory transactionIdFactory; - private final TransactionID transactionId; - private final Map> softLockMap = new HashMap>(); - private final Map storeMap = new HashMap(); - private final List listeners = new ArrayList(); - - /** - * Create a new LocalTransactionContext - * @param transactionTimeout the timeout before the context expires - * @param transactionIdFactory the transaction ID factory to retrieve a new transaction id from - */ - public LocalTransactionContext(int transactionTimeout, TransactionIDFactory transactionIdFactory) { - this.expirationTimestamp = MILLISECONDS.convert(System.nanoTime(), TimeUnit.NANOSECONDS) + - MILLISECONDS.convert(transactionTimeout, TimeUnit.SECONDS); - this.transactionIdFactory = transactionIdFactory; - this.transactionId = transactionIdFactory.createTransactionID(); - } - - /** - * Check if the context timed out - * @return true if the context timed out, false otherwise - */ - public boolean timedOut() { - return timeBeforeTimeout() <= 0; - } - - /** - * Get the time until this context will expire - * @return the time in milliseconds after which this context will expire - */ - public long timeBeforeTimeout() { - return Math.max(0, expirationTimestamp - MILLISECONDS.convert(System.nanoTime(), TimeUnit.NANOSECONDS)); - } - - /** - * Mark the context for rollback - */ - public void setRollbackOnly() { - this.rollbackOnly = true; - } - - /** - * Register a soft lock in the context - * @param cacheName the name of the cache this soft lock is in - * @param store the LocalTransactionStore this soft lock is in - * @param softLock the soft lock - */ - public void registerSoftLock(String cacheName, LocalTransactionStore store, SoftLock softLock) { - List softLocks = softLockMap.get(cacheName); - if (softLocks == null) { - softLocks = new ArrayList(); - softLockMap.put(cacheName, softLocks); - storeMap.put(cacheName, store); - } - softLocks.add(softLock); - } - - //todo this method isn't needed if there is no copy on read/write in the underlying store - /** - * Update a soft lock already registered in the context - * @param cacheName the name of the cache this soft lock is in - * @param softLock the soft lock - */ - public void updateSoftLock(String cacheName, SoftLock softLock) { - List softLocks = softLockMap.get(cacheName); - softLocks.remove(softLock); - softLocks.add(softLock); - } - - /** - * Get all soft locks registered in this context for a specific cache - * @param cacheName the name of the cache - * @return a List of registered soft locks for this cache - */ - public List getSoftLocksForCache(String cacheName) { - List softLocks = softLockMap.get(cacheName); - if (softLocks == null) { - return Collections.emptyList(); - } - - return Collections.unmodifiableList(softLocks); - } - - /** - * Check if anything was locked in this transaction's context - * @return true if at least one soft lock got registered, false otherwise - */ - public boolean hasLockedAnything() { - return !softLockMap.isEmpty(); - } - - /** - * Commit all work done in the context and release all registered soft locks - * @param ignoreTimeout true if commit should proceed no matter the timeout - */ - public void commit(boolean ignoreTimeout) { - if (!ignoreTimeout && timedOut()) { - rollback(); - throw new TransactionTimeoutException("transaction timed out, rolled back on commit"); - } - if (rollbackOnly) { - rollback(); - throw new TransactionException("transaction was marked as rollback only, rolled back on commit"); - } - - try { - fireBeforeCommitEvent(); - if (LOG.isDebugEnabled()) { - LOG.debug("{} participating cache(s), committing transaction {}", softLockMap.keySet().size(), transactionId); - } - freeze(); - transactionIdFactory.markForCommit(transactionId); - - for (Map.Entry> stringListEntry : softLockMap.entrySet()) { - String cacheName = stringListEntry.getKey(); - LocalTransactionStore store = storeMap.get(cacheName); - List softLocks = stringListEntry.getValue(); - - LOG.debug("committing soft locked values of cache {}", cacheName); - store.commit(softLocks, transactionId); - } - LOG.debug("committed transaction {}", transactionId); - } finally { - try { - unfreezeAndUnlock(); - } finally { - softLockMap.clear(); - storeMap.clear(); - fireAfterCommitEvent(); - } - } - } - - /** - * Rollback all work done in the context and release all registered soft locks - */ - public void rollback() { - try { - if (LOG.isDebugEnabled()) { - LOG.debug("{} participating cache(s), rolling back transaction {}", softLockMap.keySet().size(), transactionId); - } - freeze(); - - for (Map.Entry> stringListEntry : softLockMap.entrySet()) { - String cacheName = stringListEntry.getKey(); - LocalTransactionStore store = storeMap.get(cacheName); - List softLocks = stringListEntry.getValue(); - - LOG.debug("rolling back soft locked values of cache {}", cacheName); - store.rollback(softLocks, transactionId); - } - LOG.debug("rolled back transaction {}", transactionId); - } finally { - try { - unfreezeAndUnlock(); - } finally { - softLockMap.clear(); - storeMap.clear(); - fireAfterRollbackEvent(); - } - } - } - - /** - * Get the transaction ID of the context - * @return the transaction ID - */ - public TransactionID getTransactionId() { - return transactionId; - } - - /** - * Add a TransactionListener to this context - * @param listener the listener - */ - public void addListener(TransactionListener listener) { - this.listeners.add(listener); - } - - private void fireBeforeCommitEvent() { - for (TransactionListener listener : listeners) { - try { - listener.beforeCommit(); - } catch (Exception e) { - LOG.error("beforeCommit error", e); - } - } - } - - private void fireAfterCommitEvent() { - for (TransactionListener listener : listeners) { - try { - listener.afterCommit(); - } catch (Exception e) { - LOG.error("afterCommit error", e); - } - } - } - - private void fireAfterRollbackEvent() { - for (TransactionListener listener : listeners) { - try { - listener.afterRollback(); - } catch (Exception e) { - LOG.error("afterRollback error", e); - } - } - } - - private void unfreezeAndUnlock() { - LOG.debug("unfreezing and unlocking soft lock(s)"); - boolean success = true; - for (Map.Entry> stringListEntry : softLockMap.entrySet()) { - List softLocks = stringListEntry.getValue(); - - for (SoftLock softLock : softLocks) { - try { - softLock.unfreeze(); - LOG.debug("unfroze {}", softLock); - } catch (Exception e) { - success = false; - LOG.error("error unfreezing " + softLock, e); - } - try { - softLock.unlock(); - LOG.debug("unlocked {}", softLock); - } catch (Exception e) { - success = false; - LOG.error("error unlocking " + softLock, e); - } - } - } - if (!success) { - throw new TransactionException("Error unfreezing/unlocking transaction with ID " + transactionId); - } - } - - private void freeze() { - for (Map.Entry> stringListEntry : softLockMap.entrySet()) { - List softLocks = stringListEntry.getValue(); - - for (SoftLock softLock : softLocks) { - softLock.freeze(); - } - } - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - return transactionId.hashCode(); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (obj instanceof LocalTransactionContext) { - LocalTransactionContext otherCtx = (LocalTransactionContext) obj; - return transactionId.equals(otherCtx.transactionId); - } - return false; - } - -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/resources/ehcache-nonstop-behavior-test.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/resources/ehcache-nonstop-behavior-test.xml (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/resources/ehcache-nonstop-behavior-test.xml (revision 0) @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - - Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/config/InvalidConfigurationException.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/config/InvalidConfigurationException.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/config/InvalidConfigurationException.java (revision 0) @@ -1,80 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.sf.ehcache.config; - -import net.sf.ehcache.CacheException; - -import java.util.Collection; - -/** - * An exception to report invalid configuration settings. - * - * @author gbevin - * @author Greg Luck - */ -public class InvalidConfigurationException extends CacheException { - - /** - * Constructs a new exception with a detailed message that explains the cause. - * @param message the exception message - */ - public InvalidConfigurationException(String message) { - super(message); - } - - /** - * Constructs a new exception with a message containing all config errors - * @param errors the list of error encountered - */ - public InvalidConfigurationException(final Collection errors) { - this(null, errors); - } - - /** - * Constructs a new exception with a message containing all config errors - * @param errors the list of error encountered - */ - public InvalidConfigurationException(final String rootCause, final Collection errors) { - super(createErrorMessage(rootCause, errors)); - } - - private static String createErrorMessage(final String rootCause, Collection errors) { - final StringBuilder sb = new StringBuilder(); - if (rootCause == null) { - sb.append("There "); - if (errors.size() == 1) { - sb.append("is one error "); - } else { - sb.append("are ") - .append(errors.size()) - .append(" errors "); - } - sb.append("in your configuration: \n"); - } else { - sb.append(rootCause).append('\n'); - } - for (ConfigError error : errors) { - sb.append("\t* ") - .append(error.toString()) - .append('\n'); - } - return sb - .append("\n") - .toString(); - } - -} Index: rctags/ehcache-2.10.8.0.7/ehcache/src/test/resources/serializedforms/ReflectionAttributeExtractorSerializationTest.testMethodsKey.ser =================================================================== diff -u -N -r11085 -r11127 Binary files differ Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/config/ElementValueComparatorConfiguration.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/config/ElementValueComparatorConfiguration.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/config/ElementValueComparatorConfiguration.java (revision 0) @@ -1,111 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package net.sf.ehcache.config; - -import net.sf.ehcache.CacheException; -import net.sf.ehcache.store.DefaultElementValueComparator; -import net.sf.ehcache.store.ElementValueComparator; -import net.sf.ehcache.util.ClassLoaderUtil; - -/** - * @author Ludovic Orban - */ -public class ElementValueComparatorConfiguration { - - private static final String DEFAULT_IMPL = DefaultElementValueComparator.class.getName(); - - private volatile String className = DEFAULT_IMPL; - - /** - * Returns the fully qualified class name for the ElementValueComparator to use - * - * @return FQCN to the ElementValueComparator implementation to use - */ - public String getClassName() { - return className; - } - - /** - * Sets the fully qualified class name for the ElementValueComparator to use - * - * @param className - * FQCN - */ - public void setClass(final String className) { - this.className = className; - } - - /** - * Get (and potentially) instantiate the instance - * - * @param cacheConfiguration the cache configuration - * @param loader classloader to use to create the instance - * @return the instance - */ - public ElementValueComparator createElementComparatorInstance(CacheConfiguration cacheConfiguration, ClassLoader loader) { - try { - if (DEFAULT_IMPL.equals(className)) { - loader = getClass().getClassLoader(); - } - - return (ElementValueComparator) ClassLoaderUtil.createNewInstance( - loader, - className, - new Class[] {CacheConfiguration.class}, - new Object[] {cacheConfiguration} - ); - } catch (ClassCastException cce) { - throw new CacheException(className + " must implement " + ElementValueComparator.class.getName(), cce); - } - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((className == null) ? 0 : className.hashCode()); - return result; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - ElementValueComparatorConfiguration other = (ElementValueComparatorConfiguration) obj; - if (className == null) { - if (other.className != null) { - return false; - } - } else if (!className.equals(other.className)) { - return false; - } - return true; - } - -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/terracotta/TerracottaBootstrapCacheLoader.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/terracotta/TerracottaBootstrapCacheLoader.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/terracotta/TerracottaBootstrapCacheLoader.java (revision 0) @@ -1,271 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.sf.ehcache.terracotta; - -import java.io.IOException; -import java.util.Set; - -import net.sf.ehcache.CacheException; -import net.sf.ehcache.CacheManager; -import net.sf.ehcache.DiskStorePathManager; -import net.sf.ehcache.Disposable; -import net.sf.ehcache.Ehcache; -import net.sf.ehcache.Status; -import net.sf.ehcache.distribution.RemoteCacheException; -import net.sf.ehcache.store.MemoryLimitedCacheLoader; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * A {@link net.sf.ehcache.bootstrap.BootstrapCacheLoader} that will load Elements into a Terracotta clustered cache, based on a previously - * snapshotted key set. It is also responsible to create snapshot files to disk - * - * @author Alex Snaps - */ -public class TerracottaBootstrapCacheLoader extends MemoryLimitedCacheLoader implements Disposable { - - /** - * The default interval in seconds, between each snapshot - */ - public static final long DEFAULT_INTERVAL = 10 * 60; - /** - * The default on whether to do the snapshot on a dedicated thread or using the CacheManager's - * {@link java.util.concurrent.ScheduledExecutorService} - */ - public static final boolean DEFAULT_DEDICATED_THREAD = false; - - private static final Logger LOG = LoggerFactory.getLogger(TerracottaBootstrapCacheLoader.class); - - private final boolean aSynchronous; - private final boolean doKeySnapshot; - private final boolean doKeySnapshotOnDedicatedThread; - private final long interval; - private final DiskStorePathManager diskStorePathManager; - - private volatile KeySnapshotter keySnapshotter; - private volatile boolean immediateShutdown; - private volatile boolean doKeySnapshotOnDispose; - - private TerracottaBootstrapCacheLoader(final boolean doKeySnapshot, final boolean aSynchronous, final String directory, - final long interval, final boolean doKeySnapshotOnDedicatedThread) { - this.aSynchronous = aSynchronous; - this.doKeySnapshot = doKeySnapshot; - this.doKeySnapshotOnDedicatedThread = doKeySnapshotOnDedicatedThread; - this.interval = interval; - this.diskStorePathManager = directory != null ? new DiskStorePathManager(directory) : null; - } - - /** - * Constructor - * - * @param asynchronous do the loading asynchronously, or synchronously - * @param directory the directory to read snapshot files from, and write them to - * @param doKeySnapshots Whether to do keysnapshotting - */ - public TerracottaBootstrapCacheLoader(final boolean asynchronous, String directory, boolean doKeySnapshots) { - this(doKeySnapshots, asynchronous, directory, DEFAULT_INTERVAL, DEFAULT_DEDICATED_THREAD); - } - - /** - * Constructor - * - * @param asynchronous do the loading asynchronously, or synchronously - * @param directory the directory to read snapshot files from, and write them to - * @param interval the interval in seconds at which the snapshots of the local key set has to occur - */ - public TerracottaBootstrapCacheLoader(final boolean asynchronous, String directory, long interval) { - this(asynchronous, directory, interval, false); - } - - /** - * Constructor - * - * @param asynchronous do the loading asynchronously, or synchronously - * @param directory the directory to read snapshot files from, and write them to - * @param interval the interval in seconds at which the snapshots of the local key set has to occur - * @param onDedicatedThread whether to do the snapshot on a dedicated thread or using the CacheManager's - * {@link java.util.concurrent.ScheduledExecutorService ScheduledExecutorService} - */ - public TerracottaBootstrapCacheLoader(final boolean asynchronous, String directory, long interval, boolean onDedicatedThread) { - this(true, asynchronous, directory, interval, onDedicatedThread); - } - - /** - * Whether the on going keysnapshot will finish before the instance is disposed - * - * @return true if disposable is immediate - * @see Disposable - */ - public boolean isImmediateShutdown() { - return immediateShutdown; - } - - /** - * Sets whether the disposal of the instance will let the potential current key set being written to disk finish, or whether the - * shutdown will be immediate - * - * @param immediateShutdown true if immediate, false to let the snapshot finish - */ - public void setImmediateShutdown(final boolean immediateShutdown) { - this.immediateShutdown = immediateShutdown; - } - - /** - * {@inheritDoc} - */ - public void load(final Ehcache cache) throws CacheException { - if (!cache.getCacheConfiguration().isTerracottaClustered()) { - LOG.error("You're trying to bootstrap a non Terracotta clustered cache with a TerracottaBootstrapCacheLoader! Cache " - + "'{}' will not be bootstrapped and no keySet snapshot will be recorded...", cache.getName()); - return; - } - - if (cache.getStatus() != Status.STATUS_ALIVE) { - throw new CacheException("Cache '" + cache.getName() + "' isn't alive yet: " + cache.getStatus()); - } - - if (isAsynchronous()) { - BootstrapThread thread = new BootstrapThread(cache); - thread.start(); - } else { - doLoad(cache); - } - } - - private void doLoad(final Ehcache cache) { - CacheManager manager = cache.getCacheManager(); - if (manager == null) { - throw new CacheException("Cache must belong to a cache manager to bootstrap"); - } - - DiskStorePathManager pathManager = diskStorePathManager != null ? diskStorePathManager : cache.getCacheManager() - .getDiskStorePathManager(); - - final RotatingSnapshotFile snapshotFile = new RotatingSnapshotFile(pathManager, cache.getName(), manager.getConfiguration().getClassLoader()); - try { - final Set keys = snapshotFile.readAll(); - int loaded = 0; - for (Object key : keys) { - if (isInMemoryLimitReached(cache, loaded)) { - break; - } - cache.get(key); - loaded++; - } - LOG.info("Finished loading {} keys (of {} on disk) from previous snapshot for Cache '{}'", - new Object[] {Integer.valueOf(loaded), keys.size(), cache.getName()}); - } catch (IOException e) { - LOG.error("Couldn't load keySet for Cache '{}'", cache.getName(), e); - } - - if (doKeySnapshot) { - keySnapshotter = new KeySnapshotter(cache, interval, doKeySnapshotOnDedicatedThread, snapshotFile); - } - } - - /** - * {@inheritDoc} - */ - public boolean isAsynchronous() { - return aSynchronous; - } - - /** - * Will shut the keysnapshot thread and other resources down. - * If a snapshot is currently in progress, the method will either shutdown immediately or let the snapshot finish - * based on the configured {@link #setImmediateShutdown(boolean)} value - */ - public void dispose() { - if (keySnapshotter != null) { - if (doKeySnapshotOnDispose) { - try { - keySnapshotter.doSnapshot(); - } catch (IOException e) { - LOG.error("Error writing local key set for Cache '{}'", keySnapshotter.getCacheName(), e); - } - } else { - keySnapshotter.dispose(immediateShutdown); - } - } - if (diskStorePathManager != null) { - diskStorePathManager.releaseLock(); - } - } - - /** - * Calling this method will result in a snapshot being taken or wait for the one in progress to finish - * - * @throws IOException On exception being thrown while doing the snapshot - */ - public void doLocalKeySnapshot() throws IOException { - keySnapshotter.doSnapshot(); - } - - /** - * {@inheritDoc} - */ - @Override - public Object clone() throws CloneNotSupportedException { - return super.clone(); - } - - /** - * Accessor to the associated {@link KeySnapshotter} - * - * @return the {@link KeySnapshotter} used by this loader instance - */ - KeySnapshotter getKeySnapshotter() { - return keySnapshotter; - } - - /** - * Configures the Loader to take a snapshot when it is being disposed - * - * @param doKeySnapshotOnDispose whether to snapshot on loader disposal - */ - public void setSnapshotOnDispose(final boolean doKeySnapshotOnDispose) { - this.doKeySnapshotOnDispose = doKeySnapshotOnDispose; - } - - /** - * A background daemon thread that asynchronously calls doLoad - */ - private final class BootstrapThread extends Thread { - private Ehcache cache; - - public BootstrapThread(Ehcache cache) { - super("Bootstrap Thread for cache " + cache.getName()); - this.cache = cache; - setDaemon(true); - setPriority(Thread.NORM_PRIORITY); - } - - /** - * RemoteDebugger thread method. - */ - @Override - public final void run() { - try { - doLoad(cache); - } catch (RemoteCacheException e) { - LOG.warn("Error asynchronously performing bootstrap. The cause was: " + e.getMessage(), e); - } - cache = null; - } - } -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/constructs/nonstop/package.html =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/constructs/nonstop/package.html (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/constructs/nonstop/package.html (revision 0) @@ -1,10 +0,0 @@ - - - - -

Ehcache-nonstopcache package

- -This package contains core classes for NonStopCache features - - - Index: rctags/ehcache-2.10.8.0.7/ehcache-scheduled-refresh/src/test/resources/ehcache-scheduled-refresh.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-scheduled-refresh/src/test/resources/ehcache-scheduled-refresh.xml (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-scheduled-refresh/src/test/resources/ehcache-scheduled-refresh.xml (revision 0) @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - Index: rctags/ehcache-2.10.8.0.7/terracotta/bootstrap/src/test/java/org/terracotta/modules/ehcache/WatchableTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/terracotta/bootstrap/src/test/java/org/terracotta/modules/ehcache/WatchableTest.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/terracotta/bootstrap/src/test/java/org/terracotta/modules/ehcache/WatchableTest.java (revision 0) @@ -1,76 +0,0 @@ -/* - * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved. - */ - -package org.terracotta.modules.ehcache; - -import net.sf.ehcache.config.CacheConfiguration; -import net.sf.ehcache.util.concurrent.ConcurrentHashMap; -import org.junit.Before; -import org.junit.Test; -import org.terracotta.toolkit.concurrent.locks.ToolkitLock; -import org.terracotta.toolkit.internal.cache.BufferingToolkitCache; - -import java.io.Serializable; -import java.util.concurrent.ConcurrentMap; -import java.util.concurrent.locks.Condition; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -/** - * @author Eugene Shelestovich - */ -public class WatchableTest { - - private ToolkitLock configLock; - private ToolkitLock activeLock; - private WanAwareToolkitCache watchable; - - @Before - public void setUp() throws Exception { - final ConcurrentMap configMap = new ConcurrentHashMap(); - final BufferingToolkitCache delegate = mock(BufferingToolkitCache.class); - Condition condition = mock(Condition.class); - configLock = when(mock(ToolkitLock.class).getCondition()).thenReturn(condition).getMock(); - activeLock = when(mock(ToolkitLock.class).isHeldByCurrentThread()).thenReturn(false, true).getMock(); - watchable = new WanAwareToolkitCache( - delegate, configMap, null, configLock, activeLock, new CacheConfiguration(), true, true); - } - - @Test - public void testMustAcquireLockOnGoLive() { - when(activeLock.isHeldByCurrentThread()).thenReturn(false, true); - watchable.goLive(); - verify(activeLock).lock(); - } - - @Test - public void testMustNotAcquireLockIfAlreadyHeld() { - when(activeLock.isHeldByCurrentThread()).thenReturn(true); - watchable.goLive(); - verify(activeLock, never()).lock(); - } - - @Test - public void testMustDeactivateCacheIfLockReleased() { - watchable.goLive(); - when(activeLock.tryLock()).thenReturn(true); - assertFalse(watchable.probeLiveness()); - assertFalse(watchable.isOrchestratorAlive()); - verify(activeLock).unlock(); - } - - @Test - public void testMustNotDeactivateCacheIfLockHeld() { - watchable.goLive(); - when(activeLock.tryLock()).thenReturn(false); - assertTrue(watchable.probeLiveness()); - assertTrue(watchable.isOrchestratorAlive()); - verify(activeLock, never()).unlock(); - } -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/loader/ComponentC.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/loader/ComponentC.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/loader/ComponentC.java (revision 0) @@ -1,49 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.sf.ehcache.loader; - -/** - * Written for Dead-lock poc - * - * @author Greg Luck - * @version $Id: ComponentC.java 5594 2012-05-07 16:04:31Z cdennis $ - */ -public class ComponentC { - - private Object obj; - - /** - * @param obj - */ - public ComponentC(Object obj) { - this.obj = obj; - } - - /** - * @return - */ - public Object getObj() { - return obj; - } - - /** - * @return - */ - public String toString() { - return "C(" + obj + ")"; - } -} Index: rctags/ehcache-2.10.8.0.7/distribution/colorcache/src/assemble/bin/relative-paths.sh =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/distribution/colorcache/src/assemble/bin/relative-paths.sh (revision 11085) +++ rctags/ehcache-2.10.8.0.7/distribution/colorcache/src/assemble/bin/relative-paths.sh (revision 0) @@ -1,13 +0,0 @@ -#!/bin/bash - -case "$1" in - tc_install_dir) - echo ../../../.. - ;; - ehcache_jars_dir) - echo ../../.. - ;; - *) - echo "unknown param" - exit 1 -esac Index: rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/ehcache/tests/ClusteredCacheRemovalTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/ehcache/tests/ClusteredCacheRemovalTest.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/ehcache/tests/ClusteredCacheRemovalTest.java (revision 0) @@ -1,12 +0,0 @@ -package org.terracotta.ehcache.tests; - -import com.tc.test.config.model.TestConfig; - -/** - * @author Alex Snaps - */ -public class ClusteredCacheRemovalTest extends AbstractCacheTestBase { - public ClusteredCacheRemovalTest(TestConfig testConfig) { - super("one-cache-test.xml", testConfig, CacheRemovalClient.class); - } -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/CacheStoreHelper.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/CacheStoreHelper.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/CacheStoreHelper.java (revision 0) @@ -1,49 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.sf.ehcache; - -import net.sf.ehcache.store.Store; - -/** - * A helper class to get the internal Store from a Cache - * - * @author Abhishek Sanoujam - * - */ -public class CacheStoreHelper { - - private final Cache cache; - - /** - * Constructor accepting the cache - * - * @param cache - */ - public CacheStoreHelper(final Cache cache) { - this.cache = cache; - } - - /** - * Returns the internal {@link Store} of the cache - * - * @return the internal {@link Store} of the cache - */ - public Store getStore() { - return cache.getStore(); - } - -} Index: rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/modules/ehcache/writebehind/SynchronousDeadBucketWriteBehindTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/modules/ehcache/writebehind/SynchronousDeadBucketWriteBehindTest.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/modules/ehcache/writebehind/SynchronousDeadBucketWriteBehindTest.java (revision 0) @@ -1,92 +0,0 @@ -/* - * All content copyright (c) 2003-2008 Terracotta, Inc., except as may otherwise be noted in a separate copyright - * notice. All rights reserved. - */ -package org.terracotta.modules.ehcache.writebehind; - -import org.terracotta.ehcache.tests.AbstractCacheTestBase; -import org.terracotta.modules.ehcache.async.AsyncCoordinatorImpl; - -import com.tc.l2.L2DebugLogging.LogLevel; -import com.tc.test.config.model.TestConfig; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileReader; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -public class SynchronousDeadBucketWriteBehindTest extends AbstractCacheTestBase { - private int totalWriteCount = 0; - private int totalDeleteCount = 0; - - public SynchronousDeadBucketWriteBehindTest(TestConfig testConfig) { - super("synchronous-writebehind-test.xml", testConfig, WriteBehindClient1.class, WriteBehindClient2.class); - testConfig.getClientConfig().setParallelClients(false); - configureTCLogging(AsyncCoordinatorImpl.class.getName(), LogLevel.DEBUG); - } - - @Override - protected void postClientVerification() { - System.out.println("[Clients processed a total of " + totalWriteCount + " writes]"); - if (totalWriteCount != 1001 && totalWriteCount != 1002) { // there can be one double write due to JVM exit during - // async item processing - throw new AssertionError(totalWriteCount); - } - - System.out.println("[Clients processed a total of " + totalDeleteCount + " deletes]"); - if (totalDeleteCount != 101 && totalDeleteCount != 102) { // there can be one double delete due to JVM exit during - // async item processing - throw new AssertionError(totalDeleteCount); - } - } - - @Override - protected void evaluateClientOutput(String clientName, int exitCode, File output) throws Throwable { - super.evaluateClientOutput(clientName, exitCode, output); - - FileReader fr = null; - StringBuilder strBuilder = new StringBuilder(); - try { - fr = new FileReader(output); - BufferedReader reader = new BufferedReader(fr); - String st = ""; - while ((st = reader.readLine()) != null) { - strBuilder.append(st); - } - } catch (Exception e) { - throw new AssertionError(e); - } finally { - try { - fr.close(); - } catch (Exception e) { - // - } - } - // Detect the number of writes that have happened - int writeCount = detectLargestCount(strBuilder.toString(), - Pattern.compile("\\[WriteBehindCacheWriter written (\\d+) for " + clientName - + "\\]")); - totalWriteCount += writeCount; - System.out.println("[" + clientName + " processed " + writeCount + " writes]"); - - // Detect the number of deletes that have happened - int deleteCount = detectLargestCount(strBuilder.toString(), - Pattern.compile("\\[WriteBehindCacheWriter deleted (\\d+) for " + clientName - + "\\]")); - totalDeleteCount += deleteCount; - System.out.println("[" + clientName + " processed " + deleteCount + " deletes]"); - } - - private int detectLargestCount(String clientOutput, Pattern pattern) { - Matcher matcher = pattern.matcher(clientOutput); - int count = 0; - while (matcher.find()) { - int parsedCount = Integer.parseInt(matcher.group(1)); - if (parsedCount > count) { - count = parsedCount; - } - } - return count; - } -} \ No newline at end of file Index: rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/modules/ehcache/store/BasicCacheTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/modules/ehcache/store/BasicCacheTest.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/modules/ehcache/store/BasicCacheTest.java (revision 0) @@ -1,196 +0,0 @@ -/* - * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved. - */ -package org.terracotta.modules.ehcache.store; - -import net.sf.ehcache.Cache; -import net.sf.ehcache.Element; - -import org.terracotta.ehcache.tests.AbstractCacheTestBase; -import org.terracotta.ehcache.tests.ClientBase; -import org.terracotta.toolkit.Toolkit; -import org.terracotta.toolkit.concurrent.ToolkitBarrier; - -import com.tc.test.config.model.TestConfig; - -import java.util.Collections; -import java.util.Iterator; - -import junit.framework.Assert; - -public class BasicCacheTest extends AbstractCacheTestBase { - private static final int NODE_COUNT = 3; - - public BasicCacheTest(TestConfig testConfig) { - super(testConfig, App.class, App.class, App.class); - } - - public static class App extends ClientBase { - private final ToolkitBarrier barrier; - - public App(String[] args) { - super(args); - this.barrier = getClusteringToolkit().getBarrier("test-barrier", NODE_COUNT); - } - - public static void main(String[] args) { - new App(args).run(); - } - - @Override - protected void runTest(Cache cache, Toolkit clusteringToolkit) throws Throwable { - final int index = barrier.await(); - - // XXX: assert that the cache is clustered via methods on cache config (when methods exist) - - Assert.assertEquals(0, cache.getSize()); - - barrier.await(); - - if (index == 0) { - cache.put(new Element("key", "value")); - } - - barrier.await(); - - Assert.assertEquals(1, cache.getSize()); - Assert.assertEquals("value", cache.get("key").getObjectValue()); - Assert.assertEquals(1, cache.getKeys().size()); - Assert.assertEquals("key", cache.getKeys().iterator().next()); - - barrier.await(); - - testKeysetMutations(cache); - - barrier.await(); - - // make sure the cache is still valid after the key set mutations above - Assert.assertEquals(1, cache.getSize()); - Assert.assertEquals("value", cache.get("key").getObjectValue()); - Assert.assertEquals(1, cache.getKeys().size()); - Assert.assertEquals("key", cache.getKeys().iterator().next()); - - barrier.await(); - - if (index == 0) { - boolean removed = cache.remove("key"); - Assert.assertTrue(removed); - } - - barrier.await(); - - Assert.assertEquals(0, cache.getSize()); - } - - private void testKeysetMutations(Cache cache) { - try { - cache.getKeys().clear(); - Assert.fail(); - } catch (UnsupportedOperationException uoe) { - // expected - } - - try { - cache.getKeys().add("sdf"); - Assert.fail(); - } catch (UnsupportedOperationException uoe) { - // expected - } - - try { - cache.getKeys().add(0, "sdf"); - Assert.fail(); - } catch (UnsupportedOperationException uoe) { - // expected - } - - try { - cache.getKeys().addAll(Collections.singletonList("sdfsfd")); - Assert.fail(); - } catch (UnsupportedOperationException uoe) { - // expected - } - - try { - cache.getKeys().addAll(0, Collections.singletonList("SDfsdf")); - Assert.fail(); - } catch (UnsupportedOperationException uoe) { - // expected - } - - { - Iterator iter = cache.getKeys().iterator(); - iter.next(); - try { - iter.remove(); - Assert.fail(); - } catch (UnsupportedOperationException uoe) { - // expected - } - } - - try { - cache.getKeys().listIterator(); - Assert.fail(); - } catch (UnsupportedOperationException uoe) { - // expected for now, but if listIterator() gets implemented this test should make sure you can't mutate the - // cache through it) - } - - try { - cache.getKeys().listIterator(0); - Assert.fail(); - } catch (UnsupportedOperationException uoe) { - // expected for now, but if listIterator() gets implemented this test should make sure you can't mutate the - // cache through it) - } - - try { - cache.getKeys().remove(0); - Assert.fail(); - } catch (UnsupportedOperationException uoe) { - // expected - } - - Assert.assertTrue(cache.getKeys().contains("key")); - try { - cache.getKeys().remove("key"); - Assert.fail(); - } catch (UnsupportedOperationException uoe) { - // expected - } - - try { - cache.getKeys().removeAll(Collections.singletonList("key")); - Assert.fail(); - } catch (UnsupportedOperationException uoe) { - // expected - } - - Assert.assertFalse(cache.getKeys().contains("not in the cache!")); - try { - cache.getKeys().retainAll(Collections.singletonList("not in the cache!")); - Assert.fail(); - } catch (UnsupportedOperationException uoe) { - // expected - } - - try { - cache.getKeys().set(0, this); - Assert.fail(); - } catch (UnsupportedOperationException uoe) { - // expected - } - - try { - cache.getKeys().subList(0, 0); - Assert.fail(); - } catch (UnsupportedOperationException uoe) { - // expected for now, but if subList() gets implemented this test should make sure you can't mutate the - // cache through it (or its further iterators!) - } - } - - } - -} Index: rctags/ehcache-2.10.8.0.7/management-ehcache-impl/management-ehcache-impl-v2/src/test/java/net/sf/ehcache/management/service/impl/DfltSamplerRepositoryServiceV2Test.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/management-ehcache-impl/management-ehcache-impl-v2/src/test/java/net/sf/ehcache/management/service/impl/DfltSamplerRepositoryServiceV2Test.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/management-ehcache-impl/management-ehcache-impl-v2/src/test/java/net/sf/ehcache/management/service/impl/DfltSamplerRepositoryServiceV2Test.java (revision 0) @@ -1,109 +0,0 @@ -/* - * All content copyright (c) 2003-2012 Terracotta, Inc., except as may otherwise be noted in a separate copyright - * notice. All rights reserved. - */ -package net.sf.ehcache.management.service.impl; - -import net.sf.ehcache.Cache; -import net.sf.ehcache.CacheManager; -import net.sf.ehcache.ClusteredInstanceFactoryAccessor; -import net.sf.ehcache.config.CacheConfiguration; -import net.sf.ehcache.config.Configuration; -import net.sf.ehcache.config.ManagementRESTServiceConfiguration; -import net.sf.ehcache.constructs.blocking.BlockingCache; -import net.sf.ehcache.terracotta.ClusteredInstanceFactory; -import net.sf.ehcache.terracotta.TerracottaClient; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import java.util.Collections; - -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; -import static org.mockito.Matchers.anyBoolean; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import static org.mockito.Mockito.spy; - -/** - * @author Ludovic Orban - */ -public class DfltSamplerRepositoryServiceV2Test { - - private DfltSamplerRepositoryServiceV2 repositoryService; - private ClusteredInstanceFactory clusteredInstanceFactory; - private CacheManager cacheManager; - - @Before - public void setUp() throws Exception { - ManagementRESTServiceConfiguration managementRESTServiceConfiguration = new ManagementRESTServiceConfiguration(); - managementRESTServiceConfiguration.setEnabled(true); - RemoteAgentEndpointImpl remoteAgentEndpoint = mock(RemoteAgentEndpointImpl.class); - repositoryService = new DfltSamplerRepositoryServiceV2(managementRESTServiceConfiguration, remoteAgentEndpoint); - - Configuration configuration = new Configuration(); - configuration.setName("testCacheManager"); - CacheConfiguration cacheConfiguration = new CacheConfiguration("testCache1", 12); - configuration.addCache(cacheConfiguration); - cacheManager = new CacheManager(configuration); - // Cache ehcache = new Cache(cacheConfiguration); - TerracottaClient terracottaClient = mock(TerracottaClient.class); - clusteredInstanceFactory = mock(ClusteredInstanceFactory.class); - - ClusteredInstanceFactoryAccessor.setTerracottaClient(cacheManager, terracottaClient); - when(terracottaClient.getClusteredInstanceFactory()).thenReturn(clusteredInstanceFactory); - - repositoryService.register(cacheManager); - } - - @Test - public void testCreateCacheEntitiesDisablesNonStop() throws Exception { - repositoryService.createCacheEntities(Collections.singleton("testCacheManager"), - Collections.singleton("testCache1"), - Collections.singleton("Size")); - - verify(clusteredInstanceFactory, times(4)).enableNonStopForCurrentThread(anyBoolean()); - } - - @Test - public void testCreateCacheStatisticSampleEntityDisablesNonStop() throws Exception { - repositoryService.createCacheStatisticSampleEntity(Collections.singleton("testCacheManager"), - Collections.singleton("testCache1"), - Collections.singleton("Size")); - - verify(clusteredInstanceFactory, times(4)).enableNonStopForCurrentThread(anyBoolean()); - } - - @Test - public void testClearCacheDisablesNonStop() throws Exception { - repositoryService.clearCache("testCacheManager", "testCache1"); - - verify(clusteredInstanceFactory, times(4)).enableNonStopForCurrentThread(anyBoolean()); - } - - @Test - public void testCanAddDecoratedCache() { - Cache underlyingCache = new Cache(new CacheConfiguration("decoratedTestCache", 10)); - cacheManager.addCache(new BlockingCache(underlyingCache)); - // not using cacheEventListeners for management anymore : TAB-5077 - assertThat(underlyingCache.getCacheEventNotificationService().hasCacheEventListeners(), is(false)); - } - - @Test - public void testPropertyListenerRemoval() throws Exception { - CacheManager cacheManagerSpy = spy(cacheManager); - repositoryService.unregister(cacheManagerSpy); - verify(cacheManagerSpy).getConfiguration(); - repositoryService.register(cacheManager); - } - - @After - public void tearDown() { - CacheManager.getCacheManager("testCacheManager").shutdown(); - } - -} Index: rctags/ehcache-2.10.8.0.7/management-ehcache-impl/management-ehcache-common/src/main/java/net/sf/ehcache/management/service/ManagementServerLifecycle.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/management-ehcache-impl/management-ehcache-common/src/main/java/net/sf/ehcache/management/service/ManagementServerLifecycle.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/management-ehcache-impl/management-ehcache-common/src/main/java/net/sf/ehcache/management/service/ManagementServerLifecycle.java (revision 0) @@ -1,41 +0,0 @@ -/* - * All content copyright (c) 2003-2012 Terracotta, Inc., except as may otherwise be noted in a separate copyright - * notice. All rights reserved. - */ -package net.sf.ehcache.management.service; - -import net.sf.ehcache.CacheManager; - -/** - * A interface for services registering {@link CacheManager} objects for sampling. - * - * @author brandony - */ -public interface ManagementServerLifecycle { - - /** - * Register a {@link CacheManager} for sampling. - * - * @param cacheManager to register - */ - void register(CacheManager cacheManager); - - /** - * Unregister a {@link CacheManager} for sampling. - * - * @param cacheManager to register - */ - void unregister(CacheManager cacheManager); - - /** - * An indicator as to whether or not any {@link CacheManager} objects have been registered. - * - * @return {@code true} if an object has been registered, {@code false} otherwise - */ - boolean hasRegistered(); - - /** - * Dispose of the repository service mbean - */ - void dispose(); -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/resources/ehcache-perf-distributed.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/resources/ehcache-perf-distributed.xml (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/resources/ehcache-perf-distributed.xml (revision 0) @@ -1,34 +0,0 @@ - - - - - - - - - - - - - - - - - - Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/constructs/CacheDecoratorFactory.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/constructs/CacheDecoratorFactory.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/constructs/CacheDecoratorFactory.java (revision 0) @@ -1,85 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.sf.ehcache.constructs; - -import java.util.Properties; - -import net.sf.ehcache.Ehcache; - -/** - * An abstract factory for creating decorated Ehcache instances. Implementing classes should provide their own - * concrete factory extending this factory. - * - * @author Abhishek Sanoujam - */ -public abstract class CacheDecoratorFactory { - - /** - * Dash string : "-" - */ - public static final String DASH = "-"; - - /** - * Creates a decorated {@link Ehcache} using the properties specified for configuring the decorator. - *

- * If the returned decorated cache has the same name as the underlying cache, then the original cache will be replaced by this new - * decorated cache in the CacheManager. - * - * @param cache - * a reference to the owning cache - * @param properties - * implementation specific properties configured as delimiter - * separated name value pairs in ehcache.xml - * @return a decorated Ehcache - */ - public abstract Ehcache createDecoratedEhcache(Ehcache cache, Properties properties); - - /** - * This method is called when the factory is specified for the defaultCache in the config. - * Create the decorated {@link Ehcache} using the properties specified. - *

- * If the returned decorated cache has the same name as the underlying cache, then the original cache will be replaced by this new - * decorated cache in the CacheManager. - * - * @param cache - * a reference to the owning cache - * @param properties - * implementation specific properties configured as delimiter - * separated name value pairs in ehcache.xml - * @return a decorated Ehcache - */ - public abstract Ehcache createDefaultDecoratedEhcache(Ehcache cache, Properties properties); - - /** - * Utility method to generate name of decorated cache to be created using factory specified in defaultCache. - * - * @param cache - * the underlying cache - * @param cacheNameSuffix - * Name to be used as suffix. This is normally provided as a property in the decorator config properties. If this parameter - * is null or empty string, cache.getName() is returned - * @return Name to be used for the new decorated cache in the form of cache.getName() + "-" + cacheNameSuffix or cache.getName() if - * cacheNameSuffix is null - */ - public static String generateDefaultDecoratedCacheName(Ehcache cache, String cacheNameSuffix) { - if (cacheNameSuffix == null || cacheNameSuffix.trim().length() == 0) { - return cache.getName(); - } - return cache.getName() + DASH + cacheNameSuffix; - } - -} Index: rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/ehcache/tests/servermap/Client6.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/ehcache/tests/servermap/Client6.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/ehcache/tests/servermap/Client6.java (revision 0) @@ -1,32 +0,0 @@ -package org.terracotta.ehcache.tests.servermap; - -import net.sf.ehcache.Cache; -import net.sf.ehcache.Element; - -import org.terracotta.toolkit.Toolkit; - -public class Client6 extends ServerMapClientBase { - - public Client6(String[] args) { - super("test", args); - } - - public static void main(String[] args) { - new Client6(args).run(); - } - - @Override - protected void runTest(Cache cache, Toolkit clusteringToolkit) throws Throwable { - assertClient1Exited(cache); - BasicServerMapExpressTestHelper.assertValuesInCache(cache); - } - - private void assertClient1Exited(Cache cache) { - Element element = cache.get("client1-exited"); - if (element == null) { throw new AssertionError("Element should not be null"); } - if (!"true".equals(element.getObjectValue())) { - // - throw new AssertionError("Client1 should have already exited before this"); - } - } -} Index: rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/modules/ehcache/writebehind/BasicWriteBehindTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/modules/ehcache/writebehind/BasicWriteBehindTest.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/modules/ehcache/writebehind/BasicWriteBehindTest.java (revision 0) @@ -1,88 +0,0 @@ -/* - * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved. - */ -package org.terracotta.modules.ehcache.writebehind; - -import org.terracotta.ehcache.tests.AbstractCacheTestBase; -import org.terracotta.modules.ehcache.async.AsyncCoordinatorImpl; - -import com.tc.l2.L2DebugLogging.LogLevel; -import com.tc.test.config.model.TestConfig; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileReader; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -public class BasicWriteBehindTest extends AbstractCacheTestBase { - private int totalWriteCount = 0; - private int totalDeleteCount = 0; - public static final int ELEMENT_COUNT = 1000; - - public BasicWriteBehindTest(TestConfig testConfig) { - super("basic-writebehind-test.xml", testConfig, BasicWriteBehindTestClient.class); - configureTCLogging(AsyncCoordinatorImpl.class.getName(), LogLevel.DEBUG); - } - - @Override - protected void postClientVerification() { - System.out.println("[Clients processed a total of " + totalWriteCount + " writes]"); - if (totalWriteCount < ELEMENT_COUNT) { throw new AssertionError(totalWriteCount); } - - System.out.println("[Clients processed a total of " + totalDeleteCount + " deletes]"); - if (totalDeleteCount < ELEMENT_COUNT / 10) { throw new AssertionError(totalDeleteCount); } - } - - @Override - protected void evaluateClientOutput(String clientName, int exitCode, File output) throws Throwable { - super.evaluateClientOutput(clientName, exitCode, output); - - FileReader fr = null; - BufferedReader reader = null; - StringBuilder strBuilder = new StringBuilder(); - try { - fr = new FileReader(output); - reader = new BufferedReader(fr); - String st = ""; - while ((st = reader.readLine()) != null) { - strBuilder.append(st); - } - } catch (Exception e) { - throw new AssertionError(e); - } finally { - try { - fr.close(); - reader.close(); - } catch (Exception e) { - // - } - } - - // Detect the number of writes that have happened - int writeCount = detectLargestCount(strBuilder.toString(), - Pattern.compile("\\[WriteBehindCacheWriter written (\\d+) for " + clientName - + "\\]")); - totalWriteCount += writeCount; - System.out.println("[" + clientName + " processed " + writeCount + " writes]"); - - // Detect the number of deletes that have happened - int deleteCount = detectLargestCount(strBuilder.toString(), - Pattern.compile("\\[WriteBehindCacheWriter deleted (\\d+) for " + clientName - + "\\]")); - totalDeleteCount += deleteCount; - System.out.println("[" + clientName + " processed " + deleteCount + " deletes]"); - } - - private int detectLargestCount(String clientOutput, Pattern pattern) { - Matcher matcher = pattern.matcher(clientOutput); - int count = 0; - while (matcher.find()) { - int parsedCount = Integer.parseInt(matcher.group(1)); - if (parsedCount > count) { - count = parsedCount; - } - } - return count; - } -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/pool/impl/LockedPoolAccessor.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/pool/impl/LockedPoolAccessor.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/pool/impl/LockedPoolAccessor.java (revision 0) @@ -1,162 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.sf.ehcache.pool.impl; - -import java.util.concurrent.locks.Lock; -import java.util.concurrent.locks.ReentrantLock; - -import net.sf.ehcache.pool.Pool; -import net.sf.ehcache.pool.PoolParticipant; -import net.sf.ehcache.pool.SizeOfEngine; - -/** - * The PoolAccessor class of the StrictlyBoundedPool - * - * @author Ludovic Orban - * @author Alex Snaps - */ -final class LockedPoolAccessor extends AbstractPoolAccessor { - - private long size; - private final Lock lock = new ReentrantLock(); - - /** - * Creates a locked pool accessor with the specified properties. - * - * @param pool pool to be accessed - * @param poolParticipant accessing poolParticipant - * @param sizeOfEngine engine used to size objects - * @param currentSize initial size of the poolParticipant - */ - LockedPoolAccessor(Pool pool, PoolParticipant poolParticipant, SizeOfEngine sizeOfEngine, long currentSize) { - super(pool, poolParticipant, sizeOfEngine); - this.size = currentSize; - } - - /** - * {@inheritDoc} - */ - protected long add(long sizeOf, boolean force) throws IllegalArgumentException { - if (sizeOf < 0L) { - throw new IllegalArgumentException("cannot add negative size"); - } - - lock.lock(); - try { - while (true) { - long newSize = getPool().getSize() + sizeOf; - - if (newSize <= getPool().getMaxSize()) { - // there is enough room => add & approve - size += sizeOf; - return sizeOf; - } else { - // check that the element isn't too big - if (!force && sizeOf > getPool().getMaxSize()) { - // this is too big to fit in the pool - return -1; - } - - // if there is not enough room => evict - long missingSize = newSize - getPool().getMaxSize(); - - // eviction must be done outside the lock to avoid deadlocks as it may evict from other pools - lock.unlock(); - try { - boolean successful = getPool().getEvictor().freeSpace(getPool().getPoolAccessors(), missingSize); - if (!force && !successful) { - // cannot free enough bytes - return -1; - } - } finally { - lock.lock(); - } - - // check that the freed space was not 'stolen' by another thread while - // eviction was running out of the lock - if (!force && getPool().getSize() + sizeOf > getPool().getMaxSize()) { - continue; - } - - size += sizeOf; - return sizeOf; - } - } - } finally { - lock.unlock(); - } - } - - /** - * {@inheritDoc} - */ - protected boolean canAddWithoutEvicting(long sizeOf) { - lock.lock(); - try { - long newSize = getPool().getSize() + sizeOf; - return newSize <= getPool().getMaxSize(); - } finally { - lock.unlock(); - } - } - - /** - * {@inheritDoc} - */ - public long delete(long sizeOf) throws IllegalArgumentException { - checkLinked(); -// if (sizeOf < 0L) { -// throw new IllegalArgumentException("cannot delete negative size"); -// } - - // synchronized makes the size update MT-safe but slow - lock.lock(); - try { - size -= sizeOf; - } finally { - lock.unlock(); - } - - return sizeOf; - } - - /** - * {@inheritDoc} - */ - public long getSize() { - // locking makes the size update MT-safe but slow - lock.lock(); - try { - return size; - } finally { - lock.unlock(); - } - } - - /** - * {@inheritDoc} - */ - protected void doClear() { - // locking makes the size update MT-safe but slow - lock.lock(); - try { - size = 0L; - } finally { - lock.unlock(); - } - } -} Index: rctags/ehcache-2.10.8.0.7/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/transaction/ClusteredID.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/transaction/ClusteredID.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/transaction/ClusteredID.java (revision 0) @@ -1,10 +0,0 @@ -/* - * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved. - */ -package org.terracotta.modules.ehcache.transaction; - -public interface ClusteredID { - - String getOwnerID(); - -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/transaction/xa/SerializableXid.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/transaction/xa/SerializableXid.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/transaction/xa/SerializableXid.java (revision 0) @@ -1,106 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package net.sf.ehcache.transaction.xa; - -import java.io.Serializable; -import java.util.Arrays; - -import javax.transaction.xa.Xid; - -/** - * A serializable XID - * - * @author Ludovic Orban - */ -public class SerializableXid implements Xid, Serializable { - - private final int formatId; - private final byte[] globalTransactionId; - private final byte[] branchQualifier; - - /** - * Create a SerializableXid, copying the GTRID and BQUAL of an existing XID - * - * @param xid a SerializableXid - */ - public SerializableXid(Xid xid) { - this.formatId = xid.getFormatId(); - this.globalTransactionId = xid.getGlobalTransactionId(); - this.branchQualifier = xid.getBranchQualifier(); - } - - /** - * {@inheritDoc} - */ - public int getFormatId() { - return formatId; - } - - /** - * {@inheritDoc} - */ - public byte[] getBranchQualifier() { - return branchQualifier; - } - - /** - * {@inheritDoc} - */ - public byte[] getGlobalTransactionId() { - return globalTransactionId; - } - - /** - * {@inheritDoc} - */ - public boolean equals(Object obj) { - if (!(obj instanceof SerializableXid)) { - return false; - } - - SerializableXid otherXid = (SerializableXid) obj; - return formatId == otherXid.getFormatId() && - Arrays.equals(globalTransactionId, otherXid.getGlobalTransactionId()) && - Arrays.equals(branchQualifier, otherXid.branchQualifier); - } - - /** - * {@inheritDoc} - */ - public int hashCode() { - int hashCode = formatId; - if (globalTransactionId != null) { - hashCode += Arrays.hashCode(globalTransactionId); - } - if (branchQualifier != null) { - hashCode += Arrays.hashCode(branchQualifier); - } - return hashCode; - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return "SerializableXid{" + - "formatId=" + formatId + - ", globalTxId=" + Arrays.toString(globalTransactionId) + - ", branchQualifier=" + Arrays.toString(branchQualifier) + - '}'; - } - -} Index: rctags/ehcache-2.10.8.0.7/distribution/colorcache/src/assemble/bin/relative-paths.bat =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/distribution/colorcache/src/assemble/bin/relative-paths.bat (revision 11085) +++ rctags/ehcache-2.10.8.0.7/distribution/colorcache/src/assemble/bin/relative-paths.bat (revision 0) @@ -1,15 +0,0 @@ -@echo off - -if "%1" == "tc_install_dir" ( - echo ../../../.. - goto end -) - -if "%1" == "ehcache_jars_dir" ( - echo ../../.. - goto end -) - -echo unknown param - -:end Index: rctags/ehcache-2.10.8.0.7/ehcache/src/test/resources/serializedforms/TransactionalModeSerializationTest.testXa.ser =================================================================== diff -u -N -r11085 -r11127 Binary files differ Index: rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/ehcache/tests/container/hibernate/BaseClusteredRegionFactoryTestServlet.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/ehcache/tests/container/hibernate/BaseClusteredRegionFactoryTestServlet.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/ehcache/tests/container/hibernate/BaseClusteredRegionFactoryTestServlet.java (revision 0) @@ -1,46 +0,0 @@ -/* - * All content copyright (c) Terracotta, Inc., except as may otherwise be noted in a separate copyright - * notice. All rights reserved. - */ -package org.terracotta.ehcache.tests.container.hibernate; - -import java.io.IOException; -import java.io.PrintWriter; -import java.util.Map; - -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; - -public abstract class BaseClusteredRegionFactoryTestServlet extends HttpServlet { - - @Override - public final void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { - HttpSession session = request.getSession(true); - response.setContentType("text/html"); - PrintWriter out = response.getWriter(); - - String server = request.getParameter("server"); - if ("server0".equals(server)) { - try { - doServer0(session, request.getParameterMap()); - out.println("OK"); - } catch (Exception e) { - e.printStackTrace(out); - } - } else if ("server1".equals(server)) { - try { - doServer1(session, request.getParameterMap()); - out.println("OK"); - } catch (Exception e) { - e.printStackTrace(out); - } - } - out.flush(); - } - - protected abstract void doServer0(HttpSession session, Map parameters) throws Exception; - - protected abstract void doServer1(HttpSession session, Map parameters) throws Exception; -} Index: rctags/ehcache-2.10.8.0.7/distribution/src/main/assembly/relative-paths.sh =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/distribution/src/main/assembly/relative-paths.sh (revision 11085) +++ rctags/ehcache-2.10.8.0.7/distribution/src/main/assembly/relative-paths.sh (revision 0) @@ -1,13 +0,0 @@ -#!/bin/bash - -case "$1" in - tc_install_dir) - echo ../../../terracotta - ;; - ehcache_jars_dir) - echo ../../.. - ;; - *) - echo "unknown param" - exit 1 -esac Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/store/NullStore.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/store/NullStore.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/store/NullStore.java (revision 0) @@ -1,278 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.sf.ehcache.store; - -import net.sf.ehcache.CacheException; -import net.sf.ehcache.Element; -import net.sf.ehcache.Status; -import net.sf.ehcache.writer.CacheWriterManager; - -import java.io.IOException; -import java.util.Collections; -import java.util.List; - -/** - * A store implementation which does not store anything. - * - * @author Ludovic Orban - */ -public final class NullStore extends AbstractStore implements Store { - - private NullStore() { - } - - /** - * Create a new NullStore instance. - * @return a NullStore instance - */ - public static NullStore create() { - return new NullStore(); - } - - /** - * {@inheritDoc} - */ - public boolean put(Element element) throws CacheException { - return false; - } - - /** - * {@inheritDoc} - */ - public boolean putWithWriter(Element element, CacheWriterManager writerManager) throws CacheException { - return false; - } - - /** - * {@inheritDoc} - */ - public Element get(Object key) { - return null; - } - - /** - * {@inheritDoc} - */ - public Element getQuiet(Object key) { - return null; - } - - /** - * {@inheritDoc} - */ - public List getKeys() { - return Collections.emptyList(); - } - - /** - * {@inheritDoc} - */ - public Element remove(Object key) { - return null; - } - - /** - * {@inheritDoc} - */ - public Element removeWithWriter(Object key, CacheWriterManager writerManager) throws CacheException { - return null; - } - - /** - * {@inheritDoc} - */ - public void removeAll() throws CacheException { - } - - /** - * {@inheritDoc} - */ - public Element putIfAbsent(Element element) throws NullPointerException { - return null; - } - - /** - * {@inheritDoc} - */ - public Element removeElement(Element element, ElementValueComparator comparator) throws NullPointerException { - return null; - } - - /** - * {@inheritDoc} - */ - public boolean replace(Element old, Element element, ElementValueComparator comparator) throws NullPointerException, IllegalArgumentException { - return false; - } - - /** - * {@inheritDoc} - */ - public Element replace(Element element) throws NullPointerException { - return null; - } - - /** - * {@inheritDoc} - */ - public void dispose() { - } - - /** - * {@inheritDoc} - */ - public int getSize() { - return 0; - } - - /** - * {@inheritDoc} - */ - public int getInMemorySize() { - return 0; - } - - /** - * {@inheritDoc} - */ - public int getOffHeapSize() { - return 0; - } - - /** - * {@inheritDoc} - */ - public int getOnDiskSize() { - return 0; - } - - /** - * {@inheritDoc} - */ - public int getTerracottaClusteredSize() { - return 0; - } - - /** - * {@inheritDoc} - */ - public long getInMemorySizeInBytes() { - return 0; - } - - /** - * {@inheritDoc} - */ - public long getOffHeapSizeInBytes() { - return 0; - } - - /** - * {@inheritDoc} - */ - public long getOnDiskSizeInBytes() { - return 0; - } - - /** - * {@inheritDoc} - */ - public Status getStatus() { - return null; - } - - /** - * {@inheritDoc} - */ - public boolean containsKey(Object key) { - return false; - } - - /** - * {@inheritDoc} - */ - public boolean containsKeyOnDisk(Object key) { - return false; - } - - /** - * {@inheritDoc} - */ - public boolean containsKeyOffHeap(Object key) { - return false; - } - - /** - * {@inheritDoc} - */ - public boolean containsKeyInMemory(Object key) { - return false; - } - - /** - * {@inheritDoc} - */ - public void expireElements() { - } - - /** - * {@inheritDoc} - */ - public void flush() throws IOException { - } - - /** - * {@inheritDoc} - */ - public boolean bufferFull() { - return false; - } - - /** - * {@inheritDoc} - */ - public Policy getInMemoryEvictionPolicy() { - return null; - } - - /** - * {@inheritDoc} - */ - public void setInMemoryEvictionPolicy(Policy policy) { - } - - /** - * {@inheritDoc} - */ - public Object getInternalContext() { - return null; - } - - /** - * {@inheritDoc} - */ - public Object getMBean() { - return null; - } - - /** - * {@inheritDoc} - */ - public void recalculateSize(Object key) { - // no-op - } -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/util/concurrent/LongAdder.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/util/concurrent/LongAdder.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/util/concurrent/LongAdder.java (revision 0) @@ -1,201 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/publicdomain/zero/1.0/ - */ - -package net.sf.ehcache.util.concurrent; - -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.Serializable; - -/** - * One or more variables that together maintain an initially zero - * {@code long} sum. When updates (method {@link #add}) are contended - * across threads, the set of variables may grow dynamically to reduce - * contention. Method {@link #sum} (or, equivalently, {@link - * #longValue}) returns the current total combined across the - * variables maintaining the sum. - * - *

This class is usually preferable to {@link java.util.concurrent.atomic.AtomicLong} when - * multiple threads update a common sum that is used for purposes such - * as collecting statistics, not for fine-grained synchronization - * control. Under low update contention, the two classes have similar - * characteristics. But under high contention, expected throughput of - * this class is significantly higher, at the expense of higher space - * consumption. - * - *

This class extends {@link Number}, but does not define - * methods such as {@code hashCode} and {@code compareTo} because - * instances are expected to be mutated, and so are not useful as - * collection keys. - * - *

jsr166e note: This class is targeted to be placed in - * java.util.concurrent.atomic. - * - * @since 1.8 - * @author Doug Lea - */ -public class LongAdder extends Striped64 implements Serializable { - private static final long serialVersionUID = 7249069246863182397L; - - /** - * Version of plus for use in retryUpdate - */ - final long fn(long v, long x) { return v + x; } - - /** - * Creates a new adder with initial sum of zero. - */ - public LongAdder() { - } - - /** - * Adds the given value. - * - * @param x the value to add - */ - public void add(long x) { - Cell[] as; long b, v; HashCode hc; Cell a; int n; - if ((as = cells) != null || !casBase(b = base, b + x)) { - boolean uncontended = true; - int h = (hc = threadHashCode.get()).code; - if (as == null || (n = as.length) < 1 || - (a = as[(n - 1) & h]) == null || - !(uncontended = a.cas(v = a.value, v + x))) - retryUpdate(x, hc, uncontended); - } - } - - /** - * Equivalent to {@code add(1)}. - */ - public void increment() { - add(1L); - } - - /** - * Equivalent to {@code add(-1)}. - */ - public void decrement() { - add(-1L); - } - - /** - * Returns the current sum. The returned value is NOT an - * atomic snapshot: Invocation in the absence of concurrent - * updates returns an accurate result, but concurrent updates that - * occur while the sum is being calculated might not be - * incorporated. - * - * @return the sum - */ - public long sum() { - long sum = base; - Cell[] as = cells; - if (as != null) { - int n = as.length; - for (int i = 0; i < n; ++i) { - Cell a = as[i]; - if (a != null) - sum += a.value; - } - } - return sum; - } - - /** - * Resets variables maintaining the sum to zero. This method may - * be a useful alternative to creating a new adder, but is only - * effective if there are no concurrent updates. Because this - * method is intrinsically racy, it should only be used when it is - * known that no threads are concurrently updating. - */ - public void reset() { - internalReset(0L); - } - - /** - * Equivalent in effect to {@link #sum} followed by {@link - * #reset}. This method may apply for example during quiescent - * points between multithreaded computations. If there are - * updates concurrent with this method, the returned value is - * not guaranteed to be the final value occurring before - * the reset. - * - * @return the sum - */ - public long sumThenReset() { - long sum = base; - Cell[] as = cells; - BASE_UPDATER.set(this, 0); - if (as != null) { - int n = as.length; - for (int i = 0; i < n; ++i) { - Cell a = as[i]; - if (a != null) { - sum += a.value; - a.value = 0L; - } - } - } - return sum; - } - - /** - * Returns the String representation of the {@link #sum}. - * @return the String representation of the {@link #sum} - */ - public String toString() { - return Long.toString(sum()); - } - - /** - * Equivalent to {@link #sum}. - * - * @return the sum - */ - public long longValue() { - return sum(); - } - - /** - * Returns the {@link #sum} as an {@code int} after a narrowing - * primitive conversion. - */ - public int intValue() { - return (int)sum(); - } - - /** - * Returns the {@link #sum} as a {@code float} - * after a widening primitive conversion. - */ - public float floatValue() { - return (float)sum(); - } - - /** - * Returns the {@link #sum} as a {@code double} after a widening - * primitive conversion. - */ - public double doubleValue() { - return (double)sum(); - } - - private void writeObject(java.io.ObjectOutputStream s) - throws java.io.IOException { - s.defaultWriteObject(); - s.writeLong(sum()); - } - - private void readObject(ObjectInputStream s) - throws IOException, ClassNotFoundException { - s.defaultReadObject(); - BUSY_UPDATER.set(this, 0); - cells = null; - BASE_UPDATER.set(this, s.readLong()); - } - -} Index: rctags/ehcache-2.10.8.0.7/distribution/events/src/assemble/bin/start-db.bat =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/distribution/events/src/assemble/bin/start-db.bat (revision 11085) +++ rctags/ehcache-2.10.8.0.7/distribution/events/src/assemble/bin/start-db.bat (revision 0) @@ -1,19 +0,0 @@ -@echo off - -if not defined JAVA_HOME ( - echo JAVA_HOME is not defined - exit /b 1 -) - -setlocal - -set JAVA_HOME="%JAVA_HOME:"=%" -set root=%~d0%~p0.. -set root="%root:"=%" - -cd %root% -set h2_jar=%root%\src\main\webapp\WEB-INF\lib\h2-1.1.116.jar - -start /b "H2" %JAVA_HOME%\bin\java -cp %h2_jar% org.h2.tools.Server -tcp -tcpAllowOthers - -endlocal Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/StatisticsTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/StatisticsTest.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/StatisticsTest.java (revision 0) @@ -1,165 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.sf.ehcache; - -import java.util.concurrent.ExecutionException; -import net.sf.ehcache.statistics.FlatStatistics; -import net.sf.ehcache.statistics.StatisticsGateway; -import net.sf.ehcache.statistics.extended.ExtendedStatistics.Statistic; -import net.sf.ehcache.store.disk.DiskStoreHelper; - -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import static org.junit.Assert.fail; -import static org.hamcrest.core.Is.*; -import static org.hamcrest.core.IsNot.*; -import static org.hamcrest.core.IsNull.*; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; - -/** - * Tests for the statistics class - * - * @author Greg Luck - * @version $Id: StatisticsTest.java 7422 2013-04-26 13:01:29Z cdennis $ - */ -public class StatisticsTest extends AbstractCacheTest { - - private static final Logger LOG = LoggerFactory.getLogger(StatisticsTest.class.getName()); - - /** - * Test statistics directly from Statistics Object - */ - @Test - public void testStatisticsFromStatisticsObject() throws InterruptedException, ExecutionException { - // Set size so the second element overflows to disk. - Cache cache = new Cache("test", 1, true, false, 5, 2); - cache.getCacheConfiguration().setMaxEntriesLocalDisk(2); - manager.addCache(cache); - - cache.put(new Element("key1", "value1")); - cache.put(new Element("key2", "value1")); - - // allow disk write thread to complete - DiskStoreHelper.flushAllEntriesToDisk(cache).get(); - - cache.get("key1"); - cache.get("key2"); - - FlatStatistics statistics = cache.getStatistics(); - assertEquals(2, statistics.cacheHitCount()); - assertEquals(1, statistics.localDiskHitCount()); - assertEquals(1, statistics.localHeapHitCount()); - assertEquals(0, statistics.cacheMissCount()); - assertEquals(2, statistics.getSize()); - assertEquals(1, statistics.getLocalHeapSize()); - assertEquals(2, statistics.getLocalDiskSize()); - - // key 2 should now be in the MemoryStore - cache.get("key2"); - - assertEquals(3, statistics.cacheHitCount()); - assertEquals(1, statistics.localDiskHitCount()); - assertEquals(2, statistics.localHeapHitCount()); - assertEquals(0, statistics.cacheMissCount()); - - // Let the idle expire - Thread.sleep(6000); - - // key 1 should now be expired - assertThat(cache.get("key1"), nullValue()); - assertEquals(3, statistics.cacheHitCount()); - assertEquals(2, statistics.localDiskHitCount()); - assertEquals(2, statistics.localHeapHitCount()); - assertEquals(1, statistics.cacheMissCount()); - - // key 2 should also be expired - assertThat(cache.get("key2"), nullValue()); - assertEquals(3, statistics.cacheHitCount()); - assertEquals(2, statistics.localDiskHitCount()); - assertEquals(2, statistics.localHeapHitCount()); - assertEquals(2, statistics.cacheMissCount()); - - assertNotNull(statistics.toString()); - } - - /** - * CacheStatistics should always be sensible when the cache has not started. - */ - @Test - public void testCacheStatisticsDegradesElegantlyWhenCacheDisposed() { - Cache cache = new Cache("test", 1, true, false, 5, 2); - try { - cache.getStatistics(); - fail(); - } catch (IllegalStateException e) { - assertEquals("The test Cache is not alive (STATUS_UNINITIALISED)", e.getMessage()); - } - - } - - /** - * Tests average get time - */ - @Test - public void testAverageGetTime() { - Ehcache cache = new Cache("test", 0, true, false, 5, 2); - manager.addCache(cache); - - StatisticsGateway statistics = cache.getStatistics(); - Statistic averageGetTime = statistics.cacheGetOperation().latency().average(); - assertThat(averageGetTime.value(), is(Double.NaN)); - - for (int i = 0; i < 10000; i++) { - cache.put(new Element(Integer.valueOf(i), "value1")); - } - cache.put(new Element("key1", "value1")); - cache.put(new Element("key2", "value1")); - for (int i = 0; i < 110000; i++) { - cache.get(Integer.valueOf(i)); - } - - assertThat(averageGetTime.value(), not(Double.NaN)); - } - - /** - * Tests eviction statistics - */ - @Test - public void testEvictionStatistics() throws InterruptedException { - // set to 0 to make it run slow - Ehcache ehcache = new net.sf.ehcache.Cache("test", 10, false, false, 2, 2); - manager.addCache(ehcache); - - StatisticsGateway statistics = ehcache.getStatistics(); - assertEquals(0, statistics.cacheEvictedCount()); - - for (int i = 0; i < 10000; i++) { - ehcache.put(new Element("" + i, "value1")); - } - assertEquals(9990, statistics.cacheEvictedCount()); - - Thread.sleep(2010); - - // expiries do not count - assertEquals(9990, statistics.cacheEvictedCount()); - } -} Index: rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/com/otherclassloader/Client.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/com/otherclassloader/Client.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/com/otherclassloader/Client.java (revision 0) @@ -1,94 +0,0 @@ -/* - * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved. - */ -package com.otherclassloader; - -import net.sf.ehcache.CacheException; -import net.sf.ehcache.CacheManager; -import net.sf.ehcache.Ehcache; -import net.sf.ehcache.Element; -import net.sf.ehcache.event.CacheEventListener; -import net.sf.ehcache.event.NotificationScope; - -import java.io.ByteArrayInputStream; -import java.util.concurrent.CyclicBarrier; -import java.util.concurrent.atomic.AtomicInteger; - -public class Client implements Runnable, CacheEventListener { - - private final AtomicInteger putEvents = new AtomicInteger(); - private final String config; - private final CyclicBarrier barrier; - - public Client(String config, CyclicBarrier barrier) { - this.config = config; - this.barrier = barrier; - } - - public void run() { - try { - run0(); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - private void run0() throws Exception { - CacheManager cm = CacheManager.create(new ByteArrayInputStream(config.getBytes())); - - cm.getCache("test").getCacheEventNotificationService().registerListener(this, NotificationScope.ALL); - - barrier.await(); - - long end = System.currentTimeMillis() + 60000L; - while (System.currentTimeMillis() < end) { - int puts = putEvents.get(); - System.err.println("puts: " + puts); - if (puts == 1) { return; } - if (puts > 1) { throw new AssertionError(puts); } - Thread.sleep(500); - } - - throw new AssertionError("never saw event"); - } - - public void notifyElementRemoved(Ehcache cache, Element element) throws CacheException { - // - } - - public void notifyElementPut(Ehcache cache, Element element) throws CacheException { - System.err.println("TCCL: " + Thread.currentThread().getContextClassLoader()); - System.err.println("put(" + element.getValue() + ") with loader " + element.getValue().getClass().getClassLoader()); - - if (element.getValue().getClass().getClassLoader() != getClass().getClassLoader()) { throw new AssertionError(); } - - // do this after the assertions (so test will fail) - putEvents.incrementAndGet(); - } - - public void notifyElementUpdated(Ehcache cache, Element element) throws CacheException { - // - } - - public void notifyElementExpired(Ehcache cache, Element element) { - // - } - - public void notifyElementEvicted(Ehcache cache, Element element) { - // - } - - public void notifyRemoveAll(Ehcache cache) { - // - } - - public void dispose() { - // - } - - @Override - public Object clone() throws CloneNotSupportedException { - throw new CloneNotSupportedException(); - } - -} Index: rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/ehcache/tests/ThreadLocalTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/ehcache/tests/ThreadLocalTest.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/ehcache/tests/ThreadLocalTest.java (revision 0) @@ -1,186 +0,0 @@ -/* - * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved. - */ -package org.terracotta.ehcache.tests; - -import static org.objectweb.asm.Opcodes.ACC_PRIVATE; -import static org.objectweb.asm.Opcodes.ACC_PUBLIC; -import static org.objectweb.asm.Opcodes.ACC_SUPER; -import static org.objectweb.asm.Opcodes.ALOAD; -import static org.objectweb.asm.Opcodes.GETFIELD; -import static org.objectweb.asm.Opcodes.ILOAD; -import static org.objectweb.asm.Opcodes.INVOKESPECIAL; -import static org.objectweb.asm.Opcodes.IRETURN; -import static org.objectweb.asm.Opcodes.PUTFIELD; -import static org.objectweb.asm.Opcodes.RETURN; -import static org.objectweb.asm.Opcodes.V1_5; -import net.sf.ehcache.util.lang.VicariousThreadLocal; - -import org.objectweb.asm.ClassWriter; -import org.objectweb.asm.FieldVisitor; -import org.objectweb.asm.Label; -import org.objectweb.asm.MethodVisitor; - -import java.lang.ref.WeakReference; -import java.net.URL; -import java.net.URLClassLoader; -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.atomic.AtomicReference; - -import junit.framework.Assert; -import junit.framework.TestCase; - -public class ThreadLocalTest extends TestCase { - - public void test() throws Throwable { - // Construct Value instances from a foreign classloader - ClassLoader otherClassLoader = createClassLoader(); - - final AtomicReference> ref = new AtomicReference>(); - ref.set((Class) otherClassLoader.loadClass("org.terracotta.ehcache.tests.Value")); - - VicariousThreadLocal threadLocal = new VicariousThreadLocal() { - - @Override - protected Valueable initialValue() { - try { - Valueable v = ref.get().newInstance(); - v.setValue(5); - return v; - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - }; - int value = threadLocal.get().value(); - Assert.assertEquals(5, value); - - System.out.println("classloader: " + threadLocal.get().getClass().getClassLoader()); - Assert.assertTrue(otherClassLoader == threadLocal.get().getClass().getClassLoader()); - - WeakReference weakLoader = new WeakReference(threadLocal.get().getClass() - .getClassLoader()); - - System.out.println("Weak loader: " + weakLoader.get()); - - // release all references to the classloader for gc - otherClassLoader = null; - ref.set(null); - threadLocal = null; - int count = 0; - while (true) { - new PermStress().stress(10000); - for (int i = 0; i < 10; i++) { - System.gc(); - } - // System.out.println("threadLocal.get(): " + threadLocal); - System.out.println("Weak loader: " + weakLoader.get()); - if (weakLoader.get() == null) { - break; - } - Thread.sleep(1000); - if (++count >= 60) { throw new AssertionError("Class loader leak"); } - } - } - - protected ClassLoader createClassLoader() { - try { - byte[] valueBytes = createValueClass(); - - Map classes = new HashMap(); - classes.put("org.terracotta.ehcache.tests.Value", valueBytes); - - return new ByteClassLoader(new URL[] {}, getClass().getClassLoader(), classes); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - protected byte[] createValueClass() throws Exception { - ClassWriter cw = new ClassWriter(0); - FieldVisitor fv; - MethodVisitor mv; - - cw.visit(V1_5, ACC_PUBLIC + ACC_SUPER, "org/terracotta/ehcache/tests/Value", null, "java/lang/Object", - new String[] { "org/terracotta/ehcache/tests/Valueable" }); - - cw.visitSource("Value.java", null); - - fv = cw.visitField(ACC_PRIVATE, "v", "I", null, null); - fv.visitEnd(); - { - mv = cw.visitMethod(ACC_PUBLIC, "", "()V", null, null); - mv.visitCode(); - Label l0 = new Label(); - mv.visitLabel(l0); - mv.visitLineNumber(9, l0); - mv.visitVarInsn(ALOAD, 0); - mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "", "()V"); - Label l1 = new Label(); - mv.visitLabel(l1); - mv.visitLineNumber(11, l1); - mv.visitInsn(RETURN); - Label l2 = new Label(); - mv.visitLabel(l2); - mv.visitLocalVariable("this", "Lorg/terracotta/ehcache/tests/Value;", null, l0, l2, 0); - mv.visitMaxs(1, 1); - mv.visitEnd(); - } - { - mv = cw.visitMethod(ACC_PUBLIC, "value", "()I", null, null); - mv.visitCode(); - Label l0 = new Label(); - mv.visitLabel(l0); - mv.visitLineNumber(18, l0); - mv.visitVarInsn(ALOAD, 0); - mv.visitFieldInsn(GETFIELD, "org/terracotta/ehcache/tests/Value", "v", "I"); - mv.visitInsn(IRETURN); - Label l1 = new Label(); - mv.visitLabel(l1); - mv.visitLocalVariable("this", "Lorg/terracotta/ehcache/tests/Value;", null, l0, l1, 0); - mv.visitMaxs(1, 1); - mv.visitEnd(); - } - { - mv = cw.visitMethod(ACC_PUBLIC, "setValue", "(I)V", null, null); - mv.visitCode(); - Label l0 = new Label(); - mv.visitLabel(l0); - mv.visitLineNumber(22, l0); - mv.visitVarInsn(ALOAD, 0); - mv.visitVarInsn(ILOAD, 1); - mv.visitFieldInsn(PUTFIELD, "org/terracotta/ehcache/tests/Value", "v", "I"); - Label l1 = new Label(); - mv.visitLabel(l1); - mv.visitLineNumber(23, l1); - mv.visitInsn(RETURN); - Label l2 = new Label(); - mv.visitLabel(l2); - mv.visitLocalVariable("this", "Lorg/terracotta/ehcache/tests/Value;", null, l0, l2, 0); - mv.visitLocalVariable("v", "I", null, l0, l2, 1); - mv.visitMaxs(2, 2); - mv.visitEnd(); - } - cw.visitEnd(); - - return cw.toByteArray(); - } - - public static class ByteClassLoader extends URLClassLoader { - private final Map extraClassDefs; - - public ByteClassLoader(URL[] urls, ClassLoader parent, Map extraClassDefs) { - super(urls, parent); - this.extraClassDefs = new HashMap(extraClassDefs); - } - - @Override - protected Class findClass(final String name) throws ClassNotFoundException { - byte[] classBytes = this.extraClassDefs.remove(name); - if (classBytes != null) { return defineClass(name, classBytes, 0, classBytes.length); } - return super.findClass(name); - } - } -} Index: rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/net/sf/ehcache/osgi/TestScheduledRefreshFactory.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/net/sf/ehcache/osgi/TestScheduledRefreshFactory.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/net/sf/ehcache/osgi/TestScheduledRefreshFactory.java (revision 0) @@ -1,21 +0,0 @@ -/* - * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved. - */ -package net.sf.ehcache.osgi; - -import net.sf.ehcache.Ehcache; -import net.sf.ehcache.constructs.scheduledrefresh.ScheduledRefreshCacheExtension; -import net.sf.ehcache.constructs.scheduledrefresh.ScheduledRefreshConfiguration; -import net.sf.ehcache.extension.CacheExtension; -import net.sf.ehcache.extension.CacheExtensionFactory; - -import java.util.Properties; - -public class TestScheduledRefreshFactory extends CacheExtensionFactory { - - @Override - public CacheExtension createCacheExtension(Ehcache cache, Properties properties) { - ScheduledRefreshConfiguration conf = new ScheduledRefreshConfiguration().fromProperties(properties).build(); - return new ScheduledRefreshCacheExtension(conf, cache); - } -} Index: rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/ehcache/tests/ClusterCacheEventsRejoinEnabledTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/ehcache/tests/ClusterCacheEventsRejoinEnabledTest.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/ehcache/tests/ClusterCacheEventsRejoinEnabledTest.java (revision 0) @@ -1,15 +0,0 @@ -package org.terracotta.ehcache.tests; - -import com.tc.test.config.model.TestConfig; - -/** - * @author Alex Snaps - */ -public class ClusterCacheEventsRejoinEnabledTest extends AbstractCacheTestBase { - - public ClusterCacheEventsRejoinEnabledTest(TestConfig testConfig) { - super("basic-rejoin-cache-test.xml", testConfig, ClusterCacheEventsRejoinEnabledClient.class, - ClusterCacheEventsRejoinEnabledClient.class); - } - -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/writer/CacheWriter.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/writer/CacheWriter.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/writer/CacheWriter.java (revision 0) @@ -1,152 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package net.sf.ehcache.writer; - -import net.sf.ehcache.CacheEntry; -import net.sf.ehcache.CacheException; -import net.sf.ehcache.Ehcache; -import net.sf.ehcache.Element; -import net.sf.ehcache.writer.writebehind.operations.SingleOperationType; - -import java.util.Collection; - -/** - * A CacheWriter is an interface used for write-through and write-behind caching to a underlying resource. - *

- * If configured for a cache, CacheWriter's methods will be called on a cache operation. A cache put will cause a CacheWriter write - * and a cache remove will cause a writer delete. - *

- * Implementers should create an implementation which handles storing and deleting to an underlying resource. - *

- *

Write-Through

- * In write-through mode, the cache operation will occur and the writer operation will occur before CacheEventListeners are notified. If - * the write operation fails an exception will be thrown. This can result in a cache which is inconsistent with the underlying resource. - * To avoid this, the cache and the underlying resource should be configured to participate in a transaction. In the event of a failure - * a rollback can return all components to a consistent state. - *

- *

Write-Behind

- * In write-behind mode, writes are written to a write-behind queue. They are written by a separate execution thread in a configurable - * way. When used with Terracotta Server Array, the queue is highly available. In addition any node in the cluster may perform the - * write-behind operations. - *

- * It's important to note that the operations that are handled by the {@code CacheWriter} don't have any guaranteed ordering in write-behind mode. - * The processing ordering can be different than the scheduling ordering, so your application needs to be written with this - * in mind. More information in the CacheWriter chapter of the documentation. - *

- *

Creation and Configuration

- * CacheWriters can be created using the CacheWriterFactory or explicitly by instantiating them through Java code, giving - * you access to local resources. - *

- * The manner upon which a CacheWriter is actually called is determined by the {@link net.sf.ehcache.config.CacheWriterConfiguration} that is set up for cache - * that is using the CacheWriter. - *

- * See the CacheWriter chapter in the documentation for more information on how to use writers. - * - * @author Greg Luck - * @author Geert Bevin - * @version $Id: CacheWriter.java 10789 2018-04-26 02:08:13Z adahanne $ - */ -public interface CacheWriter { - - /** - * Creates a clone of this writer. This method will only be called by ehcache before a - * cache is initialized. - *

- * Implementations should throw CloneNotSupportedException if they do not support clone - * but that will stop them from being used with defaultCache. - * - * @return a clone - * @throws CloneNotSupportedException if the extension could not be cloned. - */ - public CacheWriter clone(Ehcache cache) throws CloneNotSupportedException; - - - /** - * Notifies writer to initialise themselves. - *

- * This method is called during the Cache's initialise method after it has changed it's - * status to alive. Cache operations are legal in this method. If you register a cache writer - * manually after a cache has been initialised already, this method will be called on the - * cache writer as soon as it has been registered. - *

- * Note that if you reuse cache writer instances or create a factory that returns the - * same cache writer instance as a singleton, your init method should be able - * to handle that situation. Unless you perform this multiple usage of a cache writer yourself, - * Ehcache will not do this though. So in the majority of the use cases, you don't need to do - * anything special. - * - * @throws net.sf.ehcache.CacheException - */ - void init(); - - /** - * Providers may be doing all sorts of exotic things and need to be able to clean up on - * dispose. - *

- * Cache operations are illegal when this method is called. The cache itself is partly - * disposed when this method is called. - */ - void dispose() throws CacheException; - - /** - * Write the specified value under the specified key to the underlying store. - * This method is intended to support both key/value creation and value update for a specific key. - * - * @param element the element to be written - */ - void write(Element element) throws CacheException; - - /** - * Write the specified Elements to the underlying store. This method is intended to support both insert and update. - * If this operation fails (by throwing an exception) after a partial success, - * the convention is that entries which have been written successfully are to be removed from the specified mapEntries, - * indicating that the write operation for the entries left in the map has failed or has not been attempted. - * - * @param elements the Elements to be written - */ - void writeAll(Collection elements) throws CacheException; - - - /** - * Delete the cache entry from the store - * - * @param entry the cache entry that is used for the delete operation - */ - void delete(CacheEntry entry) throws CacheException; - - - /** - * Remove data and keys from the underlying store for the given collection of keys, if present. If this operation fails - * (by throwing an exception) after a partial success, the convention is that keys which have been erased successfully - * are to be removed from the specified keys, indicating that the erase operation for the keys left in the collection - * has failed or has not been attempted. - * - * @param entries the entries that have been removed from the cache - */ - void deleteAll(Collection entries) throws CacheException; - - /** - * This method will be called, whenever an Element couldn't be handled by the writer and all - * the {@link net.sf.ehcache.config.CacheWriterConfiguration#getRetryAttempts() retryAttempts} have been tried. - *

When batching is enabled all the elements in the failing batch will be passed to this methods - *

Try to not throw RuntimeExceptions from this method. Should an Exception occur, it will be logged, but - * the element will be lost anyways. - * @param element the Element that triggered the failure, or one of the elements part of the batch that failed - * @param operationType the operation we tried to execute - * @param e the RuntimeException thrown by the Writer when the last retry attempt was being executed - */ - void throwAway(Element element, SingleOperationType operationType, RuntimeException e); -} Index: rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/ehcache/tests/container/hibernate/nontransactional/QueryCacheInvalidationServlet.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/ehcache/tests/container/hibernate/nontransactional/QueryCacheInvalidationServlet.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/ehcache/tests/container/hibernate/nontransactional/QueryCacheInvalidationServlet.java (revision 0) @@ -1,69 +0,0 @@ -/* - * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved. - */ -package org.terracotta.ehcache.tests.container.hibernate.nontransactional; - -import org.hibernate.Session; -import org.hibernate.Transaction; -import org.hibernate.stat.SecondLevelCacheStatistics; -import org.hibernate.stat.Statistics; -import org.junit.Assert; -import org.terracotta.ehcache.tests.container.hibernate.BaseClusteredRegionFactoryTestServlet; -import org.terracotta.ehcache.tests.container.hibernate.domain.Item; - -import java.util.Map; - -import javax.servlet.http.HttpSession; - -public class QueryCacheInvalidationServlet extends BaseClusteredRegionFactoryTestServlet { - - @Override - protected void doServer0(HttpSession session, Map parameters) throws Exception { - HibernateUtil.dropAndCreateDatabaseSchema(); - - Statistics stats = HibernateUtil.getSessionFactory().getStatistics(); - stats.setStatisticsEnabled(true); - - Session s = HibernateUtil.getSessionFactory().openSession(); - Transaction t = s.beginTransaction(); - Item i = new Item(); - i.setName("widget"); - i.setDescription("A really top-quality, full-featured widget."); - s.persist(i); - t.commit(); - s.close(); - - final SecondLevelCacheStatistics statistics = stats.getSecondLevelCacheStatistics(Item.class.getName()); - Assert.assertEquals(1, statistics.getPutCount()); - Assert.assertEquals(1, statistics.getElementCountInMemory()); - } - - @Override - protected void doServer1(HttpSession session, Map parameters) throws Exception { - Statistics stats = HibernateUtil.getSessionFactory().getStatistics(); - stats.setStatisticsEnabled(true); - - Session s = HibernateUtil.getSessionFactory().openSession(); - Transaction t = s.beginTransaction(); - Item i = (Item) s.get(Item.class, Long.valueOf(1L)); - - SecondLevelCacheStatistics slcs = stats.getSecondLevelCacheStatistics(Item.class.getName()); - - Assert.assertEquals(1, slcs.getHitCount()); - Assert.assertEquals(0, slcs.getMissCount()); - - i.setDescription("A bog standard item"); - - t.commit(); - s.close(); - - Assert.assertEquals(1, slcs.getPutCount()); - - // cleanup - s = HibernateUtil.getSessionFactory().openSession(); - t = s.beginTransaction(); - s.delete(i); - t.commit(); - s.close(); - } -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/distribution/CacheManagerPeerProvider.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/distribution/CacheManagerPeerProvider.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/distribution/CacheManagerPeerProvider.java (revision 0) @@ -1,80 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.sf.ehcache.distribution; - -import net.sf.ehcache.CacheException; -import net.sf.ehcache.Ehcache; - -import java.util.List; - -/** - * Provides a discovery service to locate {@link CachePeer} listener peers for a Cache. - * @author Greg Luck - * @version $Id: CacheManagerPeerProvider.java 10789 2018-04-26 02:08:13Z adahanne $ - */ -public interface CacheManagerPeerProvider { - - /** - * Register a new peer. - * @param nodeId Identifies a node in this replication scheme (ex: RMI URL) - */ - void registerPeer(String nodeId); - - /** - * Unregisters a peer. - * - * @param nodeId Identifies a node in this replication scheme (ex: RMI URL) - */ - void unregisterPeer(String nodeId); - - /** - * @return a list of {@link CachePeer} peers for the given cache, excluding the local peer. - */ - List listRemoteCachePeers(Ehcache cache) throws CacheException; - - /** - * Notifies providers to initialise themselves. - * @throws CacheException - */ - void init(); - - - /** - * Providers may be doing all sorts of exotic things and need to be able to clean up on dispose. - * @throws CacheException - */ - void dispose() throws CacheException; - - /** - * Time for a cluster to form. This varies considerably, depending on the implementation. - * @return the time in ms, for a cluster to form - */ - long getTimeForClusterToForm(); - - - /** - * The replication scheme. Each peer provider has a scheme name, which can be used to specify - * the scheme for replication and bootstrap purposes. Each CacheReplicator should lookup - * the provider for its scheme type during replication. Similarly a BootstrapCacheLoader - * should also look up the provider for its scheme. - *

- * @since 1.6 introduced to permit multiple distribution schemes to be used in the same CacheManager - * @return the well-known scheme name, which is determined by the replication provider author. - */ - String getScheme(); - -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/config/ehcache-terracotta.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/config/ehcache-terracotta.xml (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/config/ehcache-terracotta.xml (revision 0) @@ -1,823 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/constructs/nonstop/util/package.html =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/constructs/nonstop/util/package.html (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/constructs/nonstop/util/package.html (revision 0) @@ -1,10 +0,0 @@ - - - - -

Ehcache-nonstopcache utility package

- -This package contains utility classes for NonStopCache features - - - Index: rctags/ehcache-2.10.8.0.7/distribution/colorcache/src/assemble/jetty6.1/9082/logs/.placeholder =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/distribution/colorcache/src/assemble/jetty6.1/9082/logs/.placeholder (revision 11085) +++ rctags/ehcache-2.10.8.0.7/distribution/colorcache/src/assemble/jetty6.1/9082/logs/.placeholder (revision 0) @@ -1 +0,0 @@ \ No newline at end of file Index: rctags/ehcache-2.10.8.0.7/distribution/colorcache/src/assemble/jetty6.1/9081/logs/.placeholder =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/distribution/colorcache/src/assemble/jetty6.1/9081/logs/.placeholder (revision 11085) +++ rctags/ehcache-2.10.8.0.7/distribution/colorcache/src/assemble/jetty6.1/9081/logs/.placeholder (revision 0) @@ -1 +0,0 @@ \ No newline at end of file Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/management/Store.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/management/Store.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/management/Store.java (revision 0) @@ -1,131 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.sf.ehcache.management; - -import java.io.Serializable; -import javax.management.Attribute; -import javax.management.AttributeList; -import javax.management.AttributeNotFoundException; -import javax.management.DynamicMBean; -import javax.management.InvalidAttributeValueException; -import javax.management.MBeanException; -import javax.management.MBeanInfo; -import javax.management.MalformedObjectNameException; -import javax.management.NotCompliantMBeanException; -import javax.management.ObjectName; -import javax.management.ReflectionException; -import javax.management.StandardMBean; -import net.sf.ehcache.CacheException; -import net.sf.ehcache.Ehcache; -import net.sf.ehcache.hibernate.management.impl.EhcacheHibernateMbeanNames; - -/** - * Wrapper class for store specific dynamic mbeans. - * - * @author Chris Dennis - */ -public final class Store implements Serializable, DynamicMBean { - - private static final long serialVersionUID = 3477287016924524437L; - - private final ObjectName objectName; - private final DynamicMBean storeBean; - - private Store(Ehcache ehcache, Object storeBean) throws NotCompliantMBeanException { - this.objectName = createObjectName(ehcache.getCacheManager().getName(), ehcache.getName()); - if (storeBean instanceof DynamicMBean) { - this.storeBean = (DynamicMBean) storeBean; - } else { - this.storeBean = new StandardMBean(storeBean, null); - } - } - - /** - * Get the optional store management bean for the given cache. - */ - static Store getBean(Ehcache cache) throws NotCompliantMBeanException { - if (cache instanceof net.sf.ehcache.Cache) { - Object bean = ((net.sf.ehcache.Cache) cache).getStoreMBean(); - if (bean != null) { - return new Store(cache, bean); - } - } - return null; - } - - /** - * Creates an object name using the scheme "net.sf.ehcache:type=Store,CacheManager=,name=" - */ - static ObjectName createObjectName(String cacheManagerName, String cacheName) { - try { - return new ObjectName("net.sf.ehcache:type=Store,CacheManager=" + cacheManagerName + ",name=" - + EhcacheHibernateMbeanNames.mbeanSafe(cacheName)); - } catch (MalformedObjectNameException e) { - throw new CacheException(e); - } - } - - /** - * @return the object name for this MBean - */ - public ObjectName getObjectName() { - return objectName; - } - - /** - * {@inheritDoc} - */ - public Object getAttribute(String attribute) throws AttributeNotFoundException, MBeanException, ReflectionException { - return storeBean.getAttribute(attribute); - } - - /** - * {@inheritDoc} - */ - public void setAttribute(Attribute attribute) throws AttributeNotFoundException, InvalidAttributeValueException, - MBeanException, ReflectionException { - storeBean.setAttribute(attribute); - } - - /** - * {@inheritDoc} - */ - public AttributeList getAttributes(String[] attributes) { - return storeBean.getAttributes(attributes); - } - - /** - * {@inheritDoc} - */ - public AttributeList setAttributes(AttributeList attributes) { - return storeBean.setAttributes(attributes); - } - - /** - * {@inheritDoc} - */ - public Object invoke(String actionName, Object[] params, String[] signature) throws MBeanException, ReflectionException { - return storeBean.invoke(actionName, params, signature); - } - - /** - * {@inheritDoc} - */ - public MBeanInfo getMBeanInfo() { - return storeBean.getMBeanInfo(); - } -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/checkstyle/checkstyle.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/checkstyle/checkstyle.xml (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/checkstyle/checkstyle.xml (revision 0) @@ -1,209 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Index: rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/ehcache/tests/CopyOnWriteClient.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/ehcache/tests/CopyOnWriteClient.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/ehcache/tests/CopyOnWriteClient.java (revision 0) @@ -1,30 +0,0 @@ -package org.terracotta.ehcache.tests; - -import net.sf.ehcache.Cache; -import net.sf.ehcache.Element; - -import org.terracotta.toolkit.Toolkit; - -import java.io.Serializable; - -public class CopyOnWriteClient extends ClientBase { - - public CopyOnWriteClient(String[] args) { - super("test", args); - } - - @Override - protected void runTest(Cache cache, Toolkit toolkit) throws Throwable { - final Foo foo = new Foo(); - Element e = new Element("foo", foo); - cache.put(e); - Object o = cache.get("foo").getObjectValue(); - - if (o == foo) { throw new AssertionError(); } - } - - private static class Foo implements Serializable { - // - } - -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/transaction/manager/selector/ClassSelector.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/transaction/manager/selector/ClassSelector.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/transaction/manager/selector/ClassSelector.java (revision 0) @@ -1,63 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package net.sf.ehcache.transaction.manager.selector; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.transaction.TransactionManager; - -/** - * Abstract selector for instanciating a class - * - * @author Ludovic Orban - */ -public abstract class ClassSelector extends Selector { - private static final Logger LOG = LoggerFactory.getLogger(ClassSelector.class); - - private final String classname; - - /** - * Constructor - * - * @param vendor the transaction manager vendor name - * @param classname the name of the class to instanciate - */ - public ClassSelector(String vendor, String classname) { - super(vendor); - this.classname = classname; - } - - /** - * {@inheritDoc} - */ - @Override - protected TransactionManager doLookup() { - TransactionManager transactionManager = null; - - try { - Class txManagerClass = Class.forName(classname); - transactionManager = (TransactionManager) txManagerClass.newInstance(); - } catch (ClassNotFoundException e) { - LOG.debug("FactorySelector failed lookup", e); - } catch (InstantiationException e) { - LOG.debug("FactorySelector failed lookup", e); - } catch (IllegalAccessException e) { - LOG.debug("FactorySelector failed lookup", e); - } - return transactionManager; - } -} \ No newline at end of file Index: rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/ehcache/tests/txns/SimpleTx1.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/ehcache/tests/txns/SimpleTx1.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/ehcache/tests/txns/SimpleTx1.java (revision 0) @@ -1,161 +0,0 @@ -/* - * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved. - */ -package org.terracotta.ehcache.tests.txns; - -import net.sf.ehcache.Cache; -import net.sf.ehcache.Element; -import net.sf.ehcache.transaction.manager.DefaultTransactionManagerLookup; -import net.sf.ehcache.transaction.manager.TransactionManagerLookup; - -import org.junit.Assert; -import org.terracotta.toolkit.Toolkit; - -import java.io.Serializable; - -import javax.transaction.TransactionManager; - -public class SimpleTx1 extends AbstractTxClient { - - public SimpleTx1(String[] args) { - super(args); - - } - - @Override - protected void runTest(Cache cache, Toolkit toolkit) throws Throwable { - final TransactionManagerLookup lookup = new DefaultTransactionManagerLookup(); - final TransactionManager txnManager = lookup.getTransactionManager(); - int commitCount = 0; - int rollbackCount = 0; - System.out.println(txnManager); - - SomeClass instance = new SomeClass(1); - instance.someOtherInstance = new SomeClass(2); - - Assert.assertTrue(cache.getCacheConfiguration().isCopyOnRead()); - Assert.assertTrue(cache.getCacheConfiguration().isCopyOnWrite()); - - try { - txnManager.begin(); - cache.put(new Element("key1", "value1")); - - cache.put(new Element("someInstance", instance)); - - Element element = cache.get("key1"); - System.out.println("key1:" + element.getValue()); - System.out.println("size1: " + cache.getSize()); - Assert.assertTrue("Should NOT be the same instance", instance != cache.get("someInstance").getValue()); - txnManager.commit(); - commitCount++; - } catch (Exception e) { - e.printStackTrace(); - txnManager.rollback(); - rollbackCount++; - } - - instance.someValue = 3; - - try { - txnManager.begin(); - cache.put(new Element("key1", "value2")); - - Assert.assertTrue("Should NOT be the same instance", instance != cache.get("someInstance").getValue()); - Assert.assertTrue("Should NOT reflect the post commit change!", instance.someValue != ((SomeClass)cache.get("someInstance").getValue()).someValue); - - Element element = cache.get("key1"); - System.out.println("key1:" + element.getValue()); - if (!element.getValue().equals("value2")) { throw new AssertionError("put should be visible in same thread"); } - System.out.println("size1: " + cache.getSize()); - throw new Exception(); - } catch (AssertionError e) { - throw new AssertionError(e); - } catch (Exception e) { - txnManager.rollback(); - rollbackCount++; - } - - try { - txnManager.begin(); - - Element element = cache.get("key1"); - System.out.println("key1:" + element.getValue()); - if (!element.getValue().equals("value1")) { throw new AssertionError("should be old value"); } - System.out.println("size1: " + cache.getSize()); - - txnManager.commit(); - commitCount++; - } catch (AssertionError e) { - throw new AssertionError(e); - } catch (Exception e) { - e.printStackTrace(); - txnManager.rollback(); - rollbackCount++; - } - - if (commitCount != 2) { throw new AssertionError("expected 2 commits got: " + commitCount); } - - if (rollbackCount != 1) { throw new AssertionError("expected 1 rollback got: " + rollbackCount); } - - try { - txnManager.begin(); - - cache.put(new Element("remove1", "removeValue")); - System.out.println("size1: " + cache.getSize()); - - txnManager.commit(); - commitCount++; - } catch (AssertionError e) { - throw new AssertionError(e); - } catch (Exception e) { - txnManager.rollback(); - rollbackCount++; - } - - if (commitCount != 3) { throw new AssertionError("expected 3 commits got: " + commitCount); } - - if (rollbackCount != 1) { throw new AssertionError("expected 1 rollback got: " + rollbackCount); } - - try { - txnManager.begin(); - - int sizeBefore = cache.getSize(); - cache.remove("remove1"); - System.out.println("size1: " + cache.getSize()); - - int sizeAfter = cache.getSize(); - if (sizeAfter >= sizeBefore) { throw new AssertionError("remove should reduce the size, expected: " - + (sizeBefore - 1) + " got: " + sizeAfter); } - - Element removedElement = cache.get("remove1"); - if (removedElement != null) { throw new AssertionError("remove1 key should not exist!"); } - - txnManager.commit(); - commitCount++; - } catch (AssertionError e) { - throw new AssertionError(e); - } catch (Exception e) { - txnManager.rollback(); - rollbackCount++; - } - - if (commitCount != 4) { throw new AssertionError("expected 4 commits got: " + commitCount); } - - if (rollbackCount != 1) { throw new AssertionError("expected 1 rollback got: " + rollbackCount); } - getBarrierForAllClients().await(); - } - - public static void main(String[] args) { - new SimpleTx1(args).run(); - } - - public static final class SomeClass implements Serializable { - - public int someValue; - public SomeClass someOtherInstance; - - public SomeClass(final int someValue) { - this.someValue = someValue; - } - } -} Index: rctags/ehcache-2.10.8.0.7/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/store/nonstop/ExceptionOnTimeoutStore.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/store/nonstop/ExceptionOnTimeoutStore.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/store/nonstop/ExceptionOnTimeoutStore.java (revision 0) @@ -1,621 +0,0 @@ -/** - * Copyright Terracotta, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language governing permissions and limitations under the - * License. - */ - -package org.terracotta.modules.ehcache.store.nonstop; - -import net.sf.ehcache.CacheException; -import net.sf.ehcache.Element; -import net.sf.ehcache.Status; -import net.sf.ehcache.config.CacheConfiguration; -import net.sf.ehcache.constructs.nonstop.NonStopCacheException; -import net.sf.ehcache.search.Attribute; -import net.sf.ehcache.search.Results; -import net.sf.ehcache.search.attribute.AttributeExtractor; -import net.sf.ehcache.store.ElementValueComparator; -import net.sf.ehcache.store.Policy; -import net.sf.ehcache.store.StoreListener; -import net.sf.ehcache.store.StoreQuery; -import net.sf.ehcache.store.TerracottaStore; -import net.sf.ehcache.writer.CacheWriterManager; -import net.sf.ehcache.writer.writebehind.WriteBehind; - -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Set; - -/** - * Implementation of {@link TerracottaStore} that throws {@link NonStopCacheException} for all operations. - * - * @author Abhishek Sanoujam - */ -public final class ExceptionOnTimeoutStore implements TerracottaStore { - - /** - * the singleton instance - */ - private static final ExceptionOnTimeoutStore INSTANCE = new ExceptionOnTimeoutStore(); - - /** - * private constructor - */ - private ExceptionOnTimeoutStore() { - // - } - - /** - * returns the singleton instance - */ - public static ExceptionOnTimeoutStore getInstance() { - return INSTANCE; - } - - /** - * {@inheritDoc}. - *

- * Throws {@link NonStopCacheException} - */ - @Override - public Element get(final Object key) throws IllegalStateException, CacheException { - throw new NonStopCacheException("get timed out"); - } - - /** - * {@inheritDoc} - */ - @Override - public Element getQuiet(final Object key) throws IllegalStateException, CacheException { - throw new NonStopCacheException("getQuiet timed out"); - } - - /** - * {@inheritDoc} - *

- * Throws {@link NonStopCacheException} - */ - @Override - public Map getAllQuiet(Collection keys) { - throw new NonStopCacheException("getAllQuiet for '" + keys.size() + "' keys timed out"); - } - - /** - * {@inheritDoc} - *

- * Throws {@link NonStopCacheException} - */ - @Override - public Map getAll(Collection keys) { - throw new NonStopCacheException("getAll for '" + keys.size() + "' keys timed out"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link NonStopCacheException} - */ - @Override - public List getKeys() throws IllegalStateException, CacheException { - throw new NonStopCacheException("getKeys timed out"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link NonStopCacheException} - */ - @Override - public boolean put(final Element element) throws IllegalArgumentException, IllegalStateException, CacheException { - throw new NonStopCacheException("put timed out"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link NonStopCacheException} - */ - @Override - public void putAll(final Collection elements) throws CacheException { - throw new NonStopCacheException("putAll for " + elements.size() + " elements timed out"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link NonStopCacheException} - */ - @Override - public Element remove(final Object key) throws IllegalStateException { - throw new NonStopCacheException("remove timed out"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link NonStopCacheException} - */ - @Override - public void removeAll(final Collection keys) throws IllegalStateException { - throw new NonStopCacheException("removeAll for " + keys.size() + " keys timed out"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link NonStopCacheException} - */ - @Override - public void removeAll() throws IllegalStateException, CacheException { - throw new NonStopCacheException("removeAll timed out"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link NonStopCacheException} - */ - @Override - public void flush() throws IllegalStateException, CacheException { - throw new NonStopCacheException("flush timed out"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link NonStopCacheException} - */ - @Override - public Object getInternalContext() { - throw new NonStopCacheException("getInternalContext timed out"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link NonStopCacheException} - */ - @Override - public int getSize() throws IllegalStateException, CacheException { - throw new NonStopCacheException("getSize timed out"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link NonStopCacheException} - */ - @Override - public Element putIfAbsent(Element element) throws NullPointerException { - throw new NonStopCacheException("putIfAbsent timed out"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link NonStopCacheException} - */ - @Override - public Element replace(Element element) throws NullPointerException { - throw new NonStopCacheException("replace timed out"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link NonStopCacheException} - */ - @Override - public void addStoreListener(StoreListener listener) { - throw new NonStopCacheException("addStoreListener timed out"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link NonStopCacheException} - */ - @Override - public boolean bufferFull() { - throw new NonStopCacheException("bufferFull timed out"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link NonStopCacheException} - */ - @Override - public boolean containsKey(Object key) { - throw new NonStopCacheException("containsKey timed out"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link NonStopCacheException} - */ - @Override - public boolean containsKeyInMemory(Object key) { - throw new NonStopCacheException("containsKeyInMemory timed out"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link NonStopCacheException} - */ - @Override - public boolean containsKeyOffHeap(Object key) { - throw new NonStopCacheException("containsKeyOffHeap timed out"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link NonStopCacheException} - */ - @Override - public boolean containsKeyOnDisk(Object key) { - throw new NonStopCacheException("containsKeyOnDisk timed out"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link NonStopCacheException} - */ - @Override - public void dispose() { - throw new NonStopCacheException("dispose timed out"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link NonStopCacheException} - */ - @Override - public Results executeQuery(StoreQuery query) { - throw new NonStopCacheException("executeQuery timed out"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link NonStopCacheException} - */ - @Override - public void expireElements() { - throw new NonStopCacheException("expireElements timed out"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link NonStopCacheException} - */ - @Override - public Policy getInMemoryEvictionPolicy() { - throw new NonStopCacheException("getInMemoryEvictionPolicy timed out"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link NonStopCacheException} - */ - @Override - public int getInMemorySize() { - throw new NonStopCacheException("getInMemorySize timed out"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link NonStopCacheException} - */ - @Override - public long getInMemorySizeInBytes() { - throw new NonStopCacheException("getInMemorySizeInBytes timed out"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link NonStopCacheException} - */ - @Override - public Object getMBean() { - throw new NonStopCacheException("getMBean timed out"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link NonStopCacheException} - */ - @Override - public int getOffHeapSize() { - throw new NonStopCacheException("getOffHeapSize timed out"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link NonStopCacheException} - */ - @Override - public long getOffHeapSizeInBytes() { - throw new NonStopCacheException("getOffHeapSizeInBytes timed out"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link NonStopCacheException} - */ - @Override - public int getOnDiskSize() { - throw new NonStopCacheException("getOnDiskSize timed out"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link NonStopCacheException} - */ - @Override - public long getOnDiskSizeInBytes() { - throw new NonStopCacheException("getOnDiskSizeInBytes timed out"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link NonStopCacheException} - */ - @Override - public boolean hasAbortedSizeOf() { - throw new NonStopCacheException("hasAbortedSizeOf timed out"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link NonStopCacheException} - */ - @Override - public Status getStatus() { - throw new NonStopCacheException("getStatus timed out"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link NonStopCacheException} - */ - @Override - public int getTerracottaClusteredSize() { - throw new NonStopCacheException("getTerracottaClusteredSize timed out"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link NonStopCacheException} - */ - @Override - public boolean isCacheCoherent() { - throw new NonStopCacheException("isCacheCoherent timed out"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link NonStopCacheException} - */ - @Override - public boolean isClusterCoherent() { - throw new NonStopCacheException("isClusterCoherent timed out"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link NonStopCacheException} - */ - @Override - public boolean isNodeCoherent() { - throw new NonStopCacheException("isNodeCoherent timed out"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link NonStopCacheException} - */ - @Override - public boolean putWithWriter(Element element, CacheWriterManager writerManager) throws CacheException { - throw new NonStopCacheException("putWithWriter timed out"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link NonStopCacheException} - */ - @Override - public Element removeElement(Element element, ElementValueComparator comparator) throws NullPointerException { - throw new NonStopCacheException("removeElement timed out"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link NonStopCacheException} - */ - @Override - public void removeStoreListener(StoreListener listener) { - throw new NonStopCacheException("removeStoreListener timed out"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link NonStopCacheException} - */ - @Override - public Element removeWithWriter(Object key, CacheWriterManager writerManager) throws CacheException { - throw new NonStopCacheException("removeWithWriter timed out"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link NonStopCacheException} - */ - @Override - public boolean replace(Element old, Element element, ElementValueComparator comparator) throws NullPointerException, - IllegalArgumentException { - throw new NonStopCacheException("replace timed out"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link NonStopCacheException} - */ - @Override - public void setAttributeExtractors(Map extractors) { - throw new NonStopCacheException("setAttributeExtractors timed out"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link NonStopCacheException} - */ - @Override - public void setInMemoryEvictionPolicy(Policy policy) { - throw new NonStopCacheException("setInMemoryEvictionPolicy timed out"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link NonStopCacheException} - */ - @Override - public void setNodeCoherent(boolean coherent) throws UnsupportedOperationException { - throw new NonStopCacheException("setNodeCoherent timed out"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link NonStopCacheException} - */ - @Override - public void waitUntilClusterCoherent() throws UnsupportedOperationException { - throw new NonStopCacheException("waitUntilClusterCoherent timed out"); - } - - @Override - public Set getSearchAttributes() { - throw new NonStopCacheException("getSearchAttributes timed out"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link NonStopCacheException} - */ - @Override - public Attribute getSearchAttribute(String attributeName) { - throw new NonStopCacheException("getSearchAttribute timed out"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getLocalKeys() { - throw new NonStopCacheException("getLocalKeys() timed out"); - } - - /** - * {@inheritDoc} - */ - @Override - public CacheConfiguration.TransactionalMode getTransactionalMode() { - throw new NonStopCacheException("getTransactionalMode() timed out"); - } - - /** - * {@inheritDoc} - */ - public Element unlockedGet(Object key) { - throw new NonStopCacheException("unlockedGet() timed out"); - } - - /** - * {@inheritDoc} - */ - public Element unlockedGetQuiet(Object key) { - throw new NonStopCacheException("unlockedGetQuiet() timed out"); - } - - /** - * {@inheritDoc} - */ - @Override - public Element unsafeGet(Object key) { - throw new NonStopCacheException("unsafeGet() timed out"); - } - - /** - * {@inheritDoc} - */ - @Override - public void quickClear() { - throw new NonStopCacheException("quickClear() timed out"); - } - - /** - * {@inheritDoc} - */ - @Override - public int quickSize() { - throw new NonStopCacheException("quickSize() timed out"); - } - - /** - * {@inheritDoc} - */ - public Element unsafeGetQuiet(Object key) { - throw new NonStopCacheException("unsafeGetQuiet() timed out"); - } - - /** - * {@inheritDoc} - */ - @Override - public void recalculateSize(Object key) { - throw new UnsupportedOperationException(); - } - - @Override - public WriteBehind createWriteBehind() { - throw new UnsupportedOperationException(); - } - - @Override - public void notifyCacheEventListenersChanged() { - throw new NonStopCacheException("notifyCacheEventListenersChanged() timed out"); - } -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/store/CachingTier.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/store/CachingTier.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/store/CachingTier.java (revision 0) @@ -1,166 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package net.sf.ehcache.store; - -import java.util.concurrent.Callable; - -/** - * This interface is to be implemented by CachingTier that sit above the {@link AuthoritativeTier}. - * An important contract here is that a value being faulted in get is to be entirely faulted in before it - * can become an eviction candidate, i.e. this cache can never evict mappings being faulted in - * - * @param - * @param - * @author Alex Snaps - */ -public interface CachingTier { - - /** - * Returns {@code true} if values should be loaded to this cache on put. - *

- * This may be a dynamic decision, based for example on the occupancy of the cache. - * - * @return {@code true} if values should be loaded on put - */ - boolean loadOnPut(); - - /** - * Returns the value associated with the key, or populates the mapping using the Callable instance - * - * @param key the key to look up - * @param source the source to use, in the case of no mapping present - * @param updateStats true to update the stats, false otherwise - * @return the value mapped to the key - */ - V get(K key, Callable source, boolean updateStats); - - /** - * Removes the mapping associated to the key passed in - * - * @param key the key to the mapping to remove - * @return the value removed, null if none - */ - V remove(K key); - - /** - * Clears the cache... - * Doesn't notify any listeners - */ - void clear(); - - /** - * Clears the cache notifying listeners - */ - void clearAndNotify(); - - /** - * Adds a {@link Listener} to the cache - * - * @param listener the listener to add - */ - void addListener(Listener listener); - - /** - * Can we avoid having this somehow ? - * - * @return the count of entries held in heap - */ - @Deprecated - int getInMemorySize(); - - /** - * Can we avoid having this somehow ? - * - * @return the count of entries held off heap - */ - @Deprecated - int getOffHeapSize(); - - /** - * This should go away once the stats are in - * As the method is only there to know what tier the key is going to be fetched from - * - * @param key - * @return - */ - @Deprecated - boolean contains(K key); - - /** - * CacheTier could keep hold of the PoolAccessors for each tier... - * But what about non pooled resources ? - * - * @return - */ - @Deprecated - long getInMemorySizeInBytes(); - - /** - * CacheTier could keep hold of the PoolAccessors for each tier... - * But what about non pooled resources ? - * - * @return - */ - @Deprecated - long getOffHeapSizeInBytes(); - - /** - * CacheTier could keep hold of the PoolAccessors for each tier... - * But what about non pooled resources ? - * - * @return - */ - @Deprecated - long getOnDiskSizeInBytes(); - - /** - * This is evil! Don't call this! - * @param key the key to perform the recalculation for - */ - @Deprecated - void recalculateSize(K key); - - /** - * queries the potential eviction policy for the heap caching tier - * @return the policy - */ - @Deprecated - Policy getEvictionPolicy(); - - /** - * sets the eviction policy on the heap caching tier - * @param policy the policy to use - */ - @Deprecated - void setEvictionPolicy(Policy policy); - - /** - * A listener that will be notified when eviction of a mapping happens - * - * @param - * @param - */ - public interface Listener { - - /** - * Invoked when a mapping is evicted. - * - * @param key the key evicted - * @param value the value evicted - */ - void evicted(K key, V value); - } -} Index: rctags/ehcache-2.10.8.0.7/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/ClusteredCacheInternalContext.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/ClusteredCacheInternalContext.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/ClusteredCacheInternalContext.java (revision 0) @@ -1,33 +0,0 @@ -/* - * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved. - */ -package org.terracotta.modules.ehcache; - -import net.sf.ehcache.concurrent.CacheLockProvider; -import net.sf.ehcache.concurrent.Sync; - -import org.terracotta.toolkit.Toolkit; - -public class ClusteredCacheInternalContext implements ToolkitLookup, CacheLockProvider { - private final Toolkit toolkit; - private final CacheLockProvider cacheLockProvider; - - public ClusteredCacheInternalContext(Toolkit toolkit, CacheLockProvider cacheLockProvider) { - this.toolkit = toolkit; - this.cacheLockProvider = cacheLockProvider; - } - - @Override - public Sync getSyncForKey(Object key) { - return cacheLockProvider.getSyncForKey(key); - } - - @Override - public Toolkit getToolkit() { - return toolkit; - } - - public CacheLockProvider getCacheLockProvider() { - return cacheLockProvider; - } -} Index: rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/modules/ehcache/store/EvictionListenerTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/modules/ehcache/store/EvictionListenerTest.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/modules/ehcache/store/EvictionListenerTest.java (revision 0) @@ -1,137 +0,0 @@ -/* - * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved. - */ -package org.terracotta.modules.ehcache.store; - -import net.sf.ehcache.Cache; -import net.sf.ehcache.CacheException; -import net.sf.ehcache.Ehcache; -import net.sf.ehcache.Element; -import net.sf.ehcache.event.CacheEventListener; -import org.terracotta.ehcache.tests.AbstractCacheTestBase; -import org.terracotta.ehcache.tests.ClientBase; -import org.terracotta.toolkit.Toolkit; -import org.terracotta.toolkit.concurrent.ToolkitBarrier; -import org.terracotta.toolkit.concurrent.atomic.ToolkitAtomicLong; - -import com.tc.properties.TCPropertiesConsts; -import com.tc.test.config.model.TestConfig; - -import java.util.concurrent.Callable; - -import static org.terracotta.test.util.WaitUtil.waitUntilCallableReturnsTrue; - -public class EvictionListenerTest extends AbstractCacheTestBase { - - private static final int NODE_COUNT = 2; - - public EvictionListenerTest(TestConfig testConfig) { - super("evict-cache-test.xml", testConfig, App.class, App.class); -// testConfig.setDgcEnabled(true); -// testConfig.setDgcIntervalInSec(10); -// testConfig.getL2Config().setMaxHeap(1024); - testConfig.addTcProperty(TCPropertiesConsts.EHCACHE_EVICTOR_LOGGING_ENABLED, "true"); - } - - public static class App extends ClientBase implements CacheEventListener { - - private final ToolkitBarrier barrier; - private final ToolkitAtomicLong actualEvictionsCount; - - public App(String[] args) { - super("test2", args); - this.actualEvictionsCount = getClusteringToolkit().getAtomicLong("testLong"); - this.barrier = getClusteringToolkit().getBarrier("testBarrier", NODE_COUNT); - } - - public static void main(String[] args) { - new App(args).run(); - } - - @Override - protected void runTest(final Cache cache, final Toolkit clusteringToolkit) throws Throwable { - final int numOfElements = 1000; - final long maxEntriesInCache = cache.getCacheConfiguration().getMaxEntriesInCache(); - final long expectedEvictionsCount = numOfElements - maxEntriesInCache; - final int index = barrier.await(); - - cache.getCacheEventNotificationService().registerListener(this); - // XXX: assert that the cache is clustered via methods on cache config (when methods exist) - System.err.println(cache); - assertEquals(0, cache.getSize()); - assertEquals(1, cache.getCacheConfiguration().getTerracottaConfiguration().getConcurrency()); - barrier.await(); - - if (index == 0) { - for (int i = 0; i < numOfElements; i++) { - cache.put(new Element(i, "value")); - } - } - barrier.await(); - - waitUntilCallableReturnsTrue(new Callable() { - @Override - public Boolean call() throws Exception { - System.out.println("Client " + index + ", cache size so far: " + cache.getSize()); - return cache.getSize() == maxEntriesInCache; // it must evict exactly 600 elements, because concurrency = 1 - } - }); - System.out.println("Client " + index + ", final cache size: " + cache.getSize()); - barrier.await(); - - waitUntilCallableReturnsTrue(new Callable() { - @Override - public Boolean call() throws Exception { - System.out.println("Client " + index + ", evicted count so far: " + actualEvictionsCount.get()); - // NOTE! Only one client should ever receive eviction events, and we actually don't know which one - return actualEvictionsCount.get() == expectedEvictionsCount; - } - }); - barrier.await(); - - assertEquals(expectedEvictionsCount, this.actualEvictionsCount.get()); - } - - @Override - public void dispose() { - // don't care - } - - @Override - public void notifyElementEvicted(Ehcache cache, Element element) { - System.out.println("Element [" + element + "] evicted"); - actualEvictionsCount.incrementAndGet(); - } - - @Override - public void notifyElementExpired(Ehcache cache, Element element) { - // don't care - } - - @Override - public void notifyElementPut(Ehcache cache, Element element) throws CacheException { - // don't care - } - - @Override - public void notifyElementRemoved(Ehcache cache, Element element) throws CacheException { - // don't care - } - - @Override - public void notifyElementUpdated(Ehcache cache, Element element) throws CacheException { - // don't care - } - - @Override - public void notifyRemoveAll(Ehcache cache) { - // don't care - } - - @Override - public Object clone() throws CloneNotSupportedException { - return super.clone(); - } - } - -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/event/EvictionListenerTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/event/EvictionListenerTest.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/event/EvictionListenerTest.java (revision 0) @@ -1,382 +0,0 @@ -package net.sf.ehcache.event; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.not; -import static org.hamcrest.Matchers.greaterThan; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.fail; - -import java.io.NotSerializableException; -import java.util.Map; -import java.util.UUID; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.Future; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.logging.Filter; -import java.util.logging.LogRecord; -import java.util.logging.Logger; - -import net.sf.ehcache.Cache; -import net.sf.ehcache.CacheException; -import net.sf.ehcache.CacheManager; -import net.sf.ehcache.Ehcache; -import net.sf.ehcache.Element; -import net.sf.ehcache.config.CacheConfiguration; -import net.sf.ehcache.config.Configuration; -import net.sf.ehcache.config.DiskStoreConfiguration; -import net.sf.ehcache.config.MemoryUnit; -import net.sf.ehcache.store.MemoryStoreEvictionPolicy; -import net.sf.ehcache.store.disk.DiskStorageFactory; -import net.sf.ehcache.store.disk.DiskStoreHelper; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.terracotta.test.categories.CheckShorts; - -/** - * @author Alex Snaps - */ -@Category(CheckShorts.class) -public class EvictionListenerTest { - - private static CacheManager cacheManager; - private static final String CACHE_NAME = "listening"; - private Cache cache; - private static final int THREADS = 6; - private static final int PER_THREAD = 15000; - - @BeforeClass - public static void createCacheManager() { - Configuration configuration = new Configuration(); - configuration.diskStore(new DiskStoreConfiguration().path("./target/tmp/")).name(EvictionListenerTest.class.getSimpleName()); - cacheManager = new CacheManager(configuration); - Logger.getLogger(DiskStorageFactory.class.getName()).setFilter(new Filter() { - public boolean isLoggable(LogRecord lr) { - return !(lr.getThrown() instanceof NotSerializableException); - } - }); - } - - @Before - public void setup() { - CacheConfiguration configuration = new CacheConfiguration(CACHE_NAME, 100).overflowToDisk(true) - .maxBytesLocalDisk(1, MemoryUnit.MEGABYTES); - cache = new Cache(configuration); - cacheManager.addCache(cache); - } - - @Test - public void testEvictedOnlyOnce() throws InterruptedException, ExecutionException { - CountingCacheEventListener countingCacheEventListener = new CountingCacheEventListener(); - cache.getCacheEventNotificationService().registerListener(countingCacheEventListener); - int amountOfEntries = 10000; - for (int i = 0; i < amountOfEntries; i++) { - cache.get("key" + (1000 + (i % 10))); - cache.put(new Element("key" + i, UUID.randomUUID().toString())); - } - DiskStoreHelper.flushAllEntriesToDisk(cache).get(); - final long diskStoreSize = cache.getStatistics().getLocalDiskSize(); - Map cacheElementsEvicted = countingCacheEventListener.getCacheElementsEvicted(cache); - System.out.println("\n\n ****"); - System.out.println("DiskStore store size : " + diskStoreSize); - System.out.println(" ****\n\n"); - assertThat(cacheElementsEvicted.isEmpty(), is(false)); - for (Map.Entry entry : cacheElementsEvicted.entrySet()) { - assertThat("Evicted multiple times: " + entry.getKey(), entry.getValue().get(), equalTo(1)); - } - for (int i = 0; i < amountOfEntries; i++) { - String key = "key" + i; - if (!cache.isKeyInCache(key) && !cacheElementsEvicted.containsKey(key)) { - final String message = "Key '" + key + "' isn't in cache & we didn't get notified about its eviction!"; - System.out.println(message); - assertThat(cacheElementsEvicted.size(), is((int) (amountOfEntries - diskStoreSize))); - fail(message); - } - } - } - - @Test - public void testGetsAllEvictedKeys() throws InterruptedException, ExecutionException { - CountingCacheEventListener countingCacheEventListener = accessCache(cache); - DiskStoreHelper.flushAllEntriesToDisk(cache).get(); - Map cacheElementsEvicted = countingCacheEventListener.getCacheElementsEvicted(cache); - for (Map.Entry entry : cacheElementsEvicted.entrySet()) { - assertThat("Evicted multiple times: " + entry.getKey(), entry.getValue().get(), equalTo(1)); - } - assertThat(cache.getSize(), not(is(0))); - assertThat(cacheElementsEvicted.size() + cache.getSize(), is(THREADS * PER_THREAD)); - } - - @Test - public void testGetsAllEvictedKeysClockEviction() throws InterruptedException, ExecutionException { - cacheManager.removeCache(CACHE_NAME); - CacheConfiguration configuration = new CacheConfiguration(CACHE_NAME, 100) - .memoryStoreEvictionPolicy(MemoryStoreEvictionPolicy.CLOCK); - cache = new Cache(configuration); - cacheManager.addCache(cache); - CountingCacheEventListener countingCacheEventListener = accessCache(cache); - Map cacheElementsEvicted = countingCacheEventListener.getCacheElementsEvicted(cache); - for (Map.Entry entry : cacheElementsEvicted.entrySet()) { - assertThat("Evicted multiple times: " + entry.getKey(), entry.getValue().get(), equalTo(1)); - } - assertThat(cache.getSize(), not(is(0))); - assertThat(cacheElementsEvicted.size() + cache.getSize(), is(THREADS * PER_THREAD)); - } - - @Test - public void testGetsAllEvictedKeysWithoutDiskSizeBased() throws InterruptedException { - CacheConfiguration configuration = new CacheConfiguration().name("noDisk").maxBytesLocalHeap(100, MemoryUnit.KILOBYTES); - final Cache noDiskCache = new Cache(configuration); - cacheManager.addCache(noDiskCache); - CountingCacheEventListener countingCacheEventListener = accessCache(noDiskCache); - assertThat(noDiskCache.getStatistics().getLocalHeapSize() <= noDiskCache.getCacheConfiguration().getMaxBytesLocalHeap(), is(true)); - Map cacheElementsEvicted = countingCacheEventListener.getCacheElementsEvicted(noDiskCache); - for (Map.Entry entry : cacheElementsEvicted.entrySet()) { - assertThat("Evicted multiple times: " + entry.getKey(), entry.getValue().get(), equalTo(1)); - } - assertThat(noDiskCache.getSize(), not(is(0))); - assertThat(cacheElementsEvicted.size(), not(is(0))); - System.out.println(noDiskCache.getSize()); - assertThat(cacheElementsEvicted.size() + noDiskCache.getSize(), is(THREADS * PER_THREAD)); - } - - @Test - public void testGetsAllEvictedKeysWithoutDiskEntryBased() throws InterruptedException { - CacheConfiguration configuration = new CacheConfiguration().name("noDiskEntry").maxEntriesLocalHeap(100); - final Cache noDiskCache = new Cache(configuration); - cacheManager.addCache(noDiskCache); - CountingCacheEventListener countingCacheEventListener = accessCache(noDiskCache); - Map cacheElementsEvicted = countingCacheEventListener.getCacheElementsEvicted(noDiskCache); - for (Map.Entry entry : cacheElementsEvicted.entrySet()) { - assertThat("Evicted multiple times: " + entry.getKey(), entry.getValue().get(), equalTo(1)); - } - assertThat(noDiskCache.getSize(), not(is(0))); - assertThat(cacheElementsEvicted.size(), not(is(0))); - System.out.println(noDiskCache.getSize()); - assertThat(cacheElementsEvicted.size() + noDiskCache.getSize(), is(THREADS * PER_THREAD)); - } - - @Test - public void testGetsAllEvictedKeysWithDiskEntryBased() throws InterruptedException, ExecutionException { - CacheConfiguration configuration = new CacheConfiguration().name("diskEntry").maxEntriesLocalHeap(100) - .overflowToDisk(true).maxEntriesLocalDisk(2000); - final Cache diskCache = new Cache(configuration); - cacheManager.addCache(diskCache); - CountingCacheEventListener countingCacheEventListener = accessCache(diskCache); - Map cacheElementsEvicted = countingCacheEventListener.getCacheElementsEvicted(diskCache); - for (Map.Entry entry : cacheElementsEvicted.entrySet()) { - assertThat("Evicted multiple times: " + entry.getKey(), entry.getValue().get(), equalTo(1)); - } - assertThat(diskCache.getSize(), not(is(0))); - assertThat(cacheElementsEvicted.size(), not(is(0))); - DiskStoreHelper.flushAllEntriesToDisk(diskCache).get(); - System.out.println(diskCache.getSize()); - assertThat(cacheElementsEvicted.size() + diskCache.getSize(), is(THREADS * PER_THREAD)); - } - - @Test - public void testGetsAllEvictedKeysWithDiskPersistentEntryBased() throws InterruptedException, ExecutionException { - cache = new Cache(new CacheConfiguration("testGetsAllEvictedKeysWithDiskPersistentEntryBased", 100) - .maxEntriesLocalDisk(2000) - .eternal(true) - .diskPersistent(true)); - cacheManager.addCache(cache); - CountingCacheEventListener countingCacheEventListener = accessCache(cache); - DiskStoreHelper.flushAllEntriesToDisk(cache).get(); - Map cacheElementsEvicted = countingCacheEventListener.getCacheElementsEvicted(cache); -// for (Map.Entry entry : cacheElementsEvicted.entrySet()) { -// assertThat("Evicted multiple times: " + entry.getKey(), entry.getValue().get(), equalTo(1)); -// } - - DiskStoreHelper.flushAllEntriesToDisk(cache).get(); // Make sure all is flushed... - final int cacheSize = cache.getSize(); - final int evictedElementCount = cacheElementsEvicted.size(); - - assertThat(cacheSize, greaterThan(0)); - assertThat(evictedElementCount, greaterThan(0)); - System.out.println(cacheSize); - assertThat(evictedElementCount + cacheSize, is(THREADS * PER_THREAD)); - } - - private CountingCacheEventListener accessCache(final Cache cacheUT) throws InterruptedException { - CountingCacheEventListener countingCacheEventListener = new CountingCacheEventListener(); - cacheUT.getCacheEventNotificationService().registerListener(countingCacheEventListener); - Thread[] threads = new Thread[THREADS]; - final AtomicInteger counter = new AtomicInteger(); - for (int i = 0; i < threads.length; i++) { - threads[i] = new Thread() { - - private final int index = counter.getAndIncrement(); - - @Override - public void run() { - for (int j = index * PER_THREAD; j < (index + 1) * PER_THREAD; j++) { - cacheUT.get("key" + (1000 + (j % 10))); - if (j % 125 == 0) { - cacheUT.put(new Element("key" + j, new Object())); - } else { - cacheUT.put(new Element("key" + j, UUID.randomUUID().toString())); - } - } - } - }; - threads[i].run(); - } - for (Thread thread : threads) { - thread.join(); - } - return countingCacheEventListener; - } - - @Test - public void testEvictionDuplicates() throws Exception { - CacheConfiguration configuration = new CacheConfiguration().name("heapOnly").maxBytesLocalHeap(4, MemoryUnit.KILOBYTES).eternal(true).overflowToOffHeap(false); - final Cache heapOnlyCache = new Cache(configuration); - cacheManager.addCache(heapOnlyCache); - - final ConcurrentHashMap evicted = new ConcurrentHashMap(); - heapOnlyCache.getCacheEventNotificationService().registerListener(new CacheEventListenerAdapter(){ - @Override - public void notifyElementEvicted(Ehcache cache, Element element) { - AtomicInteger old = evicted.put(element.getObjectKey(), new AtomicInteger(1)); - if (old != null) { - fail("Got multiple evictions for " + element.getObjectKey() + "! Evicted " + old.incrementAndGet() + " times"); - } - } - }); - - Putter[] putters = new Putter[2]; - for (int i = 0; i < 2; i++) { - putters[i] = new Putter(i, heapOnlyCache); - } - for (Putter putter : putters) { - putter.start(); - } - for (Putter putter : putters) { - putter.join(); - assertFalse(putter.failed); - } - } - - private static final class Putter extends Thread { - private final int id; - private final Cache c; - private volatile boolean failed; - - - private Putter(int id, Cache c) { - this.id = id; - this.c = c; - } - - @Override - public void run() { - try { - for (int i = 0; i < 10000; i++) { - c.put(new Element(id + "-" + i, "" + i)); - } - } catch (Throwable t) { - t.printStackTrace(); - failed = true; - } - } - } - - @After - public void tearDown() throws ExecutionException, InterruptedException { - if(cache != null) { - cache.removeAll(); - final Future future = DiskStoreHelper.flushAllEntriesToDisk(cache); - if(future != null) { - future.get(); - } - } - cacheManager.removeAllCaches(); - } - - @AfterClass - public static void cleanUp() { - cacheManager.shutdown(); - } - - private static class CountingCacheEventListener implements CacheEventListener { - - private final ConcurrentMap> evictions = createMap(); - - public void notifyElementRemoved(final Ehcache cache, final Element element) throws CacheException { - // To change body of implemented methods use File | Settings | File Templates. - } - - public void notifyElementPut(final Ehcache cache, final Element element) throws CacheException { - // To change body of implemented methods use File | Settings | File Templates. - } - - public void notifyElementUpdated(final Ehcache cache, final Element element) throws CacheException { - // To change body of implemented methods use File | Settings | File Templates. - } - - public void notifyElementExpired(final Ehcache cache, final Element element) { - // To change body of implemented methods use File | Settings | File Templates. - } - - public void notifyElementEvicted(final Ehcache cache, final Element element) { - getCounterFor(element, getEntriesFor(cache, evictions)).incrementAndGet(); - } - - public void notifyRemoveAll(final Ehcache cache) { - // To change body of implemented methods use File | Settings | File Templates. - } - - public void dispose() { - // To change body of implemented methods use File | Settings | File Templates. - } - - @Override - public Object clone() throws CloneNotSupportedException { - super.clone(); - throw new UnsupportedOperationException("Don't clone me!"); - } - - private AtomicInteger getCounterFor(final Element element, final ConcurrentMap entries) { - AtomicInteger counter = entries.get(element.getKey()); - if (counter == null) { - counter = new AtomicInteger(0); - AtomicInteger previous = entries.putIfAbsent(element.getKey(), counter); - if (previous != null) { - counter = previous; - } - } - return counter; - } - - private ConcurrentMap getEntriesFor(final Ehcache cache, - final ConcurrentMap> map) { - ConcurrentMap entries; - entries = map.get(cache.getName()); - if (entries == null) { - entries = new ConcurrentHashMap(); - ConcurrentMap previous = map.putIfAbsent(cache.getName(), entries); - if (previous != null) { - entries = previous; - } - } - return entries; - } - - private ConcurrentHashMap createMap() { - return new ConcurrentHashMap(); - } - - public Map getCacheElementsEvicted(final Cache cache) { - return getEntriesFor(cache, evictions); - } - } -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/store/DiskStoreBootstrapCacheLoaderFactoryTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/store/DiskStoreBootstrapCacheLoaderFactoryTest.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/store/DiskStoreBootstrapCacheLoaderFactoryTest.java (revision 0) @@ -1,168 +0,0 @@ -package net.sf.ehcache.store; - -import net.sf.ehcache.Cache; -import net.sf.ehcache.CacheManager; -import net.sf.ehcache.Ehcache; -import net.sf.ehcache.Element; -import net.sf.ehcache.Status; -import net.sf.ehcache.config.CacheConfiguration; -import net.sf.ehcache.config.Configuration; -import net.sf.ehcache.config.DiskStoreConfiguration; -import net.sf.ehcache.store.disk.DiskStoreHelper; - -import org.junit.After; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.terracotta.test.categories.CheckShorts; - -import java.util.concurrent.BrokenBarrierException; -import java.util.concurrent.CyclicBarrier; - -import static net.sf.ehcache.config.MemoryUnit.KILOBYTES; -import static net.sf.ehcache.config.MemoryUnit.MEGABYTES; -import static org.hamcrest.core.Is.is; -import static org.hamcrest.number.OrderingComparison.greaterThan; -import static org.hamcrest.number.OrderingComparison.lessThanOrEqualTo; -import static org.junit.Assert.assertThat; - -/** - * @author Alex Snaps - */ -@Category(CheckShorts.class) -public class DiskStoreBootstrapCacheLoaderFactoryTest { - - private static final int ELEMENTS_ON_DISK = 500; - private CacheManager manager; - private Cache cacheElementCountBound; - private Cache cacheSizeBound; - private TestDiskStoreBootstrapCacheLoader cacheElementCountBoundBootstrapCacheLoader; - private TestDiskStoreBootstrapCacheLoader cacheSizeBoundBootstrapCacheLoader; - - public void setUp(CacheUT cut) { - initCacheManager(cut); - switch (cut) { - case elementBased: - cacheElementCountBound.removeAll(); - populateCache(cacheElementCountBound); - break; - case sizeBased: - cacheSizeBound.removeAll(); - populateCache(cacheSizeBound); - break; - } - } - - private void populateCache(final Cache cache) { - for (int i = 0; i < ELEMENTS_ON_DISK; i++) { - cache.put(new Element(i, "Some value for key " + i)); - } - } - - @Test - public void testLoadsFromDiskWithMaxElementsInMemorySet() throws Exception { - setUp(CacheUT.elementBased); - DiskStoreHelper.flushAllEntriesToDisk(cacheElementCountBound).get(); - long onDiskElements = cacheElementCountBound.getStatistics().getLocalDiskSize(); - cacheElementCountBoundBootstrapCacheLoader.triggerLoad(); - assertThat(cacheElementCountBound.getStatistics().getLocalHeapSize(), is(100L)); - manager.shutdown(); - initCacheManager(CacheUT.elementBased); - assertThat(cacheElementCountBound.getStatistics().getLocalDiskSize(), is(onDiskElements)); - assertThat(cacheElementCountBound.getStatistics().getLocalHeapSize(), is(0L)); - cacheElementCountBoundBootstrapCacheLoader.triggerLoad(); - assertThat(cacheElementCountBound.getStatistics().getLocalDiskSize(), is(onDiskElements)); - assertThat(cacheElementCountBound.getStatistics().getLocalHeapSize(), is(100L)); - } - - @Test - public void testLoadsFromDiskWithMaxBytesOnHeapSet() throws Exception { - setUp(CacheUT.sizeBased); - DiskStoreHelper.flushAllEntriesToDisk(cacheSizeBound).get(); - cacheSizeBoundBootstrapCacheLoader.triggerLoad(); - long onDiskSize = cacheSizeBound.getStatistics().getLocalDiskSize(); - assertThat(cacheSizeBound.getStatistics().getLocalHeapSize(), greaterThan(0L)); - assertThat(cacheSizeBound.getStatistics().getLocalHeapSizeInBytes(), lessThanOrEqualTo(KILOBYTES.toBytes(220L))); - assertThat(cacheSizeBound.getStatistics().getLocalDiskSize(), is(onDiskSize)); - manager.shutdown(); - initCacheManager(CacheUT.sizeBased); - assertThat(cacheSizeBound.getStatistics().getLocalDiskSize(), is(onDiskSize)); - assertThat(cacheSizeBound.getStatistics().getLocalHeapSize(), is(0L)); - cacheSizeBoundBootstrapCacheLoader.triggerLoad(); - assertThat(cacheSizeBound.getStatistics().getLocalHeapSize(), greaterThan(0L)); - assertThat(cacheSizeBound.getStatistics().getLocalHeapSizeInBytes(), lessThanOrEqualTo(KILOBYTES.toBytes(220L))); - } - - private void initCacheManager(CacheUT cut) { - switch (cut) { - case elementBased: - manager = new CacheManager(new Configuration().diskStore(new DiskStoreConfiguration().path("java.io.tmpdir/DiskPersistent"))); - cacheElementCountBoundBootstrapCacheLoader = new TestDiskStoreBootstrapCacheLoader(); - cacheElementCountBound = new Cache(new CacheConfiguration("maxElementsInMemory", 100) - .eternal(true) - .diskPersistent(true) - .overflowToDisk(true) - .maxEntriesLocalDisk(ELEMENTS_ON_DISK), null, cacheElementCountBoundBootstrapCacheLoader); - manager.addCache(cacheElementCountBound); - break; - case sizeBased: - manager = new CacheManager(new Configuration().diskStore(new DiskStoreConfiguration().path("java.io.tmpdir/DiskPersistentSize"))); - cacheSizeBoundBootstrapCacheLoader = new TestDiskStoreBootstrapCacheLoader(); - cacheSizeBound = new Cache(new CacheConfiguration("maxOnHeap", 0) - .eternal(true) - .diskPersistent(true) - .overflowToDisk(true) - .maxBytesLocalHeap(220, KILOBYTES) - .maxBytesLocalDisk(300, MEGABYTES), null, cacheSizeBoundBootstrapCacheLoader); - manager.addCache(cacheSizeBound); - break; - } - } - - @After - public void shutdown() { - if (manager != null && manager.getStatus() == Status.STATUS_ALIVE) { - manager.shutdown(); - } - } - - private static enum CacheUT { - elementBased, sizeBased - } - - static class TestDiskStoreBootstrapCacheLoader extends DiskStoreBootstrapCacheLoader { - - private final CyclicBarrier before = new CyclicBarrier(2); - private final CyclicBarrier after = new CyclicBarrier(2); - - public TestDiskStoreBootstrapCacheLoader() { - super(true); - } - - @Override - protected void doLoad(Ehcache cache) { - try { - before.await(); - try { - super.doLoad(cache); - } finally { - after.await(); - } - } catch (InterruptedException e) { - throw new AssertionError(e); - } catch (BrokenBarrierException e) { - throw new AssertionError(e); - } - } - - public void triggerLoad() { - try { - before.await(); - after.await(); - } catch (InterruptedException e) { - throw new AssertionError(e); - } catch (BrokenBarrierException e) { - throw new AssertionError(e); - } - } - } -} Index: rctags/ehcache-2.10.8.0.7/ehcache-scheduled-refresh/src/main/java/net/sf/ehcache/constructs/scheduledrefresh/ScheduledRefreshCacheExtension.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-scheduled-refresh/src/main/java/net/sf/ehcache/constructs/scheduledrefresh/ScheduledRefreshCacheExtension.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-scheduled-refresh/src/main/java/net/sf/ehcache/constructs/scheduledrefresh/ScheduledRefreshCacheExtension.java (revision 0) @@ -1,455 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package net.sf.ehcache.constructs.scheduledrefresh; - -import net.sf.ehcache.CacheException; -import net.sf.ehcache.Ehcache; -import net.sf.ehcache.Status; -import net.sf.ehcache.extension.CacheExtension; -import net.sf.ehcache.statistics.extended.ExtendedStatistics; -import org.quartz.CronScheduleBuilder; -import org.quartz.CronTrigger; -import org.quartz.JobBuilder; -import org.quartz.JobDataMap; -import org.quartz.JobDetail; -import org.quartz.Scheduler; -import org.quartz.SchedulerException; -import org.quartz.TriggerBuilder; -import org.quartz.impl.StdSchedulerFactory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.terracotta.statistics.StatisticsManager; - -import java.util.Collection; -import java.util.Collections; -import java.util.LinkedList; -import java.util.Properties; -import java.util.Set; -import java.util.concurrent.atomic.AtomicLong; - -/** - * This class provides a cache extension which allows for the scheduled refresh - * of all keys currently in the cache, using whichever CacheLoader's are - * defined. It uses Quartz to do the job scheduling. One extension should be - * active for a single clustered cache, as multiple extensions will run - * independently of each other. - * - * @author cschanck - */ -public class ScheduledRefreshCacheExtension implements CacheExtension { - - /** - * Logger this package uses. - */ - static final Logger LOG = LoggerFactory.getLogger(ScheduledRefreshCacheExtension.class); - - /** - * Job Property key for Terracotta Job Store to use. - */ - static final String PROP_QUARTZ_JOB_STORE_TC_CONFIG_URL = "org.quartz.jobStore.tcConfigUrl"; - - /** - * Job Property key for cache name this extension's jobs will run against - */ - static final String PROP_CACHE_NAME = ScheduledRefreshCacheExtension.class.getName() + ".cacheName"; - - /** - * Job Property key for cache manager name this extension's jobs will run - * against - */ - static final String PROP_CACHE_MGR_NAME = ScheduledRefreshCacheExtension.class.getName() + "cacheManagerName"; - - /** - * Job Property key for sending config object to scheduled job - */ - static final String PROP_CONFIG_OBJECT = ScheduledRefreshCacheExtension.class.getName() + "scheduledRefreshConfig"; - - /** - * Job Property key for sending keys to process to scheduled job - */ - static final String PROP_KEYS_TO_PROCESS = "keyObjects"; - - private static final String OVERSEER_JOB_NAME = "Overseer"; - private Ehcache underlyingCache; - private ScheduledRefreshConfiguration config; - private String name; - private Scheduler scheduler; - private String groupName; - private Status status; - private AtomicLong refreshCount = new AtomicLong(); - private AtomicLong jobCount = new AtomicLong(); - private AtomicLong keysProcessedCount = new AtomicLong(); - - /** - * Constructor. Create an extension with the specified config object against - * the specified cache. - * - * @param config Configuration to use. - * @param cache Cache to process against. - */ - public ScheduledRefreshCacheExtension(ScheduledRefreshConfiguration config, Ehcache cache) { - if(cache == null) { - throw new IllegalArgumentException("ScheduledRefresh Cache cannot be null"); - } - this.underlyingCache = cache; - if(config == null) { - throw new IllegalArgumentException("ScheduledRefresh extension config cannot be null"); - } - this.config = config; - config.validate(); - this.status = Status.STATUS_UNINITIALISED; - StatisticsManager.associate(this).withParent(cache); - } - - @Override - public void init() { - try { - if (config.getScheduledRefreshName() != null) { - this.name = "scheduledRefresh_" + underlyingCache.getCacheManager().getName() + "_" - + underlyingCache.getName() + "_" + config.getScheduledRefreshName(); - } else { - this.name = "scheduledRefresh_" + underlyingCache.getCacheManager().getName() + "_" - + underlyingCache.getName(); - } - this.groupName = name + "_grp"; - try { - makeAndStartQuartzScheduler(); - try { - scheduleOverseerJob(); - status = Status.STATUS_ALIVE; - } catch (SchedulerException e) { - LOG.error("Unable to schedule control job for Scheduled Refresh", e); - } - - } catch (SchedulerException e) { - LOG.error("Unable to instantiate Quartz Job Scheduler for Scheduled Refresh", e); - } - } catch(RuntimeException e) { - LOG.error("Unable to initialise ScheduledRefesh extension", e); - } - } - - /* - * This is more complicated at first blush than you might expect, but it - * attempts to prove that one and only one trigger is scheduled for this job, - * and that it is the right one. Even if multiple cache extensions for the - * same cache are sharing the Quartz store, it should end up with only one - * trigger winning. If there are multiple *different* cron expressions, - * someone will win, but it is not deterministic as to which one. - */ - private void scheduleOverseerJob() throws SchedulerException { - - JobDetail seed = makeOverseerJob(); - - // build our trigger - CronScheduleBuilder cronSchedule = CronScheduleBuilder.cronSchedule(config.getCronExpression()); - - CronTrigger trigger = TriggerBuilder.newTrigger() - .withIdentity(OVERSEER_JOB_NAME, groupName) - .forJob(seed).withSchedule(cronSchedule) - .build(); - - try { - scheduler.addJob(seed, false); - } catch (SchedulerException e) { - // job already present - } - try { - scheduler.scheduleJob(trigger); - } catch (SchedulerException e) { - // trigger already present - try { - scheduler.rescheduleJob(trigger.getKey(), trigger); - } catch (SchedulerException ee) { - LOG.error("Unable to modify trigger for: " + trigger.getKey()); - } - } - - } - - /* - * Add the control job, an instance of the OverseerJob class. - */ - private JobDetail makeOverseerJob() throws SchedulerException { - JobDataMap jdm = new JobDataMap(); - jdm.put(PROP_CACHE_MGR_NAME, underlyingCache.getCacheManager().getName()); - jdm.put(PROP_CACHE_NAME, underlyingCache.getName()); - jdm.put(PROP_CONFIG_OBJECT, config); - JobDetail seed = JobBuilder.newJob(OverseerJob.class).storeDurably() - .withIdentity(OVERSEER_JOB_NAME, groupName) - .usingJobData(jdm).build(); - return seed; - } - - /* - * Create and start the quartz job scheduler for this cache extension - */ - private void makeAndStartQuartzScheduler() throws SchedulerException { - Properties props = new Properties(); - props.put(StdSchedulerFactory.PROP_SCHED_INSTANCE_NAME, name); - props.put(StdSchedulerFactory.PROP_SCHED_NAME, name); - props.put(StdSchedulerFactory.PROP_SCHED_MAKE_SCHEDULER_THREAD_DAEMON, Boolean.TRUE.toString()); - props.put("org.quartz.threadPool.threadCount", Integer.toString(config.getQuartzThreadCount() + 1)); - Properties jsProps = getJobStoreProperties(); - for (Object key : props.keySet()) { - if (!jsProps.containsKey(key)) { - jsProps.put(key, props.get(key)); - } - } - - StdSchedulerFactory factory = new StdSchedulerFactory(jsProps); - scheduler = factory.getScheduler(); - - scheduler.start(); - } - - private Properties getJobStoreProperties() throws SchedulerException { - try { - String clzName = config.getJobStoreFactoryClass(); - Class clz = Class.forName(clzName); - ScheduledRefreshJobStorePropertiesFactory fact = (ScheduledRefreshJobStorePropertiesFactory) clz.newInstance(); - Properties jsProps = fact.jobStoreProperties(underlyingCache, config); - return jsProps; - } catch (Throwable t) { - throw new SchedulerException(t); - } - } - - /** - * Note that this will not stop other instances of this refresh extension on - * other nodes (in a clustered environment) from running. Until and unless - * the last scheduled refresh cache extension for a particular cache/cache - * manager/unique name is shutdown, they will continue to run. This is only - * an issue for clustered, TerracottaJobStore-backed scheduled refresh cache - * extensions. - * - * @throws CacheException - */ - @Override - public void dispose() throws CacheException { - try { - scheduler.shutdown(); - } catch (SchedulerException e) { - throw new CacheException(e); - } catch(Throwable t) { - LOG.info("ScheduledRefresh cache extension exception during shutdown.",t); - } - status = Status.STATUS_SHUTDOWN; - } - - @Override - public CacheExtension clone(Ehcache cache) throws CloneNotSupportedException { - return null; - } - - @Override - public Status getStatus() { - return status; - } - - /** - * Gets extension group name. - * - * @return the extension group name - */ - String getExtensionGroupName() { - return groupName; - } - - /** - * Gets underlying cache. - * - * @return the underlying cache - */ - Ehcache getUnderlyingCache() { - return underlyingCache; - } - - /** - * Find extension from cache. - * - * @param cache the cache - * @param groupName the group name - * @return the scheduled refresh cache extension - */ - static ScheduledRefreshCacheExtension findExtensionFromCache(Ehcache cache, String groupName) { - for (CacheExtension ce : cache.getRegisteredCacheExtensions()) { - if (ce instanceof ScheduledRefreshCacheExtension) { - ScheduledRefreshCacheExtension probe = (ScheduledRefreshCacheExtension) ce; - if (probe.getUnderlyingCache().getName().equals(cache.getName()) && - probe.getExtensionGroupName().equals(groupName)) { - return probe; - } - } - } - return null; - } - - /** - * Find all the scheduled refresh cache extensions from a cache. - * - * @param cache the cache - * @return the scheduled refresh cache extension - */ - static Collection findExtensionsFromCache(Ehcache cache) { - LinkedList exts=new LinkedList(); - for (CacheExtension ce : cache.getRegisteredCacheExtensions()) { - if (ce instanceof ScheduledRefreshCacheExtension) { - exts.add((ScheduledRefreshCacheExtension)ce); - } - } - return exts; - } - - /** - * Increment refresh count. - */ - void incrementRefreshCount() { - refreshCount.incrementAndGet(); - } - - /** - * Increment job count. - */ - void incrementJobCount() { - jobCount.incrementAndGet(); - } - - /** - * Increment processed count. - * - * @param many the many - */ - void incrementProcessedCount(int many) { - keysProcessedCount.addAndGet(many); - } - - /** - * Gets refresh count. - * - * @return the refresh count - */ - @org.terracotta.statistics.Statistic(name = "refresh", tags = "scheduledrefresh") - public long getRefreshCount() { - return refreshCount.get(); - } - - /** - * Gets job count. - * - * @return the job count - */ - @org.terracotta.statistics.Statistic(name = "job", tags = "scheduledrefresh") - public long getJobCount() { - return jobCount.get(); - } - - /** - * Gets keys processed count. - * - * @return the keys processed count - */ - @org.terracotta.statistics.Statistic(name = "keysprocessed", tags = "scheduledrefresh") - public long getKeysProcessedCount() { - return keysProcessedCount.get(); - } - - /** - * Find refreshed counter statistic. Number of times schedule refresh has been - * started on this node. - * - * @param cache the cache this statistic is attached to. - * @return the set - */ - public static Set> findRefreshStatistics(Ehcache cache) { - return cache.getStatistics().getExtended().passthru("refresh", - Collections.singletonMap("scheduledrefresh", null).keySet()); - } - - /** - * Find job counter statistic. Number of batch jobs executed on this node. - * - * @param cache the cache this statistic is attached to. - * @return the set - */ - public static Set> findJobStatistics(Ehcache cache) { - return cache.getStatistics().getExtended().passthru("job", - Collections.singletonMap("scheduledrefresh", null).keySet()); - } - - /** - * Find queued counter statistic. Number of batch jobs executed on this node. - * - * @param cache the cache this statistic is attached to. - * @return the set - */ - public static Set> findKeysProcessedStatistics(Ehcache cache) { - return cache.getStatistics().getExtended().passthru("keysprocessed", - Collections.singletonMap("scheduledrefresh", null).keySet()); - } - - /** - * Finds a single refresh statistic for this cache. This is the count of scheduled - * refresh invocations for this node. Throws {@link IllegalStateException} if - * there are none or more than one. - * - * @param cache the cache - * @return the extended statistics . statistic - */ - public static ExtendedStatistics.Statistic findRefreshStatistic(Ehcache cache) { - Set> set = findRefreshStatistics(cache); - if (set.size() == 1) { - return set.iterator().next(); - } else { - throw new IllegalStateException("Multiple scheduled refresh stats found for this cache"); - } - } - - /** - * Finds a single job statistic for this cache. This is the count of refresh batch jobs - * executed on this node. Throws {@link IllegalStateException} if there are none or - * more than one. - * - * @param cache the cache - * @return the extended statistics . statistic - */ - public static ExtendedStatistics.Statistic findJobStatistic(Ehcache cache) { - Set> set = findJobStatistics(cache); - if (set.size() == 1) { - return set.iterator().next(); - } else { - throw new IllegalStateException("Multiple scheduled refresh stats found for this cache"); - } - } - - /** - * Finds a single keys processed statistic for this cache. This is the count of keys - * refreshed on this node. Throws {@link IllegalStateException} if - * there are none or more than one. - * - * @param cache the cache - * @return the extended statistics . statistic - */ - public static ExtendedStatistics.Statistic findKeysProcessedStatistic(Ehcache cache) { - Set> set = findKeysProcessedStatistics(cache); - if (set.size() == 1) { - return set.iterator().next(); - } else { - throw new IllegalStateException("Multiple scheduled refresh stats found for this cache"); - } - } - -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/management/provider/MBeanRegistrationProviderException.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/management/provider/MBeanRegistrationProviderException.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/management/provider/MBeanRegistrationProviderException.java (revision 0) @@ -1,47 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package net.sf.ehcache.management.provider; - -/** - * Exception thrown from {@link MBeanRegistrationProvider} - * - *

- * - * @author Abhishek Sanoujam - * @since 1.7 - */ -public class MBeanRegistrationProviderException extends Exception { - - /** - * Constructor accepting a string message and a Throwable - * - * @param message - * @param cause - */ - public MBeanRegistrationProviderException(String message, Throwable cause) { - super(message, cause); - } - - /** - * Constructor accepting a message - * - * @param message - */ - public MBeanRegistrationProviderException(String message) { - super(message); - } - -} Index: rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/ehcache/tests/ClusteredEventsRemoteClient1.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/ehcache/tests/ClusteredEventsRemoteClient1.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/ehcache/tests/ClusteredEventsRemoteClient1.java (revision 0) @@ -1,24 +0,0 @@ -package org.terracotta.ehcache.tests; - -import net.sf.ehcache.Cache; -import net.sf.ehcache.Element; - -import org.terracotta.toolkit.Toolkit; - -public class ClusteredEventsRemoteClient1 extends ClientBase { - - public ClusteredEventsRemoteClient1(String[] args) { - super("testRemote", args); - } - - public static void main(String[] args) { - new ClusteredEventsRemoteClient1(args).run(); - } - - @Override - protected void runTest(Cache cache, Toolkit toolkit) throws Throwable { - getBarrierForAllClients().await(); - cache.put(new Element("key1", "value1")); - Thread.sleep(5000); - } -} \ No newline at end of file Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/pool/sizeof/AbstractSizeOfTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/pool/sizeof/AbstractSizeOfTest.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/pool/sizeof/AbstractSizeOfTest.java (revision 0) @@ -1,51 +0,0 @@ -package net.sf.ehcache.pool.sizeof; - -import java.lang.management.ManagementFactory; - -import javax.management.MBeanServer; -import javax.management.ObjectName; -import javax.management.openmbean.CompositeData; - -import static net.sf.ehcache.pool.sizeof.JvmInformation.CURRENT_JVM_INFORMATION; - -abstract class AbstractSizeOfTest { - - protected static final boolean COMPRESSED_OOPS; - protected static final boolean HOTSPOT_CMS; - protected static final boolean IS_HOTSPOT; - protected static final boolean IS_JROCKIT; - protected static final boolean IS_IBM; - protected static final boolean IS_64_BIT; - - static { - String value = getVmOptionValue("UseCompressedOops"); - if (value == null) { - System.err.println("Could not detect compressed-oops status assuming: false"); - COMPRESSED_OOPS = false; - } else { - COMPRESSED_OOPS = Boolean.valueOf(value); - } - - HOTSPOT_CMS = CURRENT_JVM_INFORMATION.getMinimumObjectSize() > CURRENT_JVM_INFORMATION.getObjectAlignment(); - - IS_64_BIT = System.getProperty("sun.arch.data.model").equals("64"); - - IS_HOTSPOT = System.getProperty("java.vm.name", "").toLowerCase().contains("hotspot"); - - IS_JROCKIT = System.getProperty("jrockit.version") != null || - System.getProperty("java.vm.name", "").toLowerCase().indexOf("jrockit") >= 0; - - IS_IBM = System.getProperty("java.vm.name", "").contains("IBM") && - System.getProperty("java.vm.vendor").contains("IBM"); - } - - private static String getVmOptionValue(String name) { - try { - MBeanServer server = ManagementFactory.getPlatformMBeanServer(); - Object vmOption = server.invoke(ObjectName.getInstance("com.sun.management:type=HotSpotDiagnostic"), "getVMOption", new Object[] {name}, new String[] {"java.lang.String"}); - return (String) ((CompositeData) vmOption).get("value"); - } catch (Throwable t) { - return null; - } - } -} Index: rctags/ehcache-2.10.8.0.7/distribution/events/src/main/java/org/hibernate/tutorial/util/HibernateUtil.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/distribution/events/src/main/java/org/hibernate/tutorial/util/HibernateUtil.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/distribution/events/src/main/java/org/hibernate/tutorial/util/HibernateUtil.java (revision 0) @@ -1,23 +0,0 @@ -package org.hibernate.tutorial.util; - -import org.hibernate.SessionFactory; -import org.hibernate.cfg.Configuration; - -public class HibernateUtil { - private static final SessionFactory sessionFactory = buildSessionFactory(); - - private static SessionFactory buildSessionFactory() { - try { - // Create the SessionFactory from hibernate.cfg.xml - return new Configuration().configure().buildSessionFactory(); - } catch (Throwable ex) { - // Make sure you log the exception, as it might be swallowed - System.err.println("Initial SessionFactory creation failed." + ex); - throw new ExceptionInInitializerError(ex); - } - } - - public static SessionFactory getSessionFactory() { - return sessionFactory; - } -} Index: rctags/ehcache-2.10.8.0.7/system-tests/src/test/resources/total-capacity-cache-test.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/system-tests/src/test/resources/total-capacity-cache-test.xml (revision 11085) +++ rctags/ehcache-2.10.8.0.7/system-tests/src/test/resources/total-capacity-cache-test.xml (revision 0) @@ -1,17 +0,0 @@ - - - - - - - - - - - - - Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/transaction/manager/selector/Selector.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/transaction/manager/selector/Selector.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/transaction/manager/selector/Selector.java (revision 0) @@ -1,88 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package net.sf.ehcache.transaction.manager.selector; - -import net.sf.ehcache.transaction.xa.EhcacheXAResource; - -import javax.transaction.TransactionManager; - -/** - * Abstract class which is used to do various things related to JTA transaction managers, - * like looking them up, registering XAResources for recovery... - * - * @author Ludovic Orban - */ -public abstract class Selector { - - private final String vendor; - private volatile TransactionManager transactionManager; - - /** - * Constructor - * - * @param vendor an indicative transaction manager vendor name - * this selector is working with. - */ - protected Selector(String vendor) { - this.vendor = vendor; - } - - /** - * Get the vendor name - * @return the vendor name - */ - public String getVendor() { - return vendor; - } - - /** - * Get the transaction manager, looking it up if necessary. - * Once the transaction manager has been looked up, its reference is cached. - * @return the transaction manager - */ - public TransactionManager getTransactionManager() { - if (transactionManager == null) { - transactionManager = doLookup(); - } - return transactionManager; - } - - /** - * Register an XAResource with the transaction manager. - * - * @param ehcacheXAResource the XAResource - * @param forRecovery true if this XAResource is being registered purely for recovery purpose - */ - public void registerResource(EhcacheXAResource ehcacheXAResource, boolean forRecovery) { - } - - /** - * Unregister an XAResource from the transaction manager. - * - * @param ehcacheXAResource the XAResource - * @param forRecovery true if this XAResource was registered purely for recovery purpose - */ - public void unregisterResource(EhcacheXAResource ehcacheXAResource, boolean forRecovery) { - } - - /** - * Lookup the transaction manager. - * - * @return the transaction manager, or null if it could not be looked up. - */ - protected abstract TransactionManager doLookup(); - -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/resources/distribution/ehcache-distributed-big-payload-1.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/resources/distribution/ehcache-distributed-big-payload-1.xml (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/resources/distribution/ehcache-distributed-big-payload-1.xml (revision 0) @@ -1,426 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/util/concurrent/Striped64.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/util/concurrent/Striped64.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/util/concurrent/Striped64.java (revision 0) @@ -1,290 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/publicdomain/zero/1.0/ - */ - -package net.sf.ehcache.util.concurrent; - -import java.util.Random; -import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; -import java.util.concurrent.atomic.AtomicLongFieldUpdater; - -/** - * A package-local class holding common representation and mechanics - * for classes supporting dynamic striping on 64bit values. The class - * extends Number so that concrete subclasses must publicly do so. - */ -@SuppressWarnings("restriction") -abstract class Striped64 extends Number { - /* - * This class maintains a lazily-initialized table of atomically - * updated variables, plus an extra "base" field. The table size - * is a power of two. Indexing uses masked per-thread hash codes. - * Nearly all declarations in this class are package-private, - * accessed directly by subclasses. - * - * Table entries are of class Cell; a variant of AtomicLong padded - * to reduce cache contention on most processors. Padding is - * overkill for most Atomics because they are usually irregularly - * scattered in memory and thus don't interfere much with each - * other. But Atomic objects residing in arrays will tend to be - * placed adjacent to each other, and so will most often share - * cache lines (with a huge negative performance impact) without - * this precaution. - * - * In part because Cells are relatively large, we avoid creating - * them until they are needed. When there is no contention, all - * updates are made to the base field. Upon first contention (a - * failed CAS on base update), the table is initialized to size 2. - * The table size is doubled upon further contention until - * reaching the nearest power of two greater than or equal to the - * number of CPUS. Table slots remain empty (null) until they are - * needed. - * - * A single spinlock ("busy") is used for initializing and - * resizing the table, as well as populating slots with new Cells. - * There is no need for a blocking lock: When the lock is not - * available, threads try other slots (or the base). During these - * retries, there is increased contention and reduced locality, - * which is still better than alternatives. - * - * Per-thread hash codes are initialized to random values. - * Contention and/or table collisions are indicated by failed - * CASes when performing an update operation (see method - * retryUpdate). Upon a collision, if the table size is less than - * the capacity, it is doubled in size unless some other thread - * holds the lock. If a hashed slot is empty, and lock is - * available, a new Cell is created. Otherwise, if the slot - * exists, a CAS is tried. Retries proceed by "double hashing", - * using a secondary hash (Marsaglia XorShift) to try to find a - * free slot. - * - * The table size is capped because, when there are more threads - * than CPUs, supposing that each thread were bound to a CPU, - * there would exist a perfect hash function mapping threads to - * slots that eliminates collisions. When we reach capacity, we - * search for this mapping by randomly varying the hash codes of - * colliding threads. Because search is random, and collisions - * only become known via CAS failures, convergence can be slow, - * and because threads are typically not bound to CPUS forever, - * may not occur at all. However, despite these limitations, - * observed contention rates are typically low in these cases. - * - * It is possible for a Cell to become unused when threads that - * once hashed to it terminate, as well as in the case where - * doubling the table causes no thread to hash to it under - * expanded mask. We do not try to detect or remove such cells, - * under the assumption that for long-running instances, observed - * contention levels will recur, so the cells will eventually be - * needed again; and for short-lived ones, it does not matter. - */ - - /** - * Padded variant of AtomicLong supporting only raw accesses plus CAS. - * The value field is placed between pads, hoping that the JVM doesn't - * reorder them. - * - * JVM intrinsics note: It would be possible to use a release-only - * form of CAS here, if it were provided. - */ - static final class Cell { - volatile long p0, p1, p2, p3, p4, p5, p6; - volatile long value; - volatile long q0, q1, q2, q3, q4, q5, q6; - Cell(long x) { VALUE_UPDATER.set(this, x); } - - final boolean cas(long cmp, long val) { - return VALUE_UPDATER.compareAndSet(this, cmp, val); - } - - private static final AtomicLongFieldUpdater VALUE_UPDATER = AtomicLongFieldUpdater.newUpdater(Cell.class, "value"); - - } - - /** - * Holder for the thread-local hash code. The code is initially - * random, but may be set to a different value upon collisions. - */ - static final class HashCode { - static final Random rng = new Random(); - int code; - HashCode() { - int h = rng.nextInt(); // Avoid zero to allow xorShift rehash - code = (h == 0) ? 1 : h; - } - } - - /** - * The corresponding ThreadLocal class - */ - static final class ThreadHashCode extends ThreadLocal { - public HashCode initialValue() { return new HashCode(); } - } - - /** - * Static per-thread hash codes. Shared across all instances to - * reduce ThreadLocal pollution and because adjustments due to - * collisions in one table are likely to be appropriate for - * others. - */ - static final ThreadHashCode threadHashCode = new ThreadHashCode(); - - /** Number of CPUS, to place bound on table size */ - static final int NCPU = Runtime.getRuntime().availableProcessors(); - - /** - * Table of cells. When non-null, size is a power of 2. - */ - transient volatile Cell[] cells; - - /** - * Base value, used mainly when there is no contention, but also as - * a fallback during table initialization races. Updated via CAS. - */ - transient volatile long base; - - /** - * Spinlock (locked via CAS) used when resizing and/or creating Cells. - */ - transient volatile int busy; - - /** - * Package-private default constructor - */ - Striped64() { - } - - /** - * CASes the base field. - */ - final boolean casBase(long cmp, long val) { - return BASE_UPDATER.compareAndSet(this, cmp, val); - } - - /** - * CASes the busy field from 0 to 1 to acquire lock. - */ - final boolean casBusy() { - return BUSY_UPDATER.compareAndSet(this, 0, 1); - } - - /** - * Computes the function of current and new value. Subclasses - * should open-code this update function for most uses, but the - * virtualized form is needed within retryUpdate. - * - * @param currentValue the current value (of either base or a cell) - * @param newValue the argument from a user update call - * @return result of the update function - */ - abstract long fn(long currentValue, long newValue); - - /** - * Handles cases of updates involving initialization, resizing, - * creating new Cells, and/or contention. See above for - * explanation. This method suffers the usual non-modularity - * problems of optimistic retry code, relying on rechecked sets of - * reads. - * - * @param x the value - * @param hc the hash code holder - * @param wasUncontended false if CAS failed before call - */ - final void retryUpdate(long x, HashCode hc, boolean wasUncontended) { - int h = hc.code; - boolean collide = false; // True if last slot nonempty - for (;;) { - Cell[] as; Cell a; int n; long v; - if ((as = cells) != null && (n = as.length) > 0) { - if ((a = as[(n - 1) & h]) == null) { - if (busy == 0) { // Try to attach new Cell - Cell r = new Cell(x); // Optimistically create - if (busy == 0 && casBusy()) { - boolean created = false; - try { // Recheck under lock - Cell[] rs; int m, j; - if ((rs = cells) != null && - (m = rs.length) > 0 && - rs[j = (m - 1) & h] == null) { - rs[j] = r; - created = true; - } - } finally { - BUSY_UPDATER.set(this, 0); - } - if (created) - break; - continue; // Slot is now non-empty - } - } - collide = false; - } - else if (!wasUncontended) // CAS already known to fail - wasUncontended = true; // Continue after rehash - else if (a.cas(v = a.value, fn(v, x))) - break; - else if (n >= NCPU || cells != as) - collide = false; // At max size or stale - else if (!collide) - collide = true; - else if (busy == 0 && casBusy()) { - try { - if (cells == as) { // Expand table unless stale - Cell[] rs = new Cell[n << 1]; - for (int i = 0; i < n; ++i) - rs[i] = as[i]; - cells = rs; - } - } finally { - BUSY_UPDATER.set(this, 0); - } - collide = false; - continue; // Retry with expanded table - } - h ^= h << 13; // Rehash - h ^= h >>> 17; - h ^= h << 5; - } - else if (busy == 0 && cells == as && casBusy()) { - boolean init = false; - try { // Initialize table - if (cells == as) { - Cell[] rs = new Cell[2]; - rs[h & 1] = new Cell(x); - cells = rs; - init = true; - } - } finally { - BUSY_UPDATER.set(this, 0); - } - if (init) - break; - } - else if (casBase(v = base, fn(v, x))) - break; // Fall back on using base - } - hc.code = h; // Record index for next time - } - - - /** - * Sets base and all cells to the given value. - */ - final void internalReset(long initialValue) { - Cell[] as = cells; - BASE_UPDATER.set(this, initialValue); - if (as != null) { - int n = as.length; - for (int i = 0; i < n; ++i) { - Cell a = as[i]; - if (a != null) - a.value = initialValue; - } - } - } - - static final AtomicLongFieldUpdater BASE_UPDATER = AtomicLongFieldUpdater.newUpdater(Striped64.class, "base"); - static final AtomicIntegerFieldUpdater BUSY_UPDATER = AtomicIntegerFieldUpdater.newUpdater(Striped64.class, "busy"); - -} \ No newline at end of file Index: rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/modules/ehcache/writebehind/SerializationWriteBehindTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/modules/ehcache/writebehind/SerializationWriteBehindTest.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/modules/ehcache/writebehind/SerializationWriteBehindTest.java (revision 0) @@ -1,92 +0,0 @@ -/* - * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved. - */ -package org.terracotta.modules.ehcache.writebehind; - -import net.sf.ehcache.Cache; -import net.sf.ehcache.Element; - -import org.terracotta.ehcache.tests.AbstractCacheTestBase; -import org.terracotta.ehcache.tests.ClientBase; -import org.terracotta.modules.ehcache.async.AsyncCoordinatorImpl; -import org.terracotta.toolkit.Toolkit; -import org.terracotta.toolkit.concurrent.ToolkitBarrier; -import org.terracotta.toolkit.concurrent.atomic.ToolkitAtomicLong; - -import com.tc.l2.L2DebugLogging.LogLevel; -import com.tc.test.config.model.TestConfig; - -import junit.framework.Assert; - -public class SerializationWriteBehindTest extends AbstractCacheTestBase { - - private static final int NODE_COUNT = 2; - - public SerializationWriteBehindTest(TestConfig testConfig) { - super("basic-writebehind-test.xml", testConfig, App.class, App.class); - configureTCLogging(AsyncCoordinatorImpl.class.getName(), LogLevel.DEBUG); - } - - public static class App extends ClientBase { - - private final ToolkitBarrier barrier; - final ToolkitAtomicLong totalWriteCount; - final ToolkitAtomicLong totalDeleteCount; - - public App(String[] args) { - super(args); - this.barrier = getClusteringToolkit().getBarrier("barrier", NODE_COUNT); - this.totalWriteCount = getClusteringToolkit().getAtomicLong("long1"); - this.totalDeleteCount = getClusteringToolkit().getAtomicLong("long2"); - } - - public static void main(String[] args) { - new App(args).run(); - } - - @Override - protected void runTest(Cache cache, Toolkit clusteringToolkit) throws Throwable { - final int index = barrier.await(); - - WriteBehindCacheWriter writer; - - if (0 == index) { - writer = new WriteBehindCacheWriter("WriteBehindCacheWriter", index, 20L); - cache.registerCacheWriter(writer); - - for (int i = 0; i < 1000; i++) { - cache.putWithWriter(new Element(new SerializationWriteBehindType("key" + i % 200), - new SerializationWriteBehindType("value" + i))); - if (0 == i % 10) { - cache.removeWithWriter(new SerializationWriteBehindType("key" + i % 200 / 10)); - } - } - } else { - writer = new WriteBehindCacheWriter("WriteBehindCacheWriter", index, 10L); - cache.registerCacheWriter(writer); - } - - Thread.sleep(60000); - barrier.await(); - - System.out.println("[Client " + index + " processed " + writer.getWriteCount() + " writes for writer 1]"); - System.out.println("[Client " + index + " processed " + writer.getDeleteCount() + " deletes for writer 1]"); - - totalWriteCount.addAndGet(writer.getWriteCount()); - totalDeleteCount.addAndGet(writer.getDeleteCount()); - - barrier.await(); - - if (0 == index) { - System.out.println("[Clients processed a total of " + totalWriteCount.get() + " writes]"); - System.out.println("[Clients processed a total of " + totalDeleteCount.get() + " deletes]"); - - Assert.assertEquals(1000, totalWriteCount.get()); - Assert.assertEquals(100, totalDeleteCount.get()); - } - - barrier.await(); - } - - } -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/statistics/ExtendedStatisticsMBeanTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/statistics/ExtendedStatisticsMBeanTest.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/statistics/ExtendedStatisticsMBeanTest.java (revision 0) @@ -1,89 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.sf.ehcache.statistics; - -import java.util.EnumSet; -import java.util.Random; -import java.util.concurrent.TimeUnit; - -import junit.framework.Assert; -import net.sf.ehcache.Cache; -import net.sf.ehcache.CacheManager; -import net.sf.ehcache.Element; -import net.sf.ehcache.store.StoreOperationOutcomes; -import net.sf.ehcache.store.StoreOperationOutcomes.PutOutcome; - -import org.junit.Ignore; -import org.junit.Test; - -/* - * Not a real test, just a harness for splunking around mbean test - */ -@Ignore -public class ExtendedStatisticsMBeanTest { - - public void testStupidEnums() { - EnumSet test = EnumSet.allOf(StoreOperationOutcomes.PutOutcome.class); - Assert.assertEquals(test.size(), StoreOperationOutcomes.PutOutcome.values().length); - - // System.out.println(ExtendedStatisticsImpl.ALL_STORE_PUT_OUTCOMES.size()); - } - - @Test - public void testLongTime() throws InterruptedException { - CacheManager cm = CacheManager.getInstance(); - final Cache cache = new Cache("test", 400, null, false, null, true, 120, 120, false, 1000, null); - cm.addCache(cache); - Thread t1 = new Thread() { - @Override - public void run() { - for (int i = 0; i < 100000; i++) { - cache.put(new Element(i, i + 1)); - try { - TimeUnit.MICROSECONDS.sleep(100); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - System.err.println("puts done"); - } - }; - Thread t2 = new Thread() { - @Override - public void run() { - Random rand = new Random(0); - for (int i = 0; i < 10000000; i++) { - cache.get(rand.nextInt(i + 1)); - try { - TimeUnit.MICROSECONDS.sleep(10); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - System.err.println("Gets done"); - } - }; - t1.start(); - t2.start(); - t1.join(); - t2.join(); - Thread.sleep(1000000); - } - -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/writer/TestCacheWriterException.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/writer/TestCacheWriterException.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/writer/TestCacheWriterException.java (revision 0) @@ -1,19 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package net.sf.ehcache.writer; - -public class TestCacheWriterException extends AbstractTestCacheWriter { -} \ No newline at end of file Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/util/LargeSet.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/util/LargeSet.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/util/LargeSet.java (revision 0) @@ -1,31 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.sf.ehcache.util; - -import java.util.Set; - -/** - * Set for holding large entries of set. The purpose is not to iterate through - * all entries for add and remove operations. - * - * @author Nabib El-Rahman - * - * @param - */ -public abstract class LargeSet extends LargeCollection implements Set { -// -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/store/CacheKeySetTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/store/CacheKeySetTest.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/store/CacheKeySetTest.java (revision 0) @@ -1,76 +0,0 @@ -package net.sf.ehcache.store; - -import org.junit.Before; -import org.junit.Test; - -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; - -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.fail; - -/** - * @author Alex Snaps - */ -public class CacheKeySetTest { - - Collection[] keySets = new Collection[] { new HashSet() {{ add(1); add(2); add(3); }}, - new HashSet() {{ add(1); add(4); add(5); }}, - new HashSet() {{ add(1); add(4); add(6); }} }; - CacheKeySet keySet; - - @Before - public void setup() { - keySet = new CacheKeySet( keySets ); - } - - @Test - public void testIteratesOverAllElementsOnce() { - Set keys = new HashSet(); - for (Collection set : keySets) { - keys.addAll(set); - } - assertThat(keys.size(), is(6)); - for (Integer integer : keySet) { - keys.remove(integer); - } - assertThat(keys.isEmpty(), is(true)); - } - - @Test - public void testSizeSumsAllCollections() { - assertThat(keySet.size(), is(9)); - } - - @Test - public void testIsEmptyAccountsForAllKeySets() { - assertThat(keySet.isEmpty(), is(false)); - assertThat(new CacheKeySet(new HashSet()).isEmpty(), is(true)); - assertThat(new CacheKeySet(new HashSet(), new HashSet()).isEmpty(), is(true)); - assertThat(new CacheKeySet(new HashSet(), new HashSet(), new HashSet()).isEmpty(), is(true)); - assertThat(new CacheKeySet(new HashSet(), new HashSet(), new HashSet() {{ add(1); }}).isEmpty(), is(false)); - assertThat(new CacheKeySet(new HashSet(), new HashSet() {{ add(1); }}, new HashSet() {{ add(1); }}).isEmpty(), is(false)); - assertThat(new CacheKeySet(new HashSet(), new HashSet() {{ add(1); }}, new HashSet()).isEmpty(), is(false)); - assertThat(new CacheKeySet(new HashSet() {{ add(1); }}, new HashSet() {{ add(1); }}, new HashSet()).isEmpty(), is(false)); - assertThat(new CacheKeySet(new HashSet() {{ add(1); }}, new HashSet(), new HashSet()).isEmpty(), is(false)); - } - - @Test - public void testContainsIsSupported() { - Set keys = new HashSet(keySet); - for (Integer key : keys) { - assertThat(keySet.contains(key), is(true)); - } - } - - @Test - public void testSupportsEmptyKeySets() { - final CacheKeySet cacheKeySet = new CacheKeySet(); - assertThat(cacheKeySet.isEmpty(), is(true)); - for (Object o : cacheKeySet) { - fail("Shouldn't get anything!"); - } - } -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/store/LfuMemoryStorePerfTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/store/LfuMemoryStorePerfTest.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/store/LfuMemoryStorePerfTest.java (revision 0) @@ -1,193 +0,0 @@ -package net.sf.ehcache.store; - -import net.sf.ehcache.Element; -import net.sf.ehcache.MemoryStorePerfTester; -import net.sf.ehcache.StopWatch; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.lang.reflect.Method; -import java.util.Collection; -import java.util.Date; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -import net.sf.ehcache.Cache; -import net.sf.ehcache.CacheException; -import net.sf.ehcache.CacheManager; -import net.sf.ehcache.config.Configuration; -import static org.junit.Assert.assertTrue; - -/** - * @author Alex Snaps - */ -public class LfuMemoryStorePerfTest extends MemoryStorePerfTester { - - private static final Logger LOG = LoggerFactory.getLogger(LfuMemoryStorePerfTest.class.getName()); - - private static final Method FIND_EVICTION_CANDIDATE; - static { - try { - FIND_EVICTION_CANDIDATE = MemoryStore.class.getDeclaredMethod("findEvictionCandidate", Element.class); - FIND_EVICTION_CANDIDATE.setAccessible(true); - } catch (SecurityException e) { - throw new RuntimeException(e); - } catch (NoSuchMethodException e) { - throw new RuntimeException(e); - } - } - - @Override - protected Cache createCache() throws CacheException { - return new Cache("LfuMemoryStorePerfTest", 12000, MemoryStoreEvictionPolicy.LFU, false, System.getProperty("java.io.tmpdir"), - true, 60, 30, false, 60, null); - } - - /** - * Benchmark to test speed. - * This takes a little longer for LFU than the others. - * Used to take about 7400ms. Now takes 827. - */ - @Test - public void testBenchmarkPutGetSurya() throws Exception { - benchmarkPutGetSuryaTest(9000); - } - - /** - * HashMap - * INFO: done putting: 128ms - * INFO: 15ms - *

- * ConcurrentHashMap - * INFO: done putting: 200ms - * INFO: 117ms - *

- * ConcurrentHashMap - */ -// @Test - public void testSpeedOfIteration() { - StopWatch stopWatch = new StopWatch(); - Map map = new ConcurrentHashMap(100000); - for (int i = 1; i <= 100000; i++) { - map.put(i, i); - } - LOG.info("done putting: " + stopWatch.getElapsedTimeString()); - - Collection collection = map.values(); - for (Object o : collection) { - o.toString(); - } - LOG.info(stopWatch.getElapsedTimeString()); - - } - - /** - * Check we get reasonable results for 2000 entries where entry 0 is accessed once increasing to entry 1999 accessed - * 2000 times. - *

- * 1 to 5000 population, with hit counts ranging from 1 to 500, not selecting lowest half. 5000 tests - *

- * Samples Cost No - * 7 38 99.24% confidence - * 8 27 99.46% confidence - * 9 10 - * 10 11300 4 99.92% confidence - * 12 2 - * 20 11428 0 99.99% confidence - *

- * 1 to 5000 population, with hit counts ranging from 1 to 500, not selecting lowest quarter. 5000 tests - * S No - * 10 291 94.18% confidence - * 20 15 - * 30 11536 1 99.99% confidence - *

- * For those with a statistical background the branch of stats which deals with this is hypothesis testing and - * the Student's T distribution. The higher your sample the greater confidence you can have in a hypothesis, in - * this case whether or not the "lowest" value lies in the bottom half or quarter of the distribution. Adding - * samples rapidly increases confidence but the return from extra sampling rapidly diminishes. - *

- * Cost is not affected much by sample size. Profiling shows that it is the iteration that is causing most of the - * time. If we had access to the array backing Map, all would work very fast. Still, it is fast enough. - *

- * A 99.99% confidence interval can be achieved that the "lowest" element is actually in the bottom quarter of the - * hit count distribution. - * - * @throws java.io.IOException Performance: - * With a sample size of 10: 523ms for 5000 runs = 104 ?s per run - * With a sample size of 30: 628ms for 5000 runs = 125 ?s per run - */ - @Test - public void testLowest() throws Exception { - CacheManager manager = new CacheManager(new Configuration().name("testLowest")); - try { - Cache cache = new Cache("test", 5000, MemoryStoreEvictionPolicy.LFU, false, null, true, 60, 30, false, 60, null); - manager.addCache(cache); - Store store = getStore(cache); - - // Populate the cache with 5000 unaccessed Elements - for (int i = 0; i < 5000; i++) { - store.put(new Element(Integer.valueOf(i), new Date())); - } - - for (int i = 0; i < 10; i++) { - // Add a new Element at the i'th position - Element newElement = new Element(Integer.valueOf(i), new Date()); - store.put(newElement); - - // Hit that Element (i+1) times - this makes it the most hit Element - // in the cache - for (int h = 0; h < (i + 1); h++) { - store.get(Integer.valueOf(i)).updateAccessStatistics(); - } - - // Select an Element for "eviction". - Element element = (Element)FIND_EVICTION_CANDIDATE.invoke(store, new Object[] { null }); - // This shouldn't be the newly added Element as it is the "most hit" - assertTrue(!element.equals(newElement)); - // In fact since the sample size is > 10, the hit count should be 0 - // as we must have selected some of the non hit Elements in our sample. - assertTrue(element.getHitCount() == 0); - } - - // Repeat the hitting procedure above, but for the remaining elements - // This gives a flat distribution of hit counts from 1 to 5000 all with - // equal probability (1 element of each count). - for (int i = 10; i < 5000; i++) { - store.put(new Element(Integer.valueOf(i), new Date())); - for (int h = 0; h < (i + 1); h++) { - store.get(Integer.valueOf(i)).updateAccessStatistics(); - } - } - - long lowestQuartile = 5000 / 4; - - long findTime = 0; - StopWatch stopWatch = new StopWatch(); - int lowestQuartileNotIdentified = 0; - for (int i = 0; i < 5000; i++) { - stopWatch.getElapsedTime(); - // Select an Element for "eviction" - Element e = (Element)FIND_EVICTION_CANDIDATE.invoke(store, new Object[] { null }); - findTime += stopWatch.getElapsedTime(); - long lowest = e.getHitCount(); - // See if it is outside the lowest quartile (i.e. it has an abnormaly - // high hit count). - if (lowest > lowestQuartile) { - LOG.info(e.getKey() + " hit count: " + e.getHitCount() + " lowestQuartile: " + lowestQuartile); - lowestQuartileNotIdentified++; - } - } - - LOG.info("Find time: " + findTime); - // Assert that we can do all this in a reasonable length of time - assertTrue(findTime < 200); - LOG.info("Selections not in lowest quartile: " + lowestQuartileNotIdentified); - // Assert that we didn't see too many eviction candidates from outside - // the lowest quartile. - assertTrue(lowestQuartileNotIdentified + " > 10!!!", lowestQuartileNotIdentified <= 10); - } finally { - manager.shutdown(); - } - } -} Index: rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/ehcache/tests/WriteBehindAtomicitySyncStrongTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/ehcache/tests/WriteBehindAtomicitySyncStrongTest.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/ehcache/tests/WriteBehindAtomicitySyncStrongTest.java (revision 0) @@ -1,14 +0,0 @@ -/* - * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved. - */ -package org.terracotta.ehcache.tests; - -import com.tc.test.config.model.TestConfig; - -public class WriteBehindAtomicitySyncStrongTest extends AbstractWriteBehindAtomicityTestBase { - - public WriteBehindAtomicitySyncStrongTest(TestConfig testConfig) { - super("strong-writebehind-test.xml", testConfig, WriteBehindAtomicityTestClient.class); - } - -} \ No newline at end of file Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/pool/sizeof/AgentLoaderSystemPropTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/pool/sizeof/AgentLoaderSystemPropTest.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/pool/sizeof/AgentLoaderSystemPropTest.java (revision 0) @@ -1,21 +0,0 @@ -package net.sf.ehcache.pool.sizeof; - -import org.junit.Test; - -import static org.hamcrest.CoreMatchers.notNullValue; -import static org.junit.Assert.assertThat; - -/** - * @author Alex Snaps - */ -public class AgentLoaderSystemPropTest { - - @Test - public void testLoadsAgentIntoSystemPropsWhenRequired() { - System.setProperty("net.sf.ehcache.sizeof.agent.instrumentationSystemProperty", "true"); - AgentLoader.loadAgent(); - if(AgentLoader.agentIsAvailable()) { - assertThat(System.getProperties().get("net.sf.ehcache.sizeof.agent.instrumentation"), notNullValue()); - } - } -} Index: rctags/ehcache-2.10.8.0.7/system-tests/src/test/resources/xaresource-test.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/system-tests/src/test/resources/xaresource-test.xml (revision 11085) +++ rctags/ehcache-2.10.8.0.7/system-tests/src/test/resources/xaresource-test.xml (revision 0) @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - - - - - - Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/transaction/local/TransactionListener.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/transaction/local/TransactionListener.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/transaction/local/TransactionListener.java (revision 0) @@ -1,40 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package net.sf.ehcache.transaction.local; - -/** - * A listener interface to get called back when a transaction is being terminated - * - * @author Ludovic Orban - */ -public interface TransactionListener { - - /** - * This method gets called right before the transaction is committed - */ - void beforeCommit(); - - /** - * This method gets called right after the transaction is committed - */ - void afterCommit(); - - /** - * This method gets called right after the transaction is rolled back - */ - void afterRollback(); - -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/config/ConfigurationFactory.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/config/ConfigurationFactory.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/config/ConfigurationFactory.java (revision 0) @@ -1,240 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.sf.ehcache.config; - -import net.sf.ehcache.CacheException; -import net.sf.ehcache.util.ClassLoaderUtil; - -import javax.xml.parsers.SAXParser; -import javax.xml.parsers.SAXParserFactory; -import java.io.BufferedInputStream; -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.Reader; -import java.io.StringReader; -import java.net.URL; -import java.util.HashSet; -import java.util.Set; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.xml.sax.InputSource; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import net.sf.ehcache.config.generator.ConfigurationSource; - -/** - * A utility class which configures beans from XML, using reflection. - * - * @author Greg Luck - * @version $Id: ConfigurationFactory.java 10789 2018-04-26 02:08:13Z adahanne $ - */ -public final class ConfigurationFactory { - - private static final Logger LOG = LoggerFactory.getLogger(ConfigurationFactory.class.getName()); - - private static final String DEFAULT_CLASSPATH_CONFIGURATION_FILE = "/ehcache.xml"; - private static final String FAILSAFE_CLASSPATH_CONFIGURATION_FILE = "/ehcache-failsafe.xml"; - - /** - * Constructor. - */ - private ConfigurationFactory() { - - } - - /** - * Configures a bean from an XML file. - */ - public static Configuration parseConfiguration(final File file) throws CacheException { - if (file == null) { - throw new CacheException("Attempt to configure ehcache from null file."); - } - - LOG.debug("Configuring ehcache from file: {}", file); - Configuration configuration = null; - InputStream input = null; - try { - input = new BufferedInputStream(new FileInputStream(file)); - configuration = parseConfiguration(input); - } catch (Exception e) { - throw new CacheException("Error configuring from " + file + ". Initial cause was " + e.getMessage(), e); - } finally { - try { - if (input != null) { - input.close(); - } - } catch (IOException e) { - LOG.error("IOException while closing configuration input stream. Error was " + e.getMessage()); - } - } - configuration.setSource(ConfigurationSource.getConfigurationSource(file)); - return configuration; - } - - /** - * Configures a bean from an XML file available as an URL. - */ - public static Configuration parseConfiguration(final URL url) throws CacheException { - LOG.debug("Configuring ehcache from URL: {}", url); - Configuration configuration; - InputStream input = null; - try { - input = url.openStream(); - configuration = parseConfiguration(input); - } catch (Exception e) { - throw new CacheException("Error configuring from " + url + ". Initial cause was " + e.getMessage(), e); - } finally { - try { - if (input != null) { - input.close(); - } - } catch (IOException e) { - LOG.error("IOException while closing configuration input stream. Error was " + e.getMessage()); - } - } - configuration.setSource(ConfigurationSource.getConfigurationSource(url)); - return configuration; - } - - /** - * Configures a bean from an XML file in the classpath. - */ - public static Configuration parseConfiguration() throws CacheException { - ClassLoader standardClassloader = Thread.currentThread().getContextClassLoader(); - URL url = null; - if (standardClassloader != null) { - url = standardClassloader.getResource(DEFAULT_CLASSPATH_CONFIGURATION_FILE); - } - if (url == null) { - url = ConfigurationFactory.class.getResource(DEFAULT_CLASSPATH_CONFIGURATION_FILE); - } - if (url != null) { - LOG.debug("Configuring ehcache from ehcache.xml found in the classpath: " + url); - } else { - url = ConfigurationFactory.class.getResource(FAILSAFE_CLASSPATH_CONFIGURATION_FILE); - - LOG.warn("No configuration found. Configuring ehcache from ehcache-failsafe.xml " - + " found in the classpath: {}", url); - - } - Configuration configuration = parseConfiguration(url); - configuration.setSource(ConfigurationSource.getConfigurationSource()); - return configuration; - } - - /** - * Configures a bean from an XML input stream. - */ - public static Configuration parseConfiguration(final InputStream inputStream) throws CacheException { - - LOG.debug("Configuring ehcache from InputStream"); - - Configuration configuration = new Configuration(); - try { - InputStream translatedInputStream = translateSystemProperties(inputStream); - final SAXParser parser = SAXParserFactory.newInstance().newSAXParser(); - final BeanHandler handler = new BeanHandler(configuration); - parser.parse(translatedInputStream, handler); - } catch (Exception e) { - throw new CacheException("Error configuring from input stream. Initial cause was " + e.getMessage(), e); - } - configuration.setSource(ConfigurationSource.getConfigurationSource(inputStream)); - return configuration; - } - - /** - * Configures a cache bean from a string of XML. - */ - public static CacheConfiguration parseCacheConfiguration(String xmlString) throws CacheException { - CacheConfiguration cacheConfiguration = new CacheConfiguration(); - try { - InputSource source = new InputSource(new StringReader(xmlString)); - final SAXParser parser = SAXParserFactory.newInstance().newSAXParser(); - final BeanHandler handler = new BeanHandler(cacheConfiguration); - parser.parse(source, handler); - } catch (Exception e) { - throw new CacheException("Error configuring from input stream. Initial cause was " + e.getMessage(), e); - } - return cacheConfiguration; - } - - /** - * Translates system properties which can be added as tokens to the config file using ${token} syntax. - *

- * So, if the config file contains a character sequence "multicastGroupAddress=${multicastAddress}", and there is a system property - * multicastAddress=230.0.0.12 then the translated sequence becomes "multicastGroupAddress=230.0.0.12" - * - * @param inputStream - * @return a translated stream - */ - private static InputStream translateSystemProperties(InputStream inputStream) throws IOException { - - StringBuilder sb = new StringBuilder(); - int c; - Reader reader = new InputStreamReader(inputStream, "UTF-8"); - while ((c = reader.read()) != -1) { - sb.append((char) c); - } - String configuration = sb.toString(); - - Set tokens = extractPropertyTokens(configuration); - for (Object tokenObject : tokens) { - String token = (String) tokenObject; - String leftTrimmed = token.replaceAll("\\$\\{", ""); - String trimmedToken = leftTrimmed.replaceAll("\\}", ""); - - String property = System.getProperty(trimmedToken); - if (property == null) { - LOG.debug("Did not find a system property for the " + token + - " token specified in the configuration.Replacing with \"\""); - } else { - //replaceAll by default clobbers \ and $ - String propertyWithQuotesProtected = Matcher.quoteReplacement(property); - configuration = configuration.replaceAll("\\$\\{" + trimmedToken + "\\}", propertyWithQuotesProtected); - - LOG.debug("Found system property value of " + property + " for the " + token + - " token specified in the configuration."); - } - } - return new ByteArrayInputStream(configuration.getBytes("UTF-8")); - } - - /** - * Extracts properties of the form ${...} - * - * @param sourceDocument the source document - * @return a Set of properties. So, duplicates are only counted once. - */ - static Set extractPropertyTokens(String sourceDocument) { - Set propertyTokens = new HashSet(); - Pattern pattern = Pattern.compile("\\$\\{.+?\\}"); - Matcher matcher = pattern.matcher(sourceDocument); - while (matcher.find()) { - String token = matcher.group(); - propertyTokens.add(token); - } - return propertyTokens; - } - - -} Index: rctags/ehcache-2.10.8.0.7/ehcache-search-parser/src/main/java/net/sf/ehcache/search/parser/ModelElement.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-search-parser/src/main/java/net/sf/ehcache/search/parser/ModelElement.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-search-parser/src/main/java/net/sf/ehcache/search/parser/ModelElement.java (revision 0) @@ -1,23 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.sf.ehcache.search.parser; - -public interface ModelElement { - - public T asEhcacheObject(ClassLoader loader); - -} Index: rctags/ehcache-2.10.8.0.7/ehcache/src/test/java/net/sf/ehcache/terracotta/upgradability/serialization/DefaultAsyncConfigSerializationTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache/src/test/java/net/sf/ehcache/terracotta/upgradability/serialization/DefaultAsyncConfigSerializationTest.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache/src/test/java/net/sf/ehcache/terracotta/upgradability/serialization/DefaultAsyncConfigSerializationTest.java (revision 0) @@ -1,43 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.sf.ehcache.terracotta.upgradability.serialization; - -import java.io.IOException; -import java.util.Comparator; -import org.junit.Test; -import org.terracotta.modules.ehcache.async.DefaultAsyncConfig; - -import static org.terracotta.upgradability.serialization.SerializationUpgradabilityTesting.validateSerializedForm; - -/** - * - * @author cdennis - */ -public class DefaultAsyncConfigSerializationTest { - - private static final Comparator COMPARATOR = new Comparator() { - @Override - public int compare(DefaultAsyncConfig o1, DefaultAsyncConfig o2) { - return 0; - } - }; - - @Test - public void testBasic() throws IOException, ClassNotFoundException { - validateSerializedForm((DefaultAsyncConfig) DefaultAsyncConfig.getInstance(), COMPARATOR, "serializedforms/DefaultAsyncConfigSerializationTest.testBasic.ser"); - } -} Index: rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/net/sf/ehcache/management/resource/services/CacheResourceServiceImplTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/net/sf/ehcache/management/resource/services/CacheResourceServiceImplTest.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/net/sf/ehcache/management/resource/services/CacheResourceServiceImplTest.java (revision 0) @@ -1,683 +0,0 @@ -package net.sf.ehcache.management.resource.services; - -import static com.jayway.restassured.RestAssured.expect; -import static org.hamcrest.CoreMatchers.allOf; -import static org.hamcrest.CoreMatchers.containsString; -import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.greaterThan; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.nullValue; -import net.sf.ehcache.Cache; -import net.sf.ehcache.CacheManager; -import net.sf.ehcache.Element; -import net.sf.ehcache.config.CacheConfiguration; -import net.sf.ehcache.config.Configuration; -import net.sf.ehcache.config.ManagementRESTServiceConfiguration; -import net.sf.ehcache.config.TerracottaClientConfiguration; -import net.sf.ehcache.config.TerracottaConfiguration; -import net.sf.ehcache.management.resource.CacheEntity; - -import org.hamcrest.Matchers; -import org.junit.BeforeClass; -import org.junit.Test; - -import com.jayway.restassured.http.ContentType; - -import java.util.HashMap; -import java.util.Map; - -/** - * @author: Anthony Dahanne - * The aim of this test is to check via HTTP that the ehcache standalone agent /tc-management-api/agents/cacheManagers/caches endpoint - * works fine - */ -public class CacheResourceServiceImplTest extends ResourceServiceImplITHelper { - - protected static final String EXPECTED_RESOURCE_LOCATION = "{baseUrl}/tc-management-api/agents{agentIds}/cacheManagers{cmIds}/caches{cacheIds}"; - - @BeforeClass - public static void setUpCluster() throws Exception { - setUpCluster(CacheResourceServiceImplTest.class); - } - - @Test - /** - * - GET the list of caches - * - * @throws Exception - */ - public void getCachesTest() throws Exception { - /* - [ - { - "version": null, - "agentId": "embedded", - "name": "testCache2", - "cacheManagerName": "testCacheManagerProgrammatic", - "attributes": { - "OnDiskSize": 1000, - "CacheOnDiskHitRate": 0, - "MostRecentRejoinTimestampMillisSample": 0, - "LocalOffHeapSizeInBytesSample": 0, - "LocalHeapSizeInBytes": 247920, - "Searchable": false, - "CacheHitMostRecentSample": 0, - "MostRecentRejoinTimeStampMillis": 0, - "CacheInMemoryHitRate": 0, - "NonStopFailureSample": 0, - "CacheHitOffHeapMostRecentSample": 0, - "NonstopTimeoutRatio": 0, - "CacheClusterOnlineSample": 0, - "NonStopTimeoutSample": 0, - "NonStopFailureRate": 0, - "LocalHeapCountBased": false, - "CacheElementPutSample": 0, - "LoggingEnabled": false, - "CacheHitRatioMostRecentSample": 0, - "MaxBytesLocalHeap": 0, - "XaRecoveredCount": 0, - "NonStopSuccessRate": 0, - "EvictedCount": 0, - "MinGetTimeNanos": null, - "NodeBulkLoadEnabled": false, - "MaxBytesLocalOffHeapAsString": "0", - "CacheSearchRate": 0, - "CacheElementRemovedMostRecentSample": 0, - "InMemorySize": 1000, - "WriterMaxQueueSize": 0, - "TerracottaConsistency": "na", - "NonStopRejoinTimeoutSample": 0, - "CacheHitInMemoryMostRecentSample": 0, - "CacheElementEvictedSample": 0, - "WriterConcurrency": 1, - "CacheMissInMemoryMostRecentSample": 0, - "CacheHitRatioSample": 0, - "LocalDiskSize": 1000, - "OverflowToDisk": true, - "CacheMissMostRecentSample": 0, - "LocalOffHeapSize": 0, - "UpdateCount": 0, - "InMemoryMissCount": 0, - "CacheMissExpiredMostRecentSample": 0, - "CachePutRate": 0, - "OffHeapMissCount": 0, - "CacheHitOnDiskMostRecentSample": 0, - "CacheMissOffHeapMostRecentSample": 0, - "CacheOnDiskMissRate": 0, - "DiskPersistent": false, - "MemoryStoreEvictionPolicy": "LRU", - "LocalHeapSize": 1000, - "TimeToIdleSeconds": 0, - "AverageGetTime": 0, - "WriterQueueLength": 0, - "NonStopFailureMostRecentSample": 0, - "CacheMissOnDiskSample": 0, - "TransactionCommitRate": 0, - "NonStopSuccessCount": 0, - "CacheElementExpiredSample": 0, - "CacheClusterOfflineMostRecentSample": 0, - "InMemoryHitCount": 0, - "XaRollbackCount": 0, - "SizeSample": 1000, - "CacheInMemoryMissRate": 0, - "CacheClusterRejoinMostRecentSample": 0, - "DiskExpiryThreadIntervalSeconds": 120, - "NonStopFailureCount": 0, - "AverageSearchTimeNanos": 0, - "CacheMissCount": 0, - "CacheMissOffHeapSample": 0, - "NonStopRejoinTimeoutRate": 0, - "MaxBytesLocalOffHeap": 0, - "CacheClusterOfflineSample": 0, - "CacheClusterOnlineCount": 0, - "CacheXaCommitsSample": 0, - "MaxBytesLocalHeapAsString": "0", - "CacheClusterOnlineMostRecentSample": 0, - "CacheMissRate": 0, - "SearchesPerSecondSample": 0, - "CacheElementPutMostRecentSample": 0, - "CacheClusterOfflineCount": 0, - "WriterQueueLengthSample": 0, - "CacheElementEvictedMostRecentSample": 0, - "HasWriteBehindWriter": false, - "LocalHeapSizeInBytesSample": 247920, - "MaxBytesLocalDiskAsString": "0", - "OverflowToOffHeap": false, - "CacheMissOnDiskMostRecentSample": 0, - "CacheElementExpiredMostRecentSample": 0, - "LocalDiskSizeSample": 1000, - "CacheRemoveRate": 0, - "CacheElementUpdatedMostRecentSample": 0, - "CacheMissNotFoundMostRecentSample": 0, - "LocalDiskSizeInBytes": 246780, - "AverageGetTimeNanosMostRecentSample": 0, - "MaxEntriesLocalHeap": 0, - "CacheOffHeapMissRate": 0, - "RemoteSizeSample": 0, - "ClusterBulkLoadEnabled": null, - "XaCommitCount": 0, - "Transactional": false, - "CacheMissCountExpired": 0, - "CacheUpdateRate": 0, - "CacheElementUpdatedSample": 0, - "PinnedToStore": "na", - "Size": 1000, - "TerracottaClustered": false, - "TransactionRollbackRate": 0, - "CacheHitInMemorySample": 0, - "LocalHeapSizeSample": 1000, - "NonStopSuccessSample": 0, - "CacheMissInMemorySample": 0, - "NonStopTimeoutRate": 0, - "CacheMissNotFoundSample": 0, - "TimeToLiveSeconds": 0, - "AverageGetTimeSample": 0, - "CacheHitCount": 0, - "MaxBytesLocalDisk": 0, - "CacheHitSample": 0, - "ExpiredCount": 0, - "NonStopRejoinTimeoutCount": 0, - "CacheXaRollbacksSample": 0, - "CacheMissSample": 0, - "PutCount": 1000, - "AverageSearchTimeSample": 0, - "CacheClusterRejoinSample": 0, - "Enabled": true, - "CacheXaCommitsMostRecentSample": 0, - "CacheXaRollbacksMostRecentSample": 0, - "CacheHitOffHeapSample": 0, - "CacheOffHeapHitRate": 0, - "RemovedCount": 0, - "CacheHitOnDiskSample": 0, - "CacheClusterRejoinCount": 0, - "AverageSearchTime": 0, - "LocalOffHeapSizeInBytes": 0, - "MaxEntriesLocalDisk": 0, - "MaxGetTimeNanos": null, - "MaxElementsOnDisk": 0, - "CacheHitRate": 0, - "LocalOffHeapSizeSample": 0, - "OffHeapHitCount": 0, - "CacheExpirationRate": 0, - "Pinned": false, - "Eternal": false, - "NonStopTimeoutMostRecentSample": 0, - "CacheHitRatio": 0, - "OffHeapSize": 0, - "CacheEvictionRate": 0, - "NonStopTimeoutCount": 0, - "SearchesPerSecond": 0, - "MaxEntriesInCache": 0, - "CacheMissExpiredSample": 0, - "LocalDiskSizeInBytesSample": 246780, - "Status": "STATUS_ALIVE", - "OnDiskMissCount": 0, - "NonStopRejoinTimeoutMostRecentSample": 0, - "OnDiskHitCount": 0, - "NonStopSuccessMostRecentSample": 0, - "PersistenceStrategy": "", - "AverageGetTimeNanos": 0, - "CacheElementRemovedSample": 0 - } - }, -] - */ - - - // I need a cacheManager not clustered - CacheManager standaloneCacheManager = createStandaloneCacheManagerARC(); - Cache cacheStandalone = standaloneCacheManager.getCache("testCacheStandaloneARC"); - - - for (int i=0; i<1000 ; i++) { - cacheStandalone.put(new Element("key" + i, "value" + i)); - } - - String agentsFilter = ""; - String cmsFilter = ""; - String cachesFilter = ""; - - - expect().contentType(ContentType.JSON) - .body("size()", is(2)) - .body("find { it.name == 'testCache' }.agentId", equalTo("embedded")) - .rootPath("find { it.name == 'testCacheStandaloneARC' }") - .body("agentId", equalTo("embedded")) - .body("cacheManagerName", equalTo("testCacheManagerStandaloneARC")) - .body("attributes.LocalHeapSizeInBytes", greaterThan(0)) - .body("attributes.InMemorySize", equalTo(1000)) - .body("attributes.LocalDiskSize", greaterThan(0)) - .body("attributes.LocalHeapSize", equalTo(1000)) - .body("attributes.SizeSample", equalTo(1000)) - .body("attributes.DiskExpiryThreadIntervalSeconds", equalTo(120)) - .body("attributes.LocalHeapSizeInBytesSample", greaterThan(0)) - .body("attributes.LocalDiskSizeSample", greaterThan(0)) - .body("attributes.LocalDiskSizeInBytes", greaterThan(0)) - .body("attributes.Size", equalTo(1000)) - .body("attributes.LocalHeapSizeSample", equalTo(1000)) - .body("attributes.PutCount", equalTo(1000)) - .body("attributes.LocalDiskSizeInBytesSample", greaterThan(0)) - .body("attributes.Status", equalTo("STATUS_ALIVE")) - .statusCode(200) - .when().get(EXPECTED_RESOURCE_LOCATION, STANDALONE_BASE_URL, agentsFilter,cmsFilter, cachesFilter); - - - cachesFilter = ";names=testCacheStandaloneARC"; - // we filter to return only the attribute CacheNames, and working only on the testCache2 Cache - expect().contentType(ContentType.JSON) - .body("get(0).agentId", equalTo("embedded")) - .body("get(0).name", equalTo("testCacheStandaloneARC")) - .body("get(0).cacheManagerName", equalTo("testCacheManagerStandaloneARC")) - .body("get(0).attributes.PutCount", equalTo(1000)) - .body("get(0).attributes.Size", equalTo(1000)) - .body("get(0).attributes.LocalHeapSizeSample", nullValue()) - .body("size()",is(1)) - .statusCode(200) - .given() - .queryParam("show", "Size") - .queryParam("show", "PutCount") - .when().get(EXPECTED_RESOURCE_LOCATION, STANDALONE_BASE_URL, agentsFilter,cmsFilter, cachesFilter); - - standaloneCacheManager.removeAllCaches(); - standaloneCacheManager.shutdown(); - - } - - @Test - /** - * - PUT an updated CacheEntity - * - * @throws Exception - */ - public void updateCachesTest__FailWhenNotSpecifyingACache() throws Exception { - // you have to specify a cache when doing mutation - CacheEntity cacheManagerEntity = new CacheEntity(); - Map attributes = new HashMap(); - attributes.put("MaxEntriesLocalHeap",20000); - attributes.put("Enabled", Boolean.FALSE); - cacheManagerEntity.getAttributes().putAll(attributes); - String agentsFilter = ""; - String cmsFilter = ""; - String cachesFilter = ""; - - expect().statusCode(400) - .body("details", equalTo("")) - .body("error", equalTo("No cache specified. Unsafe requests must specify a single cache name.")) - .given() - .contentType(ContentType.JSON) - .body(cacheManagerEntity) - .when().put(EXPECTED_RESOURCE_LOCATION, STANDALONE_BASE_URL, agentsFilter,cmsFilter, cachesFilter); - - - cachesFilter = ";names=testCache"; - expect().statusCode(400) - .body("details", equalTo("")) - .body("error", equalTo("No cache manager specified. Unsafe requests must specify a single cache manager name.")) - .given() - .contentType(ContentType.JSON) - .body(cacheManagerEntity) - .when().put(EXPECTED_RESOURCE_LOCATION, STANDALONE_BASE_URL, agentsFilter,cmsFilter, cachesFilter); - - cmsFilter = ";names=testCacheManager"; - cachesFilter = ";names=boups"; - expect().statusCode(400) - .body("details", equalTo("Cache not found !")) - .body("error", equalTo("Failed to create or update cache")) - .given() - .contentType(ContentType.JSON) - .body(cacheManagerEntity) - .when().put(EXPECTED_RESOURCE_LOCATION, STANDALONE_BASE_URL, agentsFilter,cmsFilter, cachesFilter); - - cmsFilter = ";names=pif"; - cachesFilter = ";names=testCache"; - expect().statusCode(400) - .body("details", equalTo("CacheManager not found !")) - .body("error", equalTo("Failed to create or update cache")) - .given() - .contentType(ContentType.JSON) - .body(cacheManagerEntity) - .when().put(EXPECTED_RESOURCE_LOCATION, STANDALONE_BASE_URL, agentsFilter,cmsFilter, cachesFilter); - - cmsFilter = ""; - cachesFilter = ""; - // we check nothing has changed - expect().contentType(ContentType.JSON) - .body("get(0).agentId", equalTo("embedded")) - .body("get(0).name", equalTo("testCache")) - .body("get(0).attributes.MaxEntriesLocalHeap",equalTo(10000) ) - .body("get(0).attributes.Enabled", equalTo(Boolean.TRUE)) - .statusCode(200) - .when().get(EXPECTED_RESOURCE_LOCATION, STANDALONE_BASE_URL, agentsFilter,cmsFilter, cachesFilter); - } - - @Test - /** - * - PUT an updated CacheEntity - * - * Those are the mutable attributes from the rest agent, followed by Gary's comments - * ENABLED_ATTR: the user can change directly from the management panel - * LOGGING_ENABLED: just never had this in the DevConsole and nobody's ever asked for it - * BULK_LOAD_ENABLED: will probably be adding this with the management panel overhaul - * MAX_ENTRIES_LOCAL_HEAP: we do support this, but not when you've already specified MAX_BYTES_LOCAL_HEAP - * MAX_ELEMENTS_ON_DISK: same as above, except you've already specified MAX_BYTES_LOCAL_HEAP - * MAX_ENTRIES_IN_CACHE: if it's a Terracotta-clustered cache, we support this - * MAX_BYTES_LOCAL_DISK_STRING - * MAX_BYTES_LOCAL_HEAP_STRING - * TIME_TO_IDLE_SEC - * TIME_TO_LIVE_SEC - * - * @throws Exception - */ - public void updateCachesTest() throws Exception { - - // I need a cacheManager not clustered - CacheManager standaloneCacheManager = createStandaloneCacheManager(); - - // you have to specify a cache when doing mutation - CacheEntity cacheEntity = new CacheEntity(); - Map attributes = new HashMap(); - attributes.put("MaxEntriesInCache", 30000); - attributes.put("MaxEntriesLocalHeap",20000); - attributes.put("LoggingEnabled", Boolean.TRUE); - attributes.put("MaxElementsOnDisk",40000); - attributes.put("TimeToIdleSeconds", 20); - attributes.put("TimeToLiveSeconds", 43); - attributes.put("Enabled", Boolean.FALSE); - - - String agentsFilter = ""; - String cmsFilter = ";names=testCacheManagerStandalone"; - String cachesFilter = ";names=testCacheStandalone"; - cacheEntity.getAttributes().putAll(attributes); - expect().statusCode(204).log().ifStatusCodeIsEqualTo(400) - .given() - .contentType(ContentType.JSON) - .body(cacheEntity) - .when().put(EXPECTED_RESOURCE_LOCATION, STANDALONE_BASE_URL, agentsFilter,cmsFilter, cachesFilter); - - - cmsFilter = ""; - // we check the properties were changed - expect().contentType(ContentType.JSON) - .body("get(0).agentId", equalTo("embedded")) - .body("get(0).name", equalTo("testCacheStandalone")) - .body("get(0).attributes.MaxEntriesInCache", equalTo(30000)) - .body("get(0).attributes.MaxEntriesLocalHeap", equalTo(20000)) - .body("get(0).attributes.LoggingEnabled", equalTo(Boolean.TRUE)) - .body("get(0).attributes.MaxElementsOnDisk", equalTo(40000)) - .body("get(0).attributes.TimeToIdleSeconds", equalTo(20)) - .body("get(0).attributes.TimeToLiveSeconds", equalTo(43)) - .body("get(0).attributes.Enabled", equalTo(Boolean.FALSE)) - .statusCode(200) - .when().get(EXPECTED_RESOURCE_LOCATION, STANDALONE_BASE_URL, agentsFilter,cmsFilter, cachesFilter); - - - standaloneCacheManager.removeAllCaches(); - standaloneCacheManager.shutdown(); - // I need another cache that does not have set MaxBytesLocalHeap nor MaxBytesLocalDisk - CacheManager cacheManagerNew = getCacheManagerNew(); - - cacheEntity = new CacheEntity(); - attributes = new HashMap(); - attributes.put("MaxBytesLocalDiskAsString", "30M"); - attributes.put("MaxBytesLocalHeapAsString","20M"); - cacheEntity.getAttributes().putAll(attributes); - - cmsFilter = ";names=cacheManagerNew"; - cachesFilter = ";names=CacheNew"; - - expect().log().ifStatusCodeIsEqualTo(400) - .statusCode(204) - .given() - .contentType(ContentType.JSON) - .body(cacheEntity) - .when().put(EXPECTED_RESOURCE_LOCATION, STANDALONE_BASE_URL, agentsFilter,cmsFilter, cachesFilter); - - cmsFilter = ""; - cachesFilter = ";names=CacheNew"; - // we check the properties were changed - expect().contentType(ContentType.JSON) - .body("get(0).agentId", equalTo("embedded")) - .body("get(0).name", equalTo("CacheNew")) - .body("get(0).attributes.MaxBytesLocalDiskAsString", equalTo("30M")) - .body("get(0).attributes.MaxBytesLocalHeapAsString", equalTo("20M")) - .statusCode(200) - .when().get(EXPECTED_RESOURCE_LOCATION, STANDALONE_BASE_URL, agentsFilter,cmsFilter, cachesFilter); - cacheManagerNew.removeAllCaches(); - cacheManagerNew.shutdown(); - - - } - - @Test - /** - * - PUT an updated CacheEntity - * - * Those are the mutable attributes from the rest agent, followed by Gary's comments - * ENABLED_ATTR: the user can change directly from the management panel - * LOGGING_ENABLED: just never had this in the DevConsole and nobody's ever asked for it - * BULK_LOAD_ENABLED: will probably be adding this with the management panel overhaul - * MAX_ENTRIES_LOCAL_HEAP: we do support this, but not when you've already specified MAX_BYTES_LOCAL_HEAP - * MAX_ELEMENTS_ON_DISK: same as above, except you've already specified MAX_BYTES_LOCAL_HEAP - * MAX_ENTRIES_IN_CACHE: if it's a Terracotta-clustered cache, we support this - * MAX_BYTES_LOCAL_DISK_STRING - * MAX_BYTES_LOCAL_HEAP_STRING - * TIME_TO_IDLE_SEC - * TIME_TO_LIVE_SEC - * - * @throws Exception - */ - public void updateCachesTest__clustered() throws Exception { - - - CacheManager clusteredCacheManager = createClusteredCacheManager(); - - try { - // you have to specify a cache when doing mutation - CacheEntity cacheEntity = new CacheEntity(); - Map attributes = new HashMap(); - attributes.put("MaxEntriesInCache", 30000); - attributes.put("MaxEntriesLocalHeap", 20000); - attributes.put("LoggingEnabled", Boolean.TRUE); - attributes.put("TimeToIdleSeconds", 20); - attributes.put("TimeToLiveSeconds", 43); - attributes.put("NodeBulkLoadEnabled", Boolean.TRUE); //ONLY FOR CLUSTERED !!! - attributes.put("Enabled", Boolean.FALSE); - - final String agentsFilter = ";ids=" + clusteredCacheManagerAgentId; - String cmsFilter = ";names=testCacheManagerClustered"; - String cachesFilter = ";names=testCacheClustered"; - cacheEntity.getAttributes().putAll(attributes); - expect().statusCode(204).log().ifStatusCodeIsEqualTo(400) - .given() - .contentType(ContentType.JSON) - .body(cacheEntity) - .when().put(EXPECTED_RESOURCE_LOCATION, CLUSTERED_BASE_URL, agentsFilter, cmsFilter, cachesFilter); - - - cmsFilter = ""; - // we check the properties were changed - expect().contentType(ContentType.JSON) - .body("get(0).agentId", equalTo(clusteredCacheManagerAgentId)) - .body("get(0).name", equalTo("testCacheClustered")) - .body("get(0).attributes.MaxEntriesInCache", equalTo(30000)) - .body("get(0).attributes.MaxEntriesLocalHeap", equalTo(20000)) - .body("get(0).attributes.LoggingEnabled", equalTo(Boolean.TRUE)) - .body("get(0).attributes.NodeBulkLoadEnabled", equalTo(Boolean.TRUE)) //ONLY FOR CLUSTERED !!! - .body("get(0).attributes.ClusterBulkLoadEnabled", equalTo(Boolean.TRUE)) //ONLY FOR CLUSTERED !!! - .body("get(0).attributes.TimeToIdleSeconds", equalTo(20)) - .body("get(0).attributes.TimeToLiveSeconds", equalTo(43)) - .body("get(0).attributes.Enabled", equalTo(Boolean.FALSE)) - .statusCode(200) - .when().get(EXPECTED_RESOURCE_LOCATION, CLUSTERED_BASE_URL, agentsFilter, cmsFilter, cachesFilter); - } finally { - clusteredCacheManager.shutdown(); - } - - } - - - @Test - /** - * - PUT an updated CacheEntity, with attributes not allowed - * only 6 attributes are supported (cf previosu test), the others are forbidden because we do not allow them to be updated - * @throws Exception - */ - public void updateCachesTest__FailWhenMutatingForbiddenAttributes() throws Exception { - - CacheEntity cacheManagerEntity = new CacheEntity(); - cacheManagerEntity.setName("superName"); - Map attributes = new HashMap(); - attributes.put("LocalOffHeapSizeInBytes","20000"); - attributes.put("Pinned", Boolean.TRUE); - cacheManagerEntity.getAttributes().putAll(attributes); - - String agentsFilter = ""; - String cmsFilter = ";names=testCacheManager"; - String cachesFilter = ";names=testCache"; - - expect().statusCode(400) - .body("details", allOf(containsString("You are not allowed to update those attributes : name LocalOffHeapSizeInBytes Pinned . Only"), - containsString("TimeToIdleSeconds"), containsString("Enabled"), containsString("MaxBytesLocalDiskAsString"), - containsString("MaxBytesLocalHeapAsString"), containsString("MaxElementsOnDisk"), containsString("TimeToLiveSeconds"), - containsString("MaxEntriesLocalHeap"), containsString("LoggingEnabled"), containsString("NodeBulkLoadEnabled"), - containsString("MaxEntriesInCache"), Matchers.containsString(" can be updated for a Cache."))) - .body("error", equalTo("Failed to create or update cache")) - .given() - .contentType(ContentType.JSON) - .body(cacheManagerEntity) - .when().put(EXPECTED_RESOURCE_LOCATION, STANDALONE_BASE_URL, agentsFilter, cmsFilter, cachesFilter); - - cmsFilter =""; - // we check nothing has changed - expect().contentType(ContentType.JSON) - .body("get(0).agentId", equalTo("embedded")) - .body("get(0).name", equalTo("testCache")) - .body("get(0).attributes.LocalOffHeapSizeInBytes", equalTo(0)) - .body("get(0).attributes.Pinned", equalTo(Boolean.FALSE)) - .body("size()",is(1)) - .statusCode(200) - .when().get(EXPECTED_RESOURCE_LOCATION, STANDALONE_BASE_URL, agentsFilter,cmsFilter, cachesFilter); - } - - - - @Test - /** - * - PUT an updated CacheEntity - * @throws Exception - */ - public void updateCachesTest__CacheManagerDoesNotExist() throws Exception { - - - String agentsFilter = ""; - String cmsFilter = ";names=cachemanagerDoesNotExist"; - String cachesFilter = ";names=testCache"; - - CacheEntity cacheEntity = new CacheEntity(); - expect().statusCode(400) - .body("details", equalTo("CacheManager not found !")) - .body("error", equalTo("Failed to create or update cache")) - .given() - .contentType(ContentType.JSON) - .body(cacheEntity) - .when().put(EXPECTED_RESOURCE_LOCATION, STANDALONE_BASE_URL, agentsFilter,cmsFilter, cachesFilter); - } - - - @Test - /** - * - PUT a CacheEntity, not matching any known caches : creating is not allowed - * - * @throws Exception - */ - public void updateCachesTest__CantCreateCache() throws Exception { - - - String agentsFilter = ""; - String cmsFilter = ";names=testCacheManager"; - String cachesFilter = ";names=cacheThatDoesNotExist"; - CacheEntity cacheEntity = new CacheEntity(); - expect().statusCode(400) - .body("details", equalTo("Cache not found !")) - .body("error", equalTo("Failed to create or update cache")) - .given() - .contentType(ContentType.JSON) - .body(cacheEntity) - .when().put(EXPECTED_RESOURCE_LOCATION, STANDALONE_BASE_URL, agentsFilter,cmsFilter, cachesFilter); - } - - private CacheManager getCacheManagerNew() { - Configuration configuration = new Configuration(); - configuration.setName("cacheManagerNew"); - - CacheConfiguration myCache = new CacheConfiguration() - .eternal(false).name("CacheNew"); - myCache.setMaxBytesLocalHeap("5M"); - myCache.setMaxBytesLocalDisk("3M"); - configuration.addCache(myCache); - ManagementRESTServiceConfiguration managementRESTServiceConfiguration = new ManagementRESTServiceConfiguration(); - managementRESTServiceConfiguration.setBind("0.0.0.0:"+STANDALONE_REST_AGENT_PORT); - managementRESTServiceConfiguration.setEnabled(true); - configuration.addManagementRESTService(managementRESTServiceConfiguration); - CacheManager cacheManager = new CacheManager(configuration); - Cache exampleCache = cacheManager.getCache("CacheNew"); - assert (exampleCache != null); - return cacheManager; - } - - private CacheManager createStandaloneCacheManagerARC() { - Configuration configuration = new Configuration(); - configuration.setName("testCacheManagerStandaloneARC"); - configuration.setMaxBytesLocalDisk("10M"); - configuration.setMaxBytesLocalHeap("5M"); - CacheConfiguration myCache = new CacheConfiguration().eternal(false).name("testCacheStandaloneARC"); - configuration.addCache(myCache); - ManagementRESTServiceConfiguration managementRESTServiceConfiguration = new ManagementRESTServiceConfiguration(); - managementRESTServiceConfiguration.setBind("0.0.0.0:"+STANDALONE_REST_AGENT_PORT); - managementRESTServiceConfiguration.setEnabled(true); - configuration.addManagementRESTService(managementRESTServiceConfiguration); - - CacheManager mgr = new CacheManager(configuration); - Cache exampleCache = mgr.getCache("testCacheStandaloneARC"); - assert (exampleCache != null); - return mgr; - } - - private CacheManager createStandaloneCacheManager() { - CacheConfiguration myCache = new CacheConfiguration().eternal(false).name("testCacheStandalone").maxEntriesLocalHeap(10000); - Configuration configuration = new Configuration().name("testCacheManagerStandalone").cache(myCache); - - ManagementRESTServiceConfiguration managementRESTServiceConfiguration = new ManagementRESTServiceConfiguration(); - managementRESTServiceConfiguration.setBind("0.0.0.0:"+STANDALONE_REST_AGENT_PORT); - managementRESTServiceConfiguration.setEnabled(true); - configuration.addManagementRESTService(managementRESTServiceConfiguration); - - CacheManager mgr = new CacheManager(configuration); - Cache exampleCache = mgr.getCache("testCacheStandalone"); - assert (exampleCache != null); - return mgr; - } - - private String clusteredCacheManagerAgentId; - - private CacheManager createClusteredCacheManager() { - Configuration configuration = new Configuration(); - configuration.setName("testCacheManagerClustered"); - TerracottaClientConfiguration terracottaConfiguration = new TerracottaClientConfiguration().url(CLUSTER_URL); - configuration.addTerracottaConfig(terracottaConfiguration); - CacheConfiguration myCache = new CacheConfiguration().eternal(false).name("testCacheClustered").terracotta(new TerracottaConfiguration()).maxEntriesLocalHeap(10000).timeToIdleSeconds(1); - configuration.addCache(myCache); - ManagementRESTServiceConfiguration managementRESTServiceConfiguration = new ManagementRESTServiceConfiguration(); - managementRESTServiceConfiguration.setBind("0.0.0.0:"+STANDALONE_REST_AGENT_PORT); - managementRESTServiceConfiguration.setEnabled(true); - configuration.addManagementRESTService(managementRESTServiceConfiguration); - - CacheManager mgr = new CacheManager(configuration); - Cache exampleCache = mgr.getCache("testCacheClustered"); - assert (exampleCache != null); - clusteredCacheManagerAgentId = ResourceServiceImplITHelper.waitUntilEhcacheAgentUp(mgr.getClusterUUID()); - return mgr; - } - -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/transaction/xa/XATransactionSizeOfTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/transaction/xa/XATransactionSizeOfTest.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/transaction/xa/XATransactionSizeOfTest.java (revision 0) @@ -1,118 +0,0 @@ -package net.sf.ehcache.transaction.xa; - -import bitronix.tm.BitronixTransactionManager; -import bitronix.tm.TransactionManagerServices; -import net.sf.ehcache.CacheManager; -import net.sf.ehcache.Ehcache; -import net.sf.ehcache.Element; -import net.sf.ehcache.config.CacheConfiguration; -import net.sf.ehcache.config.Configuration; -import net.sf.ehcache.config.CopyStrategyConfiguration; -import net.sf.ehcache.config.MemoryUnit; -import net.sf.ehcache.config.SizeOfPolicyConfiguration; -import net.sf.ehcache.store.compound.SerializationCopyStrategy; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import java.util.ArrayList; -import java.util.List; -import java.util.logging.ConsoleHandler; -import java.util.logging.Level; -import java.util.logging.Logger; - -import javax.transaction.Status; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -/** - * @author lorban - */ -public class XATransactionSizeOfTest { - - private BitronixTransactionManager transactionManager; - private CacheManager cacheManager; - private Ehcache cache1; - - @Before - public void setUp() throws Exception { - CacheConfiguration txCache1Cfg = new CacheConfiguration().name("txCache1") - .transactionalMode(CacheConfiguration.TransactionalMode.XA_STRICT) - .sizeOfPolicy(new SizeOfPolicyConfiguration().maxDepth(13) - .maxDepthExceededBehavior(SizeOfPolicyConfiguration.MaxDepthExceededBehavior.ABORT)); - CopyStrategyConfiguration copyStrategyConfiguration = new CopyStrategyConfiguration(); - copyStrategyConfiguration.setClass(SerializationCopyStrategy.class.getName()); - txCache1Cfg.addCopyStrategy(copyStrategyConfiguration); - Configuration configuration = new Configuration().maxBytesLocalHeap(10, MemoryUnit.MEGABYTES) - .cache(txCache1Cfg); - - TransactionManagerServices.getConfiguration().setJournal("null").setServerId(XATransactionSizeOfTest.class.getSimpleName()); - transactionManager = TransactionManagerServices.getTransactionManager(); - - cacheManager = new CacheManager(configuration); - transactionManager.begin(); - cache1 = cacheManager.getEhcache("txCache1"); - cache1.removeAll(); - transactionManager.commit(); - } - - @After - public void tearDown() throws Exception { - if (transactionManager.getStatus() != Status.STATUS_NO_TRANSACTION) { - transactionManager.rollback(); - } - transactionManager.shutdown(); - cacheManager.shutdown(); - } - - /** - * Make sure the sizeof engine detects that there are too many objects to be walked. - */ - @Test - public void testHasAbortedSizeOf() throws Exception { - transactionManager.begin(); - - List strings = new ArrayList(); - for (int i = 0; i < 100; i++) { - strings.add("" + i); - } - cache1.put(new Element(0, strings)); - - transactionManager.commit(); - assertTrue(cache1.hasAbortedSizeOf()); - } - - /** - * Make sure XA doesn't store stuff that makes the sizeof engine mistakenly walk the whole heap. - * - * Here's what is walked when storing elements with integers both as key and value: - * - * 40b net.sf.ehcache.store.chm.SelectableConcurrentHashMap$HashEntry@1205901244 - * 80b net.sf.ehcache.Element@1942996580 - * 32b net.sf.ehcache.transaction.SoftLockID@1216216770 - * 80b net.sf.ehcache.Element@350784291 - * 24b java.lang.Integer@1618147776 - * ignored java.lang.Integer@1897411861 - * 24b net.sf.ehcache.transaction.xa.XidTransactionIDImpl@738355611 - * 32b java.lang.String@739090040 - * 32b [C@840888032 - * 24b net.sf.ehcache.transaction.xa.SerializableXid@215272917 - * 56b [B@750131952 - * 56b [B@1738709374 - * - * That's 12 objects, so make sure SizeOfPolicyConfiguration's maxDepth is >= 13. - */ - @Test - public void testSizeOf() throws Exception { - transactionManager.begin(); - - for (int i = 0; i < 100; i++) { - cache1.put(new Element(i, i)); - } - - transactionManager.commit(); - assertFalse(cache1.hasAbortedSizeOf()); - } - -} Index: rctags/ehcache-2.10.8.0.7/distribution/colorcache/src/assemble/README.txt =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/distribution/colorcache/src/assemble/README.txt (revision 11085) +++ rctags/ehcache-2.10.8.0.7/distribution/colorcache/src/assemble/README.txt (revision 0) @@ -1,25 +0,0 @@ -How to run this sample ------------------------------- - -NOTE: Windows users please use the equivalent Batch scripts - -NOTE: JAVA_HOME environment variable must be set to valid path of JDK 1.6+ installation prior to running the scripts below. - -1. Start Terracotta server first - bin/start-sample-server.sh - -2. Start sample: bin/start-sample.sh - -3. Access colorcache sample at - -- http://localhost:9081/colorcache - -- http://localhost:9082/colorcache - -4. Shut down sample: bin/stop-sample.sh - -How to monitor cache usage with the Terracotta Management Console ------------------------------- - -With the sample running, you can monitor the runtime statistics -of the cache using the Terracotta Management console. - -See http://terracotta.org/documentation/tms/tms for more information. \ No newline at end of file Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/management/ManagementServiceTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/management/ManagementServiceTest.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/management/ManagementServiceTest.java (revision 0) @@ -1,462 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.sf.ehcache.management; - -import net.sf.ehcache.AbstractCacheTest; -import net.sf.ehcache.Ehcache; -import net.sf.ehcache.Element; -import net.sf.ehcache.config.Configuration; -import net.sf.ehcache.config.ConfigurationFactory; -import net.sf.ehcache.constructs.blocking.BlockingCache; -import net.sf.ehcache.store.disk.DiskStoreHelper; - -import org.hamcrest.collection.IsEmptyCollection; -import org.hamcrest.core.Is; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.File; -import java.io.IOException; -import java.net.BindException; -import java.rmi.RemoteException; -import java.rmi.registry.LocateRegistry; -import java.rmi.server.ExportException; -import java.util.Iterator; -import java.util.List; -import java.util.Random; -import java.util.Set; - -import javax.management.JMException; -import javax.management.MBeanAttributeInfo; -import javax.management.MBeanInfo; -import javax.management.MBeanRegistrationException; -import javax.management.MBeanServer; -import javax.management.MBeanServerConnection; -import javax.management.MBeanServerFactory; -import javax.management.ObjectName; -import javax.management.remote.JMXConnector; -import javax.management.remote.JMXConnectorServer; -import javax.management.remote.JMXConnectorServerFactory; -import javax.management.remote.JMXServiceURL; - -import static org.hamcrest.collection.IsCollectionWithSize.hasSize; -import static org.hamcrest.core.IsNull.notNullValue; -import static org.hamcrest.core.IsNull.nullValue; -import static org.junit.Assert.assertThat; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.doThrow; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; -import static org.mockito.Mockito.when; - -/** - * These tests use the JDK1.5 platform mbean server - * To interactively examine behaviour, add a Thread.sleep(...) and add -Dcom.sun.management.jmxremote to the java - * invocation. - *

- * To see ehcache specific types in the JMX client add the ehcache.jar to the classpath. - * e.g. to avoid the "Unavailable" message in jconsole caused by ClassNotFound add: - * jconsole -J-Djava.class.path=core/target/classes - * - * @author Greg Luck - * @version $Id: ManagementServiceTest.java 10789 2018-04-26 02:08:13Z adahanne $ - */ -public class ManagementServiceTest extends AbstractCacheTest { - - private static final Logger LOG = LoggerFactory.getLogger(ManagementServiceTest.class.getName()); - private static final int OBJECTS_IN_TEST_EHCACHE = 46; - private MBeanServer mBeanServer; - - - /** - * setup test - */ - @Override - @Before - public void setUp() throws Exception { - super.setUp(); - mBeanServer = createMBeanServer(); - } - - private MBeanServer create14MBeanServer() { - return MBeanServerFactory.createMBeanServer("SimpleAgent"); - } - - /** - * teardown - */ - @Override - @After - public void tearDown() throws Exception { - super.tearDown(); - //Ensure the CacheManager shutdown clears all ObjectNames from the MBeanServer - assertThat(mBeanServer.queryNames(new ObjectName("net.sf.ehcache:*"), null), IsEmptyCollection.empty()); - } - - - /** - * Integration test for the registration service - */ - @Test - public void testRegistrationServiceFourTrue() throws Exception { - ManagementService.registerMBeans(manager, mBeanServer, true, true, true, true, true); - assertThat(mBeanServer.queryNames(new ObjectName("net.sf.ehcache:*"), null), hasSize(OBJECTS_IN_TEST_EHCACHE)); - } - - /** - * Integration test for the registration service - */ - @Test - public void testRegistrationServiceFourTrueUsing14MBeanServer() throws Exception { - mBeanServer = create14MBeanServer(); - ManagementService.registerMBeans(manager, mBeanServer, true, true, true, true, true); - assertThat(mBeanServer.queryNames(new ObjectName("net.sf.ehcache:*"), null), hasSize(OBJECTS_IN_TEST_EHCACHE)); - } - - - /** - * Integration test for the registration service using a contructed ManagementService as would be done - * by an IoC container. - */ - @Test - public void testRegistrationServiceFourTrueUsing14MBeanServerWithConstructorInjection() throws Exception { - mBeanServer = create14MBeanServer(); - ManagementService managementService = new ManagementService(manager, mBeanServer, true, true, true, true, true); - managementService.init(); - assertThat(mBeanServer.queryNames(new ObjectName("net.sf.ehcache:*"), null), hasSize(OBJECTS_IN_TEST_EHCACHE)); - } - - /** - * Integration test for the registration service - */ - @Test - public void testRegistrationServiceListensForCacheChanges() throws Exception { - ManagementService.registerMBeans(manager, mBeanServer, true, true, true, true, true); - assertThat(mBeanServer.queryNames(new ObjectName("net.sf.ehcache:*"), null), hasSize(OBJECTS_IN_TEST_EHCACHE)); - manager.addCache("new cache"); - assertThat(mBeanServer.queryNames(new ObjectName("net.sf.ehcache:*"), null), hasSize(OBJECTS_IN_TEST_EHCACHE + 3)); - manager.removeCache("sampleCache1"); - assertThat(mBeanServer.queryNames(new ObjectName("net.sf.ehcache:*"), null), hasSize(OBJECTS_IN_TEST_EHCACHE)); - } - - /** - * Integration test for the registration service - */ - @Test - public void testMultipleCacheManagers() throws Exception { - ManagementService.registerMBeans(manager, mBeanServer, true, true, true, true, true); - assertThat(mBeanServer.queryNames(new ObjectName("net.sf.ehcache:*"), null), hasSize(OBJECTS_IN_TEST_EHCACHE)); - File file = new File(AbstractCacheTest.SRC_CONFIG_DIR + "ehcache.xml"); - Configuration configuration = ConfigurationFactory.parseConfiguration(file).name("cm-2"); - net.sf.ehcache.CacheManager secondCacheManager = new net.sf.ehcache.CacheManager(configuration); - ManagementService.registerMBeans(secondCacheManager, mBeanServer, true, true, true, true, true); - assertThat(mBeanServer.queryNames(new ObjectName("net.sf.ehcache:*"), null), hasSize(OBJECTS_IN_TEST_EHCACHE + 19)); - secondCacheManager.shutdown(); - assertThat(mBeanServer.queryNames(new ObjectName("net.sf.ehcache:*"), null), hasSize(OBJECTS_IN_TEST_EHCACHE)); - } - - /** - * Checks that Statistics updates - */ - @Test - public void testStatisticsMBeanUpdatesAsStatsChange() throws Exception { - ManagementService.registerMBeans(manager, mBeanServer, false, false, false, true, false); - Ehcache cache = manager.getCache("sampleCache1"); - ObjectName name = CacheStatistics.createObjectName(manager.getName(), cache.getName()); - assertThat(mBeanServer.getAttribute(name, "ObjectCount"), Is.is(Long.valueOf(0L))); - cache.put(new Element("1", "value")); - cache.get("1"); - DiskStoreHelper.flushAllEntriesToDisk((net.sf.ehcache.Cache)cache).get(); - assertThat(mBeanServer.getAttribute(name, "ObjectCount"), Is.is(Long.valueOf(1L))); - assertThat(mBeanServer.getAttribute(name, "MemoryStoreObjectCount"), Is.is(Long.valueOf(1L))); - assertThat(mBeanServer.getAttribute(name, "DiskStoreObjectCount"), Is.is(Long.valueOf(1L))); - } - - /** - * Integration test for the registration service - */ - @Test - public void testRegistrationServiceThreeTrue() throws Exception { - ManagementService.registerMBeans(manager, mBeanServer, true, true, true, false, false); - assertThat(mBeanServer.queryNames(new ObjectName("net.sf.ehcache:*"), null), hasSize(31)); - - } - - /** - * Integration test for the registration service - */ - @Test - public void testRegistrationServiceTwoTrue() throws Exception { - ManagementService.registerMBeans(manager, mBeanServer, true, true, false, false, false); - assertThat(mBeanServer.queryNames(new ObjectName("net.sf.ehcache:*"), null), hasSize(16)); - } - - /** - * Integration test for the registration service - */ - @Test - public void testRegistrationServiceOneTrue() throws Exception { - ManagementService.registerMBeans(manager, mBeanServer, true, false, false, false, false); - assertThat(mBeanServer.queryNames(new ObjectName("net.sf.ehcache:*"), null), hasSize(1)); - } - - /** - * Integration test for the registration service - */ - @Test - public void testRegistrationServiceNoneTrue() throws Exception { - ManagementService.registerMBeans(manager, mBeanServer, false, false, false, false, false); - assertThat(mBeanServer.queryNames(new ObjectName("net.sf.ehcache:*"), null), IsEmptyCollection.empty()); - } - - /** - * Can we register the CacheManager MBean? - */ - @Test - public void testRegisterCacheManager() throws Exception { - //Set size so the second element overflows to disk. - Ehcache ehcache = new net.sf.ehcache.Cache("testNoOverflowToDisk", 1, false, false, 500, 200); - manager.addCache(ehcache); - - ehcache.put(new Element("key1", "value1")); - ehcache.put(new Element("key2", "value1")); - assertThat(ehcache.get("key1"), nullValue()); - assertThat(ehcache.get("key2"), notNullValue()); - - - ObjectName name = new ObjectName("net.sf.ehcache:type=CacheManager,name=1"); - CacheManager cacheManager = new CacheManager(manager); - mBeanServer.registerMBean(cacheManager, name); - mBeanServer.unregisterMBean(name); - - name = new ObjectName("net.sf.ehcache:type=CacheManager.Cache,CacheManager=1,name=testOverflowToDisk"); - mBeanServer.registerMBean(new Cache(ehcache), name); - mBeanServer.unregisterMBean(name); - - name = new ObjectName("net.sf.ehcache:type=CacheManager.Cache,CacheManager=1,name=sampleCache1"); - mBeanServer.registerMBean(new Cache(manager.getCache("sampleCache1")), name); - mBeanServer.unregisterMBean(name); - - } - - - /** - * Can we register the CacheManager MBean? - */ - @Test - public void testListCachesFromManager() throws Exception { - ManagementService.registerMBeans(manager, mBeanServer, true, false, false, false, false); - - Ehcache ehcache = manager.getCache("sampleCache1"); - - ehcache.put(new Element("key1", "value1")); - ehcache.put(new Element("key2", "value1")); - assertThat(ehcache.get("key1"), notNullValue()); - assertThat(ehcache.get("key2"), notNullValue()); - - ObjectName name = CacheManager.createObjectName(manager); - - Object object = mBeanServer.getAttribute(name, "Status"); - LOG.info(object.toString()); - - List caches = (List) mBeanServer.getAttribute(name, "Caches"); - assertThat(caches, hasSize(15)); - - for (int i = 0; i < caches.size(); i++) { - Cache cache = (Cache) caches.get(i); - String cacheName = cache.getName(); - CacheStatistics cacheStatistics = cache.getStatistics(); - CacheConfiguration cacheConfiguration = cache.getCacheConfiguration(); - LOG.info(cacheName + " " + cacheStatistics + " " + cacheConfiguration); - } - } - - /** - * Shows that all MBeans are fully traversable locally - * - * @throws JMException - */ - @Test - public void testTraversalUsingMBeanServer() throws JMException { - //Test CacheManager - //not all attributes are accessible due to serializability constraints - traverseMBeanAttributesUsingMBeanServer("CacheManager"); - - //Test Cache - //not all attributes are accessible due to serializability constraints - traverseMBeanAttributesUsingMBeanServer("Cache"); - - //Test CacheStatistics - traverseMBeanAttributesUsingMBeanServer("CacheStatistics"); - - //Test CacheConfiguration - traverseMBeanAttributesUsingMBeanServer("CacheConfiguration"); - - } - - - /** - * Creates an RMI JMXConnectorServer, connects to it and demonstrates what attributes are traversable. - * The answer is not all. - *

- * Note that this test creates a Registry which will keep running until the JVM Exists. There - * is no way to stop it but it should do no harm. - */ - @Test - public void testJMXConnectorServer() throws Exception { - - ManagementService.registerMBeans(manager, mBeanServer, true, true, true, true, true); - - int registryPort = startRegistry(50000, 60000, 100); - JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:" + registryPort + "/ManagementServiceTest/testJMXConnectorServer"); - JMXConnectorServer cs = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mBeanServer); - cs.start(); - JMXConnector connector = cs.toJMXConnector(null); - connector.connect(null); - MBeanServerConnection connection = connector.getMBeanServerConnection(); - assertThat(connection.queryNames(new ObjectName("net.sf.ehcache:*"), null), hasSize(OBJECTS_IN_TEST_EHCACHE)); - - - Ehcache ehcache = manager.getCache("sampleCache1"); - - ehcache.put(new Element("key1", "value1")); - ehcache.put(new Element("key2", "value1")); - assertThat(ehcache.get("key1"), notNullValue()); - assertThat(ehcache.get("key2"), notNullValue()); - - //Test CacheManager - //not all attributes are accessible due to serializability constraints - //traverseMBeanAttributes(connection, "CacheManager"); - - //Test Cache - //not all attributes are accessible due to serializability constraints - //traverseMBeanAttributes(connection, "Cache"); - - //Test CacheStatistics - traverseMBeanAttributes(connection, "CacheStatistics"); - - //Test CacheConfiguration - traverseMBeanAttributes(connection, "CacheConfiguration"); - - cs.stop(); - } - - private int startRegistry(int portRangeStart, int portRangeEnd, int attempts) throws RemoteException { - Random rndm = new Random(); - for (int i = 0; ; i++) { - int candidatePort = rndm.nextInt(portRangeEnd - portRangeStart) + portRangeStart; - LOG.info("Attempting to start RMI registry on port " + candidatePort); - try { - LocateRegistry.createRegistry(candidatePort); - return candidatePort; - } catch (ExportException e) { - if (e.getCause() instanceof BindException) { - LOG.warn("Failed to bind to port " + candidatePort); - } - if (i >= attempts) { - throw e; - } - } - } - } - - @Test - public void testSupportsDecoratedCaches() { - ManagementService.registerMBeans(manager, mBeanServer, true, true, true, true, true); - - net.sf.ehcache.Cache cache = new net.sf.ehcache.Cache(new net.sf.ehcache.config.CacheConfiguration("decoratedCache", 1000)); - BlockingCache blockingCache = new BlockingCache(cache); - - manager.addCacheIfAbsent(blockingCache); - } - - @Test - public void testNotifyCacheRemovedCallsUnregisterForAll() throws Exception { - MBeanServer server = mock(MBeanServer.class); - when(server.isRegistered(any(ObjectName.class))).thenReturn(true); - - net.sf.ehcache.CacheManager cm = mock(net.sf.ehcache.CacheManager.class); - when(cm.toString()).thenReturn("cmName"); - - ManagementService managementService = new ManagementService(cm, server, false, true, true, true, true); - - managementService.notifyCacheRemoved("testName"); - verify(server, times(4)).isRegistered(any(ObjectName.class)); - verify(server, times(4)).unregisterMBean(any(ObjectName.class)); - } - - @Test - public void testNotifyCacheRemovedDoesNotCallWhenNotRegistered() { - MBeanServer server = mock(MBeanServer.class); - when(server.isRegistered(any(ObjectName.class))).thenReturn(true); - - net.sf.ehcache.CacheManager cm = mock(net.sf.ehcache.CacheManager.class); - when(cm.toString()).thenReturn("cmName"); - - ManagementService managementService = new ManagementService(cm, server, false, false, false, false, false); - - managementService.notifyCacheRemoved("testName"); - verifyZeroInteractions(server); - } - - @Test - public void testNotifyCacheRemovedCallsUnregisterForAllEvenWithException() throws Exception { - MBeanServer server = mock(MBeanServer.class); - when(server.isRegistered(any(ObjectName.class))).thenReturn(true); - doThrow(new MBeanRegistrationException(new IllegalStateException())).when(server).unregisterMBean(any(ObjectName.class)); - - net.sf.ehcache.CacheManager cm = mock(net.sf.ehcache.CacheManager.class); - when(cm.toString()).thenReturn("cmName"); - - ManagementService managementService = new ManagementService(cm, server, false, true, true, true, true); - - managementService.notifyCacheRemoved("testName"); - verify(server, times(4)).isRegistered(any(ObjectName.class)); - verify(server, times(4)).unregisterMBean(any(ObjectName.class)); - } - - private void traverseMBeanAttributes(MBeanServerConnection connection, String type) throws JMException, IOException { - Set objectNames = connection.queryNames(new ObjectName("net.sf.ehcache:type=" + type + ",*"), null); - for (Iterator iterator = objectNames.iterator(); iterator.hasNext();) { - ObjectName objectName = (ObjectName) iterator.next(); - MBeanInfo mBeanInfo = connection.getMBeanInfo(objectName); - MBeanAttributeInfo[] attributes = mBeanInfo.getAttributes(); - for (MBeanAttributeInfo attribute : attributes) { - LOG.info(attribute.getName() + " " + connection.getAttribute(objectName, attribute.getName())); - } - } - } - - private void traverseMBeanAttributesUsingMBeanServer(String type) throws JMException { - Set objectNames = mBeanServer.queryNames(new ObjectName("net.sf.ehcache:type=" + type + ",*"), null); - for (Iterator iterator = objectNames.iterator(); iterator.hasNext();) { - ObjectName objectName = (ObjectName) iterator.next(); - MBeanInfo mBeanInfo = mBeanServer.getMBeanInfo(objectName); - MBeanAttributeInfo[] attributes = mBeanInfo.getAttributes(); - for (MBeanAttributeInfo attribute : attributes) { - LOG.info(attribute.getName() + " " + mBeanServer.getAttribute(objectName, attribute.getName())); - } - } - } - - -} Index: rctags/ehcache-2.10.8.0.7/terracotta/bootstrap/src/test/java/org/terracotta/modules/ehcache/store/ToolkitNonStopConfigurationTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/terracotta/bootstrap/src/test/java/org/terracotta/modules/ehcache/store/ToolkitNonStopConfigurationTest.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/terracotta/bootstrap/src/test/java/org/terracotta/modules/ehcache/store/ToolkitNonStopConfigurationTest.java (revision 0) @@ -1,51 +0,0 @@ -/** - * Copyright Terracotta, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language governing permissions and limitations under the - * License. - */ - -package org.terracotta.modules.ehcache.store; - -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; - -import net.sf.ehcache.config.NonstopConfiguration; -import net.sf.ehcache.config.TimeoutBehaviorConfiguration; - -import org.junit.Test; -import org.terracotta.toolkit.nonstop.NonStopConfigurationFields; - -/** - * ToolkitNonStopConfigurationTest - */ -public class ToolkitNonStopConfigurationTest { - - @Test - public void testTimeoutBehaviorTypeConversion() { - TimeoutBehaviorConfiguration timeoutBehaviorException = new TimeoutBehaviorConfiguration(); - timeoutBehaviorException.setType("exception"); - assertConfig(timeoutBehaviorException, NonStopConfigurationFields.NonStopReadTimeoutBehavior.EXCEPTION, - NonStopConfigurationFields.NonStopWriteTimeoutBehavior.EXCEPTION); - - timeoutBehaviorException.setType("noop"); - assertConfig(timeoutBehaviorException, NonStopConfigurationFields.NonStopReadTimeoutBehavior.NO_OP, NonStopConfigurationFields.NonStopWriteTimeoutBehavior.NO_OP); - - timeoutBehaviorException.setType("localReads"); - assertConfig(timeoutBehaviorException, NonStopConfigurationFields.NonStopReadTimeoutBehavior.LOCAL_READS, NonStopConfigurationFields.NonStopWriteTimeoutBehavior.NO_OP); - - timeoutBehaviorException.setType("localReadsAndExceptionOnWrite"); - assertConfig(timeoutBehaviorException, NonStopConfigurationFields.NonStopReadTimeoutBehavior.LOCAL_READS, NonStopConfigurationFields.NonStopWriteTimeoutBehavior.EXCEPTION); - } - - private void assertConfig(TimeoutBehaviorConfiguration timeoutBehaviorConfiguration, - NonStopConfigurationFields.NonStopReadTimeoutBehavior readTimeoutBehavior, - NonStopConfigurationFields.NonStopWriteTimeoutBehavior writeTimeoutBehavior) { - NonstopConfiguration nonstopConfiguration = new NonstopConfiguration(); - ToolkitNonStopConfiguration nonStopConfiguration = new ToolkitNonStopConfiguration(nonstopConfiguration.timeoutBehavior(timeoutBehaviorConfiguration)); - assertThat(nonStopConfiguration.getReadOpNonStopTimeoutBehavior(), is(readTimeoutBehavior)); - assertThat(nonStopConfiguration.getWriteOpNonStopTimeoutBehavior(), is(writeTimeoutBehavior)); - } -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/distribution/RMICacheManagerPeerListener.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/distribution/RMICacheManagerPeerListener.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/distribution/RMICacheManagerPeerListener.java (revision 0) @@ -1,603 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.sf.ehcache.distribution; - -import net.sf.ehcache.CacheException; -import net.sf.ehcache.CacheManager; -import net.sf.ehcache.Ehcache; -import net.sf.ehcache.Status; -import net.sf.ehcache.event.CacheEventListener; - -import java.io.IOException; -import java.net.InetAddress; -import java.net.ServerSocket; -import java.net.UnknownHostException; -import java.rmi.Naming; -import java.rmi.NotBoundException; -import java.rmi.Remote; -import java.rmi.RemoteException; -import java.rmi.registry.LocateRegistry; -import java.rmi.registry.Registry; -import java.rmi.server.ExportException; -import java.rmi.server.UnicastRemoteObject; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * A cache server which exposes available cache operations remotely through RMI. - *

- * It acts as a Decorator to a Cache. It holds an instance of cache, which is a local cache it talks to. - *

- * This class could specify a security manager with code like: - *

- * if (System.getSecurityManager() == null) {
- *     System.setSecurityManager(new RMISecurityManager());
- * }
- * 
- * Doing so would require the addition of grant statements in the java.policy file. - *

- * If no security manager is specified no class loading, by RMI clients or servers, is allowed, - * aside from what can be found in the local CLASSPATH. The classpath of each instance of this class should have - * all required classes to enable distribution, so no remote classloading is required or desirable. Accordingly, - * no security manager is set and there are no special JVM configuration requirements. - *

- * This class opens a ServerSocket. The dispose method should be called for orderly closure of that socket. This class - * has a shutdown hook which calls dispose() as a convenience feature for developers. - * - * @author Greg Luck - * @version $Id: RMICacheManagerPeerListener.java 10789 2018-04-26 02:08:13Z adahanne $ - */ -public class RMICacheManagerPeerListener implements CacheManagerPeerListener { - - private static final Logger LOG = LoggerFactory.getLogger(RMICacheManagerPeerListener.class.getName()); - private static final int MINIMUM_SENSIBLE_TIMEOUT = 200; - private static final int NAMING_UNBIND_RETRY_INTERVAL = 400; - private static final int NAMING_UNBIND_MAX_RETRIES = 10; - - /** - * The cache peers. The value is an RMICachePeer. - */ - protected final Map cachePeers = new HashMap(); - - /** - * status. - */ - protected Status status; - - /** - * The RMI listener port - */ - protected Integer port; - - private Registry registry; - private boolean registryCreated; - private final String hostName; - - private CacheManager cacheManager; - private Integer socketTimeoutMillis; - private Integer remoteObjectPort; - - /** - * Constructor with full arguments. - * - * @param hostName may be null, in which case the hostName will be looked up. Machines with multiple - * interfaces should specify this if they do not want it to be the default NIC. - * @param port a port in the range 1025 - 65536 - * @param remoteObjectPort the port number on which the remote objects bound in the registry receive calls. - This defaults to a free port if not specified. - * @param cacheManager the CacheManager this listener belongs to - * @param socketTimeoutMillis TCP/IP Socket timeout when waiting on response - */ - public RMICacheManagerPeerListener(String hostName, Integer port, Integer remoteObjectPort, CacheManager cacheManager, - Integer socketTimeoutMillis) throws UnknownHostException { - - status = Status.STATUS_UNINITIALISED; - - if (hostName != null && hostName.length() != 0) { - this.hostName = hostName; - if (hostName.equals("localhost")) { - LOG.warn("Explicitly setting the listener hostname to 'localhost' is not recommended. " - + "It will only work if all CacheManager peers are on the same machine."); - } - } else { - this.hostName = calculateHostAddress(); - } - if (port == null || port.intValue() == 0) { - assignFreePort(false); - } else { - this.port = port; - } - - //by default is 0, which is ok. - this.remoteObjectPort = remoteObjectPort; - - this.cacheManager = cacheManager; - if (socketTimeoutMillis == null || socketTimeoutMillis.intValue() < MINIMUM_SENSIBLE_TIMEOUT) { - throw new IllegalArgumentException("socketTimoutMillis must be a reasonable value greater than 200ms"); - } - this.socketTimeoutMillis = socketTimeoutMillis; - - } - - /** - * Assigns a free port to be the listener port. - * - * @throws IllegalStateException if the statis of the listener is not {@link net.sf.ehcache.Status#STATUS_UNINITIALISED} - */ - protected void assignFreePort(boolean forced) throws IllegalStateException { - if (status != Status.STATUS_UNINITIALISED) { - throw new IllegalStateException("Cannot change the port of an already started listener."); - } - this.port = Integer.valueOf(this.getFreePort()); - if (forced) { - LOG.warn("Resolving RMI port conflict by automatically using a free TCP/IP port to listen on: " + this.port); - } else { - LOG.debug("Automatically finding a free TCP/IP port to listen on: " + this.port); - } - } - - - /** - * Calculates the host address as the default NICs IP address - * - * @throws UnknownHostException - */ - protected String calculateHostAddress() throws UnknownHostException { - return InetAddress.getLocalHost().getHostAddress(); - } - - - /** - * Gets a free server socket port. - * - * @return a number in the range 1025 - 65536 that was free at the time this method was executed - * @throws IllegalArgumentException - */ - protected int getFreePort() throws IllegalArgumentException { - ServerSocket serverSocket = null; - try { - serverSocket = new ServerSocket(0); - return serverSocket.getLocalPort(); - } catch (IOException e) { - throw new IllegalArgumentException("Could not acquire a free port number."); - } finally { - if (serverSocket != null && !serverSocket.isClosed()) { - try { - serverSocket.close(); - } catch (Exception e) { - LOG.debug("Error closing ServerSocket: " + e.getMessage()); - } - } - } - } - - - /** - * {@inheritDoc} - */ - public void init() throws CacheException { - if (!status.equals(Status.STATUS_UNINITIALISED)) { - return; - } - RMICachePeer rmiCachePeer = null; - try { - startRegistry(); - int counter = 0; - populateListOfRemoteCachePeers(); - synchronized (cachePeers) { - for (Iterator iterator = cachePeers.values().iterator(); iterator.hasNext();) { - rmiCachePeer = (RMICachePeer) iterator.next(); - bind(rmiCachePeer.getUrl(), rmiCachePeer); - counter++; - } - } - LOG.debug(counter + " RMICachePeers bound in registry for RMI listener"); - status = Status.STATUS_ALIVE; - } catch (Exception e) { - String url = null; - if (rmiCachePeer != null) { - url = rmiCachePeer.getUrl(); - } - - throw new CacheException("Problem starting listener for RMICachePeer " - + url + ". Initial cause was " + e.getMessage(), e); - } - } - - /** - * Bind a cache peer - * - * @param rmiCachePeer - */ - protected void bind(String peerName, RMICachePeer rmiCachePeer) throws Exception { - Naming.rebind(peerName, rmiCachePeer); - } - - /** - * Returns a list of bound objects. - *

- * This should match the list of cachePeers i.e. they should always be bound - * - * @return a list of String representations of RMICachePeer objects - */ - protected String[] listBoundRMICachePeers() throws CacheException { - try { - return registry.list(); - } catch (RemoteException e) { - throw new CacheException("Unable to list cache peers " + e.getMessage()); - } - } - - /** - * Returns a reference to the remote object. - * - * @param name the name of the cache e.g. sampleCache1 - */ - protected Remote lookupPeer(String name) throws CacheException { - try { - return registry.lookup(name); - } catch (Exception e) { - throw new CacheException("Unable to lookup peer for replicated cache " + name + " " - + e.getMessage()); - } - } - - /** - * Should be called on init because this is one of the last things that should happen on CacheManager startup. - */ - protected void populateListOfRemoteCachePeers() throws RemoteException { - String[] names = cacheManager.getCacheNames(); - for (int i = 0; i < names.length; i++) { - String name = names[i]; - Ehcache cache = cacheManager.getEhcache(name); - synchronized (cachePeers) { - if (cachePeers.get(name) == null) { - if (isDistributed(cache)) { - RMICachePeer peer; - if (cache.getCacheConfiguration().getTransactionalMode().isTransactional()) { - peer = new TransactionalRMICachePeer(cache, hostName, port, remoteObjectPort, socketTimeoutMillis); - } else { - peer = new RMICachePeer(cache, hostName, port, remoteObjectPort, socketTimeoutMillis); - } - cachePeers.put(name, peer); - } - } - } - } - - } - - /** - * Determine if the given cache is distributed. - * - * @param cache the cache to check - * @return true if a CacheReplicator is found in the listeners - */ - protected boolean isDistributed(Ehcache cache) { - Set listeners = cache.getCacheEventNotificationService().getCacheEventListeners(); - for (Iterator iterator = listeners.iterator(); iterator.hasNext();) { - CacheEventListener cacheEventListener = (CacheEventListener) iterator.next(); - if (cacheEventListener instanceof CacheReplicator) { - return true; - } - } - return false; - } - - /** - * Start the rmiregistry. - *

- * The alternative is to use the rmiregistry binary, in which case: - *

    - *
  1. rmiregistry running - *
  2. -Djava.rmi.server.codebase="file:///Users/gluck/work/ehcache/build/classes/ file:///Users/gluck/work/ehcache/lib/commons-logging-1.0.4.jar" - *
- * - * @throws RemoteException - */ - protected void startRegistry() throws RemoteException { - try { - registry = LocateRegistry.getRegistry(port.intValue()); - try { - registry.list(); - } catch (RemoteException e) { - //may not be created. Let's create it. - registry = LocateRegistry.createRegistry(port.intValue()); - registryCreated = true; - } - } catch (ExportException exception) { - LOG.error("Exception starting RMI registry. Error was " + exception.getMessage(), exception); - } - } - - /** - * Stop the rmiregistry if it was started by this class. - * - * @throws RemoteException - */ - protected void stopRegistry() throws RemoteException { - if (registryCreated) { - // the unexportObject call must be done on the Registry object returned - // by createRegistry not by getRegistry, a NoSuchObjectException is - // thrown otherwise - boolean success = UnicastRemoteObject.unexportObject(registry, true); - if (success) { - LOG.debug("rmiregistry unexported."); - } else { - LOG.warn("Could not unexport rmiregistry."); - } - } - } - - /** - * Stop the listener. It - *
    - *
  • unbinds the objects from the registry - *
  • unexports Remote objects - *
- */ - public void dispose() throws CacheException { - if (!status.equals(Status.STATUS_ALIVE)) { - return; - } - try { - int counter = 0; - synchronized (cachePeers) { - for (Iterator iterator = cachePeers.values().iterator(); iterator.hasNext();) { - RMICachePeer rmiCachePeer = (RMICachePeer) iterator.next(); - disposeRMICachePeer(rmiCachePeer); - counter++; - } - stopRegistry(); - } - LOG.debug(counter + " RMICachePeers unbound from registry in RMI listener"); - status = Status.STATUS_SHUTDOWN; - } catch (Exception e) { - throw new CacheException("Problem unbinding remote cache peers. Initial cause was " + e.getMessage(), e); - } - } - - /** - * A template method to dispose an individual RMICachePeer. This consists of: - *
    - *
  1. Unbinding the peer from the naming service - *
  2. Unexporting the peer - *
- * Override to specialise behaviour - * - * @param rmiCachePeer the cache peer to dispose of - * @throws Exception thrown if something goes wrong - */ - protected void disposeRMICachePeer(RMICachePeer rmiCachePeer) throws Exception { - unbind(rmiCachePeer); - } - - /** - * Unbinds an RMICachePeer and unexports it. - *

- * We unbind from the registry first before unexporting. - * Unbinding first removes the very small possibility of a client - * getting the object from the registry while we are trying to unexport it. - *

- * This method may take up to 4 seconds to complete, if we are having trouble - * unexporting the peer. - * - * @param rmiCachePeer the bound and exported cache peer - * @throws Exception - */ - protected void unbind(RMICachePeer rmiCachePeer) throws Exception { - String url = rmiCachePeer.getUrl(); - try { - Naming.unbind(url); - } catch (NotBoundException e) { - LOG.warn(url + " not bound therefore not unbinding."); - } - // Try to gracefully unexport before forcing it. - boolean unexported = UnicastRemoteObject.unexportObject(rmiCachePeer, false); - for (int count = 1; (count < NAMING_UNBIND_MAX_RETRIES) && !unexported; count++) { - try { - Thread.sleep(NAMING_UNBIND_RETRY_INTERVAL); - } catch (InterruptedException ie) { - // break out of the unexportObject loop - break; - } - unexported = UnicastRemoteObject.unexportObject(rmiCachePeer, false); - } - - // If we still haven't been able to unexport, force the unexport - // as a last resort. - if (!unexported) { - if (!UnicastRemoteObject.unexportObject(rmiCachePeer, true)) { - LOG.warn("Unable to unexport rmiCachePeer: " + rmiCachePeer.getUrl() + ". Skipping."); - } - } - } - - /** - * All of the caches which are listening for remote changes. - * - * @return a list of RMICachePeer objects. The list if not live - */ - public List getBoundCachePeers() { - List cachePeerList = new ArrayList(); - synchronized (cachePeers) { - for (Iterator iterator = cachePeers.values().iterator(); iterator.hasNext();) { - RMICachePeer rmiCachePeer = (RMICachePeer) iterator.next(); - cachePeerList.add(rmiCachePeer); - } - } - return cachePeerList; - } - - /** - * Returns the listener status. - */ - public Status getStatus() { - return status; - } - - /** - * A listener will normally have a resource that only one instance can use at the same time, - * such as a port. This identifier is used to tell if it is unique and will not conflict with an - * existing instance using the resource. - * - * @return a String identifier for the resource - */ - public String getUniqueResourceIdentifier() { - return "RMI listener port: " + port; - } - - /** - * If a conflict is detected in unique resource use, this method signals the listener to attempt - * automatic resolution of the resource conflict. - * - * @throws IllegalStateException if the statis of the listener is not {@link net.sf.ehcache.Status#STATUS_UNINITIALISED} - */ - public void attemptResolutionOfUniqueResourceConflict() throws IllegalStateException, CacheException { - assignFreePort(true); - } - - /** - * The replication scheme this listener interacts with. - * Each peer provider has a scheme name, which can be used by caches to specify for replication and bootstrap purposes. - * - * @return the well-known scheme name, which is determined by the replication provider author. - */ - public String getScheme() { - return "RMI"; - } - - /** - * Called immediately after a cache has been added and activated. - *

- * Note that the CacheManager calls this method from a synchronized method. Any attempt to call a synchronized - * method on CacheManager from this method will cause a deadlock. - *

- * Note that activation will also cause a CacheEventListener status change notification from - * {@link net.sf.ehcache.Status#STATUS_UNINITIALISED} to {@link net.sf.ehcache.Status#STATUS_ALIVE}. Care should be - * taken on processing that notification because: - *

    - *
  • the cache will not yet be accessible from the CacheManager. - *
  • the addCaches methods whih cause this notification are synchronized on the CacheManager. An attempt to call - * {@link net.sf.ehcache.CacheManager#getCache(String)} will cause a deadlock. - *
- * The calling method will block until this method returns. - *

- * Repopulates the list of cache peers and rebinds the list. - * This method should be called if a cache is dynamically added - * - * @param cacheName the name of the Cache the operation relates to - * @see net.sf.ehcache.event.CacheEventListener - */ - public void notifyCacheAdded(String cacheName) throws CacheException { - - - LOG.debug("Adding to RMI listener", cacheName); - - //Don't add if exists. - synchronized (cachePeers) { - if (cachePeers.get(cacheName) != null) { - return; - } - } - - Ehcache cache = cacheManager.getEhcache(cacheName); - if (isDistributed(cache)) { - RMICachePeer rmiCachePeer = null; - String url = null; - try { - if (cache.getCacheConfiguration().getTransactionalMode().isTransactional()) { - rmiCachePeer = new TransactionalRMICachePeer(cache, hostName, port, remoteObjectPort, socketTimeoutMillis); - } else { - rmiCachePeer = new RMICachePeer(cache, hostName, port, remoteObjectPort, socketTimeoutMillis); - } - url = rmiCachePeer.getUrl(); - bind(url, rmiCachePeer); - } catch (Exception e) { - throw new CacheException("Problem starting listener for RMICachePeer " - + url + ". Initial cause was " + e.getMessage(), e); - } - - synchronized (cachePeers) { - cachePeers.put(cacheName, rmiCachePeer); - } - - } - if (LOG.isDebugEnabled()) { - LOG.debug(cachePeers.size() + " RMICachePeers bound in registry for RMI listener"); - } - } - - /** - * Called immediately after a cache has been disposed and removed. The calling method will block until - * this method returns. - *

- * Note that the CacheManager calls this method from a synchronized method. Any attempt to call a synchronized - * method on CacheManager from this method will cause a deadlock. - *

- * Note that a {@link net.sf.ehcache.event.CacheEventListener} status changed will also be triggered. Any attempt from that notification - * to access CacheManager will also result in a deadlock. - * - * @param cacheName the name of the Cache the operation relates to - */ - public void notifyCacheRemoved(String cacheName) { - - - LOG.debug("Removing from RMI listener", cacheName); - - //don't remove if already removed. - synchronized (cachePeers) { - if (cachePeers.get(cacheName) == null) { - return; - } - } - - RMICachePeer rmiCachePeer; - synchronized (cachePeers) { - rmiCachePeer = (RMICachePeer) cachePeers.remove(cacheName); - } - String url = null; - try { - unbind(rmiCachePeer); - } catch (Exception e) { - throw new CacheException("Error removing Cache Peer " - + url + " from listener. Message was: " + e.getMessage(), e); - } - - if (LOG.isDebugEnabled()) { - LOG.debug(cachePeers.size() + " RMICachePeers bound in registry for RMI listener"); - } - } - - - /** - * Package local method for testing - */ - void addCachePeer(String name, RMICachePeer peer) { - synchronized (cachePeers) { - cachePeers.put(name, peer); - - } - } -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/terracotta/EventReplicationTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/terracotta/EventReplicationTest.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/terracotta/EventReplicationTest.java (revision 0) @@ -1,44 +0,0 @@ -package net.sf.ehcache.terracotta; - -import net.sf.ehcache.Cache; -import net.sf.ehcache.CacheManager; -import net.sf.ehcache.Element; -import net.sf.ehcache.config.CacheConfiguration; -import net.sf.ehcache.config.TerracottaConfiguration; -import net.sf.ehcache.event.TerracottaCacheEventReplicationFactory; -import org.junit.Test; - -import java.util.List; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.notNullValue; -import static org.junit.Assert.assertThat; - -/** - * @author Alex Snaps - */ -public class EventReplicationTest { - - @Test - public void testConfigFileHonorsClusteringOff() { - final CacheManager cacheManager = new CacheManager(CacheManager.class.getResourceAsStream("/terracotta/ehcache-event-replication.xml")); - try{ - final Cache cache = cacheManager.getCache("replication"); - assertThat(cache, notNullValue()); - final TerracottaConfiguration terracottaConfiguration = cache.getCacheConfiguration().getTerracottaConfiguration(); - assertThat(terracottaConfiguration, notNullValue()); - assertThat(terracottaConfiguration.isClustered(), is(false)); - final List eventListenerConfigurations = cache.getCacheConfiguration().getCacheEventListenerConfigurations(); - assertThat(eventListenerConfigurations, notNullValue()); - assertThat(eventListenerConfigurations.size(), is(1)); - assertThat(((CacheConfiguration.CacheEventListenerFactoryConfiguration)eventListenerConfigurations.get(0)).getFullyQualifiedClassPath(), - equalTo(TerracottaCacheEventReplicationFactory.class.getName())); - cache.put(new Element("key", "value")); - assertThat((String) cache.get("key").getValue(), equalTo("value")); - - } finally { - cacheManager.shutdown(); - } - } -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/management/DummyManagementServerImpl.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/management/DummyManagementServerImpl.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/management/DummyManagementServerImpl.java (revision 0) @@ -1,60 +0,0 @@ -package net.sf.ehcache.management; - -import net.sf.ehcache.CacheManager; -import net.sf.ehcache.config.ManagementRESTServiceConfiguration; - -import java.util.HashMap; -import java.util.Map; - -/** - * @author Ludovic Orban - */ -public class DummyManagementServerImpl implements ManagementServer { - - public static enum Status { - STARTED, STOPPED - } - - public Status status = Status.STOPPED; - public final static Map registeredCacheManagers = new HashMap(); - - public DummyManagementServerImpl() { - } - - @Override - public void start() { - status = Status.STARTED; - } - - @Override - public void stop() { - status = Status.STOPPED; - } - - @Override - public void register(CacheManager managedResource) { - registeredCacheManagers.put(managedResource.getName(), managedResource); - } - - @Override - public void unregister(CacheManager managedResource) { - registeredCacheManagers.remove(managedResource.getName()); - } - - @Override - public boolean hasRegistered() { - return !registeredCacheManagers.isEmpty(); - } - - @Override - public void initialize(ManagementRESTServiceConfiguration configuration) { - } - - @Override - public void registerClusterRemoteEndpoint(String clientUUID) { - } - - @Override - public void unregisterClusterRemoteEndpoint(String clientUUID) { - } -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/distribution/RMICacheManagerPeerIT.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/distribution/RMICacheManagerPeerIT.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/distribution/RMICacheManagerPeerIT.java (revision 0) @@ -1,228 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.sf.ehcache.distribution; - - -import net.sf.ehcache.Cache; -import net.sf.ehcache.CacheManager; -import net.sf.ehcache.Ehcache; -import net.sf.ehcache.Element; -import net.sf.ehcache.util.RetryAssert; - -import org.hamcrest.collection.IsEmptyCollection; -import org.junit.After; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; - -import org.junit.Test; - -import java.net.SocketTimeoutException; -import java.rmi.RemoteException; -import java.rmi.UnmarshalException; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Set; -import java.util.concurrent.Callable; -import java.util.concurrent.TimeUnit; - -import net.sf.ehcache.config.CacheConfiguration; -import net.sf.ehcache.config.Configuration; -import net.sf.ehcache.distribution.RmiEventMessage.RmiEventType; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Unit tests for RMICachePeer - *

- * Note these tests need a live network interface running in multicast mode to work - * - * @author Greg Luck - * @version $Id: RMICacheManagerPeerIT.java 10789 2018-04-26 02:08:13Z adahanne $ - */ -public class RMICacheManagerPeerIT extends AbstractRMITest { - - private static final Logger LOG = LoggerFactory.getLogger(RMICacheManagerPeerIT.class.getName()); - - @After - public void tearDown() throws InterruptedException { - RetryAssert.assertBy(30, TimeUnit.SECONDS, new Callable>() { - public Set call() throws Exception { - return getActiveReplicationThreads(); - } - }, IsEmptyCollection.empty()); - } - - - /** - * Can we create the peer using remote port of 0? - */ - @Test - public void testCreatePeerWithAutomaticRemotePort() throws RemoteException { - Cache cache = new Cache(new CacheConfiguration().name("test").maxEntriesLocalHeap(10)); - for (int i = 0; i < 10; i++) { - new RMICachePeer(cache, "localhost", 5010, Integer.valueOf(0), Integer.valueOf(2000)); - } - } - - - /** - * Can we create the peer using a specified free remote port of 45000 - */ - @Test - public void testCreatePeerWithSpecificRemotePort() throws RemoteException { - Cache cache = new Cache(new CacheConfiguration().name("test").maxEntriesLocalHeap(10)); - for (int i = 0; i < 10; i++) { - new RMICachePeer(cache, "localhost", 5010, Integer.valueOf(45000), Integer.valueOf(2000)); - } - } - - - /** - * See if socket.setSoTimeout(socketTimeoutMillis) works. Should throw a SocketTimeoutException - * - * @throws RemoteException - */ - @Test - public void testFailsIfTimeoutExceeded() throws Exception { - CacheManager manager = new CacheManager(new Configuration().name("testFailsIfTimeoutExceeded")); - try { - Cache cache = new Cache(new CacheConfiguration().name("test").maxEntriesLocalHeap(10)); - RMICacheManagerPeerListener peerListener = new RMICacheManagerPeerListener("localhost", 5010, Integer.valueOf(0), manager, Integer.valueOf(2000)); - try { - RMICachePeer rmiCachePeer = new SlowRMICachePeer(cache, "localhost", 5010, Integer.valueOf(1000), 2000); - peerListener.addCachePeer(cache.getName(), rmiCachePeer); - peerListener.init(); - - - try { - CachePeer cachePeer = new ManualRMICacheManagerPeerProvider().lookupRemoteCachePeer(rmiCachePeer.getUrl()); - cachePeer.put(new Element("1", new Date())); - fail(); - } catch (UnmarshalException e) { - assertEquals(SocketTimeoutException.class, e.getCause().getClass()); - } - } finally { - peerListener.dispose(); - } - } finally { - manager.shutdown(); - } - } - - /** - * See if socket.setSoTimeout(socketTimeoutMillis) works. - * Should not fail because the put takes less than the timeout. - * - * @throws RemoteException - */ - @Test - public void testWorksIfTimeoutNotExceeded() throws Exception { - CacheManager manager = new CacheManager(new Configuration().name("testWorksIfTimeoutNotExceeded")); - try { - Cache cache = new Cache(new CacheConfiguration().name("test").maxEntriesLocalHeap(10)); - RMICacheManagerPeerListener peerListener = new RMICacheManagerPeerListener("localhost", 5010, Integer.valueOf(0), manager, Integer.valueOf(2000)); - try { - RMICachePeer rmiCachePeer = new SlowRMICachePeer(cache, "localhost", 5010, Integer.valueOf(2000), 0); - - peerListener.addCachePeer(cache.getName(), rmiCachePeer); - peerListener.init(); - - CachePeer cachePeer = new ManualRMICacheManagerPeerProvider().lookupRemoteCachePeer(rmiCachePeer.getUrl()); - cachePeer.put(new Element("1", new Date())); - } finally { - peerListener.dispose(); - } - } finally { - manager.shutdown(); - } - } - - /** - * Test send. - *

- * This is a unit test because it was throwing AbstractMethodError if a method has changed signature, - * or NoSuchMethodError is a new one is added. The problem is that rmic needs - * to recompile the stub after any changes are made to the CachePeer source, something done by ant - * compile but not by the IDE. - */ - @Test - public void testSend() throws Exception { - CacheManager manager = new CacheManager(new Configuration().name("testWorksIfTimeoutNotExceeded")); - try { - Cache cache = new Cache(new CacheConfiguration().name("test").maxEntriesLocalHeap(10)); - RMICachePeer rmiCachePeer = new RMICachePeer(cache, "localhost", 5010, Integer.valueOf(0), Integer.valueOf(2100)); - RMICacheManagerPeerListener peerListener = new RMICacheManagerPeerListener("localhost", 5010, Integer.valueOf(0), manager, Integer.valueOf(2000)); - manager.addCache(cache); - - peerListener.addCachePeer(cache.getName(), rmiCachePeer); - peerListener.init(); - - CachePeer cachePeer = new ManualRMICacheManagerPeerProvider().lookupRemoteCachePeer(rmiCachePeer.getUrl()); - Element element = new Element("1", new Date()); - RmiEventMessage eventMessage = new RmiEventMessage(null, RmiEventType.PUT, null, element); - List eventMessages = new ArrayList(); - eventMessages.add(eventMessage); - cachePeer.send(eventMessages); - } finally { - manager.shutdown(); - } - } - - - /** - * RMICachePeer that breaks in lots of interesting ways. - */ - class SlowRMICachePeer extends RMICachePeer { - - private final long sleepTime; - - /** - * Constructor - * - * @param cache - * @param hostName - * @param port - * @param socketTimeoutMillis - * @throws RemoteException - */ - public SlowRMICachePeer(Ehcache cache, String hostName, Integer port, Integer socketTimeoutMillis, int sleepTime) - throws RemoteException { - super(cache, hostName, port, Integer.valueOf(0), socketTimeoutMillis); - this.sleepTime = sleepTime; - } - - /** - * Puts an Element into the underlying cache without notifying listeners or updating statistics. - * - * @param element - * @throws java.rmi.RemoteException - * @throws IllegalArgumentException - * @throws IllegalStateException - */ - @Override - public void put(Element element) throws RemoteException, IllegalArgumentException, IllegalStateException { - try { - Thread.sleep(sleepTime); - } catch (InterruptedException exception) { - LOG.error(exception.getMessage(), exception); - } - } - } -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/constructs/blocking/UpdatingCacheEntryFactory.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/constructs/blocking/UpdatingCacheEntryFactory.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/constructs/blocking/UpdatingCacheEntryFactory.java (revision 0) @@ -1,50 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.sf.ehcache.constructs.blocking; - -/** - * A CacheEntryFactory with one additional method, updateEntryValue((Serializable key, Serializable value) - * which allows the cache entry to updated rather than replaced. This has the following - * potential benefits: - *

    - *
  • Where only part of the value needs to be updated, it is quicker - *
  • Memory use can be smoothed, which is useful for particularly large objects which are being - * refreshed contrinuously - *
- * - * @author Greg Luck - * @version $Id: UpdatingCacheEntryFactory.java 10789 2018-04-26 02:08:13Z adahanne $ - */ -public interface UpdatingCacheEntryFactory extends CacheEntryFactory { - /** - * Perform an incremental update of data within a CacheEntry. - * Based on identification of dirty values within a CacheEntry - * Insert Update or Delete those entries based on the existing value. - *

- * This method does not return a modified value, because it modifies the value passed into it, relying - * on the pass by reference feature of Java. - * - * Implementations of this method must be thread safe. - * - * @param key the cache Key - * @param value a value copied from the value that belonged to the Element in the cache. Value must be mutable - * @throws Exception - */ - void updateEntryValue(Object key, Object value) throws Exception; - -} - Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/store/PressuredStore.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/store/PressuredStore.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/store/PressuredStore.java (revision 0) @@ -1,32 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package net.sf.ehcache.store; - -import java.util.concurrent.Callable; - -/** - * A store that can be under pressure... you wouldn't want your store to be under pressure, now would you ? - * - * @author Alex Snaps - */ -public interface PressuredStore { - - /** - * Registers an emergency valve - * @param valve - */ - void registerEmergencyValve(Callable valve); -} Index: rctags/ehcache-2.10.8.0.7/management-ehcache-v2/src/main/java/net/sf/ehcache/management/resource/services/CacheStatisticSamplesResourceServiceImplV2.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/management-ehcache-v2/src/main/java/net/sf/ehcache/management/resource/services/CacheStatisticSamplesResourceServiceImplV2.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/management-ehcache-v2/src/main/java/net/sf/ehcache/management/resource/services/CacheStatisticSamplesResourceServiceImplV2.java (revision 0) @@ -1,74 +0,0 @@ -/* - * All content copyright (c) 2003-2012 Terracotta, Inc., except as may otherwise be noted in a separate copyright - * notice. All rights reserved. - */ -package net.sf.ehcache.management.resource.services; - -import java.util.Arrays; -import java.util.HashSet; -import java.util.Set; - -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.UriInfo; - -import net.sf.ehcache.management.service.EntityResourceFactoryV2; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.terracotta.management.ServiceExecutionException; -import org.terracotta.management.ServiceLocator; -import org.terracotta.management.resource.ResponseEntityV2; -import org.terracotta.management.resource.exceptions.ResourceRuntimeException; -import org.terracotta.management.resource.services.validator.RequestValidator; - -/** - * @author brandony - */ -@Path("/v2/agents/cacheManagers/caches/statistics/samples") -public final class CacheStatisticSamplesResourceServiceImplV2 { - private static final Logger LOG = LoggerFactory.getLogger(CacheStatisticSamplesResourceServiceImplV2.class); - private final EntityResourceFactoryV2 entityResourceFactory; - - private final RequestValidator validator; - - public CacheStatisticSamplesResourceServiceImplV2() { - this.entityResourceFactory = ServiceLocator.locate(EntityResourceFactoryV2.class); - this.validator = ServiceLocator.locate(RequestValidator.class); - } - - /** - * - * @param info - * @return - */ - @GET - @Produces(MediaType.APPLICATION_JSON) - public ResponseEntityV2 getCacheStatisticSamples(@Context UriInfo info) { - LOG.debug(String.format("Invoking CacheStatisticSamplesResourceServiceImpl.getCacheStatisticSamples: %s", - info.getRequestUri())); - - validator.validateSafe(info); - - String cacheManagerNames = info.getPathSegments().get(2).getMatrixParameters().getFirst("names"); - Set cmNames = cacheManagerNames == null ? null : new HashSet( - Arrays.asList(cacheManagerNames.split(","))); - - String cacheNames = info.getPathSegments().get(3).getMatrixParameters().getFirst("names"); - Set cNames = cacheNames == null ? null : new HashSet(Arrays.asList(cacheNames.split(","))); - - String sampleNames = info.getPathSegments().get(5).getMatrixParameters().getFirst("names"); - Set sNames = sampleNames == null ? null : new HashSet(Arrays.asList(sampleNames.split(","))); - - try { - return entityResourceFactory.createCacheStatisticSampleEntity(cmNames, cNames, sNames); - } catch (ServiceExecutionException e) { - throw new ResourceRuntimeException("Failed to get cache statistics sample", e, - Response.Status.BAD_REQUEST.getStatusCode()); - } - } -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/hibernate/EhcacheJtaTransactionManagerLookup.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/hibernate/EhcacheJtaTransactionManagerLookup.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/hibernate/EhcacheJtaTransactionManagerLookup.java (revision 0) @@ -1,60 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package net.sf.ehcache.hibernate; - -import net.sf.ehcache.transaction.manager.DefaultTransactionManagerLookup; -import org.hibernate.HibernateException; -import org.hibernate.transaction.TransactionManagerLookup; - -import javax.transaction.Transaction; -import javax.transaction.TransactionManager; -import java.util.Properties; - -/** - * Hibernate TransactionManagerLookup which also is a Ehcache transaction manager lookup. - * - * @author Ludovic Orban - */ -public class EhcacheJtaTransactionManagerLookup extends DefaultTransactionManagerLookup implements TransactionManagerLookup { - - /** - * Construct a new transaction manager lookup. - */ - public EhcacheJtaTransactionManagerLookup() { - super(); - } - - /** - * {@inheritDoc} - */ - public TransactionManager getTransactionManager(Properties properties) throws HibernateException { - return getTransactionManager(); - } - - /** - * {@inheritDoc} - */ - public String getUserTransactionName() { - return null; - } - - /** - * {@inheritDoc} - */ - public Object getTransactionIdentifier(Transaction transaction) { - return transaction; - } -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/writer/writebehind/WriteBehindQueueTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/writer/writebehind/WriteBehindQueueTest.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/writer/writebehind/WriteBehindQueueTest.java (revision 0) @@ -1,111 +0,0 @@ -package net.sf.ehcache.writer.writebehind; - -import net.sf.ehcache.CacheEntry; -import net.sf.ehcache.CacheException; -import net.sf.ehcache.Ehcache; -import net.sf.ehcache.Element; -import net.sf.ehcache.config.CacheConfiguration; -import net.sf.ehcache.config.CacheWriterConfiguration; -import net.sf.ehcache.writer.CacheWriter; -import net.sf.ehcache.writer.writebehind.operations.SingleOperationType; - -import org.junit.Test; - -import java.util.Collection; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -import static org.junit.Assert.*; - -/** - * WriteBehindQueueTest - */ -public class WriteBehindQueueTest { - @Test - public void testLastWriteBlockedOnFullQueue() throws InterruptedException { - CacheConfiguration cacheConfiguration = new CacheConfiguration(); - CacheWriterConfiguration writerConfiguration = cacheConfiguration.getCacheWriterConfiguration(); - writerConfiguration.setWriteBehindMaxQueueSize(1); - writerConfiguration.setMinWriteDelay(0); - final WriteBehindQueue writeBehindQueue = new WriteBehindQueue(cacheConfiguration); - - writeBehindQueue.start(new BlockingWriter()); - - writeBehindQueue.write(new Element("a", "a")); - - new Thread(new Runnable() { - @Override - public void run() { - writeBehindQueue.write(new Element("b", "b")); - } - }).start(); - - new Thread(new Runnable() { - @Override - public void run() { - writeBehindQueue.write(new Element("c", "c")); - } - }).start(); - - BlockingWriter.firstLatch.countDown(); - - boolean await = BlockingWriter.secondLatch.await(10, TimeUnit.SECONDS); - if (!await) { - fail("write still stuck after 10 seconds"); - } - } - - private static class BlockingWriter implements CacheWriter { - - static CountDownLatch firstLatch = new CountDownLatch(1); - static CountDownLatch secondLatch = new CountDownLatch(2); - - @Override - public CacheWriter clone(Ehcache cache) throws CloneNotSupportedException { - throw new UnsupportedOperationException("TODO Implement me!"); - } - - @Override - public void init() { - throw new UnsupportedOperationException("TODO Implement me!"); - } - - @Override - public void dispose() throws CacheException { - throw new UnsupportedOperationException("TODO Implement me!"); - } - - @Override - public void write(Element element) throws CacheException { - if (element.getObjectKey().equals("a")) { - try { - firstLatch.await(); - } catch (InterruptedException e) { - throw new CacheException(e); - } - } else { - secondLatch.countDown(); - } - } - - @Override - public void writeAll(Collection elements) throws CacheException { - throw new UnsupportedOperationException("TODO Implement me!"); - } - - @Override - public void delete(CacheEntry entry) throws CacheException { - throw new UnsupportedOperationException("TODO Implement me!"); - } - - @Override - public void deleteAll(Collection entries) throws CacheException { - throw new UnsupportedOperationException("TODO Implement me!"); - } - - @Override - public void throwAway(Element element, SingleOperationType operationType, RuntimeException e) { - throw new UnsupportedOperationException("TODO Implement me!"); - } - } -} \ No newline at end of file Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/management/sampled/MBeanRegistrationProviderTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/management/sampled/MBeanRegistrationProviderTest.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/management/sampled/MBeanRegistrationProviderTest.java (revision 0) @@ -1,221 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.sf.ehcache.management.sampled; - -import static org.junit.Assert.assertEquals; - -import java.io.File; -import java.util.Set; - -import javax.management.MBeanServer; -import javax.management.ObjectName; - -import net.sf.ehcache.AbstractCacheTest; -import net.sf.ehcache.CacheManager; -import net.sf.ehcache.config.Configuration; -import net.sf.ehcache.config.ConfigurationFactory; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Tests for testing the mbean registration provider - * - * @author Abhishek Sanoujam - * @version $Id: MBeanRegistrationProviderTest.java 1178 2009-09-23 23:50:15Z - * asingh - * $ - */ -public class MBeanRegistrationProviderTest extends AbstractCacheTest { - - private static final Logger LOG = LoggerFactory.getLogger(MBeanRegistrationProviderTest.class.getName()); - - private MBeanServer mbeanServer; - - private CacheManager cacheManager; - - @Override - @Before - public void setUp() throws Exception { - super.setUp(); - mbeanServer = createMBeanServer(); - cleanUpExistingMbeans(); - } - - @Override - @After - public void tearDown() throws Exception { - if (cacheManager != null) { - cacheManager.shutdown(); - } - super.tearDown(); - assertEquals(0, mbeanServer.queryNames(new ObjectName("net.sf.ehcache:*"), null).size()); - cacheManager = null; - cleanUpExistingMbeans(); - } - - private void cleanUpExistingMbeans() throws Exception { - Set queryNames = mbeanServer.queryNames(new ObjectName("net.sf.ehcache:*"), null); - for (ObjectName name : queryNames) { - mbeanServer.unregisterMBean(name); - } - } - - @Test - public void testMonitoringOn() throws Exception { - File file = new File(TEST_CONFIG_DIR + "ehcache-monitoring-on.xml"); - Configuration configuration = ConfigurationFactory.parseConfiguration(file); - cacheManager = new CacheManager(configuration); - assertSampledMBeansGroupRegistered(3); - assertCacheManagerMBeansRegistered("cacheManagerOn", 1); - } - - private void assertSampledMBeansGroupRegistered(final int size) throws Exception { - Set queryNames = mbeanServer.queryNames(new ObjectName(SampledEhcacheMBeans.GROUP_ID + ":*"), null); - assertEquals(size, queryNames.size()); - } - - private void assertCacheManagerMBeansRegistered(String cacheManagerName, int size) throws Exception { - Set queryNames = mbeanServer.queryNames(SampledEhcacheMBeans.getCacheManagerObjectName(null, cacheManagerName), null); - assertEquals(size, queryNames.size()); - } - - private void assertCacheManagerMBeansRegistered(int size) throws Exception { - Set queryNames = mbeanServer.queryNames(SampledEhcacheMBeans.getQueryCacheManagersObjectName(null), null); - assertEquals(size, queryNames.size()); - } - - @Test - public void testMonitoringOff() throws Exception { - File file = new File(TEST_CONFIG_DIR + "ehcache-monitoring-off.xml"); - Configuration configuration = ConfigurationFactory.parseConfiguration(file); - cacheManager = new CacheManager(configuration); - assertSampledMBeansGroupRegistered(0); - assertCacheManagerMBeansRegistered("cacheManagerOff", 0); - } - - @Test - public void testMonitoringAutodetect() throws Exception { - System.setProperty("tc.active", "false"); - doTestMonitoringAutodetect(false, "tc-not-active"); - - System.setProperty("tc.active", "true"); - doTestMonitoringAutodetect(true, "tc-active"); - - // reset property - System.setProperty("tc.active", "false"); - } - - public void doTestMonitoringAutodetect(boolean dsoActive, String name) throws Exception { - File file = new File(TEST_CONFIG_DIR + "ehcache-monitoring-autodetect.xml"); - Configuration configuration = ConfigurationFactory.parseConfiguration(file).name(name); - CacheManager localCacheManager = new CacheManager(configuration); - try { - if (dsoActive) { - assertSampledMBeansGroupRegistered(3); - assertCacheManagerMBeansRegistered("cacheManagerAutoDetect", 0); - } else { - assertSampledMBeansGroupRegistered(0); - assertCacheManagerMBeansRegistered("cacheManagerAutoDetect", 0); - } - } finally { - localCacheManager.shutdown(); - } - } - - @Test - public void testMultipleCacheManagerDifferentNames() throws Exception { - System.setProperty("tc.active", "true"); - File file = new File(TEST_CONFIG_DIR + "ehcache-monitoring-autodetect.xml"); - Configuration configuration = ConfigurationFactory.parseConfiguration(file); - cacheManager = new CacheManager(configuration); - assertSampledMBeansGroupRegistered(3); - assertCacheManagerMBeansRegistered("cacheManagerAutoDetect", 1); - - file = new File(TEST_CONFIG_DIR + "ehcache-monitoring-on.xml"); - configuration = ConfigurationFactory.parseConfiguration(file); - CacheManager otherCacheManager = new CacheManager(configuration); - assertSampledMBeansGroupRegistered(3 + 3); - assertCacheManagerMBeansRegistered(2); - - cacheManager.shutdown(); - otherCacheManager.shutdown(); - // reset property - System.setProperty("tc.active", "false"); - } - - @Test - public void testMultipleCacheManagerSameNames() throws Exception { - int count = 8; - CacheManager[] managers = new CacheManager[count]; - for (int i = 0; i < count; i++) { - File file = new File(TEST_CONFIG_DIR + "ehcache-monitoring-on.xml"); - Configuration configuration = ConfigurationFactory.parseConfiguration(file).name("cm-" + i); - managers[i] = new CacheManager(configuration); - assertSampledMBeansGroupRegistered(3 * (i + 1)); - assertCacheManagerMBeansRegistered(i + 1); - } - - CacheManager[] duplicates = new CacheManager[count]; - for (int i = 0; i < count; i++) { - File file = new File(TEST_CONFIG_DIR + "ehcache-monitoring-on.xml"); - Configuration configuration = ConfigurationFactory.parseConfiguration(file).name("cm-dup-" + i); - - duplicates[i] = new CacheManager(configuration); - assertSampledMBeansGroupRegistered(3 * (i + 1) + count * 3); - assertCacheManagerMBeansRegistered((i + 1) + count); - } - // shutting down the cacheManager should clean up the mbeans - for (CacheManager mgr : managers) { - mgr.shutdown(); - } - for (CacheManager mgr : duplicates) { - mgr.shutdown(); - } - assertSampledMBeansGroupRegistered(0); - assertCacheManagerMBeansRegistered(0); - } - - @Test - public void testInvalidCacheNames() throws Exception { - System.setProperty("tc.active", "true"); - - File file = new File(TEST_CONFIG_DIR + "ehcache-invalid-cache-names.xml"); - Configuration configuration = ConfigurationFactory.parseConfiguration(file); - cacheManager = new CacheManager(configuration); - assertSampledMBeansGroupRegistered(4); - assertCacheManagerMBeansRegistered("invalidCacheNames", 1); - - System.setProperty("tc.active", "false"); - } - - @Test - public void testInvalidCacheManagerName() throws Exception { - System.setProperty("tc.active", "true"); - - File file = new File(TEST_CONFIG_DIR + "ehcache-invalid-cache-manager-name.xml"); - Configuration configuration = ConfigurationFactory.parseConfiguration(file); - cacheManager = new CacheManager(configuration); - assertSampledMBeansGroupRegistered(1); - assertCacheManagerMBeansRegistered("invalid:CacheManagerName", 1); - - System.setProperty("tc.active", "false"); - } -} Index: rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/ehcache/tests/Valueable.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/ehcache/tests/Valueable.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/ehcache/tests/Valueable.java (revision 0) @@ -1,11 +0,0 @@ -/* - * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved. - */ -package org.terracotta.ehcache.tests; - -import java.io.Serializable; - -public interface Valueable extends Serializable { - int value(); - void setValue(int value); -} Index: rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/ehcache/tests/servermap/ServerMapClearExpressTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/ehcache/tests/servermap/ServerMapClearExpressTest.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/ehcache/tests/servermap/ServerMapClearExpressTest.java (revision 0) @@ -1,14 +0,0 @@ -package org.terracotta.ehcache.tests.servermap; - -import org.terracotta.ehcache.tests.AbstractCacheTestBase; - -import com.tc.test.config.model.TestConfig; - -public class ServerMapClearExpressTest extends AbstractCacheTestBase { - - public ServerMapClearExpressTest(TestConfig testConfig) { - super("/servermap/servermap-clear-test.xml", testConfig, ServerMapClearExpressTestClient1.class, - ServerMapClearExpressTestClient2.class); - } - -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/resources/ehcache-nolisteners.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/resources/ehcache-nolisteners.xml (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/resources/ehcache-nolisteners.xml (revision 0) @@ -1,182 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/transaction/manager/selector/NullSelector.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/transaction/manager/selector/NullSelector.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/transaction/manager/selector/NullSelector.java (revision 0) @@ -1,41 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package net.sf.ehcache.transaction.manager.selector; - -import javax.transaction.TransactionManager; - -/** - * A selector that always returns a null transaction manager - * - * @author Ludovic Orban - */ -public class NullSelector extends Selector { - - /** - * Constructor - */ - public NullSelector() { - super("null"); - } - - /** - * {@inheritDoc} - */ - @Override - protected TransactionManager doLookup() { - return null; - } -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/loader/ExceptionThrowingLoader.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/loader/ExceptionThrowingLoader.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/loader/ExceptionThrowingLoader.java (revision 0) @@ -1,117 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.sf.ehcache.loader; - - -import net.sf.ehcache.CacheException; - -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Random; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - -/** - * A cache loader that throws exceptions when used - *

- * Each load has a random delay to introduce some nice threading entropy. - * - * @author Greg Luck - * @version $Id: ExceptionThrowingLoader.java 10789 2018-04-26 02:08:13Z adahanne $ - */ -public class ExceptionThrowingLoader extends CountingCacheLoader { - - private static final Logger LOG = LoggerFactory.getLogger(ExceptionThrowingLoader.class.getName()); - - private int loadCounter; - private int loadAllCounter; - private Random random = new Random(); - private String name = "ExceptionThrowingLoader"; - - /** - * loads an object. Application writers should implement this - * method to customize the loading of cache object. This method is called - * by the caching service when the requested object is not in the cache. - *

- * - * @param key the key identifying the object being loaded - * @return The object that is to be stored in the cache. - */ - public Object load(Object key) throws CacheException { - try { - Thread.sleep(random.nextInt(3) + 1); - } catch (InterruptedException e) { - LOG.error("Interrupted"); - } - throw new CacheException("Some exception with key " + key); - } - - /** - * loads multiple object. Application writers should implement this - * method to customize the loading of cache object. This method is called - * by the caching service when the requested object is not in the cache. - *

- * - * @param keys a Collection of keys identifying the objects to be loaded - * @return A Map of objects that are to be stored in the cache. - */ - - public Map loadAll(Collection keys) throws CacheException { - Map map = new HashMap(keys.size()); - for (Iterator iterator = keys.iterator(); iterator.hasNext();) { - Object key = iterator.next(); - try { - Thread.sleep(random.nextInt(4)); - } catch (InterruptedException e) { - LOG.error("Interrupted"); - } - map.put(key, Integer.valueOf(loadAllCounter++)); - throw new CacheException("Some exception with key " + key); - } - - return map; - } - - - /** - * Load using both a key and an argument. - *

- * JCache will use the load(key) method where the argument is null. - */ - public Object load(Object key, Object argument) throws CacheException { - try { - Thread.sleep(random.nextInt(3) + 1); - } catch (InterruptedException e) { - LOG.error("Interrupted"); - } - throw new CacheException("Some exception with key " + key); - } - - /** - * Load using both a key and an argument. - *

- * JCache will use the loadAll(key) method where the argument is null. - */ - public Map loadAll(Collection keys, Object argument) throws CacheException { - throw new CacheException("Some exception with key " + keys.toArray()[0]); - } - -} Index: rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/modules/ehcache/writebehind/DistributionDeadBucketWriteBehindTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/modules/ehcache/writebehind/DistributionDeadBucketWriteBehindTest.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/modules/ehcache/writebehind/DistributionDeadBucketWriteBehindTest.java (revision 0) @@ -1,98 +0,0 @@ -/* - * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved. - */ -package org.terracotta.modules.ehcache.writebehind; - -import org.terracotta.ehcache.tests.AbstractCacheTestBase; -import org.terracotta.modules.ehcache.async.AsyncCoordinatorImpl; - -import com.tc.l2.L2DebugLogging.LogLevel; -import com.tc.test.config.model.TestConfig; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileReader; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -public class DistributionDeadBucketWriteBehindTest extends AbstractCacheTestBase { - public static final String DISTRIBUTION_BARRIER_NAME = "DistributionDeadBucketWriteBehindTestBarrier"; - public static final int NODE_COUNT = 4; - private int totalWriteCount = 0; - private int totalDeleteCount = 0; - - public DistributionDeadBucketWriteBehindTest(TestConfig testConfig) { - super("basic-writebehind-test.xml", testConfig); - disableTest(); - testConfig.getClientConfig().setClientClasses(DeadBucketWriteBehindClient.class, NODE_COUNT); - testConfig.getClientConfig().setParallelClients(true); - configureTCLogging(AsyncCoordinatorImpl.class.getName(), LogLevel.DEBUG); - } - - @Override - protected void postClientVerification() { - System.out.println("[Clients processed a total of " + totalWriteCount + " writes]"); - if (totalWriteCount < 2000 || totalWriteCount > 2003) { throw new AssertionError(totalWriteCount); } - - System.out.println("[Clients processed a total of " + totalDeleteCount + " deletes]"); - if (totalDeleteCount < 200 || totalDeleteCount > 203) { throw new AssertionError(totalDeleteCount); } - } - - @Override - protected void evaluateClientOutput(String clientName, int exitCode, File output) throws Throwable { - super.evaluateClientOutput(clientName, exitCode, output); - - FileReader fr = null; - BufferedReader reader = null; - StringBuilder strBuilder = new StringBuilder(); - try { - fr = new FileReader(output); - reader = new BufferedReader(fr); - String st = ""; - while ((st = reader.readLine()) != null) { - strBuilder.append(st); - } - } catch (Exception e) { - throw new AssertionError(e); - } finally { - try { - fr.close(); - reader.close(); - } catch (Exception e) { - // - } - } - - // Detect the number of writes that have happened - int writeCount = detectLargestCount(strBuilder.toString(), - Pattern.compile("\\[WriteBehindCacheWriter written (\\d+) for " + clientName - + "\\]")); - totalWriteCount += writeCount; - System.out.println("[" + clientName + " processed " + writeCount + " writes]"); - if (writeCount < 1 || writeCount > 1001) { throw new AssertionError( - "dead nodes distribution is not uniform writeCount " - + writeCount); } - - // Detect the number of deletes that have happened - int deleteCount = detectLargestCount(strBuilder.toString(), - Pattern.compile("\\[WriteBehindCacheWriter deleted (\\d+) for " + clientName - + "\\]")); - totalDeleteCount += deleteCount; - System.out.println("[" + clientName + " processed " + deleteCount + " deletes]"); - if (deleteCount < 1 || deleteCount > 101) { throw new AssertionError( - "dead nodes distribution is not uniform deleteCount " - + deleteCount); } - } - - private int detectLargestCount(String clientOutput, Pattern pattern) { - Matcher matcher = pattern.matcher(clientOutput); - int count = 0; - while (matcher.find()) { - int parsedCount = Integer.parseInt(matcher.group(1)); - if (parsedCount > count) { - count = parsedCount; - } - } - return count; - } -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/event/CacheManagerEventListenerFactory.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/event/CacheManagerEventListenerFactory.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/event/CacheManagerEventListenerFactory.java (revision 0) @@ -1,45 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.sf.ehcache.event; - -import net.sf.ehcache.CacheManager; - -import java.util.Properties; - -/** - * An abstract factory for creating {@link CacheManagerEventListener}s. Implementers should - * provide their own concrete factory extending this factory. It can then be configured in - * ehcache.xml - * - * @author Greg Luck - * @version $Id: CacheManagerEventListenerFactory.java 5594 2012-05-07 16:04:31Z cdennis $ - * @see "http://ehcache.org/documentation/apis/cachemanager-event-listeners" - */ -public abstract class CacheManagerEventListenerFactory { - - /** - * Create a CacheEventListener - * - * - * @param cacheManager the cache manager - * @param properties implementation specific properties. These are configured as comma - * separated name value pairs in ehcache.xml. Properties may be null - * @return a constructed CacheManagerEventListener - */ - public abstract CacheManagerEventListener - createCacheManagerEventListener(CacheManager cacheManager, Properties properties); -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/statistics/extended/StandardPassThroughStatistic.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/statistics/extended/StandardPassThroughStatistic.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/statistics/extended/StandardPassThroughStatistic.java (revision 0) @@ -1,125 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package net.sf.ehcache.statistics.extended; - -import java.util.Arrays; -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; -import net.sf.ehcache.Ehcache; -import org.terracotta.context.query.Query; - -import static net.sf.ehcache.statistics.extended.EhcacheQueryBuilder.cache; -import static net.sf.ehcache.statistics.extended.EhcacheQueryBuilder.descendants; - -/** - * - * @author cdennis - */ -public enum StandardPassThroughStatistic { - - /** cache size */ - CACHE_SIZE(cache(), Integer.TYPE, null, "size", "cache"), - - /** local heap size in entries */ - LOCAL_HEAP_SIZE(cache().children().exclude(Ehcache.class).add(descendants()), Integer.TYPE, 0, "size", "local-heap"), - - /** local hea size in bytes*/ - LOCAL_HEAP_SIZE_BYTES(cache().children().exclude(Ehcache.class).add(descendants()), Long.TYPE, 0L, "size-in-bytes", "local-heap"), - - /** local off heap size in entry count */ - LOCAL_OFFHEAP_SIZE(cache().children().exclude(Ehcache.class).add(descendants()), Long.TYPE, 0L, "size", "local-offheap"), - - /** local offheap size in bytes */ - LOCAL_OFFHEAP_SIZE_BYTES(cache().children().exclude(Ehcache.class).add(descendants()), Long.TYPE, 0L, "size-in-bytes", "local-offheap"), - - /** local disk size in entries */ - LOCAL_DISK_SIZE(cache().children().exclude(Ehcache.class).add(descendants()), Integer.TYPE, 0, "size", "local-disk"), - - /** local disk size in bytes */ - LOCAL_DISK_SIZE_BYTES(cache().children().exclude(Ehcache.class).add(descendants()), Long.TYPE, 0L, "size-in-bytes", "local-disk"), - - /** writer queue length */ - WRITER_QUEUE_LENGTH(cache().descendants(), Long.TYPE, 0L, "queue-length", "write-behind"), - - /** remote size */ - REMOTE_SIZE(cache().descendants(), Long.TYPE, 0L, "size", "remote"), - - /** last rejoin time */ - LAST_REJOIN_TIMESTAMP(cache().descendants(), Long.TYPE, 0L, "lastRejoinTime", "cache"); - - private static final int THIRTY = 30; - - private final Class type; - private final Query context; - private final Number absentValue; - private final String name; - private final Set tags; - - private StandardPassThroughStatistic(Query context, Class type, T absentValue, String name, String ... tags) { - this.context = context; - this.type = type; - this.absentValue = absentValue; - this.name = name; - this.tags = Collections.unmodifiableSet(new HashSet(Arrays.asList(tags))); - } - - /** - * Query that select context nodes for this statistic. - * - * @return context query - */ - final Query context() { - return context; - } - - /** - * Statistic value type. - * - * @return value type - */ - public final Class type() { - return type; - } - - /** - * Statistic value when absent. - * - * @return absent value - */ - public final Number absentValue() { - return absentValue; - } - - /** - * The name of the statistic as found in the statistics context tree. - * - * @return the statistic name - */ - public final String statisticName() { - return name; - } - - /** - * A set of tags that will be on the statistic found in the statistics context tree. - * - * @return the statistic tags - */ - public final Set tags() { - return tags; - } - -} Index: rctags/ehcache-2.10.8.0.7/ehcache/src/test/resources/serializedforms/ClusteredTransactionIDSerializationTest.testBasic.ser =================================================================== diff -u -N -r11085 -r11127 Binary files differ Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/transaction/TransactionIDImpl.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/transaction/TransactionIDImpl.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/transaction/TransactionIDImpl.java (revision 0) @@ -1,74 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package net.sf.ehcache.transaction; - -import java.util.concurrent.atomic.AtomicInteger; - -/** - * A transaction ID implementation with uniqueness across a single JVM - * - * @author Ludovic Orban - */ -public class TransactionIDImpl implements TransactionID { - - private static final AtomicInteger ID_GENERATOR = new AtomicInteger(); - - private final int id; - - /** - * Create a new TransactionIDImpl instance - */ - public TransactionIDImpl() { - this.id = ID_GENERATOR.getAndIncrement(); - } - - /** - * Create a new TransactionIDImpl instance from an existing one - * @param transactionId the transaction Id to copy - */ - protected TransactionIDImpl(TransactionIDImpl transactionId) { - TransactionIDImpl txIdImpl = transactionId; - this.id = txIdImpl.id; - } - - /** - * {@inheritDoc} - */ - @Override - public final boolean equals(Object obj) { - if (obj instanceof TransactionIDImpl) { - TransactionIDImpl otherId = (TransactionIDImpl) obj; - return id == otherId.id; - } - return false; - } - - /** - * {@inheritDoc} - */ - @Override - public final int hashCode() { - return id; - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return Integer.toString(id); - } -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/transaction/xa/XaRollbackOutcome.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/transaction/xa/XaRollbackOutcome.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/transaction/xa/XaRollbackOutcome.java (revision 0) @@ -1,30 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package net.sf.ehcache.transaction.xa; - -/** - * The Enum XaRollbackOutcome. - * - * @author cdennis - */ -public enum XaRollbackOutcome { - - /** The exception. */ - EXCEPTION, - - /** The rolledback. */ - ROLLEDBACK -} Index: rctags/ehcache-2.10.8.0.7/management-ehcache-v1/src/main/java/net/sf/ehcache/management/service/EntityResourceFactory.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/management-ehcache-v1/src/main/java/net/sf/ehcache/management/service/EntityResourceFactory.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/management-ehcache-v1/src/main/java/net/sf/ehcache/management/service/EntityResourceFactory.java (revision 0) @@ -1,82 +0,0 @@ -package net.sf.ehcache.management.service; - -import net.sf.ehcache.management.resource.CacheConfigEntity; -import net.sf.ehcache.management.resource.CacheEntity; -import net.sf.ehcache.management.resource.CacheManagerConfigEntity; -import net.sf.ehcache.management.resource.CacheManagerEntity; -import net.sf.ehcache.management.resource.CacheStatisticSampleEntity; - -import org.terracotta.management.ServiceExecutionException; - -import java.util.Collection; -import java.util.Set; - -/** - * A factory interface for resources related to Ehcache. - * - * @author brandony - */ -public interface EntityResourceFactory { - - /** - * A factory method for {@link CacheManagerEntity} objects. - * - * @param cacheManagerNames a {@code Set} of names for the CacheManager objects to be represented by the - * returned resources - * @param attributes a {@code Set} of specific cache manager attributes to include in the returned representations; - * if null, all attributes will be included - * @return a {@code Collection} of {@code CacheManagerEntity} objects - */ - Collection createCacheManagerEntities(Set cacheManagerNames, - Set attributes) throws ServiceExecutionException; - - /** - * A factory method for {@link CacheManagerConfigEntity} objects. - * - * @param cacheManagerNames a {@code Set} of names for the CacheManager configurations to be represented by the - * returned resources - * @return a {@code Collection} of {@code CacheManagerConfigEntity} objects - */ - Collection createCacheManagerConfigEntities(Set cacheManagerNames) throws ServiceExecutionException; - - /** - * A factory method for {@link CacheEntity} objects. - * - * @param cacheManagerNames a {@code Set} of names for the CacheManagers that manage the Cache - * objects to be represented by the returned resources - * @param cacheNames a {@code Set} of names for the Cache objects to be represented by the - * returned resources - * @param attributes a {@code Set} of specific cache manager attributes to include in the returned representations; - * if null, all attributes will be included - * @return a {@code Collection} of {@code CacheEntity} objects - */ - Collection createCacheEntities(Set cacheManagerNames, - Set cacheNames, - Set attributes) throws ServiceExecutionException; - - /** - * A factory method for {@link CacheConfigEntity} objects. - * - * @param cacheManagerNames a {@code Set} of names for the CacheManagers that manage the Cache - * objects to be represented by the returned resources - * @param cacheNames a {@code Set} of names for the Cache objects to be represented by the - * returned resources - * @return a {@code Collection} of {@code CacheConfigEntity} objects - */ - Collection createCacheConfigEntities(Set cacheManagerNames, - Set cacheNames) throws ServiceExecutionException; - - /** - * A factory method for {@link CacheStatisticSampleEntity} objects. - * - * @param cacheManagerNames a {@code Set} of names for the CacheManagers that manage the Caches whose - * sampled statistics are to be represented by the returned resources - * @param cacheNames a {@code Set} of names for the Caches whose sampled statistics are to be represented - * by the returned resources - * @param statNames a {@code Set} of names for the sampled statistics to be represented by the returned resources - * @return a {@code Collection} of {@code CacheStatisticSampleEntity} objects - */ - Collection createCacheStatisticSampleEntity(Set cacheManagerNames, - Set cacheNames, - Set statNames) throws ServiceExecutionException; -} Index: rctags/ehcache-2.10.8.0.7/distribution/events/src/assemble/bin/stop-sample.sh =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/distribution/events/src/assemble/bin/stop-sample.sh (revision 11085) +++ rctags/ehcache-2.10.8.0.7/distribution/events/src/assemble/bin/stop-sample.sh (revision 0) @@ -1,18 +0,0 @@ -#!/bin/bash - -cygwin=false -if [ `uname | grep CYGWIN` ]; then - cygwin=true -fi - -if [ "$JAVA_HOME" = "" ]; then - echo "JAVA_HOME is not defined" - exit 1 -fi - -unset CDPATH -root=`dirname $0`/.. -root=`cd $root && pwd` - -$root/bin/stop-jetty.sh 9081 -$root/bin/stop-jetty.sh 9082 Index: rctags/ehcache-2.10.8.0.7/system-tests/src/test/resources/scheduled-refresh-cache-test.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/system-tests/src/test/resources/scheduled-refresh-cache-test.xml (revision 11085) +++ rctags/ehcache-2.10.8.0.7/system-tests/src/test/resources/scheduled-refresh-cache-test.xml (revision 0) @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - Index: rctags/ehcache-2.10.8.0.7/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/async/ProcessingBucket.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/async/ProcessingBucket.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/async/ProcessingBucket.java (revision 0) @@ -1,551 +0,0 @@ -/* - * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved. - */ -package org.terracotta.modules.ehcache.async; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.terracotta.modules.ehcache.async.AsyncCoordinatorImpl.Callback; -import org.terracotta.modules.ehcache.async.exceptions.ProcessingException; -import org.terracotta.toolkit.cluster.ClusterInfo; -import org.terracotta.toolkit.internal.collections.ToolkitListInternal; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicLong; -import java.util.concurrent.locks.Condition; -import java.util.concurrent.locks.Lock; -import java.util.concurrent.locks.ReentrantReadWriteLock; - -public class ProcessingBucket { - private enum STOP_STATE { - NORMAL, STOP_REQUESTED, STOPPED - } - - private static final Logger LOGGER = LoggerFactory.getLogger(ProcessingBucket.class - .getName()); - private static final int UNLIMITED_QUEUE_SIZE = 0; - private static final String threadNamePrefix = "ProcessingWorker|"; - private final String bucketName; - private final AsyncConfig config; - private final ClusterInfo cluster; - private final ItemProcessor processor; - private volatile ItemsFilter filter; - private final long baselineTimestampMillis; - private final Lock bucketWriteLock; - private final Lock bucketReadLock; - private final Condition bucketNotEmpty; - private final Condition bucketNotFull; - private final Condition stoppedButBucketNotEmpty; - private final ToolkitListInternal toolkitList; - private long lastProcessingTimeMillis = -1; - private long lastWorkDoneMillis = -1; - private volatile STOP_STATE stopState = STOP_STATE.NORMAL; - private final AtomicLong workDelay; - private final ProcessingWorker processingWorkerRunnable; - private volatile Thread processingWorkerThread; - private Callback cleanupCallback; - private final boolean workingOnDeadBucket; - private volatile boolean destroyAfterStop; - - public ProcessingBucket(String bucketName, AsyncConfig config, ToolkitListInternal toolkitList, - ClusterInfo cluster, - ItemProcessor processor, boolean workingOnDeadBucket) { - this.bucketName = bucketName; - this.config = config; - this.cluster = cluster; - this.processor = processor; - this.toolkitList = toolkitList; - this.baselineTimestampMillis = System.currentTimeMillis(); - ReentrantReadWriteLock bucketLock = new ReentrantReadWriteLock(); - this.bucketReadLock = bucketLock.readLock(); - this.bucketWriteLock = bucketLock.writeLock(); - this.bucketNotEmpty = bucketWriteLock.newCondition(); - this.bucketNotFull = bucketWriteLock.newCondition(); - this.stoppedButBucketNotEmpty = bucketWriteLock.newCondition(); - this.workDelay = new AtomicLong(config.getWorkDelay()); - this.workingOnDeadBucket = workingOnDeadBucket; - this.processingWorkerRunnable = new ProcessingWorker(threadNamePrefix + bucketName); - this.destroyAfterStop = true; - } - - public String getBucketName() { - return bucketName; - } - - /** - * @return returns recent time stamp when processItems() executed. - */ - public long getLastProcessing() { - bucketReadLock.lock(); - try { - return lastProcessingTimeMillis; - } finally { - bucketReadLock.unlock(); - } - } - - public void setItemsFilter(ItemsFilter filter) { - this.filter = filter; - } - - private long baselinedCurrentTimeMillis() { - return System.currentTimeMillis() - baselineTimestampMillis; - } - - void start() { - bucketWriteLock.lock(); - try { - ensureNonExistingThread(); - processingWorkerThread = new Thread(processingWorkerRunnable); - processingWorkerThread.setName(processingWorkerRunnable.getThreadName()); - processingWorkerThread.setDaemon(true); - processingWorkerThread.start(); - } finally { - bucketWriteLock.unlock(); - } - } - - private void ensureNonExistingThread() { - if (processingWorkerThread != null) { throw new AssertionError(processingWorkerRunnable.getThreadName()); } - } - - private boolean isCancelled() { - try { - bucketReadLock.lock(); - try { - return (stopState == STOP_STATE.STOPPED) || (workingOnDeadBucket && toolkitList.isEmpty()); - } finally { - bucketReadLock.unlock(); - } - } catch (RuntimeException e) { - if (isTCNRE(e)) { - return true; - } else { - throw e; - } - } - } - - private boolean isTCNRE(Throwable th) { - return th.getClass().getName().equals("com.tc.exception.TCNotRunningException"); - } - - public int getWaitCount() { - bucketReadLock.lock(); - try { - return toolkitList.size(); - } finally { - bucketReadLock.unlock(); - } - } - - public void stopNow() { - bucketWriteLock.lock(); - try { - destroyAfterStop = false; - stopState = STOP_STATE.STOPPED; - bucketNotEmpty.signalAll(); - bucketNotFull.signalAll(); - processingWorkerThread.interrupt(); - } finally { - bucketWriteLock.unlock(); - } - } - - public void stop() { - bucketWriteLock.lock(); - try { - workDelay.set(0); - stopState = STOP_STATE.STOP_REQUESTED; - while (!toolkitList.isEmpty()) { - stoppedButBucketNotEmpty.await(); - } - stopState = STOP_STATE.STOPPED; - bucketNotEmpty.signalAll(); - bucketNotFull.signalAll(); - processingWorkerThread.interrupt(); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - } finally { - bucketWriteLock.unlock(); - } - } - - public void destroy() { - try { - debug("destroying bucket " + bucketName + " " + toolkitList.size()); - toolkitList.destroy(); - } catch (Throwable t) { - if (isTCNRE(t) && !cluster.areOperationsEnabled()) { - LOGGER - .warn("destroyToolkitList caught TCNotRunningException on processing thread, but looks like we were shut down. " - + "This can safely be ignored!", t); - } - } - } - - private String getThreadName() { - return processingWorkerRunnable.getThreadName(); - } - - // Do not take any clustered write lock in this path. - public void add(final E item) { - if (null == item) return; - int maxQueueSize = config.getMaxQueueSize(); - bucketWriteLock.lock(); - boolean interrupted = false; - try { - if (maxQueueSize != UNLIMITED_QUEUE_SIZE) { - while (!isCancelled() && toolkitList.size() >= maxQueueSize) { - try { - bucketNotFull.await(); - } catch (final InterruptedException e) { - interrupted = true; - } - } - } - boolean signalNotEmpty = toolkitList.isEmpty(); - toolkitList.unlockedAdd(item); - if (signalNotEmpty) { - bucketNotEmpty.signalAll(); - } - } finally { - bucketWriteLock.unlock(); - if (interrupted) { - Thread.currentThread().interrupt(); - } - } - } - - private int determineBatchSize() { - int batchSize = config.getBatchSize(); - int listSize = toolkitList.size(); - if (listSize < batchSize) { - batchSize = listSize; - } - return batchSize; - } - - private void debug(String message) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug(message); - } - } - - private void filterQuarantined() { - if (null == filter) { return; } - - bucketWriteLock.lock(); - try { - ItemsFilter itemsFilter = this.filter; - if (itemsFilter != null) { - debug(getThreadName() + " : filterQuarantined: filtering " + toolkitList.size() + " quarantined items"); - itemsFilter.filter(toolkitList); - debug(getThreadName() + " : filterQuarantined: retained " + toolkitList.size() + " quarantined items"); - } - } finally { - bucketWriteLock.unlock(); - } - } - - /** - * This method process items from bucket. Execution of this method does not guarantee that items from a non empty - * bucket will be processed. - */ - private void processItems() throws ProcessingException { - final int workSize; - - bucketWriteLock.lock(); - try { - // set some state related to this processing run - lastProcessingTimeMillis = baselinedCurrentTimeMillis(); - - workSize = toolkitList.size(); - // if there's no work that needs to be done, stop the processing - if (0 == workSize) { - debug(getThreadName() + " : processItems : nothing to process"); - return; - } - // filter might remove items from list, so this should be with-in writeLock - filterQuarantined(); - } finally { - bucketWriteLock.unlock(); - } - - // if the batching is enabled and work size is smaller than batch size, don't process anything as long as the max - // allowed fall behind delay hasn't expired - final int batchSize = config.getBatchSize(); - if (config.isBatchingEnabled() && batchSize > 0) { - // wait for another round if the batch size hasn't been filled up yet and the max write delay hasn't expired yet - if (workSize < batchSize && config.getMaxAllowedFallBehind() > lastProcessingTimeMillis - lastWorkDoneMillis) { - bucketReadLock.lock(); - try { - if (stopState == STOP_STATE.NORMAL) { - debug(getThreadName() + " : processItems : only " + workSize + " work items available, waiting for " - + batchSize + " items to fill up a batch"); - return; - } - } finally { - bucketReadLock.unlock(); - } - } - - // enforce the rate limit and wait for another round if too much would be processed compared to - // the last time when a batch was executed - final int rateLimit = config.getRateLimit(); - if (rateLimit > 0) { - final long secondsSinceLastWorkDone; - final int effectiveBatchSize; - bucketReadLock.lock(); - try { - if (stopState == STOP_STATE.NORMAL) { - secondsSinceLastWorkDone = (baselinedCurrentTimeMillis() - lastWorkDoneMillis) / 1000; - effectiveBatchSize = determineBatchSize(); - long maxBatchSizeSinceLastWorkDone = rateLimit * secondsSinceLastWorkDone; - if (effectiveBatchSize > maxBatchSizeSinceLastWorkDone) { - debug(getThreadName() + " : processItems() : last work was done " + secondsSinceLastWorkDone - + " seconds ago, processing " + effectiveBatchSize - + " batch items would exceed the rate limit of " + rateLimit + ", waiting for a while."); - return; - } - } - } finally { - bucketReadLock.unlock(); - } - } - } - - bucketWriteLock.lock(); - try { - lastWorkDoneMillis = baselinedCurrentTimeMillis(); - } finally { - bucketWriteLock.unlock(); - } - - doProcessItems(); - } - - private void doProcessItems() throws ProcessingException { - // process the quarantined items and remove them as they're processed - // don't process work if this node's operations have been disabled - if (!cluster.areOperationsEnabled()) { - return; - } else { - if (config.isBatchingEnabled() && config.getBatchSize() > 0) { - processBatchedItems(); - } else { - processListSnapshot(); - } - if (toolkitList.isEmpty() && stopState == STOP_STATE.STOP_REQUESTED) { - signalStop(); - } - } - } - - private void signalStop() { - bucketWriteLock.lock(); - try { - stoppedButBucketNotEmpty.signalAll(); - } finally { - bucketWriteLock.unlock(); - } - } - - private void processListSnapshot() throws ProcessingException { - int size = toolkitList.size(); - debug(getThreadName() + " : processListSnapshot size " + size + " quarantined items"); - while (size-- > 0) { - processSingleItem(); - } - } - - private void processSingleItem() throws ProcessingException { - // process the next item - final E item = getItemsFromQueue(1).get(0); - final int retryAttempts = config.getRetryAttempts(); - int executionsLeft = retryAttempts + 1; - while (executionsLeft-- > 0) { - try { - processor.process(item); - break; - } catch (final RuntimeException e) { - if (executionsLeft <= 0) { - try { - processor.throwAway(item, e); - } catch (final Throwable th) { - LOGGER.warn("processSingleItem caught error while throwing away an item: " + item, th); - } - } else { - LOGGER.warn(getThreadName() + " : processSingleItem() : exception during processing, retrying in " - + retryAttempts + " milliseconds, " + executionsLeft + " retries left", e); - try { - Thread.sleep(config.getRetryAttemptDelay()); - } catch (InterruptedException e1) { - Thread.currentThread().interrupt(); - throw e; - } - } - } - } - removeFromQueue(1); - } - - private void processBatchedItems() throws ProcessingException { - final int effectiveBatchSize = determineBatchSize(); - List batch = getItemsFromQueue(effectiveBatchSize); - final int retryAttempts = config.getRetryAttempts(); - int executionsLeft = retryAttempts + 1; - while (executionsLeft-- > 0) { - try { - processor.process(batch); - break; - } catch (final RuntimeException e) { - LOGGER.warn("processBatchedItems caught error while processing batch of " + batch.size(), e); - if (executionsLeft <= 0) { - for (E item : batch) { - try { - processor.throwAway(item, e); - } catch (final Throwable th) { - LOGGER.warn("processBatchedItems caught error while throwing away an item: " + item, th); - } - } - } else { - LOGGER.warn(getThreadName() + " : processBatchedItems() : exception during processing, retrying in " - + retryAttempts + " milliseconds, " + executionsLeft + " retries left", e); - try { - Thread.sleep(config.getRetryAttemptDelay()); - } catch (InterruptedException e1) { - Thread.currentThread().interrupt(); - throw e; - } - } - } - } - - removeFromQueue(effectiveBatchSize); - } - - private List getItemsFromQueue(final int effectiveBatchSize) { - bucketReadLock.lock(); - try { - List batch = new ArrayList(effectiveBatchSize); - for (int i = 0; i < effectiveBatchSize; i++) { - final E item = toolkitList.get(i); - batch.add(item); - } - return batch; - } finally { - bucketReadLock.unlock(); - } - } - - private void removeFromQueue(final int effectiveBatchSize) { - bucketWriteLock.lock(); - try { - boolean signalNotFull = toolkitList.size() >= this.config.getMaxQueueSize(); - - for (int i = 0; i < effectiveBatchSize; i++) { - toolkitList.remove(0); - } - - if (signalNotFull) { - bucketNotFull.signalAll(); - } - } finally { - bucketWriteLock.unlock(); - } - } - - void setCleanupCallback(Callback cleanupDeadBucket) { - this.cleanupCallback = cleanupDeadBucket; - } - - private final class ProcessingWorker implements Runnable { - private final String threadName; - - public ProcessingWorker(String threadName) { - this.threadName = threadName; - } - - public String getThreadName() { - return threadName; - } - - @Override - public void run() { - try { - while (!isCancelled()) { - // process the items if this node's operations are enabled - if (cluster.areOperationsEnabled()) { - try { - processItems(); - } catch (final Throwable e) { - if (cluster.areOperationsEnabled()) { - if (!isTCNRE(e)) { - LOGGER.error("Caught error on processing bucket " + bucketName, e); - } - } else { - LOGGER.warn("Caught error on processing items, but looks like we were shut down. " - + "This can probably be safely ignored", e); - } - continue; - } - } - - final long currentLastProcessing = getLastProcessing(); - - // Wait for new items or until the work delay has expired. - // Do not continue if the actual work delay wasn't at least the one specified in the config - // otherwise it's possible to create a new work list for just a couple of items in case - // the item processor is very fast, causing a large amount of data churn and broadcasts. - // However, if the work delay is expired, the processing should start immediately. - bucketWriteLock.lock(); - try { - try { - long tmpWorkDelay = workDelay.get(); - if (tmpWorkDelay != 0) { - do { - bucketNotEmpty.await(tmpWorkDelay, TimeUnit.MILLISECONDS); - long actualWorkDelay = baselinedCurrentTimeMillis() - currentLastProcessing; - if (actualWorkDelay < tmpWorkDelay) { - tmpWorkDelay -= actualWorkDelay; - } else { - tmpWorkDelay = 0; - } - } while (tmpWorkDelay > 0 && stopState == STOP_STATE.NORMAL); - } else { - while (!workingOnDeadBucket && stopState == STOP_STATE.NORMAL && toolkitList.isEmpty()) { - bucketNotEmpty.await(); - } - } - } catch (final InterruptedException e) { - // if the processing worker thread is interrupted, act as if the bucket was canceled - stop(); - Thread.currentThread().interrupt(); - } - } finally { - bucketWriteLock.unlock(); - } - } - } catch (Throwable t) { - if (isTCNRE(t) && !cluster.areOperationsEnabled()) { - LOGGER.warn("Caught TCNotRunningException on processing thread, but looks like we were shut down. " - + "This can safely be ignored!", t); - } - } - - if (destroyAfterStop) { - // Destroy anyways, either stop happened or other dead-client bucket was finished processing - if (workingOnDeadBucket) { - cleanupCallback.callback(); - } else { - destroy(); - } - } - } - } - -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/transaction/manager/selector/AtomikosSelector.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/transaction/manager/selector/AtomikosSelector.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/transaction/manager/selector/AtomikosSelector.java (revision 0) @@ -1,31 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package net.sf.ehcache.transaction.manager.selector; - -/** - * A Selector for the Atomikos transaction manager. - * - * @author Ludovic Orban - */ -public class AtomikosSelector extends ClassSelector { - - /** - * Constructor - */ - public AtomikosSelector() { - super("Atomikos", "com.atomikos.icatch.jta.UserTransactionManager"); - } -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/resources/ehcache-tx-twopc.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/resources/ehcache-tx-twopc.xml (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/resources/ehcache-tx-twopc.xml (revision 0) @@ -1,30 +0,0 @@ - - - - - - - - - - Index: rctags/ehcache-2.10.8.0.7/ehcache/src/test/resources/serializedforms/ReflectionAttributeExtractorSerializationTest.testFieldsKey.ser =================================================================== diff -u -N -r11085 -r11127 Binary files differ Index: rctags/ehcache-2.10.8.0.7/management-ehcache-v1/src/main/java/net/sf/ehcache/management/resource/CacheEntity.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/management-ehcache-v1/src/main/java/net/sf/ehcache/management/resource/CacheEntity.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/management-ehcache-v1/src/main/java/net/sf/ehcache/management/resource/CacheEntity.java (revision 0) @@ -1,23 +0,0 @@ -/* All content copyright (c) 2003-2012 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.*/ - -package net.sf.ehcache.management.resource; - -import java.util.HashMap; -import java.util.Map; - - -/** - *

- * An entity representing a cache resource from the management API. - *

- * - * @author brandony - * - */ -public class CacheEntity extends AbstractCacheEntity { - private Map attributes = new HashMap(); - - public Map getAttributes() { - return attributes; - } -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/DynamicCacheConfigurationTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/DynamicCacheConfigurationTest.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/DynamicCacheConfigurationTest.java (revision 0) @@ -1,330 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package net.sf.ehcache; - -import net.sf.ehcache.config.CacheConfiguration; -import net.sf.ehcache.config.Configuration; -import net.sf.ehcache.store.disk.DiskStoreHelper; - -import org.hamcrest.core.CombinableMatcher; -import org.junit.Assert; -import org.junit.Test; - -import static java.util.concurrent.TimeUnit.SECONDS; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.number.OrderingComparison.greaterThan; -import static org.hamcrest.number.OrderingComparison.lessThanOrEqualTo; -import static org.junit.Assert.assertThat; - -/** - * @author cdennis - */ -public class DynamicCacheConfigurationTest extends AbstractCacheTest { - - @Test - public void testTTIChange() throws InterruptedException { - Cache cache = new Cache("testTTIChange", 10, false, false, 0, 10); - - manager.addCache(cache); - - cache.put(new Element("key1", new Object())); - cache.put(new Element("key2", new Object())); - - assertThat(cache.get("key1").getTimeToIdle(), is(10)); - assertThat(cache.get("key2").getTimeToIdle(), is(10)); - Element element2 = cache.get("key2"); - assertThat(element2.getExpirationTime(), is(element2.getLastAccessTime() + SECONDS.toMillis(10))); - SECONDS.sleep(1); - - assertThat(cache.get("key2").getTimeToIdle(), is(10)); - element2 = cache.get("key2"); - assertThat(element2.getExpirationTime(), is(element2.getLastAccessTime() + SECONDS.toMillis(10))); - - cache.getCacheConfiguration().setTimeToIdleSeconds(20); - - cache.put(new Element("key1", new Object())); - assertThat(cache.get("key1").getTimeToIdle(), is(20)); - assertThat(cache.get("key2").getTimeToIdle(), is(20)); - - cache.getCacheConfiguration().setTimeToIdleSeconds(1); - - cache.put(new Element("key1", new Object())); - cache.put(new Element("key2", new Object())); - - assertThat(cache.get("key1").getTimeToIdle(), is(1)); - assertThat(cache.get("key2").getTimeToIdle(), is(1)); - } - - @Test - public void testTTLChange() throws InterruptedException { - Cache cache = new Cache("testTTLChange", 10, false, false, 10, 0); - - manager.addCache(cache); - - cache.put(new Element("key1", new Object())); - assertThat(cache.get("key1").getExpirationTime(), lessThanOrEqualTo(System.currentTimeMillis() + SECONDS.toMillis(10))); - assertThat(cache.get("key1").getTimeToLive(), is(10)); - - SECONDS.sleep(1); - assertThat(cache.get("key1").getExpirationTime(), lessThanOrEqualTo(System.currentTimeMillis() + SECONDS.toMillis(9))); - - Assert.assertNotNull(cache.get("key1")); - cache.put(new Element("key2", new Object())); - - assertThat(cache.get("key2").getTimeToLive(), is(10)); - - cache.getCacheConfiguration().setTimeToLiveSeconds(20); - - cache.put(new Element("key1", new Object())); - - assertThat(cache.get("key1").getTimeToLive(), is(20)); - assertThat(cache.get("key2").getTimeToLive(), is(20)); - - cache.getCacheConfiguration().setTimeToLiveSeconds(4); - - cache.put(new Element("key1", new Object())); - cache.put(new Element("key2", new Object())); - - assertThat(cache.get("key1").getTimeToLive(), is(4)); - assertThat(cache.get("key2").getTimeToLive(), is(4)); - } - - @Test - public void testTTIChangeWithCustomElements() throws InterruptedException { - Cache cache = new Cache("testTTIChangeWithCustomElements", 10, false, false, 0, 10); - - manager.addCache(cache); - - cache.put(new Element("default", new Object())); - cache.put(new Element("eternal", new Object(), true, 0, 0)); - cache.put(new Element("short", new Object(), false, 1, 1)); - cache.put(new Element("long", new Object(), false, 100, 100)); - - assertThat(cache.get("default").getTimeToIdle(), is(10)); - assertThat(cache.get("default").isEternal(), is(false)); - assertThat(cache.get("eternal").isEternal(), is(true)); - assertThat(cache.get("short").getTimeToIdle(), is(1)); - assertThat(cache.get("long").getTimeToIdle(), is(100)); - - cache.getCacheConfiguration().setTimeToIdleSeconds(4); - - cache.put(new Element("default", new Object())); - cache.put(new Element("short", new Object(), false, 1, 1)); - - assertThat(cache.get("default").getTimeToIdle(), is(4)); - assertThat(cache.get("default").isEternal(), is(false)); - assertThat(cache.get("eternal").isEternal(), is(true)); - assertThat(cache.get("short").getTimeToIdle(), is(1)); - assertThat(cache.get("long").getTimeToIdle(), is(100)); - } - - @Test - public void testTTLChangeWithCustomElement() throws InterruptedException { - Cache cache = new Cache("testTTLChangeWithCustomElements", 10, false, false, 10, 0); - - manager.addCache(cache); - - cache.put(new Element("default", new Object())); - cache.put(new Element("eternal", new Object(), true, 0, 0)); - cache.put(new Element("short", new Object(), false, 1, 1)); - cache.put(new Element("long", new Object(), false, 100, 100)); - - assertThat(cache.get("default").getTimeToLive(), is(10)); - assertThat(cache.get("default").isEternal(), is(false)); - assertThat(cache.get("eternal").isEternal(), is(true)); - assertThat(cache.get("short").getTimeToLive(), is(1)); - assertThat(cache.get("long").getTimeToLive(), is(100)); - - cache.getCacheConfiguration().setTimeToLiveSeconds(20); - - cache.put(new Element("default", new Object())); - cache.put(new Element("short", new Object(), false, 1, 1)); - - assertThat(cache.get("default").getTimeToLive(), is(20)); - assertThat(cache.get("default").isEternal(), is(false)); - assertThat(cache.get("eternal").isEternal(), is(true)); - assertThat(cache.get("short").getTimeToLive(), is(1)); - assertThat(cache.get("long").getTimeToLive(), is(100)); - - } - - @Test - public void testMemoryCapacityChange() { - Cache cache = new Cache("testMemoryCapacityChange", 10, false, true, 0, 0); - manager.addCache(cache); - - for (int i = 0; i < 20; i++) { - cache.put(new Element("key" + i, new Object())); - Assert.assertTrue(cache.getSize() <= 10); - Assert.assertTrue(cache.getStatistics().getLocalHeapSize() <= 10); - } - - cache.getCacheConfiguration().setMaxElementsInMemory(20); - - for (int i = 20; i < 40; i++) { - cache.put(new Element("key" + i, new Object())); - Assert.assertTrue(cache.getSize() <= 20); - Assert.assertTrue(cache.getSize() > 10); - Assert.assertTrue(cache.getStatistics().getLocalHeapSize() <= 20); - Assert.assertTrue(cache.getStatistics().getLocalHeapSize() > 10); - } - - cache.getCacheConfiguration().setMaxElementsInMemory(5); - - for (int i = 40; i < 60; i++) { - cache.put(new Element("key" + i, new Object())); - } - - Assert.assertEquals(5, cache.getSize()); - Assert.assertEquals(5, cache.getStatistics().getLocalHeapSize()); - } - - @Test - public void testDiskCapacityChange() throws Exception { - final int DISK_WIGGLE = 2; - - Cache cache = new Cache("testDiskCapacityChange", 10, true, true, 0, 0); - cache.getCacheConfiguration().setMaxElementsOnDisk(20); - manager.addCache(cache); - - for (int i = 0; i < 40; i++) { - cache.put(new Element("key" + i, new byte[0])); - DiskStoreHelper.flushAllEntriesToDisk(cache).get(); - assertThat(cache.getSize(), lessThanOrEqualTo(20)); - assertThat(cache.getStatistics().getLocalHeapSize(), lessThanOrEqualTo(10L)); - assertThat(cache.getStatistics().getLocalDiskSize(), lessThanOrEqualTo(20L + DISK_WIGGLE)); - } - - cache.getCacheConfiguration().setMaxElementsOnDisk(20); - - for (int i = 40; i < 80; i++) { - cache.put(new Element("key" + i, new byte[0])); - DiskStoreHelper.flushAllEntriesToDisk(cache).get(); - assertThat(cache.getSize(), CombinableMatcher.both(lessThanOrEqualTo(30)).and(greaterThan(10))); - assertThat(cache.getStatistics().getLocalHeapSize(), lessThanOrEqualTo(10L)); - assertThat(cache.getStatistics().getLocalDiskSize(), CombinableMatcher.both(lessThanOrEqualTo(20L + DISK_WIGGLE)).and(greaterThan(10L))); - } - - cache.getCacheConfiguration().setMaxElementsOnDisk(10); - - for (int i = 80; i < 120; i++) { - cache.put(new Element("key" + i, new byte[0])); - DiskStoreHelper.flushAllEntriesToDisk(cache).get(); - } - - assertThat(cache.getSize(), lessThanOrEqualTo(10)); - assertThat(cache.getStatistics().getLocalHeapSize(), lessThanOrEqualTo(10L)); - Assert.assertEquals(10, cache.getStatistics().getLocalDiskSize()); - } - - @Test - public void testCacheWithFrozenConfig() { - Configuration managerConfig = new Configuration() - .dynamicConfig(false) - .defaultCache(new CacheConfiguration("definedCache1", 20)) - .cache(new CacheConfiguration("definedCache", 10).eternal(true)).name("new-cm"); - - CacheManager manager = new CacheManager(managerConfig); - - Cache defined = manager.getCache("definedCache"); - try { - defined.getCacheConfiguration().setTimeToIdleSeconds(99); - Assert.fail(); - } catch (CacheException e) { - // expected - } - - try { - defined.setDisabled(true); - Assert.fail(); - } catch (CacheException e) { - // expected - } - - defined.put(new Element("key", "value")); - Assert.assertNotNull(defined.get("key")); - - Cache programmatic = new Cache("programmatic", 10, false, true, 0, 0); - manager.addCache(programmatic); - try { - programmatic.getCacheConfiguration().setTimeToIdleSeconds(99); - Assert.fail(); - } catch (CacheException e) { - // expected - } - - try { - programmatic.setDisabled(true); - Assert.fail(); - } catch (CacheException e) { - // expected - } - - programmatic.put(new Element("key", "value")); - Assert.assertNotNull(programmatic.get("key")); - manager.shutdown(); - } - - @Test - public void testConfiguringClonedCache() throws CloneNotSupportedException { - Cache cache = new Cache("testConfiguringClonedCache", 10, false, true, 0, 0); - Cache clone = cache.clone(); - clone.setName("testConfiguringClonedCacheCloned"); - - manager.addCache(cache); - manager.addCache(clone); - - Assert.assertEquals(10, cache.getCacheConfiguration().getMaxElementsInMemory()); - Assert.assertEquals(10, clone.getCacheConfiguration().getMaxElementsInMemory()); - - for (int i = 0; i < 20; i++) { - cache.put(new Element("key" + i, new Object())); - Assert.assertTrue(cache.getSize() <= 10); - Assert.assertTrue(cache.getStatistics().getLocalHeapSize() <= 10); - } - - for (int i = 0; i < 20; i++) { - clone.put(new Element("key" + i, new Object())); - Assert.assertTrue(clone.getSize() <= 10); - Assert.assertTrue(clone.getStatistics().getLocalHeapSize() <= 10); - } - - cache.getCacheConfiguration().setMaxElementsInMemory(20); - clone.getCacheConfiguration().setMaxElementsInMemory(5); - - for (int i = 20; i < 40; i++) { - cache.put(new Element("key" + i, new Object())); - Assert.assertTrue(cache.getSize() <= 20); - Assert.assertTrue(cache.getSize() > 10); - Assert.assertTrue(cache.getStatistics().getLocalHeapSize() <= 20); - Assert.assertTrue(cache.getStatistics().getLocalHeapSize() > 10); - } - - for (int i = 20; i < 40; i++) { - clone.put(new Element("key" + i, new Object())); - } - - Assert.assertEquals(5, clone.getSize()); - Assert.assertEquals(5, clone.getStatistics().getLocalHeapSize()); - - cache.getCacheConfiguration().setMaxElementsInMemory(5); - clone.getCacheConfiguration().setMaxElementsInMemory(20); - - for (int i = 40; i < 60; i++) { - cache.put(new Element("key" + i, new Object())); - } - - Assert.assertEquals(5, cache.getSize()); - Assert.assertEquals(5, cache.getStatistics().getLocalHeapSize()); - - for (int i = 40; i < 60; i++) { - clone.put(new Element("key" + i, new Object())); - Assert.assertTrue(clone.getSize() <= 20); - Assert.assertTrue(clone.getSize() > 5); - Assert.assertTrue(clone.getStatistics().getLocalHeapSize() <= 20); - Assert.assertTrue(clone.getStatistics().getLocalHeapSize() > 5); - } - } -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/statistics/CoreStatisticsImpl.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/statistics/CoreStatisticsImpl.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/statistics/CoreStatisticsImpl.java (revision 0) @@ -1,291 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.sf.ehcache.statistics; - -import net.sf.ehcache.CacheOperationOutcomes; -import net.sf.ehcache.CacheOperationOutcomes.ClusterEventOutcomes; -import net.sf.ehcache.CacheOperationOutcomes.EvictionOutcome; -import net.sf.ehcache.CacheOperationOutcomes.ExpiredOutcome; -import net.sf.ehcache.statistics.extended.ExtendedStatistics; -import net.sf.ehcache.statistics.extended.ExtendedStatistics.Operation; -import net.sf.ehcache.store.StoreOperationOutcomes.GetOutcome; -import net.sf.ehcache.store.StoreOperationOutcomes.PutOutcome; -import net.sf.ehcache.store.StoreOperationOutcomes.RemoveOutcome; -import net.sf.ehcache.transaction.xa.XaCommitOutcome; -import net.sf.ehcache.transaction.xa.XaRecoveryOutcome; -import net.sf.ehcache.transaction.xa.XaRollbackOutcome; - -import java.util.Arrays; -import java.util.EnumSet; - -/** - * The CoreStatisticsImpl class. - * - * @author cschanck - */ -public class CoreStatisticsImpl implements CoreStatistics { - - private final ExtendedStatistics extended; - private final CountOperation cacheGet; - private final CountOperation cachePut; - private final CountOperation cacheRemove; - private final CountOperation cacheReplace1; - private final CountOperation cacheReplace2; - private final CountOperation cachePutIfAbsent; - private final CountOperation cacheRemoveElement; - private final CountOperation localHeapGet; - private final CountOperation localHeapPut; - - private final CountOperation localHeapRemove; - private final CountOperation localOffHeapGet; - private final CountOperation localOffHeapPut; - private final CountOperation localOffHeapRemove; - private final CountOperation localDiskGet; - private final CountOperation localDiskPut; - private final CountOperation localDiskRemove; - private final CountOperation xaCommit; - private final CountOperation xaRecovery; - private final CountOperation xaRollback; - private final CountOperation evicted; - private final CountOperation expired; - - private final CountOperation cacheClusterEvent; - - /** - * Instantiates a new core statistics impl. - * - * @param extended the extended - */ - public CoreStatisticsImpl(ExtendedStatistics extended) { - this.extended = extended; - this.cacheGet = asCountOperation(extended.get()); - this.cachePut = asCountOperation(extended.put()); - this.cacheRemove = asCountOperation(extended.remove()); - this.cacheReplace1 = asCountOperation(extended.replaceOneArg()); - this.cacheReplace2 = asCountOperation(extended.replaceOneArg()); - this.cachePutIfAbsent = asCountOperation(extended.putIfAbsent()); - this.cacheRemoveElement = asCountOperation(extended.removeElement()); - this.localHeapGet = asCountOperation(extended.heapGet()); - this.localHeapPut = asCountOperation(extended.heapPut()); - this.localHeapRemove = asCountOperation(extended.heapRemove()); - - this.localOffHeapGet = asCountOperation(extended.offheapGet()); - this.localOffHeapPut = asCountOperation(extended.offheapPut()); - this.localOffHeapRemove = asCountOperation(extended.offheapRemove()); - - this.localDiskGet = asCountOperation(extended.diskGet()); - this.localDiskPut = asCountOperation(extended.diskPut()); - this.localDiskRemove = asCountOperation(extended.diskRemove()); - - this.xaCommit = asCountOperation(extended.xaCommit()); - this.xaRecovery = asCountOperation(extended.xaRecovery()); - this.xaRollback = asCountOperation(extended.xaRollback()); - - this.evicted = asCountOperation(extended.eviction()); - this.expired = asCountOperation(extended.expiry()); - - this.cacheClusterEvent = asCountOperation(extended.clusterEvent()); - } - - private static > CountOperation asCountOperation(final Operation compoundOp) { - return new CountOperation() { - @Override - public long value(T result) { - return compoundOp.component(result).count().value(); - } - - @Override - public long value(T... results) { - return compoundOp.compound(EnumSet.copyOf(Arrays.asList(results))).count().value(); - } - - }; - } - - /* (non-Javadoc) - * @see net.sf.ehcache.statistics.CoreStatistics#get() - */ - @Override - public CountOperation get() { - return cacheGet; - } - - /* (non-Javadoc) - * @see net.sf.ehcache.statistics.CoreStatistics#put() - */ - @Override - public CountOperation put() { - return cachePut; - } - - /* (non-Javadoc) - * @see net.sf.ehcache.statistics.CoreStatistics#remove() - */ - @Override - public CountOperation remove() { - return cacheRemove; - } - - /* (non-Javadoc) - * @see net.sf.ehcache.statistics.CoreStatistics#replaceOneArg() - */ - @Override - public CountOperation replaceOneArg() { - return cacheReplace1; - } - - /* (non-Javadoc) - * @see net.sf.ehcache.statistics.CoreStatistics#replaceTwoArg() - */ - @Override - public CountOperation replaceTwoArg() { - return cacheReplace2; - } - - /* (non-Javadoc) - * @see net.sf.ehcache.statistics.CoreStatistics#putIfAbsent() - */ - @Override - public CountOperation putIfAbsent() { - return cachePutIfAbsent; - } - - /* (non-Javadoc) - * @see net.sf.ehcache.statistics.CoreStatistics#removeElement() - */ - @Override - public CountOperation removeElement() { - return cacheRemoveElement; - } - - /* (non-Javadoc) - * @see net.sf.ehcache.statistics.CoreStatistics#localHeapGet() - */ - @Override - public CountOperation localHeapGet() { - return localHeapGet; - } - - /* (non-Javadoc) - * @see net.sf.ehcache.statistics.CoreStatistics#localHeapPut() - */ - @Override - public CountOperation localHeapPut() { - return localHeapPut; - } - - /* (non-Javadoc) - * @see net.sf.ehcache.statistics.CoreStatistics#localHeapRemove() - */ - @Override - public CountOperation localHeapRemove() { - return localHeapRemove; - } - - /* (non-Javadoc) - * @see net.sf.ehcache.statistics.CoreStatistics#localOffHeapGet() - */ - @Override - public CountOperation localOffHeapGet() { - return localOffHeapGet; - } - - /* (non-Javadoc) - * @see net.sf.ehcache.statistics.CoreStatistics#localOffHeapPut() - */ - @Override - public CountOperation localOffHeapPut() { - return localOffHeapPut; - } - - /* (non-Javadoc) - * @see net.sf.ehcache.statistics.CoreStatistics#localOffHeapRemove() - */ - @Override - public CountOperation localOffHeapRemove() { - return localOffHeapRemove; - } - - /* (non-Javadoc) - * @see net.sf.ehcache.statistics.CoreStatistics#localDiskGet() - */ - @Override - public CountOperation localDiskGet() { - return localDiskGet; - } - - /* (non-Javadoc) - * @see net.sf.ehcache.statistics.CoreStatistics#localDiskPut() - */ - @Override - public CountOperation localDiskPut() { - return localDiskPut; - } - - /* (non-Javadoc) - * @see net.sf.ehcache.statistics.CoreStatistics#localDiskRemove() - */ - @Override - public CountOperation localDiskRemove() { - return localDiskRemove; - } - - /** - * {@inheritDoc} - */ - public CountOperation xaCommit() { - return xaCommit; - } - - /** - * {@inheritDoc} - */ - @Override - public CountOperation xaRecovery() { - return xaRecovery; - } - - /** - * {@inheritDoc} - */ - @Override - public CountOperation xaRollback() { - return xaRollback; - } - - /* - * {@inheritDoc} - */ - @Override - public CountOperation cacheEviction() { - return evicted; - } - - /* - * {@inheritDoc} - */ - @Override - public CountOperation cacheExpiration() { - return expired; - } - - @Override - public CountOperation cacheClusterEvent() { - return cacheClusterEvent; - } - -} \ No newline at end of file Index: rctags/ehcache-2.10.8.0.7/management-ehcache-impl/management-ehcache-common/src/main/java/com/terracotta/management/ApplicationEhCache.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/management-ehcache-impl/management-ehcache-common/src/main/java/com/terracotta/management/ApplicationEhCache.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/management-ehcache-impl/management-ehcache-common/src/main/java/com/terracotta/management/ApplicationEhCache.java (revision 0) @@ -1,25 +0,0 @@ -/* - * All content copyright (c) 2003-2012 Terracotta, Inc., except as may otherwise be noted in a separate copyright - * notice. All rights reserved. - */ -package com.terracotta.management; - -import java.util.HashSet; -import java.util.ServiceLoader; -import java.util.Set; - -import javax.ws.rs.core.Application; - -public class ApplicationEhCache extends Application { - - @Override - public Set> getClasses() { - Set> restResourcesClasses = new HashSet>(); - ServiceLoader loader = ServiceLoader.load(ApplicationEhCacheService.class, ApplicationEhCacheService.class.getClassLoader()); - for (ApplicationEhCacheService applicationEhCacheService : loader) { - restResourcesClasses.addAll(applicationEhCacheService.getRestResourceClasses()); - } - return restResourcesClasses; - } - -} \ No newline at end of file Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/resources/ehcache-withdefaultset.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/resources/ehcache-withdefaultset.xml (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/resources/ehcache-withdefaultset.xml (revision 0) @@ -1,164 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/event/RegisteredEventListenersMockHelper.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/event/RegisteredEventListenersMockHelper.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/event/RegisteredEventListenersMockHelper.java (revision 0) @@ -1,48 +0,0 @@ -package net.sf.ehcache.event; - -import net.sf.ehcache.Cache; -import net.sf.ehcache.CacheStoreHelper; -import net.sf.ehcache.Ehcache; -import net.sf.ehcache.Element; - -/** - * This class exists solely to widen the scope of the 5 internal package protected methods in - * {@link net.sf.ehcache.event.RegisteredEventListeners} so that it can be mocked. - * - * @author cschanck - */ -public class RegisteredEventListenersMockHelper extends RegisteredEventListeners { - - public RegisteredEventListenersMockHelper(Cache cache) { - super(cache); - } - - public RegisteredEventListenersMockHelper(Ehcache cache, CacheStoreHelper helper) { - super(cache, helper); - } - - @Override - public void internalNotifyElementRemoved(Element element, ElementCreationCallback callback, boolean remoteEvent) { - super.internalNotifyElementRemoved(element, callback, remoteEvent); - } - - @Override - public void internalNotifyElementPut(Element element, ElementCreationCallback callback, boolean remoteEvent) { - super.internalNotifyElementPut(element, callback, remoteEvent); - } - - @Override - public void internalNotifyElementUpdated(Element element, ElementCreationCallback callback, boolean remoteEvent) { - super.internalNotifyElementUpdated(element, callback, remoteEvent); - } - - @Override - public void internalNotifyElementExpiry(Element element, ElementCreationCallback callback, boolean remoteEvent) { - super.internalNotifyElementExpiry(element, callback, remoteEvent); - } - - @Override - public void internalNotifyElementEvicted(Element element, ElementCreationCallback callback, boolean remoteEvent) { - super.internalNotifyElementEvicted(element, callback, remoteEvent); - } -} Index: rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/ehcache/tests/OtherClassloaderCacheTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/ehcache/tests/OtherClassloaderCacheTest.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/ehcache/tests/OtherClassloaderCacheTest.java (revision 0) @@ -1,22 +0,0 @@ -/* - * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved. - */ -package org.terracotta.ehcache.tests; - -import org.objectweb.asm.ClassWriter; -import org.terracotta.test.util.TestBaseUtil; - -import com.tc.test.config.model.TestConfig; - -public class OtherClassloaderCacheTest extends AbstractCacheTestBase { - - @Override - protected String getTestDependencies() { - return TestBaseUtil.jarFor(ClassWriter.class); - } - public OtherClassloaderCacheTest(TestConfig testConfig) { - super("small-memory-cache-test.xml", testConfig, OtherClassloaderClient.class, ReaderClient.class); - testConfig.getClientConfig().setParallelClients(false); - } - -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/distribution/LegacyEventMessage.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/distribution/LegacyEventMessage.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/distribution/LegacyEventMessage.java (revision 0) @@ -1,126 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.sf.ehcache.distribution; - -import java.io.IOException; -import java.io.Serializable; -import java.lang.ref.SoftReference; - -import net.sf.ehcache.Element; - -/** - * An Event Message, in respect of a particular cache. - *

- * The message is Serializable, so that it can be sent across the network. - *

- * The value of an Element is referenced with a SoftReference, so that a - * value will fail to be delivered in preference to an OutOfMemory error. - * - * @author Greg Luck - * @version $Id: EventMessage.java 2154 2010-04-06 02:45:52Z cdennis $ - */ -public class LegacyEventMessage extends EventMessage { - - /** - * A put or update event. - */ - public static final int PUT = 0; - - /** - * A remove or invalidate event. - */ - public static final int REMOVE = 1; - - - /** - * A removeAll, which removes all elements from a cache - */ - public static final int REMOVE_ALL = 3; - - private static final long serialVersionUID = -293616939110963630L; - - /** - * The event component. - */ - private final int event; - - /** - * The element component. This is held by a SoftReference, so as to prevent - * out of memory errors. - */ - private transient SoftReference elementSoftReference; - - /** - * Used to check if the value has been GCed - */ - private final boolean wasElementNotNull; - - - /** - * Full constructor. - * - * @param event - * @param key - * @param element - */ - public LegacyEventMessage(int event, Serializable key, Element element) { - super(null, key); - this.event = event; - wasElementNotNull = element != null; - elementSoftReference = new SoftReference(element); - } - - /** - * Gets the event. - * - * @return either {@link #PUT} or {@link #REMOVE} - */ - public final int getEvent() { - return event; - } - - /** - * @return the element component of the message. null if a {@link #REMOVE} event - */ - public final Element getElement() { - return (Element) elementSoftReference.get(); - } - - /** - * @return true if because of SoftReference GC this LegacyEventMessage is no longer valid - */ - public boolean isValid() { - if (!wasElementNotNull) { - return true; - } else { - return getElement() != null; - } - } - - private void writeObject(java.io.ObjectOutputStream out) throws IOException { - out.defaultWriteObject(); - Element element = getElement(); - out.writeObject(element); - } - - private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException { - in.defaultReadObject(); - Element element = (Element) in.readObject(); - elementSoftReference = new SoftReference(element); - } -} - Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/statistics/LiveCacheStatisticsTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/statistics/LiveCacheStatisticsTest.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/statistics/LiveCacheStatisticsTest.java (revision 0) @@ -1,460 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.sf.ehcache.statistics; - -import net.sf.ehcache.AbstractCacheTest; -import net.sf.ehcache.Cache; - -import org.junit.Test; - -/** - * Tests for the statistics class - * - * @author Abhishek Sanoujam - * @version $Id: CacheUsageStatisticsTest.java 1221 2009-09-25 17:29:35Z asingh - * $ - */ -public class LiveCacheStatisticsTest extends AbstractCacheTest { - - - /** - * test enable disable - */ - @Test - public void testEnableDisable() { -// Cache cache = new Cache("test", 1, true, false, 5, 2); -// manager.addCache(cache); -// -// cache.setStatisticsEnabled(true); -// assertTrue(cache.isStatisticsEnabled()); -// assertFalse(cache.isSampledStatisticsEnabled()); -// -// cache.setStatisticsEnabled(false); -// assertFalse(cache.isStatisticsEnabled()); -// assertFalse(cache.isSampledStatisticsEnabled()); -// -// // enabling sampled enables both -// cache.setSampledStatisticsEnabled(true); -// assertTrue(cache.isStatisticsEnabled()); -// assertTrue(cache.isSampledStatisticsEnabled()); -// -// cache.setSampledStatisticsEnabled(false); -// assertTrue(cache.isStatisticsEnabled()); -// assertFalse(cache.isSampledStatisticsEnabled()); -// -// // enable sampled again -// cache.setSampledStatisticsEnabled(true); -// assertTrue(cache.isStatisticsEnabled()); -// assertTrue(cache.isSampledStatisticsEnabled()); -// -// // disabling live disables sampled too -// cache.setStatisticsEnabled(false); -// assertFalse(cache.isStatisticsEnabled()); -// assertFalse(cache.isSampledStatisticsEnabled()); - } - - /** - * Test statistics enabling/disabling/clearing - * - * @throws InterruptedException - */ - @Test - public void testCacheUsageStatistics() throws InterruptedException { -// // Set size so the second element overflows to disk. -// Cache cache = new Cache("test", 1, true, false, 5, 2); -// manager.addCache(cache); -// -// cache.setStatisticsEnabled(true); -// doTestCacheUsageStatistics(cache, true); -// -// // test enable/disable statistics -// cache.setStatisticsEnabled(false); -// doTestCacheUsageStatistics(cache, false); -// -// assertEquals(Statistics.STATISTICS_ACCURACY_BEST_EFFORT, cache -// .getLiveCacheStatistics().getStatisticsAccuracy()); -// assertEquals("Best Effort", cache.getLiveCacheStatistics() -// .getStatisticsAccuracyDescription()); - - } - - /** - * Test statistics directly. Tests - * - cacheHitCount - * - onDiskHitCount - * - inMemoryHitCount - * - cacheMissCount - * - size - * - inMemorySize - * - onDiskSize - * - clearing statistics - * - average get time - */ - public void doTestCacheUsageStatistics(Cache cache, - boolean statisticsEnabled) throws InterruptedException { -// -// cache.put(new Element("key1", "value1")); -// cache.put(new Element("key2", "value1")); -// // key1 should be in the Disk Store -// cache.get("key1"); -// -// LiveCacheStatistics statistics = cache.getLiveCacheStatistics(); -// if (statisticsEnabled) { -// assertEquals(1, statistics.getCacheHitCount()); -// assertEquals(1, statistics.getOnDiskHitCount()); -// assertEquals(0, statistics.getInMemoryHitCount()); -// assertEquals(0, statistics.getCacheMissCount()); -// assertEquals(2, statistics.getSize()); -// assertEquals(1, statistics.getInMemorySize()); -// final LiveCacheStatistics finalStatistics = statistics; -// RetryAssert.assertBy(5, SECONDS, new Callable() { -// public Long call() throws Exception { -// return finalStatistics.getOnDiskSize(); -// } -// }, Is.is(2L)); -// } else { -// assertEquals(0, statistics.getCacheHitCount()); -// assertEquals(0, statistics.getOnDiskHitCount()); -// assertEquals(0, statistics.getInMemoryHitCount()); -// assertEquals(0, statistics.getCacheMissCount()); -// assertEquals(0, statistics.getSize()); -// assertEquals(0, statistics.getInMemorySize()); -// assertEquals(0, statistics.getOnDiskSize()); -// } -// -// // key 1 should now be in the LruMemoryStore -// cache.get("key1"); -// -// statistics = cache.getLiveCacheStatistics(); -// if (statisticsEnabled) { -// assertEquals(2, statistics.getCacheHitCount()); -// assertEquals(1, statistics.getOnDiskHitCount()); -// assertEquals(1, statistics.getInMemoryHitCount()); -// assertEquals(0, statistics.getCacheMissCount()); -// } else { -// assertEquals(0, statistics.getCacheHitCount()); -// assertEquals(0, statistics.getOnDiskHitCount()); -// assertEquals(0, statistics.getInMemoryHitCount()); -// assertEquals(0, statistics.getCacheMissCount()); -// } -// -// // Let the idle expire -// Thread.sleep(6000); -// -// // key 1 should now be expired -// cache.get("key1"); -// statistics = cache.getLiveCacheStatistics(); -// if (statisticsEnabled) { -// assertEquals(2, statistics.getCacheHitCount()); -// assertEquals(1, statistics.getOnDiskHitCount()); -// assertEquals(1, statistics.getInMemoryHitCount()); -// assertEquals(1, statistics.getCacheMissCount()); -// } else { -// assertEquals(0, statistics.getCacheHitCount()); -// assertEquals(0, statistics.getOnDiskHitCount()); -// assertEquals(0, statistics.getInMemoryHitCount()); -// assertEquals(0, statistics.getCacheMissCount()); -// } -// -// // key 2 should also be expired -// cache.get("key1"); -// statistics = cache.getLiveCacheStatistics(); -// if (statisticsEnabled) { -// assertEquals(2, statistics.getCacheHitCount()); -// assertEquals(1, statistics.getOnDiskHitCount()); -// assertEquals(1, statistics.getInMemoryHitCount()); -// assertEquals(2, statistics.getCacheMissCount()); -// } else { -// assertEquals(0, statistics.getCacheHitCount()); -// assertEquals(0, statistics.getOnDiskHitCount()); -// assertEquals(0, statistics.getInMemoryHitCount()); -// assertEquals(0, statistics.getCacheMissCount()); -// } -// -// cache.clearStatistics(); -// // everything should be zero now -// assertEquals(0, statistics.getCacheHitCount()); -// assertEquals(0, statistics.getOnDiskHitCount()); -// assertEquals(0, statistics.getInMemoryHitCount()); -// assertEquals(0, statistics.getCacheMissCount()); -// -// assertNotNull(statistics.toString()); - } - - /** - * Test average get time - * - * @throws InterruptedException - */ - @Test - public void testAverageGetTime() throws InterruptedException { -// Cache cache = new Cache("test", 0, true, false, 5, 2); -// manager.addCache(cache); -// cache.setStatisticsEnabled(true); -// doTestAverageGetTime(cache, true); -// -// // test enable/disable statistics -// cache.setStatisticsEnabled(false); -// doTestAverageGetTime(cache, false); - } - - /** - * Tests average get time - */ - public void doTestAverageGetTime(Cache cache, boolean statsEnabled) { -// LiveCacheStatistics statistics = cache.getLiveCacheStatistics(); -// float averageGetTime = statistics.getAverageGetTimeMillis(); -// assertTrue(0 == statistics.getAverageGetTimeMillis()); -// -// for (int i = 0; i < 10000; i++) { -// cache.put(new Element("" + i, "value1")); -// } -// cache.put(new Element("key1", "value1")); -// cache.put(new Element("key2", "value1")); -// for (int i = 0; i < 110000; i++) { -// cache.get("" + i); -// } -// -// statistics = cache.getLiveCacheStatistics(); -// averageGetTime = statistics.getAverageGetTimeMillis(); -// if (statsEnabled) { -// assertTrue(averageGetTime >= .000001); -// } else { -// assertTrue(0 == averageGetTime); -// } -// cache.clearStatistics(); -// assertTrue(0 == statistics.getAverageGetTimeMillis()); - } - - /** - * Test cache eviction/expiry stats - * - * @throws InterruptedException - */ - @Test - public void testEvictionStatistics() throws InterruptedException { -// doTestEvictionStatistics(true); -// -// doTestEvictionStatistics(false); - } - - /** - * Tests eviction statistics - * - evictedCount - * - missCountNotFound - * - missCountExpired - * - missCount - * - expiredCount - * - size - */ - public void doTestEvictionStatistics(boolean statsEnabled) - throws InterruptedException { -// // run 5 times with random total and capacity values -// Random rand = new Random(); -// int min = 100; -// for (int loop = 0; loop < 5; loop++) { -// int a = rand.nextInt(10000) + min; -// int b = rand.nextInt(10000) + min; -// if (a == b) { -// a += min; -// } -// int total = Math.max(a, b); -// int capacity = Math.min(a, b); -// Ehcache ehcache = new net.sf.ehcache.Cache("test-" + statsEnabled -// + "-" + loop, capacity, false, false, 2, 2); -// manager.addCache(ehcache); -// ehcache.setStatisticsEnabled(statsEnabled); -// -// LiveCacheStatistics statistics = ehcache.getLiveCacheStatistics(); -// assertEquals(0, statistics.getEvictedCount()); -// -// for (int i = 0; i < total; i++) { -// ehcache.put(new Element("" + i, "value1")); -// } -// if (statsEnabled) { -// assertEquals(total - capacity, statistics.getEvictedCount()); -// } else { -// assertEquals(0, statistics.getEvictedCount()); -// } -// -// Thread.sleep(3010); -// -// // expiries do not count as eviction -// if (statsEnabled) { -// assertEquals(total - capacity, statistics.getEvictedCount()); -// } else { -// assertEquals(0, statistics.getEvictedCount()); -// } -// -// // no expiration till a get is tried -// assertEquals(0, statistics.getCacheMissCount()); -// assertEquals(0, statistics.getCacheMissCountExpired()); -// assertEquals(0, statistics.getExpiredCount()); -// assertEquals(0, statistics.getCacheMissCount()); -// -// for (int i = 0; i < total; i++) { -// ehcache.get("" + i); -// } -// -// if (statsEnabled) { -// assertEquals(total, statistics.getCacheMissCount()); -// assertEquals(capacity, statistics.getCacheMissCountExpired()); -// assertEquals(capacity, statistics.getExpiredCount()); -// assertEquals(total, statistics.getCacheMissCount()); -// assertEquals(0, statistics.getSize()); -// } else { -// assertEquals(0, statistics.getCacheMissCount()); -// assertEquals(0, statistics.getCacheMissCountExpired()); -// assertEquals(0, statistics.getExpiredCount()); -// assertEquals(0, statistics.getCacheMissCount()); -// assertEquals(0, statistics.getSize()); -// } -// -// ehcache.clearStatistics(); -// -// assertEquals(0, statistics.getCacheMissCount()); -// assertEquals(0, statistics.getCacheMissCountExpired()); -// assertEquals(0, statistics.getExpiredCount()); -// assertEquals(0, statistics.getCacheMissCount()); -// assertEquals(0, statistics.getSize()); -// } - - } - - /** - * Test element put/update/remove - * - putCount - * - updateCount - * - removeCount - */ - @Test - public void testPutUpdateRemoveStats() throws InterruptedException { -// doTestElementUpdateRemove(true); -// -// doTestElementUpdateRemove(false); - } - - public void doTestElementUpdateRemove(boolean statsEnabled) - throws InterruptedException { -// Random rand = new Random(); -// int min = 100; -// for (int loop = 0; loop < 5; loop++) { -// int total = rand.nextInt(10000) + min; -// -// // always ensure enough capacity. Otherwise cannot predict -// // updateCount with eviction (based on capacity) -// Ehcache ehcache = new net.sf.ehcache.Cache("test-" + statsEnabled -// + "-" + loop, total + 1, false, false, 1200, 1200); -// manager.addCache(ehcache); -// ehcache.setStatisticsEnabled(statsEnabled); -// -// LiveCacheStatistics statistics = ehcache.getLiveCacheStatistics(); -// -// assertEquals(0, statistics.getEvictedCount()); -// assertEquals(0, statistics.getPutCount()); -// assertEquals(0, statistics.getRemovedCount()); -// assertEquals(0, statistics.getUpdateCount()); -// -// for (int i = 0; i < total; i++) { -// ehcache.put(new Element("" + i, "value1")); -// } -// if (statsEnabled) { -// assertEquals(total, statistics.getPutCount()); -// assertEquals(0, statistics.getEvictedCount()); -// assertEquals(total, statistics.getSize()); -// assertEquals(0, statistics.getUpdateCount()); -// assertEquals(0, statistics.getRemovedCount()); -// } else { -// assertEquals(0, statistics.getPutCount()); -// assertEquals(0, statistics.getEvictedCount()); -// assertEquals(0, statistics.getSize()); -// assertEquals(0, statistics.getRemovedCount()); -// assertEquals(0, statistics.getUpdateCount()); -// } -// -// // minimum 1 update -// int updates = rand.nextInt(total - 1) + 1; -// assertTrue(updates >= 1); -// for (int i = 0; i < updates; i++) { -// ehcache.put(new Element("" + i, "value1")); -// } -// if (statsEnabled) { -// assertEquals(total, statistics.getSize()); -// assertEquals(updates, statistics.getUpdateCount()); -// assertEquals(total, statistics.getPutCount()); -// assertEquals(0, statistics.getEvictedCount()); -// assertEquals(0, statistics.getRemovedCount()); -// } else { -// assertEquals(0, statistics.getSize()); -// assertEquals(0, statistics.getPutCount()); -// assertEquals(0, statistics.getRemovedCount()); -// assertEquals(0, statistics.getEvictedCount()); -// assertEquals(0, statistics.getUpdateCount()); -// } -// -// // minimum 1 remove -// int remove = rand.nextInt(total - 1) + 1; -// assertTrue(updates >= 1); -// for (int i = 0; i < remove; i++) { -// ehcache.remove("" + i); -// } -// if (statsEnabled) { -// assertEquals(total - remove, statistics.getSize()); -// assertEquals(updates, statistics.getUpdateCount()); -// assertEquals(remove, statistics.getRemovedCount()); -// assertEquals(total, statistics.getPutCount()); -// assertEquals(0, statistics.getEvictedCount()); -// } else { -// assertEquals(0, statistics.getSize()); -// assertEquals(0, statistics.getPutCount()); -// assertEquals(0, statistics.getRemovedCount()); -// assertEquals(0, statistics.getEvictedCount()); -// assertEquals(0, statistics.getUpdateCount()); -// } -// -// ehcache.clearStatistics(); -// -// assertEquals(0, statistics.getPutCount()); -// assertEquals(0, statistics.getRemovedCount()); -// assertEquals(0, statistics.getEvictedCount()); -// assertEquals(0, statistics.getUpdateCount()); -// } - - } - - /** - * CacheStatistics should always be sensible when the cache has not - * started. - */ - @Test - public void testCacheAlive() { -// Cache cache = new Cache("test", 1, true, false, 5, 2); -// String string = cache.toString(); -// assertTrue(string.contains("test")); -// try { -// LiveCacheStatistics statistics = cache.getLiveCacheStatistics(); -// fail(); -// } catch (IllegalStateException e) { -// assertEquals("The test Cache is not alive (STATUS_UNINITIALISED)", e.getMessage()); -// } -// // initialize cache now -// manager.addCache(cache); -// LiveCacheStatistics statistics = cache.getLiveCacheStatistics(); -// assertEquals(0, statistics.getCacheHitCount()); - } - -} Index: rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/ehcache/tests/NonHibernateCacheDecoratorFactory.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/ehcache/tests/NonHibernateCacheDecoratorFactory.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/ehcache/tests/NonHibernateCacheDecoratorFactory.java (revision 0) @@ -1,24 +0,0 @@ -package org.terracotta.ehcache.tests; - -import net.sf.ehcache.Ehcache; -import net.sf.ehcache.constructs.CacheDecoratorFactory; - -import java.util.Properties; - -public class NonHibernateCacheDecoratorFactory extends CacheDecoratorFactory { - - // private static final String DAO_NAME = "daoName"; - - @Override - public Ehcache createDecoratedEhcache(Ehcache cache, Properties properties) { - NonHibernateCacheDecorator cacheDecorator = new NonHibernateCacheDecorator(cache); - return cacheDecorator; - } - - @Override - public Ehcache createDefaultDecoratedEhcache(Ehcache cache, Properties properties) { - NonHibernateCacheDecorator cacheDecorator = new NonHibernateCacheDecorator(cache); - return cacheDecorator; - } - -} Index: rctags/ehcache-2.10.8.0.7/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/writebehind/WriteBehindAsyncConfig.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/writebehind/WriteBehindAsyncConfig.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/writebehind/WriteBehindAsyncConfig.java (revision 0) @@ -1,114 +0,0 @@ -/* - * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved. - */ -package org.terracotta.modules.ehcache.writebehind; - -import org.terracotta.modules.ehcache.async.AsyncConfig; - -public class WriteBehindAsyncConfig implements AsyncConfig { - private final long workDelay; - private final long maxFallBehind; - private final boolean batchingEnabled; - private final int batchSize; - private final boolean synchronousWrite; - private final int retryAttempts; - private final long retryAttemptDelay; - private final int rateLimit; - private final int maxQueueSize; - - public WriteBehindAsyncConfig(long workDelay, long maxAllowedFallBehind, boolean batchingEnabled, int batchSize, - boolean synchronousWrite, int retryAttempts, long retryAttemptDelay, int rateLimit, - final int maxQueueSize) { - this.workDelay = workDelay; - this.maxFallBehind = maxAllowedFallBehind; - this.batchingEnabled = batchingEnabled; - this.batchSize = batchSize; - this.synchronousWrite = synchronousWrite; - this.retryAttempts = retryAttempts; - this.retryAttemptDelay = retryAttemptDelay; - this.rateLimit = rateLimit; - this.maxQueueSize = maxQueueSize; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + batchSize; - result = prime * result + (batchingEnabled ? 1231 : 1237); - result = prime * result + (int) (maxFallBehind ^ (maxFallBehind >>> 32)); - result = prime * result + maxQueueSize; - result = prime * result + rateLimit; - result = prime * result + (int) (retryAttemptDelay ^ (retryAttemptDelay >>> 32)); - result = prime * result + retryAttempts; - result = prime * result + (synchronousWrite ? 1231 : 1237); - result = prime * result + (int) (workDelay ^ (workDelay >>> 32)); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null) return false; - if (getClass() != obj.getClass()) return false; - WriteBehindAsyncConfig other = (WriteBehindAsyncConfig) obj; - if (batchSize != other.batchSize) return false; - if (batchingEnabled != other.batchingEnabled) return false; - if (maxFallBehind != other.maxFallBehind) return false; - if (maxQueueSize != other.maxQueueSize) return false; - if (rateLimit != other.rateLimit) return false; - if (retryAttemptDelay != other.retryAttemptDelay) return false; - if (retryAttempts != other.retryAttempts) return false; - if (synchronousWrite != other.synchronousWrite) return false; - if (workDelay != other.workDelay) return false; - return true; - } - - @Override - public String toString() { - return "WriteBehindAsyncConfig [workDelay=" + workDelay + ", maxFallBehind=" + maxFallBehind + ", batchingEnabled=" - + batchingEnabled + ", batchSize=" + batchSize + ", synchronousWrite=" + synchronousWrite - + ", retryAttempts=" + retryAttempts + ", retryAttemptDelay=" + retryAttemptDelay + ", rateLimit=" - + rateLimit + ", maxQueueSize=" + maxQueueSize + "]"; - } - - public long getWorkDelay() { - return workDelay; - } - - public long getMaxAllowedFallBehind() { - return maxFallBehind; - } - - public boolean isStealingEnabled() { - return false; - } - - public boolean isBatchingEnabled() { - return batchingEnabled; - } - - public int getBatchSize() { - return batchSize; - } - - public int getMaxQueueSize() { - return maxQueueSize; - } - - public boolean isSynchronousWrite() { - return synchronousWrite; - } - - public int getRetryAttempts() { - return retryAttempts; - } - - public long getRetryAttemptDelay() { - return retryAttemptDelay; - } - - public int getRateLimit() { - return rateLimit; - } -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/transaction/SoftLockManagerImpl.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/transaction/SoftLockManagerImpl.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/transaction/SoftLockManagerImpl.java (revision 0) @@ -1,50 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package net.sf.ehcache.transaction; - -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; - -/** - * A SoftLockFactory implementation which creates soft locks with Read-Committed isolation level - * - * @author Ludovic Orban - */ -public class SoftLockManagerImpl extends AbstractSoftLockManager { - - // actually all we need would be a ConcurrentSet... - private final ConcurrentMap newKeyLocks = new ConcurrentHashMap(); - - private final ConcurrentMap allLocks = new ConcurrentHashMap(); - - /** - * Create a new ReadCommittedSoftLockFactoryImpl instance for a cache - * @param cacheName the name of the cache - */ - public SoftLockManagerImpl(String cacheName, SoftLockFactory lockFactory) { - super(cacheName, lockFactory); - } - - @Override - protected ConcurrentMap getAllLocks() { - return allLocks; - } - - @Override - protected ConcurrentMap getNewKeyLocks() { - return newKeyLocks; - } -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/resources/large.jpg =================================================================== diff -u -N -r11085 -r11127 Binary files differ Index: rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/ehcache/tests/mbean/DSOMBean.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/ehcache/tests/mbean/DSOMBean.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/ehcache/tests/mbean/DSOMBean.java (revision 0) @@ -1,34 +0,0 @@ -/* - * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved. - */ -package org.terracotta.ehcache.tests.mbean; - -import java.util.Map; - -import javax.management.ObjectName; - -/** - * @author Abhishek Sanoujam - */ -public interface DSOMBean { - - long getGlobalServerMapGetSizeRequestsCount(); - - long getGlobalServerMapGetValueRequestsCount(); - - long getGlobalServerMapGetSizeRequestsRate(); - - long getGlobalServerMapGetValueRequestsRate(); - - long getReadOperationRate(); - - Map getServerMapGetSizeRequestsCount(); - - Map getServerMapGetValueRequestsCount(); - - Map getServerMapGetSizeRequestsRate(); - - Map getServerMapGetValueRequestsRate(); - - Void dumpClusterState(); -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/resources/ehcache-store.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/resources/ehcache-store.xml (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/resources/ehcache-store.xml (revision 0) @@ -1,21 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/resources/ehcache-monitoring-off.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/resources/ehcache-monitoring-off.xml (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/resources/ehcache-monitoring-off.xml (revision 0) @@ -1,34 +0,0 @@ - - - - - - - - - - - - - - Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/store/LfuPolicy.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/store/LfuPolicy.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/store/LfuPolicy.java (revision 0) @@ -1,57 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.sf.ehcache.store; - -import net.sf.ehcache.Element; - - -/** - * Contains common LFU policy code for use between the LfuMemoryStore and the DiskStore, which also - * uses an LfuPolicy for evictions. - * - * @author Greg Luck - * @version $Id: LfuPolicy.java 5594 2012-05-07 16:04:31Z cdennis $ - */ -public class LfuPolicy extends AbstractPolicy { - - /** - * The name of this policy as a string literal - */ - public static final String NAME = "LFU"; - - /** - * @return the name of the Policy. Inbuilt examples are LRU, LFU and FIFO. - */ - public String getName() { - return NAME; - } - - /** - * Compares the desirableness for eviction of two elements - * - * Compares hit counts. If both zero, - * - * @param element1 the element to compare against - * @param element2 the element to compare - * @return true if the second element is preferable to the first element for ths policy - */ - public boolean compare(Element element1, Element element2) { - return element2.getHitCount() < element1.getHitCount(); - - } - -} Index: rctags/ehcache-2.10.8.0.7/system-tests/src/test/resources/lifecycle/cache-destroy.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/system-tests/src/test/resources/lifecycle/cache-destroy.xml (revision 11085) +++ rctags/ehcache-2.10.8.0.7/system-tests/src/test/resources/lifecycle/cache-destroy.xml (revision 0) @@ -1,29 +0,0 @@ - - - - - - - - - - - Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/distribution/CacheManagerPeerProviderFactory.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/distribution/CacheManagerPeerProviderFactory.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/distribution/CacheManagerPeerProviderFactory.java (revision 0) @@ -1,42 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.sf.ehcache.distribution; - -import net.sf.ehcache.CacheManager; - -import java.util.Properties; - -/** - * An abstract factory for creating peers. Implementers should provide their own - * concrete factory extending this factory. It can then be configured in ehcache.xml - * @author Greg Luck - * @version $Id: CacheManagerPeerProviderFactory.java 5594 2012-05-07 16:04:31Z cdennis $ - */ -public abstract class CacheManagerPeerProviderFactory { - - /** - * Create a peer provider. - * @param cacheManager the CacheManager instance connected to this peer provider - * @param properties implementation specific properties. These are configured as comma - * separated name value pairs in ehcache.xml - * @return a constructed CacheManagerPeerProvider - */ - public abstract CacheManagerPeerProvider createCachePeerProvider(CacheManager cacheManager, Properties properties); - - - -} Index: rctags/ehcache-2.10.8.0.7/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/writebehind/CacheWriterProcessor.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/writebehind/CacheWriterProcessor.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/writebehind/CacheWriterProcessor.java (revision 0) @@ -1,124 +0,0 @@ -/* - * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved. - */ -package org.terracotta.modules.ehcache.writebehind; - -import net.sf.ehcache.CacheEntry; -import net.sf.ehcache.CacheException; -import net.sf.ehcache.Element; -import net.sf.ehcache.writer.CacheWriter; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.terracotta.modules.ehcache.async.ItemProcessor; -import org.terracotta.modules.ehcache.writebehind.operations.BatchAsyncOperation; -import org.terracotta.modules.ehcache.writebehind.operations.DeleteAllAsyncOperation; -import org.terracotta.modules.ehcache.writebehind.operations.DeleteAsyncOperation; -import org.terracotta.modules.ehcache.writebehind.operations.SingleAsyncOperation; -import org.terracotta.modules.ehcache.writebehind.operations.WriteAllAsyncOperation; -import org.terracotta.modules.ehcache.writebehind.operations.WriteAsyncOperation; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -/** - * An implementation of {@code ItemProcessor} that delegates the processing to a {@code CacheWriter} instance - *

- * Instances of this class will be used when items are processed one by one. Note that {@code CacheWriter} instances - * will not be shared across a Terracotta DSO cluster and are intended to be local on a node. They are tied to an - * individual write behind queue. You're thus free to use local resources in an {@code CacheWriter}, like database - * connections or file handles. - * - * @author Abhishek Maheshwari - */ -public class CacheWriterProcessor implements ItemProcessor { - private final CacheWriter cacheWriter; - private static final Logger LOGGER = LoggerFactory.getLogger(CacheWriterProcessor.class.getName()); - - /** - * Creates a new item processor for a specific cache writer. - * - * @param cacheWriter the cache writer for which the wrapper has to be created - */ - public CacheWriterProcessor(CacheWriter cacheWriter) { - this.cacheWriter = cacheWriter; - } - - @Override - public void process(SingleAsyncOperation item) { - try { - item.performSingleOperation(cacheWriter); - } catch (Exception e) { - throw new CacheException("Unexpected exception while processing write behind operation", e); - } - - } - - CacheWriter getCacheWriter() { - return cacheWriter; - } - - @Override - public void process(Collection items) { - final List itemsPerType = new ArrayList(); - Class opClass = WriteAsyncOperation.class; - for (SingleAsyncOperation item : items) { - // keep adding items of same operationClass - if (item.getClass() == opClass) { - itemsPerType.add(item); - } else { - // execute the batch - executeBatch(itemsPerType); - // switch to new operationClass and add items in itemsPerType - opClass = item.getClass(); - itemsPerType.clear(); - itemsPerType.add(item); - } - } - // finally execute the last batch - executeBatch(itemsPerType); - } - - private void executeBatch(final List itemsPerType) { - if (!itemsPerType.isEmpty()) { - Class opClass = itemsPerType.get(0).getClass(); - try { - BatchAsyncOperation batch = createBatchOprForType(opClass, itemsPerType); - batch.performBatchOperation(cacheWriter); - } catch (Exception e) { - LOGGER.warn("error while processing batch write behind operation " + e); - throw new CacheException("Unexpected exception while processing write behind operation " + e, e); - } - } - } - - private BatchAsyncOperation createBatchOprForType(Class operationClass, Collection operations) { - if (operationClass == WriteAsyncOperation.class) { - final List elements = new ArrayList(); - for (SingleAsyncOperation operation : operations) { - elements.add(operation.getElement()); - } - return new WriteAllAsyncOperation(elements); - } - - if (operationClass == DeleteAsyncOperation.class) { - List entries = new ArrayList(); - for (SingleAsyncOperation operation : operations) { - entries.add(new CacheEntry(operation.getKey(), operation.getElement())); - } - return new DeleteAllAsyncOperation(entries); - } - throw new RuntimeException("no batch operation created for " + operationClass.getName()); - } - - @Override - public void throwAway(SingleAsyncOperation item, RuntimeException runtimeException) { - try { - item.throwAwayElement(cacheWriter, runtimeException); - } catch (Exception e) { - throw new CacheException("Unexpected exception while throwing away write behind operation", e); - } - } - -} Index: rctags/ehcache-2.10.8.0.7/system-tests/src/test/resources/byteman/LocalTxTestDebug.btm =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/system-tests/src/test/resources/byteman/LocalTxTestDebug.btm (revision 11085) +++ rctags/ehcache-2.10.8.0.7/system-tests/src/test/resources/byteman/LocalTxTestDebug.btm (revision 0) @@ -1,77 +0,0 @@ - - -RULE trace ServerMap gets -CLASS ServerMap -METHOD doGet -AT EXIT -#IF NOT $getType.name().equals("UNSAFE") -IF false -DO traceln(" ____ ServerMap.doGet key.hashCode(): \"" + $key.hashCode() + "\", \"" + $getType + "\", \"" + $quiet + " -> " + $!); -ENDRULE - -RULE trace ServerMap puts -CLASS ServerMap -METHOD doLogicalPut -AT ENTRY -IF false -DO traceln(" _____ ServerMap.doLogicalPut - key.hashCode(): \"" + $key.hashCode() + "\", mutateType: \"" + $type + "\", value: \"" + $value); -ENDRULE - - -RULE trace ServerMap removes -CLASS ServerMap -METHOD doLogicalRemove -AT ENTRY -IF false -DO traceln(" _____ ServerMap.doLogicalRemove - key.hashCode(): \"" + $key.hashCode() + "\", mutateType: \"" + $type); -ENDRULE - -RULE trace clusteredStore doPut -CLASS ClusteredStore -METHOD doPut -AT EXIT -IF false -DO traceln(" _____ ClusteredStore.doPut - pkey.hashCode(): \"" + $portableKey.hashCode() + "\", return: \"" + $!); -ENDRULE - -RULE trace clusteredStore replace -CLASS ClusteredStore -METHOD replace(Element,Element,ElementValueComparator) -AT EXIT -IF false -DO traceln(" _____ ClusteredStore.replace old: "+$old+" element: "+$element+" return: \"" + $!); -ENDRULE - -RULE trace CustomLifespanSerializedEntry isExpired -CLASS CustomLifespanSerializedEntry -METHOD isExpired -AT EXIT -IF false -DO traceln(" _____ CustomLifespanSerializedEntry isExpired atTime: " +$atTime+ " maxTTISeconds: "+$maxTTISeconds+" maxTTLSeconds: "+$maxTTLSeconds+" lastAccessedTime: "+$0.lastAccessedTime+" createTime: "+$0.createTime+" return: " + $!); -ENDRULE - -RULE trace ServerMap createSerializedEntry -CLASS ServerMap -METHOD createSerializedEntry -AT ENTRY -IF false -DO traceln(" _____XXX ServerMap createSerializedEntry createTime: "+$createTimeInSecs+" now: " + $0.timeSource.now()); -ENDRULE - -RULE trace DefaultElementValueComparator -CLASS DefaultElementValueComparator -METHOD equals(Element, Element) -AT ENTRY -IF false -DO traceln(" _____XXX DefaultElementValueComparator: e1: " + $e1 + ", e2: " + $e2); -ENDRULE - - -RULE trace EhcacheTxnsClusteredStateFacadeImpl clear -CLASS EhcacheTxnsClusteredStateFacadeImpl -METHOD clearSoftLock -AT ENTRY -IF false -DO traceln(" _____XXX clearSoftLock: softLockId: " + $softLockId); -ENDRULE - Index: rctags/ehcache-2.10.8.0.7/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/TerracottaToolkitBuilder.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/TerracottaToolkitBuilder.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/TerracottaToolkitBuilder.java (revision 0) @@ -1,200 +0,0 @@ -/* - * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved. Licensed under the Apache - * License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain - * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in - * writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS - * OF ANY KIND, either express or implied. See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.terracotta.modules.ehcache; - -import org.terracotta.toolkit.Toolkit; -import org.terracotta.toolkit.ToolkitFactory; -import org.terracotta.toolkit.ToolkitInstantiationException; - -import java.util.Collections; -import java.util.HashSet; -import java.util.Properties; -import java.util.Set; - -public class TerracottaToolkitBuilder { - - private static final String TC_TUNNELLED_MBEAN_DOMAINS_KEY = "tunnelledMBeanDomains"; - private static final String TC_CONFIG_SNIPPET_KEY = "tcConfigSnippet"; - private static final String REJOIN_KEY = "rejoin"; - private static final String PRODUCT_ID_KEY = "productId"; - private static final String CLASSLOADER_KEY = "classloader"; - private static final String NONSTOP_INIT_ENABLED_KEY = "toolkit.nonstop.init.enabled"; - - private boolean rejoin; - private final TCConfigTypeStatus tcConfigTypeStatus = new TCConfigTypeStatus(); - private final Set tunnelledMBeanDomains = Collections.synchronizedSet(new HashSet()); - private String productId; - private ClassLoader classLoader; - private final boolean NONSTOP_INIT_ENABLED = Boolean.getBoolean(NONSTOP_INIT_ENABLED_KEY); - - public Toolkit buildToolkit() throws IllegalStateException { - if (tcConfigTypeStatus.getState() == TCConfigTypeState.INIT) { - // - throw new IllegalStateException( - "Please set the tcConfigSnippet or tcConfigUrl before attempting to create client"); - } - final String tcConfigOrUrl; - final boolean isUrl; - switch (tcConfigTypeStatus.getState()) { - case TC_CONFIG_SNIPPET: - tcConfigOrUrl = tcConfigTypeStatus.getTcConfigSnippet(); - isUrl = false; - break; - case TC_CONFIG_URL: - tcConfigOrUrl = tcConfigTypeStatus.getTcConfigUrl(); - isUrl = true; - break; - default: - throw new IllegalStateException("Unknown tc config type - " + tcConfigTypeStatus.getState()); - } - String toolkitUrl = createTerracottaToolkitUrl(isUrl, tcConfigOrUrl); - return createToolkit(toolkitUrl, getTerracottaToolkitProperties(isUrl, tcConfigOrUrl, classLoader)); - } - - private Toolkit createToolkit(String url, Properties props) { - try { - return ToolkitFactory.createToolkit(url, props); - } catch (ToolkitInstantiationException e) { - throw new RuntimeException(e); - } - } - - private Properties getTerracottaToolkitProperties(boolean isUrl, String tcConfigOrUrl, ClassLoader loader) { - Properties properties = new Properties(); - - if (loader != null) { - properties.put(CLASSLOADER_KEY, loader); - } - - properties.setProperty(TC_TUNNELLED_MBEAN_DOMAINS_KEY, getTunnelledDomainCSV()); - if (!isUrl) { - properties.setProperty(TC_CONFIG_SNIPPET_KEY, tcConfigOrUrl); - } - properties.setProperty(REJOIN_KEY, String.valueOf(rejoin)); - if (productId != null) { - properties.setProperty(PRODUCT_ID_KEY, productId); - } - properties.setProperty(NONSTOP_INIT_ENABLED_KEY, String.valueOf(NONSTOP_INIT_ENABLED)); - return properties; - } - - private String getTunnelledDomainCSV() { - StringBuilder sb = new StringBuilder(); - for (String domain : tunnelledMBeanDomains) { - sb.append(domain).append(","); - } - // remove last comma - return sb.deleteCharAt(sb.length() - 1).toString(); - } - - private String createTerracottaToolkitUrl(boolean isUrl, String tcConfigOrUrl) { - if (isUrl) { - return "toolkit:nonstop-terracotta://" + tcConfigOrUrl; - } else { - return "toolkit:nonstop-terracotta:"; - } - } - - public TerracottaToolkitBuilder addTunnelledMBeanDomain(String tunnelledMBeanDomain) { - this.tunnelledMBeanDomains.add(tunnelledMBeanDomain); - return this; - } - - public Set getTunnelledMBeanDomains() { - return Collections.unmodifiableSet(tunnelledMBeanDomains); - } - - public TerracottaToolkitBuilder removeTunnelledMBeanDomain(String tunnelledMBeanDomain) { - tunnelledMBeanDomains.remove(tunnelledMBeanDomain); - return this; - } - - public TerracottaToolkitBuilder setTCConfigSnippet(String tcConfig) throws IllegalStateException { - tcConfigTypeStatus.setTcConfigSnippet(tcConfig); - return this; - } - - public String getTCConfigSnippet() { - return tcConfigTypeStatus.getTcConfigSnippet(); - } - - public TerracottaToolkitBuilder setTCConfigUrl(String tcConfigUrl) throws IllegalStateException { - tcConfigTypeStatus.setTcConfigUrl(tcConfigUrl); - return this; - } - - public String getTCConfigUrl() { - return tcConfigTypeStatus.getTcConfigUrl(); - } - - public boolean isConfigUrl() { - return tcConfigTypeStatus.getState() == TCConfigTypeState.TC_CONFIG_URL; - } - - private static enum TCConfigTypeState { - INIT, TC_CONFIG_SNIPPET, TC_CONFIG_URL; - } - - private static class TCConfigTypeStatus { - private TCConfigTypeState state = TCConfigTypeState.INIT; - - private String tcConfigSnippet; - private String tcConfigUrl; - - public synchronized void setTcConfigSnippet(String tcConfigSnippet) { - if (state == TCConfigTypeState.TC_CONFIG_URL) { - // - throw new IllegalStateException("TCConfig url was already set to - " + tcConfigUrl); - } - this.state = TCConfigTypeState.TC_CONFIG_SNIPPET; - this.tcConfigSnippet = tcConfigSnippet; - } - - public synchronized void setTcConfigUrl(String tcConfigUrl) { - if (state == TCConfigTypeState.TC_CONFIG_SNIPPET) { - // - throw new IllegalStateException("TCConfig snippet was already set to - " + tcConfigSnippet); - } - this.state = TCConfigTypeState.TC_CONFIG_URL; - this.tcConfigUrl = tcConfigUrl; - } - - public synchronized String getTcConfigSnippet() { - return tcConfigSnippet; - } - - public synchronized String getTcConfigUrl() { - return tcConfigUrl; - } - - public TCConfigTypeState getState() { - return state; - } - - } - - public void setRejoinEnabled(boolean rejoin) { - this.rejoin = rejoin; - } - - public String getProductId() { - return productId; - } - - public TerracottaToolkitBuilder setClassLoader(ClassLoader loader) { - this.classLoader = loader; - return this; - } - - public TerracottaToolkitBuilder setProductId(final String productId) { - this.productId = productId; - return this; - } -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/search/query/QueryManager.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/search/query/QueryManager.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/search/query/QueryManager.java (revision 0) @@ -1,42 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.sf.ehcache.search.query; - -import net.sf.ehcache.CacheException; -import net.sf.ehcache.search.Query; - -/** - * Main entry point from Ehcache into the query manager responsible - * for parsing SQL-like statements and returning a net.sf.ehcache.search.Query object. - *

- * This interface obviates Ehcache's dependence on a specific dialect of SQL. - * Implementations are free to decide which SQL-like language is supported by them. - * - * @author dkumar - */ -public interface QueryManager { - - /** - * Parses a {@link java.lang.String String} statement expressing an Ehcache Search query and returns - * a {@link net.sf.ehcache.search.Query Query} object for the cache specified in the statement. - * - * @param statement a String expressing an Ehcache Search query - * @return a {@link net.sf.ehcache.search.Query Query}object tied to the cache specified in the statement - * @throws CacheException if the cache could not be found or if a parse error occurs - */ - Query createQuery(String statement) throws CacheException; -} Index: rctags/ehcache-2.10.8.0.7/system-tests/src/test/resources/net/sf/ehcache/osgi/Item.hbm.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/system-tests/src/test/resources/net/sf/ehcache/osgi/Item.hbm.xml (revision 11085) +++ rctags/ehcache-2.10.8.0.7/system-tests/src/test/resources/net/sf/ehcache/osgi/Item.hbm.xml (revision 0) @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/loader/ComponentBLoader.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/loader/ComponentBLoader.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/loader/ComponentBLoader.java (revision 0) @@ -1,54 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.sf.ehcache.loader; - -import net.sf.ehcache.CacheException; - - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - -/** - * Written for Dead-lock poc - * - * @author Greg Luck - * @version $Id: ComponentBLoader.java 5594 2012-05-07 16:04:31Z cdennis $ - */ -public class ComponentBLoader extends BaseComponentLoader { - - private static final Logger LOG = LoggerFactory.getLogger(ComponentBLoader.class.getName()); - - /** - * @return - */ - public String getName() { - return "LoaderB"; - } - - /** - * @param arg0 - * @return - * @throws CacheException - */ - public Object load(Object arg0) throws CacheException { - LOG.info("Loading Component B..."); - String key = (String) arg0; - return new ComponentB(key); - } - -} Index: rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/modules/ehcache/l1bm/L1BMOnHeapWithTTISanityTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/modules/ehcache/l1bm/L1BMOnHeapWithTTISanityTest.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/modules/ehcache/l1bm/L1BMOnHeapWithTTISanityTest.java (revision 0) @@ -1,161 +0,0 @@ -/* - * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved. - */ -package org.terracotta.modules.ehcache.l1bm; - -import net.sf.ehcache.Cache; -import net.sf.ehcache.CacheManager; -import net.sf.ehcache.Element; -import net.sf.ehcache.config.CacheConfiguration; -import net.sf.ehcache.config.TerracottaConfiguration; -import net.sf.ehcache.config.TerracottaConfiguration.Consistency; - -import org.terracotta.ehcache.tests.AbstractCacheTestBase; -import org.terracotta.ehcache.tests.ClientBase; -import org.terracotta.toolkit.Toolkit; -import org.terracotta.toolkit.concurrent.ToolkitBarrier; - -import com.tc.test.config.model.TestConfig; - -import java.util.HashSet; -import java.util.Set; -import java.util.concurrent.BrokenBarrierException; - -import junit.framework.Assert; - -public class L1BMOnHeapWithTTISanityTest extends AbstractCacheTestBase { - private static final int NODE_COUNT = 2; - - public L1BMOnHeapWithTTISanityTest(TestConfig testConfig) { - super(testConfig, App.class, App.class); - } - - public static class App extends ClientBase { - private final ToolkitBarrier barrier; - - public App(String[] args) { - super(args); - this.barrier = getClusteringToolkit().getBarrier("test-barrier", NODE_COUNT); - } - - public static void main(String[] args) { - new App(args).run(); - } - - @Override - protected void runTest(Cache cache, Toolkit clusteringToolkit) throws Throwable { - Cache dcv2EventualSerializationWithStats = createCache("dcv2EventualSerializationWithStats", cacheManager, - Consistency.EVENTUAL); - testL1BigMemorySanity(dcv2EventualSerializationWithStats, true); - dcv2EventualSerializationWithStats.removeAll(); - - Cache dcv2EventualSerializationWithoutStats = createCache("dcv2EventualSerializationWithoutStats", cacheManager, - Consistency.EVENTUAL); - testL1BigMemorySanity(dcv2EventualSerializationWithoutStats, true); - dcv2EventualSerializationWithoutStats.removeAll(); - - Cache dcv2StrongSerializationWithStats = createCache("dcv2StrongSerializationWithStats", cacheManager, - Consistency.STRONG); - testL1BigMemorySanity(dcv2StrongSerializationWithStats, false); - dcv2StrongSerializationWithStats.removeAll(); - - Cache dcv2StrongWithoutStats = createCache("dcv2StrongWithoutStats", cacheManager, Consistency.STRONG); - testL1BigMemorySanity(dcv2StrongWithoutStats, false); - dcv2StrongWithoutStats.removeAll(); - } - - private void testL1BigMemorySanity(Cache cache, boolean shouldWait) throws InterruptedException, - BrokenBarrierException { - int index = barrier.await(); - int numOfElements = 500; - if (index == 0) { - for (int i = 0; i < numOfElements; i++) { - cache.put(new Element("key" + i, "val" + i)); - } - System.out.println("XXXXX done with putting " + cache.getSize() + " entries"); - } - barrier.await(); - if (shouldWait) { - while (cache.getSize() != numOfElements) { - Thread.sleep(1000); - } - } - Assert.assertEquals(numOfElements, cache.getSize()); - System.out.println("XXXXXX client " + index + " cache size: " + cache.getSize() + " local: " - + cache.getStatistics().getLocalHeapSize()); - if (index == 0) { - Assert.assertTrue(cache.getStatistics().getLocalHeapSize() > 0); - } else { - Assert.assertEquals(0, cache.getStatistics().getLocalHeapSize()); - } - - barrier.await(); - - System.out.println("XXXXXX testing get"); - for (int i = 0; i < numOfElements; i++) { - Assert.assertNotNull("value for key" + i + " is null", cache.get("key" + i)); - } - Assert.assertTrue(cache.getStatistics().getLocalHeapSize() > 0); - - barrier.await(); - System.out.println("XXXX done with basic get, now removing random entries..."); - Set removedKeySet = new HashSet(); - for (int i = 0; i < numOfElements; i++) { - if (i % 10 == 0) { - removedKeySet.add("key" + i); - } - } - - if (index == 0) { - cache.removeAll(removedKeySet); - } - - barrier.await(); - if (shouldWait) { - while (cache.getSize() != numOfElements - removedKeySet.size()) { - Thread.sleep(1000); - } - } - System.out.println("XXXXX removed " + removedKeySet.size() + " elements. Cache size: " + cache.getSize()); - - System.out.println("XXXX testing get after remove."); - for (int i = 0; i < numOfElements; i++) { - String key = "key" + i; - if (removedKeySet.contains(key)) { - if (shouldWait) { - while (cache.get(key) != null) { - System.out.println("value for " + key + " is not null"); - } - } - Assert.assertNull("value for " + key + " is not null", cache.get(key)); - } else { - Assert.assertNotNull("value for " + key + " is null", cache.get(key)); - } - } - - // wait to get element expired - System.out.println("waiting for elements to get expired..."); - Thread.sleep(35000); - System.out.println("All elements should be null after expiration..."); - for (int i = 0; i < numOfElements; i++) { - Assert.assertNull("value for key" + i + " is not null", cache.get("key" + i)); - } - System.out.println("XXXXXX done with " + cache.getName()); - } - - private Cache createCache(String cacheName, CacheManager cm, Consistency consistency) { - CacheConfiguration cacheConfiguration = new CacheConfiguration(); - cacheConfiguration.setTimeToIdleSeconds(30); - cacheConfiguration.setName(cacheName); - cacheConfiguration.setMaxBytesLocalHeap(409600L); - - TerracottaConfiguration tcConfiguration = new TerracottaConfiguration(); - tcConfiguration.setConsistency(consistency); - cacheConfiguration.addTerracotta(tcConfiguration); - - Cache cache = new Cache(cacheConfiguration); - cm.addCache(cache); - return cache; - } - } -} Index: rctags/ehcache-2.10.8.0.7/system-tests/src/test/resources/net/sf/ehcache/osgi/jta.properties =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/system-tests/src/test/resources/net/sf/ehcache/osgi/jta.properties (revision 11085) +++ rctags/ehcache-2.10.8.0.7/system-tests/src/test/resources/net/sf/ehcache/osgi/jta.properties (revision 0) @@ -1,14 +0,0 @@ -com.atomikos.icatch.service=com.atomikos.icatch.standalone.UserTransactionServiceFactory -com.atomikos.icatch.console_file_name = tm-dev.out -com.atomikos.icatch.log_base_name = tmlog-dev -com.atomikos.icatch.tm_unique_name = com.atomikos.spring.jdbc.tm-dev -com.atomikos.icatch.console_file_name = tm-dev.out -com.atomikos.icatch.log_base_name = tmlog-dev -com.atomikos.icatch.tm_unique_name = com.atomikos.spring.jdbc.tm-dev -com.atomikos.icatch.serial_jta_transactions=false -com.atomikos.icatch.automatic_resource_registration=true -com.atomikos.icatch.max_actives=15000 -com.atomikos.icatch.max_timeout=3600000 -com.atomikos.icatch.output_dir=atomikos-tmp/ -com.atomikos.icatch.log_base_dir=atomikos-tmp/ -com.atomikos.icatch.enable_logging=false Index: rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/ehcache/tests/ThreadIgnore.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/ehcache/tests/ThreadIgnore.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/ehcache/tests/ThreadIgnore.java (revision 0) @@ -1,29 +0,0 @@ -/* - * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved. - */ -package org.terracotta.ehcache.tests; - -public class ThreadIgnore { - private final String firstFramePackage; - private final String threadNamePrefix; - - public ThreadIgnore(String threadNamePrefix, String firstFramePackage) { - this.threadNamePrefix = threadNamePrefix; - this.firstFramePackage = firstFramePackage; - } - - public boolean canIgnore(SimpleThreadInfo info) { - if (info.getName().startsWith(threadNamePrefix)) { - - String[] stack = info.getStackTraceArray(); - if (stack.length > 1) { - String frame = stack[stack.length - 2].trim().replaceFirst("at ", ""); - if (frame.startsWith(firstFramePackage)) { return true; } - } else { - return true; - } - } - - return false; - } -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/CacheTAB6174Test.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/CacheTAB6174Test.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/CacheTAB6174Test.java (revision 0) @@ -1,232 +0,0 @@ -package net.sf.ehcache; - -import net.sf.ehcache.event.CacheEventListener; -import org.junit.Assert; -import org.junit.Test; - -import java.io.ByteArrayInputStream; -import java.nio.charset.Charset; -import java.util.concurrent.atomic.AtomicInteger; - -import static org.hamcrest.Matchers.greaterThan; - -/** - * @author cschanck - **/ -public class CacheTAB6174Test { - - private class Bar { - private final String str; - - public Bar(String str) { - this.str = str; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - - Bar bar = (Bar) o; - - return !(str != null ? !str.equals(bar.str) : bar.str != null); - - } - - @Override - public int hashCode() { - return str != null ? str.hashCode() : 0; - } - } - - private static class Foo implements CacheEventListener { - private AtomicInteger removed=new AtomicInteger(0); - private AtomicInteger expired=new AtomicInteger(0); - private AtomicInteger put=new AtomicInteger(0); - private AtomicInteger updated=new AtomicInteger(0); - private AtomicInteger evicted=new AtomicInteger(0); - - public int getRemoved() { - return removed.get(); - } - - public int getExpired() { - return expired.get(); - } - - public int getPut() { - return put.get(); - } - - public int getUpdated() { - return updated.get(); - } - - public int getEvicted() { - return evicted.get(); - } - - @Override - public Object clone() throws CloneNotSupportedException { - return super.clone(); - } - - @Override - public void notifyElementRemoved(Ehcache cache, Element arg1) throws CacheException { - Object objValue = arg1.getObjectValue(); - if(objValue!=null) { - removed.incrementAndGet(); - Assert.assertTrue(objValue.getClass().equals(String.class)); - } - } - - @Override - public void notifyElementPut(Ehcache cache, Element arg1) throws CacheException { - put.incrementAndGet(); - Object objValue = arg1.getObjectValue(); - Assert.assertTrue(objValue.getClass().equals(String.class)); - } - - @Override - public void notifyElementUpdated(Ehcache cache, Element arg1) throws CacheException { - updated.incrementAndGet(); - Object objValue = arg1.getObjectValue(); - Assert.assertTrue(objValue.getClass().equals(String.class)); - } - - @Override - public void notifyElementExpired(Ehcache cache, Element arg1) { - expired.incrementAndGet(); - Object objValue = arg1.getObjectValue(); - Assert.assertTrue(objValue.getClass().equals(String.class)); - } - - @Override - public void notifyElementEvicted(Ehcache cache, Element arg1) { - evicted.incrementAndGet(); - Object objValue = arg1.getObjectValue(); - Assert.assertTrue(objValue.getClass().equals(String.class)); - } - - @Override - public void notifyRemoveAll(Ehcache cache) { - - } - - @Override - public void dispose() { - - } - } - - @Test - public void test6174LegacyLRUMemStore() { - System.getProperties().put(Cache.NET_SF_EHCACHE_USE_CLASSIC_LRU,"true"); - String s = " "; - CacheManager cm = CacheManager.create(new ByteArrayInputStream(s.getBytes(Charset.forName("utf-8")))); - Cache cache = cm.getCache("ServiceResults"); - System.getProperties().remove(Cache.NET_SF_EHCACHE_USE_CLASSIC_LRU); - actuallyTest(cache); - } - - @Test - public void test6174DefaultMemStore() { - String s = " "; - CacheManager cm = CacheManager.create(new ByteArrayInputStream(s.getBytes(Charset.forName("utf-8")))); - Cache cache = cm.getCache("ServiceResults"); - actuallyTest(cache); - } - - @Test - public void test6174DefaultMemStoreLRU() { - String s = " "; - CacheManager cm = CacheManager.create(new ByteArrayInputStream(s.getBytes(Charset.forName("utf-8")))); - Cache cache = cm.getCache("ServiceResults"); - actuallyTest(cache); - } - - @Test - public void test6174DefaultMemStoreLFU() { - String s = " "; - CacheManager cm = CacheManager.create(new ByteArrayInputStream(s.getBytes(Charset.forName("utf-8")))); - Cache cache = cm.getCache("ServiceResults"); - actuallyTest(cache); - } - - @Test - public void test6174DefaultMemStoreClock() { - String s = " "; - CacheManager cm = CacheManager.create(new ByteArrayInputStream(s.getBytes(Charset.forName("utf-8")))); - Cache cache = cm.getCache("ServiceResults"); - actuallyTest(cache); - } - - @Test - public void test6174DefaultMemStoreFIFO() { - String s = " "; - CacheManager cm = CacheManager.create(new ByteArrayInputStream(s.getBytes(Charset.forName("utf-8")))); - Cache cache = cm.getCache("ServiceResults"); - actuallyTest(cache); - } - - private void actuallyTest(Cache cache) { - Foo foo = new Foo(); - cache.getCacheEventNotificationService().registerListener(foo); - for (int i = 0; i < 10; i++) { - cache.put(new Element(new Bar("foo" + i), "bar" + i, 2, 2)); - } - for (int i = 0; i < 10; i++) { - cache.get(new Bar("foo" + i)); - } - for (int i = 0; i < 7; i++) { - cache.remove(new Bar("foo" + i)); - } - cache.put(new Element(new Bar("foo" + 0), "bar2", 2, 2)); - cache.put(new Element(new Bar("foo" + 0), "bar3", 2, 2)); - cache.put(new Element(new Bar("foo100"), "bar100", 1, 1)); - boolean interrupted = false; - try { - Thread.sleep(1100); - } catch (InterruptedException e) { - interrupted = true; - } - cache.get(new Bar("foo100")); - try { - Thread.sleep(1100); - } catch (InterruptedException e) { - interrupted = true; - } - cache.put(new Element(new Bar("foo" + 10), "bar10")); - Assert.assertThat(foo.getEvicted(), greaterThan(0)); - Assert.assertThat(foo.getPut(), greaterThan(0)); - Assert.assertThat(foo.getRemoved(), greaterThan(0)); - Assert.assertThat(foo.getUpdated(), greaterThan(0)); - Assert.assertThat(foo.getExpired(), greaterThan(0)); - if (interrupted) { - Thread.currentThread().interrupt(); - } - } - -} Index: rctags/ehcache-2.10.8.0.7/system-tests/.settings/org.maven.ide.eclipse.prefs =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/system-tests/.settings/org.maven.ide.eclipse.prefs (revision 11085) +++ rctags/ehcache-2.10.8.0.7/system-tests/.settings/org.maven.ide.eclipse.prefs (revision 0) @@ -1,9 +0,0 @@ -#Tue Jun 01 13:21:36 PDT 2010 -activeProfiles= -eclipse.preferences.version=1 -fullBuildGoals=process-test-resources -includeModules=false -resolveWorkspaceProjects=true -resourceFilterGoals=process-resources resources\:testResources -skipCompilerPlugin=true -version=1 Index: rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/ehcache/tests/servermap/ServerMapClearExpressTestClient2.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/ehcache/tests/servermap/ServerMapClearExpressTestClient2.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/ehcache/tests/servermap/ServerMapClearExpressTestClient2.java (revision 0) @@ -1,26 +0,0 @@ -package org.terracotta.ehcache.tests.servermap; - -import net.sf.ehcache.Cache; - -import org.terracotta.toolkit.Toolkit; -import org.terracotta.ehcache.tests.mbean.DSOMBean; -import org.terracotta.ehcache.tests.mbean.DSOMBeanController; - -public class ServerMapClearExpressTestClient2 extends ServerMapClientBase { - - private final DSOMBean dsoMBean; - - public ServerMapClearExpressTestClient2(String[] args) { - super("test", args); - dsoMBean = new DSOMBeanController("localhost", getTestControlMbean().getGroupsData()[0].getJmxPort(0)); - } - - public static void main(String[] args) { - new ServerMapClearExpressTestClient2(args).run(); - } - - @Override - protected void runTest(Cache cache, Toolkit clusteringToolkit) throws Throwable { - ServerMapClearTestHelper.doTest(cache, clusteringToolkit, dsoMBean); - } -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/distribution/RMIBootstrapCacheLoaderFactory.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/distribution/RMIBootstrapCacheLoaderFactory.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/distribution/RMIBootstrapCacheLoaderFactory.java (revision 0) @@ -1,100 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.sf.ehcache.distribution; - -import net.sf.ehcache.bootstrap.BootstrapCacheLoaderFactory; -import net.sf.ehcache.util.PropertyUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.Properties; - - -/** - * A factory to create a configured RMIBootstrapCacheLoader - * @author Greg Luck - * @version $Id: RMIBootstrapCacheLoaderFactory.java 5594 2012-05-07 16:04:31Z cdennis $ - */ -public class RMIBootstrapCacheLoaderFactory extends BootstrapCacheLoaderFactory { - - - /** - * The property name expected in ehcache.xml for the maximum chunk size in bytes - */ - public static final String MAXIMUM_CHUNK_SIZE_BYTES = "maximumChunkSizeBytes"; - - /** - * The default maximum serialized size of the elements to request from a remote cache peer during bootstrap. - */ - protected static final int DEFAULT_MAXIMUM_CHUNK_SIZE_BYTES = 5000000; - - /** - * The highest reasonable chunk size in bytes - */ - protected static final int ONE_HUNDRED_MB = 100000000; - - /** - * The lowest reasonable chunk size in bytes - */ - protected static final int FIVE_KB = 5000; - - private static final Logger LOG = LoggerFactory.getLogger(RMIBootstrapCacheLoaderFactory.class.getName()); - - - /** - * Create a BootstrapCacheLoader - * - * @param properties implementation specific properties. These are configured as comma - * separated name value pairs in ehcache.xml - * @return a constructed BootstrapCacheLoader - */ - public RMIBootstrapCacheLoader createBootstrapCacheLoader(Properties properties) { - boolean bootstrapAsynchronously = extractBootstrapAsynchronously(properties); - int maximumChunkSizeBytes = extractMaximumChunkSizeBytes(properties); - return new RMIBootstrapCacheLoader(bootstrapAsynchronously, maximumChunkSizeBytes); - } - - /** - * - * @param properties the properties passed by the CacheManager, read from the configuration file - * @return the max chunk size in bytes - */ - protected int extractMaximumChunkSizeBytes(Properties properties) { - int maximumChunkSizeBytes; - String maximumChunkSizeBytesString = PropertyUtil.extractAndLogProperty(MAXIMUM_CHUNK_SIZE_BYTES, properties); - if (maximumChunkSizeBytesString != null) { - try { - int maximumChunkSizeBytesCandidate = Integer.parseInt(maximumChunkSizeBytesString); - if ((maximumChunkSizeBytesCandidate < FIVE_KB) || (maximumChunkSizeBytesCandidate > ONE_HUNDRED_MB)) { - LOG.warn("Trying to set the chunk size to an unreasonable number. Using the default instead."); - maximumChunkSizeBytes = DEFAULT_MAXIMUM_CHUNK_SIZE_BYTES; - } else { - maximumChunkSizeBytes = maximumChunkSizeBytesCandidate; - } - } catch (NumberFormatException e) { - LOG.warn("Number format exception trying to set chunk size. Using the default instead."); - maximumChunkSizeBytes = DEFAULT_MAXIMUM_CHUNK_SIZE_BYTES; - } - - } else { - maximumChunkSizeBytes = DEFAULT_MAXIMUM_CHUNK_SIZE_BYTES; - } - return maximumChunkSizeBytes; - } - - -} Index: rctags/ehcache-2.10.8.0.7/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/writebehind/operations/BatchAsyncOperation.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/writebehind/operations/BatchAsyncOperation.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/writebehind/operations/BatchAsyncOperation.java (revision 0) @@ -1,23 +0,0 @@ -/* - * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved. - */ -package org.terracotta.modules.ehcache.writebehind.operations; - -import net.sf.ehcache.writer.CacheWriter; - -/** - * Interface to implement batch operations that are executed on a cache writer after being called by the async - * coordinator - * - * @author Geert Bevin - * @version $Id: BatchAsyncOperation.java 5227 2012-02-02 02:35:49Z hhuynh $ - */ -public interface BatchAsyncOperation { - /** - * Perform the batch operation for a particular batch writer - * - * @param cacheWriter the cache writer this operation should be performed upon - */ - void performBatchOperation(CacheWriter cacheWriter); - -} Index: rctags/ehcache-2.10.8.0.7/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/writebehind/KeyBasedOperationWrapper.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/writebehind/KeyBasedOperationWrapper.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/writebehind/KeyBasedOperationWrapper.java (revision 0) @@ -1,24 +0,0 @@ -/* - * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved. - */ -package org.terracotta.modules.ehcache.writebehind; - -import net.sf.ehcache.writer.writebehind.operations.KeyBasedOperation; - -public class KeyBasedOperationWrapper implements KeyBasedOperation { - private final Object key; - private final long creationTime; - - public KeyBasedOperationWrapper(Object key, long creationTime) { - this.key = key; - this.creationTime = creationTime; - } - - public Object getKey() { - return key; - } - - public long getCreationTime() { - return creationTime; - } -} Index: rctags/ehcache-2.10.8.0.7/management-ehcache-v1/src/main/java/net/sf/ehcache/management/service/CacheService.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/management-ehcache-v1/src/main/java/net/sf/ehcache/management/service/CacheService.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/management-ehcache-v1/src/main/java/net/sf/ehcache/management/service/CacheService.java (revision 0) @@ -1,34 +0,0 @@ -package net.sf.ehcache.management.service; - -import net.sf.ehcache.management.resource.CacheEntity; - -import org.terracotta.management.ServiceExecutionException; - -/** - * An interface for service implementations providing operations on Cache objects. - * - * @author brandony - */ -public interface CacheService { - - /** - * Create or update a cache represented by the submitted entity. - * - * @param cacheManagerName the name of the CacheManager managing the Cache to be updated - * @param cacheName the name of the Cache to be updated - * @param resource the representation of the resource informing this update - * @throws ServiceExecutionException if the update fails - */ - void createOrUpdateCache(String cacheManagerName, - String cacheName, - CacheEntity resource) throws ServiceExecutionException; - - /** - * Clears all the elements in the cache. - * - * @param cacheManagerName the name of the CacheManager managing the Cache to be cleared - * @param cacheName the name of the Cache to be cleared - */ - void clearCache(String cacheManagerName, - String cacheName) throws ServiceExecutionException; -} Index: rctags/ehcache-2.10.8.0.7/system-tests/src/test/resources/embedded-config-cache-test-ns.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/system-tests/src/test/resources/embedded-config-cache-test-ns.xml (revision 11085) +++ rctags/ehcache-2.10.8.0.7/system-tests/src/test/resources/embedded-config-cache-test-ns.xml (revision 0) @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - - - - PORT - - - - - - Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/extension/CacheExtensionFactory.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/extension/CacheExtensionFactory.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/extension/CacheExtensionFactory.java (revision 0) @@ -1,38 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.sf.ehcache.extension; - -import net.sf.ehcache.Ehcache; - -import java.util.Properties; - -/** - * An abstract factory for creating CacheExtensions. Implementers should provide their own - * concrete factory extending this factory. It can then be configured in ehcache.xml. - * - * @author Greg Luck - * @version $Id: CacheExtensionFactory.java 5594 2012-05-07 16:04:31Z cdennis $ - */ -public abstract class CacheExtensionFactory { - - /** - * @param cache the cache this extension should hold a reference to, and to whose lifecycle it should be bound. - * @param properties implementation specific properties configured as delimiter separated name value pairs in ehcache.xml - */ - public abstract CacheExtension createCacheExtension(Ehcache cache, Properties properties); - -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/pool/impl/package.html =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/pool/impl/package.html (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/pool/impl/package.html (revision 0) @@ -1,8 +0,0 @@ - - - - - This package contains implementations of the resource pooling interfaces. -

- - Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/store/LruPolicy.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/store/LruPolicy.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/store/LruPolicy.java (revision 0) @@ -1,57 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.sf.ehcache.store; - -import net.sf.ehcache.Element; - - -/** - * Contains common LFU policy code for use between the LfuMemoryStore and the DiskStore, which also - * uses an LfuPolicy for evictions. - * - * @author Greg Luck - * @version $Id: LruPolicy.java 5594 2012-05-07 16:04:31Z cdennis $ - */ -public class LruPolicy extends AbstractPolicy { - - /** - * The name of this policy as a string literal - */ - public static final String NAME = "LRU"; - - /** - * @return the name of the Policy. Inbuilt examples are LRU, LFU and FIFO. - */ - public String getName() { - return NAME; - } - - /** - * Compares the desirableness for eviction of two elements - * - * Compares hit counts. If both zero, - * - * @param element1 the element to compare against - * @param element2 the element to compare - * @return true if the second element is preferable to the first element for ths policy - */ - public boolean compare(Element element1, Element element2) { - return element2.getLastAccessTime() < element1.getLastAccessTime(); - - } - -} Index: rctags/ehcache-2.10.8.0.7/ehcache/src/test/java/net/sf/ehcache/terracotta/upgradability/serialization/WriteAsyncOperationSerializationTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache/src/test/java/net/sf/ehcache/terracotta/upgradability/serialization/WriteAsyncOperationSerializationTest.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache/src/test/java/net/sf/ehcache/terracotta/upgradability/serialization/WriteAsyncOperationSerializationTest.java (revision 0) @@ -1,48 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.sf.ehcache.terracotta.upgradability.serialization; - -import java.io.IOException; -import java.util.Comparator; - -import net.sf.ehcache.Element; - -import org.junit.Test; -import org.terracotta.modules.ehcache.writebehind.operations.WriteAsyncOperation; - -import static org.terracotta.upgradability.serialization.SerializationUpgradabilityTesting.validateSerializedForm; - -/** - * - * @author cdennis - */ -public class WriteAsyncOperationSerializationTest { - - private static final Comparator COMPARATOR = new Comparator() { - @Override - public int compare(WriteAsyncOperation o1, WriteAsyncOperation o2) { - return o1.getKey().equals(o2.getKey()) && o1.getElement().getObjectKey().equals(o2.getElement().getObjectKey()) - && o1.getElement().getObjectValue().equals(o2.getElement().getObjectValue()) - && o1.getCreationTime() == o2.getCreationTime() ? 0 : -1; - } - }; - - @Test - public void testBasic() throws IOException, ClassNotFoundException { - validateSerializedForm(new WriteAsyncOperation(new Element("foo", "bar", 1L, 2L, 3L, 4L, 0L), 42L), COMPARATOR, "serializedforms/WriteAsyncOperationSerializationTest.testBasic.ser"); - } -} Index: rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/ehcache/tests/AbstractCacheTestBase.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/ehcache/tests/AbstractCacheTestBase.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/ehcache/tests/AbstractCacheTestBase.java (revision 0) @@ -1,156 +0,0 @@ -/* - * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved. - */ -package org.terracotta.ehcache.tests; - -import net.sf.ehcache.CacheManager; - -import org.apache.commons.io.FileUtils; -import org.apache.commons.io.IOUtils; -import org.terracotta.test.util.TestBaseUtil; -import org.terracotta.tests.base.AbstractClientBase; -import org.terracotta.tests.base.AbstractTestBase; -import org.terracotta.toolkit.ToolkitFactory; - -import com.tc.l2.L2DebugLogging.LogLevel; -import com.tc.management.beans.L2MBeanNames; -import com.tc.test.config.model.TestConfig; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import javax.transaction.TransactionManager; - -public class AbstractCacheTestBase extends AbstractTestBase { - protected final String ehcacheConfigPath; - private final Set writtenXmls = new HashSet(); - - public AbstractCacheTestBase(TestConfig testConfig, Class... c) { - this("basic-cache-test.xml", testConfig, c); - } - - public AbstractCacheTestBase(final String ehcacheConfigPath, TestConfig testConfig) { - this(ehcacheConfigPath, testConfig, Client1.class, Client2.class); - testConfig.getClientConfig().setParallelClients(false); - } - - public AbstractCacheTestBase(final String ehcacheConfigPath, TestConfig testConfig, - Class... c) { - super(testConfig); - this.ehcacheConfigPath = ehcacheConfigPath; - testConfig.getL2Config().setOffHeapEnabled(true); - testConfig.getL2Config().setMaxOffHeapDataSize(512); - testConfig.getL2Config().setMaxHeap(1024); - testConfig.getL2Config().setMinHeap(256); - testConfig.getClientConfig().setClientClasses(c); - } - - @Override - protected String createClassPath(Class client) throws IOException { - List toolkitRuntime = TestBaseUtil.getToolkitRuntimeDependencies(ToolkitFactory.class); - List ehcache = TestBaseUtil.getEhcacheDependencies(CacheManager.class); - List ehcacheExpress = new ArrayList(); - ehcacheExpress.addAll(toolkitRuntime); - ehcacheExpress.addAll(ehcache); - - String slf4jApi = TestBaseUtil.jarFor(org.slf4j.LoggerFactory.class); - String slf4jBinder = TestBaseUtil.jarFor(org.slf4j.impl.StaticLoggerBinder.class); - String l2Mbean = TestBaseUtil.jarFor(L2MBeanNames.class); - String jta = TestBaseUtil.jarFor(TransactionManager.class); - String clientBase = TestBaseUtil.jarFor(ClientBase.class); - String hamcrest = TestBaseUtil.jarFor(org.hamcrest.core.Is.class); - - writeEhcacheConfigWithPort(ehcacheConfigPath); - copyFile("/log4j2.xml", "log4j2.xml"); - String classpath = makeClasspath(ehcacheExpress, tempDir.getAbsolutePath(), jta, slf4jApi, slf4jBinder, - clientBase, l2Mbean, hamcrest); - - return classpath; - } - - private void copyFile(String fileName, String outputFileName) throws IOException { - FileUtils.copyInputStreamToFile(this.getClass().getResourceAsStream(fileName), new File(tempDir, outputFileName)); - } - - /** - * Read the ehcache.xml file as a resource, replace PORT token with appropriate port, write the ehcache.xml file back - * out to the temp dir, and return the resulting resource directory. - */ - protected String writeEhcacheConfigWithPortAndNameSuffix(String resourcePath, String nameSuffix) throws IOException { - return writeXmlFileWithPort(resourcePath, "ehcache-config.xml", nameSuffix); - } - - protected String writeEhcacheConfigWithPort(String resourcePath) throws IOException { - return writeXmlFileWithPort(resourcePath, "ehcache-config.xml"); - } - - @SuppressWarnings("unchecked") - protected String writeXmlFileWithPort(String resourcePath, String outputName) throws IOException { - return writeXmlFileWithPort(resourcePath, outputName, null); - } - - @SuppressWarnings("unchecked") - protected synchronized String writeXmlFileWithPort(String resourcePath, String outputName, String nameSuffix) - throws IOException { - if (nameSuffix != null && outputName.indexOf(".xml") > 0) { - outputName = outputName.substring(0, outputName.indexOf(".xml")) + "-" + nameSuffix + ".xml"; - } - if (!writtenXmls.add(outputName)) { - System.out.println("OUTPUT FILE: " + outputName + " already written. Skipping..."); - return tempDir.getAbsolutePath(); - } - resourcePath = resourcePath.startsWith("/") ? resourcePath : "/" + resourcePath; - // Slurp resourcePath file - System.out.println("RESOURCE PATH: " + resourcePath + ", Output name: " + outputName); - - InputStream is = this.getClass().getResourceAsStream(resourcePath); - - List lines = IOUtils.readLines(is); - - final boolean isStandAloneTest = getTestConfig().isStandAloneTest(); - // Replace PORT token - for (int i = 0; i < lines.size(); i++) { - String line = lines.get(i); - if (!isStandAloneTest) { - line = line.replace("localhost:PORT", getTerracottaURL()); - line = line.replace("CONFIG", ehcacheConfigPath); - line = line.replace("TEMP", tempDir.getAbsolutePath()); - line = line.replace("TERRACOTTA_URL", getTerracottaURL()); - line = line.replace("PORT", Integer.toString(getGroupsData()[0].getTsaPort(0))); - - String nameSuffixReplaceValue = nameSuffix == null ? "" : "-" + nameSuffix; - line = line.replace("__NAME_SUFFIX__", nameSuffixReplaceValue); - } else { - if (line.contains("terracotta")) { - line = ""; - } - } - lines.set(i, line); - } - - // Write - File outputFile = new File(tempDir, outputName); - FileOutputStream fos = new FileOutputStream(outputFile); - IOUtils.writeLines(lines, IOUtils.LINE_SEPARATOR, fos); - return tempDir.getAbsolutePath(); - } - - public String getEhcacheConfigPath() { - return ehcacheConfigPath; - } - - public void enableNonStopDebugLogs() { - configureTCLogging("com.terracotta.toolkit.nonstop.NonStopManagerImpl", LogLevel.DEBUG); - configureTCLogging("com.terracotta.toolkit.NonStopInitializationService", LogLevel.DEBUG); - configureTCLogging("com.terracotta.toolkit.NonStopClusterInfo", LogLevel.DEBUG); - configureTCLogging("com.terracotta.toolkit.nonstop.AbstractToolkitObjectLookupAsync", LogLevel.DEBUG); - configureTCLogging("com.terracotta.toolkit.nonstop.NonStopInvocationHandler", LogLevel.DEBUG); - } - -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/management/sampled/CacheSamplerImplTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/management/sampled/CacheSamplerImplTest.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/management/sampled/CacheSamplerImplTest.java (revision 0) @@ -1,109 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package net.sf.ehcache.management.sampled; - -import net.sf.ehcache.Cache; -import net.sf.ehcache.CacheManager; -import net.sf.ehcache.Ehcache; -import net.sf.ehcache.config.CacheConfiguration; -import net.sf.ehcache.config.TerracottaConfiguration; -import net.sf.ehcache.statistics.StatisticsGateway; -import net.sf.ehcache.statistics.extended.ExtendedStatistics; -import org.junit.Before; -import org.junit.Test; - -import static org.hamcrest.core.IsEqual.equalTo; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -/** - * Test to check that quickStore() is called on clustered caches and getSize() on unclustered ones. - * - * @author Ludovic Orban - */ -public class CacheSamplerImplTest { - - private static final long EXACT_SIZE = 456L; - private static final long QUICK_SIZE = 123L; - - private CacheConfiguration cacheConfiguration = new CacheConfiguration(); - private Ehcache cache = mock(Cache.class); - private StatisticsGateway statisticsGateway = mock(StatisticsGateway.class); - private ExtendedStatistics extendedStatistics = mock(ExtendedStatistics.class); - private ExtendedStatistics.Statistic remoteSizeStat = mock(ExtendedStatistics.Statistic.class); - - @Before - public void setUpCacheSamplerImpl() { - when(cache.getCacheConfiguration()).thenReturn(cacheConfiguration); - when(cache.getStatistics()).thenReturn(statisticsGateway); - when(statisticsGateway.getExtended()).thenReturn(extendedStatistics); - when(statisticsGateway.getSize()).thenReturn(EXACT_SIZE); - when(extendedStatistics.remoteSize()).thenReturn(remoteSizeStat); - when(remoteSizeStat.value()).thenReturn(QUICK_SIZE); - } - - @Test - public void given_clustered_cache__cacheSampler_getSize_returns_quick_size() throws Exception { - cacheConfiguration.terracotta(new TerracottaConfiguration().clustered(true)); - CacheSamplerImpl cacheSampler = new CacheSamplerImpl(cache); - - assertThat(cacheSampler.getSize(), equalTo(QUICK_SIZE)); - } - - @Test - public void given_unclustered_cache__cacheSampler_getSize_returns_exact_size() throws Exception { - cacheConfiguration.terracotta(new TerracottaConfiguration().clustered(false)); - CacheSamplerImpl cacheSampler = new CacheSamplerImpl(cache); - - assertThat(cacheSampler.getSize(), equalTo(EXACT_SIZE)); - } - - @Test - public void testCacheSize() { - CacheManager manager = new CacheManager(); - CacheConfiguration conf = new CacheConfiguration("test", 0); - conf.setTransactionalMode("LOCAL"); - testSize(conf, manager); - CacheConfiguration conf1 = new CacheConfiguration("test1", 0); - conf1.setTransactionalMode("XA"); - testSize(conf1, manager); - CacheConfiguration conf2 = new CacheConfiguration("test2", 0); - conf2.setTransactionalMode("XA_STRICT"); - testSize(conf2, manager); - CacheConfiguration conf3 = new CacheConfiguration("test3", 0); - testSize(conf3, manager, false); - - manager.shutdown(); - - } - - private void testSize(CacheConfiguration conf, CacheManager mgr) { - testSize(conf, mgr, true); - } - - private void testSize(CacheConfiguration conf,CacheManager mgr, boolean checkTransactional) { - mgr.addCache(new Cache(conf)); - CacheSamplerImpl impl = new CacheSamplerImpl(mgr.getCache(conf.getName())); - if(checkTransactional) { - assertTrue(impl.getTransactional()); - } - assertEquals(impl.getSize(), 0); - } - -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/search/query/TestQueryManagerBuilder.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/search/query/TestQueryManagerBuilder.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/search/query/TestQueryManagerBuilder.java (revision 0) @@ -1,20 +0,0 @@ -package net.sf.ehcache.search.query; - -import net.sf.ehcache.CacheException; -import net.sf.ehcache.search.Query; - -/** - * @author Anthony Dahanne - */ -public class TestQueryManagerBuilder { - public static QueryManagerBuilder getQueryManagerBuilder() { - return new QueryManagerBuilder(QM.class); - } - - public static class QM implements QueryManager { - @Override - public Query createQuery(String statement) throws CacheException { - return null; - } - } -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/distribution/TransactionalRMICachePeer.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/distribution/TransactionalRMICachePeer.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/distribution/TransactionalRMICachePeer.java (revision 0) @@ -1,166 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.sf.ehcache.distribution; - -import net.sf.ehcache.Ehcache; -import net.sf.ehcache.Element; -import net.sf.ehcache.util.CacheTransactionHelper; - -import java.io.Serializable; -import java.rmi.RemoteException; -import java.util.List; - -/** - * An RMI based implementation of CachePeer supporting transactions. - * - * @author Ludovic Orban - */ -public class TransactionalRMICachePeer extends RMICachePeer { - - private final Ehcache cache; - - /** - * Construct a new remote peer supporting transactions - * - * @param cache The cache attached to the peer - * @param hostName The host name the peer is running on. - * @param rmiRegistryPort The port number on which the RMI Registry listens. Should be an unused port in - * the range 1025 - 65536 - * @param remoteObjectPort the port number on which the remote objects bound in the registry receive calls. - * This defaults to a free port if not specified. - * Should be an unused port in the range 1025 - 65536 - * @param socketTimeoutMillis - * @throws java.rmi.RemoteException - */ - public TransactionalRMICachePeer(Ehcache cache, String hostName, Integer rmiRegistryPort, - Integer remoteObjectPort, Integer socketTimeoutMillis) throws RemoteException { - super(cache, hostName, rmiRegistryPort, remoteObjectPort, socketTimeoutMillis); - this.cache = cache; - } - - @Override - public List getKeys() throws RemoteException { - boolean started = CacheTransactionHelper.isTransactionStarted(cache); - if (!started) { - CacheTransactionHelper.beginTransactionIfNeeded(cache); - } - - try { - return super.getKeys(); - } finally { - if (!started) { - CacheTransactionHelper.commitTransactionIfNeeded(cache); - } - } - } - - @Override - public Element getQuiet(Serializable key) throws RemoteException { - boolean started = CacheTransactionHelper.isTransactionStarted(cache); - if (!started) { - CacheTransactionHelper.beginTransactionIfNeeded(cache); - } - - try { - return super.getQuiet(key); - } finally { - if (!started) { - CacheTransactionHelper.commitTransactionIfNeeded(cache); - } - } - } - - @Override - public List getElements(List keys) throws RemoteException { - boolean started = CacheTransactionHelper.isTransactionStarted(cache); - if (!started) { - CacheTransactionHelper.beginTransactionIfNeeded(cache); - } - - try { - return super.getElements(keys); - } finally { - if (!started) { - CacheTransactionHelper.commitTransactionIfNeeded(cache); - } - } - } - - @Override - public void put(Element element) throws RemoteException, IllegalArgumentException, IllegalStateException { - boolean started = CacheTransactionHelper.isTransactionStarted(cache); - if (!started) { - CacheTransactionHelper.beginTransactionIfNeeded(cache); - } - - try { - super.put(element); - } finally { - if (!started) { - CacheTransactionHelper.commitTransactionIfNeeded(cache); - } - } - } - - @Override - public boolean remove(Serializable key) throws RemoteException, IllegalStateException { - boolean started = CacheTransactionHelper.isTransactionStarted(cache); - if (!started) { - CacheTransactionHelper.beginTransactionIfNeeded(cache); - } - - try { - return super.remove(key); - } finally { - if (!started) { - CacheTransactionHelper.commitTransactionIfNeeded(cache); - } - } - } - - @Override - public void removeAll() throws RemoteException, IllegalStateException { - boolean started = CacheTransactionHelper.isTransactionStarted(cache); - if (!started) { - CacheTransactionHelper.beginTransactionIfNeeded(cache); - } - - try { - super.removeAll(); - } finally { - if (!started) { - CacheTransactionHelper.commitTransactionIfNeeded(cache); - } - } - } - - @Override - public void send(List eventMessages) throws RemoteException { - boolean started = CacheTransactionHelper.isTransactionStarted(cache); - if (!started) { - CacheTransactionHelper.beginTransactionIfNeeded(cache); - } - - try { - super.send(eventMessages); - } finally { - if (!started) { - CacheTransactionHelper.commitTransactionIfNeeded(cache); - } - } - } -} Index: rctags/ehcache-2.10.8.0.7/distribution/events/src/assemble/bin/start-sample.sh =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/distribution/events/src/assemble/bin/start-sample.sh (revision 11085) +++ rctags/ehcache-2.10.8.0.7/distribution/events/src/assemble/bin/start-sample.sh (revision 0) @@ -1,31 +0,0 @@ -#!/bin/bash - -cygwin=false -if [ `uname | grep CYGWIN` ]; then - cygwin=true -fi - -if [ "$JAVA_HOME" = "" ]; then - echo "JAVA_HOME is not defined" - exit 1 -fi - -appname=events - -unset CDPATH -root=`dirname $0`/.. -root=`cd $root && pwd` - -$root/bin/package.sh - -if [ $? -ne 0 ]; then - exit 1 -fi - -$root/bin/start-jetty.sh 9081 -echo "Go to: http://localhost:9081/$appname" -echo -sleep 3 -$root/bin/start-jetty.sh 9082 -echo "Go to: http://localhost:9082/$appname" -echo Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/resources/ehcache-invalid-cache-manager-name.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/resources/ehcache-invalid-cache-manager-name.xml (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/resources/ehcache-invalid-cache-manager-name.xml (revision 0) @@ -1,11 +0,0 @@ - - - - Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/resources/distribution/ehcache-manual-distributed1.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/resources/distribution/ehcache-manual-distributed1.xml (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/resources/distribution/ehcache-manual-distributed1.xml (revision 0) @@ -1,746 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Index: rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/ehcache/tests/txns/BareXAResourceTx.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/ehcache/tests/txns/BareXAResourceTx.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/ehcache/tests/txns/BareXAResourceTx.java (revision 0) @@ -1,410 +0,0 @@ -/* - * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved. - */ -package org.terracotta.ehcache.tests.txns; - -import net.sf.ehcache.Cache; -import net.sf.ehcache.CacheException; -import net.sf.ehcache.Element; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.terracotta.ehcache.tests.xa.DummyTransactionManagerLookup; -import org.terracotta.ehcache.tests.xa.DummyXid; -import org.terracotta.ehcache.tests.xa.EhCacheXAResourceExtractor; -import org.terracotta.toolkit.Toolkit; - -import javax.transaction.Transaction; -import javax.transaction.TransactionManager; -import javax.transaction.xa.XAException; -import javax.transaction.xa.XAResource; -import javax.transaction.xa.Xid; - -import junit.framework.Assert; -import junit.framework.AssertionFailedError; - -public class BareXAResourceTx extends AbstractTxClient { - - private static final Logger LOG = LoggerFactory.getLogger(BareXAResourceTx.class); - - public BareXAResourceTx(String[] args) { - super(args); - } - - private TransactionManager tm; - private Cache cache; - - @Override - protected void runTest(Cache theCache, Toolkit toolkit) throws Throwable { - tm = new DummyTransactionManagerLookup().getTransactionManager(); - this.cache = theCache; - - try { - setUp(); - LOG.info("running testTwoPhaseCommit"); - testTwoPhaseCommit(); - - setUp(); - LOG.info("running testOnePhaseCommit"); - testOnePhaseCommit(); - - setUp(); - LOG.info("running testTMFAILRollback"); - testTMFAILRollback(); - - setUp(); - LOG.info("running testTMSUCCESSRollback"); - testTMSUCCESSRollback(); - - setUp(); - LOG.info("running testIsolationWithNewElement"); - testIsolationWithNewElement(); - - setUp(); - LOG.info("running testIsolationWithExistingElement"); - testIsolationWithExistingElement(); - - setUp(); - LOG.info("running testConflictWithNewElement"); - testConflictWithNewElement(); - - setUp(); - LOG.info("running testConflictWithExistingElement"); - testConflictWithExistingElement(); - - setUp(); - LOG.info("running testRollbackAfterPrepare"); - testRollbackAfterPrepare(); - - setUp(); - LOG.info("running testRollbackWithoutPrepare"); - testRollbackWithoutPrepare(); - - setUp(); - LOG.info("running testEnlistment"); - testEnlistment(); - } finally { - LOG.info("done running tests"); - } - } - - private void setUp() throws Exception { - tm.begin(); - - // clean up cache - Xid xid = new DummyXid(-1, -1); - getXAResource().start(xid, XAResource.TMNOFLAGS); - cache.removeAll(); - getXAResource().end(xid, XAResource.TMSUCCESS); - getXAResource().commit(xid, true); - - // clean up in-doubt TXs - Xid[] xids = getXAResource().recover(XAResource.TMSTARTRSCAN | XAResource.TMENDRSCAN); - if (xids != null) { - for (Xid aXid : xids) { - getXAResource().rollback(aXid); - } - } - } - - public void testTwoPhaseCommit() throws Exception { - final Element ELEMENT = new Element("1", "one"); - final Xid xid11 = new DummyXid(1, 1); - final Xid xid21 = new DummyXid(2, 1); - - getXAResource().start(xid11, XAResource.TMNOFLAGS); - cache.put(ELEMENT); - getXAResource().end(xid11, XAResource.TMSUCCESS); - - Assert.assertEquals(XAResource.XA_OK, getXAResource().prepare(xid11)); - getXAResource().commit(xid11, false); - - getXAResource().start(xid21, XAResource.TMNOFLAGS); - Assert.assertEquals(ELEMENT, cache.get(ELEMENT.getKey())); // "TX XID21 should see committed data of TX XID11" - getXAResource().end(xid21, XAResource.TMSUCCESS); - getXAResource().rollback(xid21); - - Xid[] recoveredXids = getXAResource().recover(XAResource.TMSTARTRSCAN | XAResource.TMENDRSCAN); - Assert.assertTrue("there should be 0 in-doubt TX", recoveredXids == null || 0 == recoveredXids.length); - } - - public void testOnePhaseCommit() throws Exception { - final Element ELEMENT = new Element("1", "one"); - final Xid xid11 = new DummyXid(1, 1); - final Xid xid21 = new DummyXid(2, 1); - - getXAResource().start(xid11, XAResource.TMNOFLAGS); - cache.put(ELEMENT); - getXAResource().end(xid11, XAResource.TMSUCCESS); - - getXAResource().commit(xid11, true); - - getXAResource().start(xid21, XAResource.TMNOFLAGS); - Assert.assertEquals(ELEMENT, cache.get(ELEMENT.getKey())); // "TX XID21 should see committed data of TX XID11" - getXAResource().end(xid21, XAResource.TMSUCCESS); - getXAResource().rollback(xid21); - - Xid[] recoveredXids = getXAResource().recover(XAResource.TMSTARTRSCAN | XAResource.TMENDRSCAN); - Assert.assertTrue("there should be 0 in-doubt TX", recoveredXids == null || 0 == recoveredXids.length); - } - - public void testTMFAILRollback() throws Exception { - final Element ELEMENT = new Element("1", "one"); - final Xid xid11 = new DummyXid(1, 1); - final Xid xid21 = new DummyXid(2, 1); - - getXAResource().start(xid11, XAResource.TMNOFLAGS); - cache.put(ELEMENT); - getXAResource().end(xid11, XAResource.TMFAIL); - - getXAResource().rollback(xid11); - - getXAResource().start(xid21, XAResource.TMNOFLAGS); - Assert.assertTrue(cache.get(ELEMENT.getKey()) == null); // "TX XID21 should not see rolled back data of TX XID11" - getXAResource().end(xid21, XAResource.TMSUCCESS); - getXAResource().rollback(xid21); - - Xid[] recoveredXids = getXAResource().recover(XAResource.TMSTARTRSCAN | XAResource.TMENDRSCAN); - Assert.assertTrue("there should be 0 in-doubt TX", recoveredXids == null || 0 == recoveredXids.length); - } - - public void testTMSUCCESSRollback() throws Exception { - final Element ELEMENT = new Element("1", "one"); - final Xid xid11 = new DummyXid(1, 1); - final Xid xid21 = new DummyXid(2, 1); - - getXAResource().start(xid11, XAResource.TMNOFLAGS); - cache.put(ELEMENT); - getXAResource().end(xid11, XAResource.TMSUCCESS); - - getXAResource().rollback(xid11); - - getXAResource().start(xid21, XAResource.TMNOFLAGS); - Assert.assertTrue(cache.get(ELEMENT.getKey()) == null); // "TX XID21 should not see rolled back data of TX XID11" - getXAResource().end(xid21, XAResource.TMSUCCESS); - getXAResource().rollback(xid21); - - Xid[] recoveredXids = getXAResource().recover(XAResource.TMSTARTRSCAN | XAResource.TMENDRSCAN); - Assert.assertTrue("there should be 0 in-doubt TX", recoveredXids == null || 0 == recoveredXids.length); - } - - public void testIsolationWithNewElement() throws Exception { - final Element ELEMENT = new Element("1", "one"); - final Xid xid11 = new DummyXid(1, 1); - final Xid xid21 = new DummyXid(2, 1); - - getXAResource().start(xid11, XAResource.TMNOFLAGS); - cache.put(ELEMENT); - getXAResource().end(xid11, XAResource.TMSUCCESS); - Transaction tx11 = tm.suspend(); - - tm.begin(); - getXAResource().start(xid21, XAResource.TMNOFLAGS); - Assert.assertTrue(cache.get(ELEMENT.getKey()) == null); // "TX XID21 should not be able to see data in progress of TX XID11 " - getXAResource().end(xid21, XAResource.TMSUCCESS); - Transaction tx21 = tm.suspend(); - - tm.resume(tx11); - Assert.assertEquals(XAResource.XA_OK, getXAResource().prepare(xid11)); - - getXAResource().commit(xid11, false); - - tm.resume(tx21); - getXAResource().start(xid21, XAResource.TMJOIN); - Assert.assertEquals(ELEMENT, cache.get(ELEMENT.getKey())); // "TX XID21 should see committed data of TX XID11" - getXAResource().end(xid21, XAResource.TMSUCCESS); - getXAResource().rollback(xid21); - - Xid[] recoveredXids = getXAResource().recover(XAResource.TMSTARTRSCAN | XAResource.TMENDRSCAN); - Assert.assertTrue("there should be 0 in-doubt TX", recoveredXids == null || 0 == recoveredXids.length); - } - - public void testIsolationWithExistingElement() throws Exception { - final Element ELEMENT_OLD = new Element("1", "one"); - final Element ELEMENT_NEW = new Element("1", "two-divided-by-two"); - final Xid xid01 = new DummyXid(0, 1); - final Xid xid11 = new DummyXid(1, 1); - final Xid xid21 = new DummyXid(2, 1); - - // init cache - getXAResource().start(xid01, XAResource.TMNOFLAGS); - cache.put(ELEMENT_OLD); - getXAResource().end(xid01, XAResource.TMSUCCESS); - getXAResource().commit(xid01, true); - - getXAResource().start(xid11, XAResource.TMNOFLAGS); - cache.put(ELEMENT_NEW); - getXAResource().end(xid11, XAResource.TMSUCCESS); - Transaction tx11 = tm.suspend(); - - tm.begin(); - getXAResource().start(xid21, XAResource.TMNOFLAGS); - Assert.assertEquals(ELEMENT_OLD, cache.get(ELEMENT_OLD.getKey())); // "TX XID21 should see old data" - getXAResource().end(xid21, XAResource.TMSUCCESS); - Transaction tx21 = tm.suspend(); - - tm.resume(tx11); - Assert.assertEquals(XAResource.XA_OK, getXAResource().prepare(xid11)); - - getXAResource().commit(xid11, false); - - tm.resume(tx21); - getXAResource().start(xid21, XAResource.TMJOIN); - Assert.assertEquals(ELEMENT_NEW, cache.get(ELEMENT_NEW.getKey())); // "TX XID21 should see committed data of TX XID11" - getXAResource().end(xid21, XAResource.TMSUCCESS); - getXAResource().rollback(xid21); - - Xid[] recoveredXids = getXAResource().recover(XAResource.TMSTARTRSCAN | XAResource.TMENDRSCAN); - Assert.assertTrue("there should be 0 in-doubt TX", recoveredXids == null || 0 == recoveredXids.length); - } - - public void testConflictWithNewElement() throws Exception { - final Element ELEMENT1 = new Element("1", "one"); - final Element ELEMENT2 = new Element("1", "two-divided-by-two"); - final Xid xid01 = new DummyXid(0, 1); - final Xid xid11 = new DummyXid(1, 1); - final Xid xid21 = new DummyXid(2, 1); - - getXAResource().start(xid11, XAResource.TMNOFLAGS); - cache.put(ELEMENT1); - getXAResource().end(xid11, XAResource.TMSUCCESS); - Transaction tx11 = tm.suspend(); - - tm.begin(); - getXAResource().start(xid21, XAResource.TMNOFLAGS); - cache.put(ELEMENT2); - getXAResource().end(xid21, XAResource.TMSUCCESS); - Transaction tx21 = tm.suspend(); - - tm.resume(tx11); - Assert.assertEquals(XAResource.XA_OK, getXAResource().prepare(xid11)); - getXAResource().commit(xid11, false); - - tm.resume(tx21); - try { - getXAResource().prepare(xid21); - throw new AssertionFailedError("expected XAException"); - } catch (XAException ex) { - Assert.assertEquals(XAException.XA_RBINTEGRITY, ex.errorCode); - } - getXAResource().rollback(xid21); - - tm.begin(); - getXAResource().start(xid01, XAResource.TMNOFLAGS); - Assert.assertEquals(ELEMENT2, cache.get(ELEMENT1.getKey())); // "TX XID01 should see committed data of TX XID21" - getXAResource().end(xid01, XAResource.TMSUCCESS); - getXAResource().rollback(xid21); - - Xid[] recoveredXids = getXAResource().recover(XAResource.TMSTARTRSCAN | XAResource.TMENDRSCAN); - Assert.assertTrue("there should be 0 in-doubt TX", recoveredXids == null || 0 == recoveredXids.length); - } - - public void testConflictWithExistingElement() throws Exception { - final Element ELEMENT0 = new Element("1", "unknown-yet"); - final Element ELEMENT1 = new Element("1", "one"); - final Element ELEMENT2 = new Element("1", "two-divided-by-two"); - final Xid xid01 = new DummyXid(0, 1); - final Xid xid11 = new DummyXid(1, 1); - final Xid xid21 = new DummyXid(2, 1); - - // init cache - getXAResource().start(xid01, XAResource.TMNOFLAGS); - cache.put(ELEMENT0); - getXAResource().end(xid01, XAResource.TMSUCCESS); - getXAResource().commit(xid01, true); - - tm.begin(); - getXAResource().start(xid11, XAResource.TMNOFLAGS); - cache.put(ELEMENT1); - getXAResource().end(xid11, XAResource.TMSUCCESS); - Transaction tx11 = tm.suspend(); - - tm.begin(); - getXAResource().start(xid21, XAResource.TMNOFLAGS); - cache.put(ELEMENT2); - getXAResource().end(xid21, XAResource.TMSUCCESS); - - Assert.assertEquals(XAResource.XA_OK, getXAResource().prepare(xid21)); - getXAResource().commit(xid21, false); - - tm.resume(tx11); - try { - getXAResource().prepare(xid11); - throw new AssertionFailedError("expected XAException"); - } catch (XAException ex) { - Assert.assertEquals(XAException.XA_RBINTEGRITY, ex.errorCode); - } - getXAResource().rollback(xid11); - - tm.begin(); - getXAResource().start(xid01, XAResource.TMNOFLAGS); - Assert.assertEquals(ELEMENT1, cache.get(ELEMENT0.getKey())); // "TX XID01 should see committed data of TX XID11" - getXAResource().end(xid01, XAResource.TMSUCCESS); - getXAResource().rollback(xid21); - - Xid[] recoveredXids = getXAResource().recover(XAResource.TMSTARTRSCAN | XAResource.TMENDRSCAN); - Assert.assertTrue("there should be 0 in-doubt TX", recoveredXids == null || 0 == recoveredXids.length); - } - - public void testRollbackAfterPrepare() throws Exception { - final Element ELEMENT = new Element("1", "one"); - final Xid xid11 = new DummyXid(1, 1); - final Xid xid21 = new DummyXid(2, 1); - - getXAResource().start(xid11, XAResource.TMNOFLAGS); - cache.put(ELEMENT); - getXAResource().end(xid11, XAResource.TMSUCCESS); - - Assert.assertEquals(XAResource.XA_OK, getXAResource().prepare(xid11)); - getXAResource().rollback(xid11); - - tm.begin(); - getXAResource().start(xid21, XAResource.TMNOFLAGS); - Assert.assertNull(cache.get(ELEMENT.getKey())); // "TX XID21 should see no data" - getXAResource().end(xid21, XAResource.TMSUCCESS); - getXAResource().rollback(xid21); - - Xid[] recoveredXids = getXAResource().recover(XAResource.TMSTARTRSCAN | XAResource.TMENDRSCAN); - Assert.assertTrue("there should be 0 in-doubt TX", recoveredXids == null || 0 == recoveredXids.length); - } - - public void testRollbackWithoutPrepare() throws Exception { - final Element ELEMENT = new Element("1", "one"); - final Xid xid11 = new DummyXid(1, 1); - final Xid xid21 = new DummyXid(2, 1); - - getXAResource().start(xid11, XAResource.TMNOFLAGS); - cache.put(ELEMENT); - getXAResource().end(xid11, XAResource.TMSUCCESS); - - getXAResource().rollback(xid11); - - tm.begin(); - getXAResource().start(xid21, XAResource.TMNOFLAGS); - Assert.assertTrue(cache.get(ELEMENT.getKey()) == null); // "TX XID21 should see no data" - getXAResource().end(xid21, XAResource.TMSUCCESS); - getXAResource().rollback(xid21); - - Xid[] recoveredXids = getXAResource().recover(XAResource.TMSTARTRSCAN | XAResource.TMENDRSCAN); - Assert.assertTrue("there should be 0 in-doubt TX", recoveredXids == null || 0 == recoveredXids.length); - } - - public void testEnlistment() throws Exception { - try { - final Element ELEMENT = new Element("1", "one"); - cache.put(ELEMENT); - throw new AssertionError("expected CacheException"); - } catch (CacheException e) { - // expected - } - } - - private XAResource getXAResource() { - return EhCacheXAResourceExtractor.extractXAResource(cache); - } - - public static void main(String[] args) { - new BareXAResourceTx(args).run(); - } - -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/search/attribute/AttributeExtractorException.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/search/attribute/AttributeExtractorException.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/search/attribute/AttributeExtractorException.java (revision 0) @@ -1,64 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.sf.ehcache.search.attribute; - -import net.sf.ehcache.search.SearchException; - -import java.io.Serializable; - -/** - * An exception to indicate that an attribute extractor was unable to be processed. - *

- * Attributes are extracted on put or update, so this exception will be thrown to the calling - * thread. - * - * @author Greg Luck - */ -public class AttributeExtractorException extends SearchException implements Serializable { - - - private static final long serialVersionUID = 5066522240394222152L; - - - /** - * Construct a AttributeExtractorException - * - * @param message the description of the exception - */ - public AttributeExtractorException(String message) { - super(message); - } - - /** - * Construct a AttributeExtractorException with an underlying cause and message - * - * @param message - * @param cause - */ - public AttributeExtractorException(String message, Throwable cause) { - super(message, cause); - } - - /** - * Construct a AttributeExtractorException with an underlying cause - * - * @param cause - */ - public AttributeExtractorException(Throwable cause) { - super(cause); - } -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/hibernate/management/impl/CollectionStats.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/hibernate/management/impl/CollectionStats.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/hibernate/management/impl/CollectionStats.java (revision 0) @@ -1,250 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.sf.ehcache.hibernate.management.impl; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import javax.management.openmbean.CompositeData; -import javax.management.openmbean.CompositeDataSupport; -import javax.management.openmbean.CompositeType; -import javax.management.openmbean.OpenDataException; -import javax.management.openmbean.OpenType; -import javax.management.openmbean.SimpleType; -import javax.management.openmbean.TabularData; -import javax.management.openmbean.TabularDataSupport; -import javax.management.openmbean.TabularType; - -import org.hibernate.stat.CollectionStatistics; - -/** - * CollectionStats - * @author gkeim - */ -public class CollectionStats implements Serializable { - private static final String COMPOSITE_TYPE_NAME = "CollectionsStats"; - private static final String COMPOSITE_TYPE_DESCRIPTION = "Statistics per Collections"; - private static final String[] ITEM_NAMES = new String[] {"roleName", "shortName", "loadCount", - "fetchCount", "updateCount", "removeCount", "recreateCount", }; - private static final String[] ITEM_DESCRIPTIONS = new String[] {"roleName", "shortName", "loadCount", - "fetchCount", "updateCount", "removeCount", "recreateCount", }; - private static final OpenType[] ITEM_TYPES = new OpenType[] {SimpleType.STRING, - SimpleType.STRING, SimpleType.LONG, SimpleType.LONG, SimpleType.LONG, SimpleType.LONG, SimpleType.LONG, }; - private static final CompositeType COMPOSITE_TYPE; - private static final String TABULAR_TYPE_NAME = "Statistics by Collection"; - private static final String TABULAR_TYPE_DESCRIPTION = "All Collection Statistics"; - private static final String[] INDEX_NAMES = new String[] {"roleName", }; - private static final TabularType TABULAR_TYPE; - - static { - try { - COMPOSITE_TYPE = new CompositeType(COMPOSITE_TYPE_NAME, COMPOSITE_TYPE_DESCRIPTION, ITEM_NAMES, - ITEM_DESCRIPTIONS, ITEM_TYPES); - TABULAR_TYPE = new TabularType(TABULAR_TYPE_NAME, TABULAR_TYPE_DESCRIPTION, COMPOSITE_TYPE, INDEX_NAMES); - } catch (OpenDataException e) { - throw new RuntimeException(e); - } - } - - /** - * roleName - */ - protected final String roleName; - - /** - * shortName - */ - protected final String shortName; - - /** - * loadCount - */ - protected long loadCount; - - /** - * fetchCount - */ - protected long fetchCount; - - /** - * updateCount - */ - protected long updateCount; - - /** - * removeCount - */ - protected long removeCount; - - /** - * recreateCount - */ - protected long recreateCount; - - - /** - * @param roleName - */ - public CollectionStats(String roleName) { - this.roleName = roleName; - this.shortName = CacheRegionUtils.determineShortName(roleName); - } - - /** - * @param name - * @param src - */ - public CollectionStats(String name, CollectionStatistics src) { - this(name); - - try { - this.loadCount = BeanUtils.getLongBeanProperty(src, "loadCount"); - this.fetchCount = BeanUtils.getLongBeanProperty(src, "fetchCount"); - this.updateCount = BeanUtils.getLongBeanProperty(src, "updateCount"); - this.removeCount = BeanUtils.getLongBeanProperty(src, "removeCount"); - this.recreateCount = BeanUtils.getLongBeanProperty(src, "recreateCount"); - } catch (Exception e) { - e.printStackTrace(); - throw new RuntimeException("Exception retrieving statistics", e); - } - } - - /** - * @param cData - */ - public CollectionStats(final CompositeData cData) { - int i = 0; - roleName = (String) cData.get(ITEM_NAMES[i++]); - shortName = (String) cData.get(ITEM_NAMES[i++]); - loadCount = (Long) cData.get(ITEM_NAMES[i++]); - fetchCount = (Long) cData.get(ITEM_NAMES[i++]); - updateCount = (Long) cData.get(ITEM_NAMES[i++]); - removeCount = (Long) cData.get(ITEM_NAMES[i++]); - recreateCount = (Long) cData.get(ITEM_NAMES[i++]); - } - - private static int safeParseInt(String s) { - try { - return Integer.parseInt(s); - } catch (Exception e) { - return -1; - } - } - - /** - * @param stats - */ - public void add(CollectionStats stats) { - loadCount += stats.getLoadCount(); - fetchCount += stats.getFetchCount(); - updateCount += stats.getUpdateCount(); - removeCount += stats.getRemoveCount(); - recreateCount += stats.getRecreateCount(); - } - - /** - * toString - */ - @Override - public String toString() { - return "roleName=" + roleName + "shortName=" + shortName + ", loadCount=" + loadCount + ", fetchCount=" - + fetchCount + ", updateCount=" + updateCount + ", removeCount=" + removeCount + ", recreateCount" - + recreateCount; - } - - /** - * getRoleName - */ - public String getRoleName() { - return roleName; - } - - /** - * getShortName - */ - public String getShortName() { - return shortName; - } - - /** - * getLoadCount - */ - public long getLoadCount() { - return loadCount; - } - - /** - * getFetchCount - */ - public long getFetchCount() { - return fetchCount; - } - - /** - * getUpdateCount - */ - public long getUpdateCount() { - return updateCount; - } - - /** - * getRemoveCount - */ - public long getRemoveCount() { - return removeCount; - } - - /** - * getRecreateCount - */ - public long getRecreateCount() { - return recreateCount; - } - - /** - * toCompositeData - */ - public CompositeData toCompositeData() { - try { - return new CompositeDataSupport(COMPOSITE_TYPE, ITEM_NAMES, new Object[] {roleName, shortName, loadCount, - fetchCount, updateCount, removeCount, recreateCount, }); - } catch (OpenDataException e) { - throw new RuntimeException(e); - } - } - - /** - * newTabularDataInstance - */ - public static TabularData newTabularDataInstance() { - return new TabularDataSupport(TABULAR_TYPE); - } - - /** - * fromTabularData - */ - public static CollectionStats[] fromTabularData(final TabularData tabularData) { - final List countList = new ArrayList(tabularData.size()); - for (final Iterator pos = tabularData.values().iterator(); pos.hasNext();) { - countList.add(new CollectionStats((CompositeData) pos.next())); - } - return countList.toArray(new CollectionStats[countList.size()]); - } - -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/constructs/refreshahead/RefreshAheadCacheTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/constructs/refreshahead/RefreshAheadCacheTest.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/constructs/refreshahead/RefreshAheadCacheTest.java (revision 0) @@ -1,179 +0,0 @@ -package net.sf.ehcache.constructs.refreshahead; - -import net.sf.ehcache.Cache; -import net.sf.ehcache.CacheManager; -import net.sf.ehcache.Ehcache; -import net.sf.ehcache.Element; -import net.sf.ehcache.config.CacheConfiguration; -import net.sf.ehcache.config.Configuration; -import net.sf.ehcache.loader.CacheLoader; -import net.sf.ehcache.statistics.extended.ExtendedStatistics; - -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.terracotta.test.categories.CheckShorts; - -import java.util.Set; -import java.util.concurrent.Callable; -import java.util.concurrent.TimeUnit; - -import static net.sf.ehcache.util.RetryAssert.assertBy; -import static net.sf.ehcache.util.RetryAssert.sleepFor; -import static org.hamcrest.CoreMatchers.not; -import static org.hamcrest.CoreMatchers.nullValue; -import static org.hamcrest.CoreMatchers.sameInstance; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; - -@Category(CheckShorts.class) -public class RefreshAheadCacheTest { - - private static CacheLoader stringifyCacheLoader = new StringifyCacheLoaderFactory().createCacheLoader(null, null); - - @Test - public void testSimpleCaseProgrammatic() { - - CacheManager manager = new CacheManager(new Configuration().name("programmatic")); - - try { - manager.addCache(new Cache(new CacheConfiguration().name("test").timeToLiveSeconds(10).overflowToDisk(false) - .maxElementsInMemory(100))); - Ehcache cache = manager.getEhcache("test"); - - RefreshAheadCacheConfiguration refreshConfig = new RefreshAheadCacheConfiguration().timeToRefreshSeconds(3).numberOfThreads(4) - .maximumRefreshBacklogItems(100) - .build(); - final RefreshAheadCache decorator = new RefreshAheadCache(cache, refreshConfig); - - cache.registerCacheLoader(stringifyCacheLoader); - - Set> offerStat = RefreshAheadCache.findOfferStatistic(decorator); - Set> processedStat = RefreshAheadCache.findProcessedStatistic(decorator); - Set> successStat = RefreshAheadCache.findRefreshedStatistic(decorator); - Set> droppedStat = RefreshAheadCache.findDroppedStatistic(decorator); - Set> backlogStat = RefreshAheadCache.findBacklogStatistic(decorator); - assertFalse(offerStat.isEmpty()); - assertFalse(processedStat.isEmpty()); - assertFalse(droppedStat.isEmpty()); - assertFalse(successStat.isEmpty()); - assertFalse(backlogStat.isEmpty()); - - final Integer key1 = 1; - decorator.put(new Element(key1, "1")); - decorator.put(new Element(2, "2")); - decorator.put(new Element(3, "3")); - decorator.put(new Element(4, "4")); - - // get the first one - Element got = decorator.get(key1); - long creationTime = got.getCreationTime(); - assertNotNull(got); - assertEquals(0, decorator.getRefreshSuccessCount()); - - sleepFor(1, TimeUnit.SECONDS); - // now, you should get the same one, no refresh ahead - got = decorator.get(key1); - assertNotNull(got); - assertEquals(0, decorator.getRefreshSuccessCount()); - assertEquals(0, successStat.iterator().next().value().longValue()); - assertEquals(got.getCreationTime(), creationTime); - - // wait long enough for refresh ahead to trigger. - assertBy(5, TimeUnit.SECONDS, new Callable() { - @Override - public Element call() throws Exception { - return decorator.get(key1); - } - }, not(sameInstance(got))); - got = decorator.get(key1); - assertEquals(1, decorator.getRefreshSuccessCount()); - assertEquals(1, successStat.iterator().next().value().longValue()); - assertEquals(1, processedStat.iterator().next().value().longValue()); - assertEquals(0, droppedStat.iterator().next().value().longValue()); - assertEquals(0, backlogStat.iterator().next().value().longValue()); - assertFalse(creationTime == got.getCreationTime()); - } finally { - manager.shutdown(); - } - } - - @Test - public void testSimpleCaseXML() { - - CacheManager cacheManager = new CacheManager(getClass().getResourceAsStream - ("/ehcache-refresh-ahead-simple.xml")); - - try { - final Ehcache decorator = cacheManager.getEhcache("testRefreshAhead1"); - - final Integer key1 = 1; - decorator.put(new Element(key1, "1")); - decorator.put(new Element(2, "2")); - decorator.put(new Element(3, "3")); - decorator.put(new Element(4, "4")); - - // get the first one - Element got = decorator.get(key1); - long creationTime = got.getCreationTime(); - assertNotNull(got); - - sleepFor(1, TimeUnit.SECONDS); - // now, you should get the same one, no refresh ahead - got = decorator.get(key1); - assertNotNull(got); - assertEquals(got.getCreationTime(), creationTime); - - assertBy(5, TimeUnit.SECONDS, new Callable() { - @Override - public Element call() throws Exception { - return decorator.get(key1); - } - }, not(sameInstance(got))); - // better not have the same creation time as originally - got = decorator.get(key1); - assertFalse(creationTime == got.getCreationTime()); - - } finally { - cacheManager.shutdown(); - } - } - - @Test - public void testSimpleCaseXMLNullEvicts() { - - CacheManager cacheManager = new CacheManager(getClass().getResourceAsStream - ("/ehcache-refresh-ahead-simple.xml")); - - try { - final Ehcache decorator=cacheManager.getEhcache("testRefreshAhead2"); - - - final Integer key1 = 1; - decorator.put(new Element(key1, "1")); - decorator.put(new Element(2, "2")); - decorator.put(new Element(3, "3")); - decorator.put(new Element(4, "4")); - - // get the first one - Element got = decorator.get(key1); - long creationTime = got.getCreationTime(); - assertNotNull(got); - - sleepFor(1, TimeUnit.SECONDS); - // now, you should get the same one, no refresh ahead - got = decorator.get(key1); - assertNotNull(got); - assertEquals(got.getCreationTime(), creationTime); - - assertBy(5, TimeUnit.SECONDS, new Callable() { - @Override - public Element call() throws Exception { - return decorator.get(key1); - } - }, nullValue()); - } finally { - cacheManager.shutdown(); - } - } -} \ No newline at end of file Index: rctags/ehcache-2.10.8.0.7/system-tests/src/test/resources/servermap/lock-gc-test.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/system-tests/src/test/resources/servermap/lock-gc-test.xml (revision 11085) +++ rctags/ehcache-2.10.8.0.7/system-tests/src/test/resources/servermap/lock-gc-test.xml (revision 0) @@ -1,18 +0,0 @@ - - - - - - - - - - - - - Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/loader/ComponentALoader.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/loader/ComponentALoader.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/loader/ComponentALoader.java (revision 0) @@ -1,71 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.sf.ehcache.loader; - - -import net.sf.ehcache.CacheException; - - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - -/** - * Written for Dead-lock poc - * - * @author Greg Luck - * @version $Id: ComponentALoader.java 5594 2012-05-07 16:04:31Z cdennis $ - */ -public class ComponentALoader extends BaseComponentLoader { - - private static final Logger LOG = LoggerFactory.getLogger(ComponentALoader.class.getName()); - - /** - * @return - */ - public String getName() { - return "LoaderA"; - } - - /** - * @param arg0 - * @return - * @throws CacheException - */ - public Object load(Object arg0) throws CacheException { - String key = null; - ComponentA a = null; - ComponentB b = null; - - boolean createDeadLock = Boolean.valueOf(props.getProperty("createDeadLock")).booleanValue(); - - LOG.info("createDeadLock=" + createDeadLock); - - if (createDeadLock) { - key = (String) arg0; - } else { - key = new String((String) arg0); - } - - LOG.info("Getting componentB..."); - b = (ComponentB) CacheHelper.get("ehcache-loaderinteractions.xml", "BCache", key); - - return new ComponentA(key, b); - - } - -} Index: rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/net/sf/ehcache/osgi/IncrementingCacheLoader.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/net/sf/ehcache/osgi/IncrementingCacheLoader.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/net/sf/ehcache/osgi/IncrementingCacheLoader.java (revision 0) @@ -1,110 +0,0 @@ -/* - * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved. - */ -package net.sf.ehcache.osgi; - -import net.sf.ehcache.CacheException; -import net.sf.ehcache.Ehcache; -import net.sf.ehcache.Status; -import net.sf.ehcache.loader.CacheLoader; - -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; - -public class IncrementingCacheLoader implements CacheLoader { - private final int incrementalAmount; - private final boolean matchEvens; - private long msDelay = 0L; - - public IncrementingCacheLoader(boolean matchEvens, int inc) { - this.incrementalAmount = inc; - this.matchEvens = matchEvens; - } - - @Override - public Map loadAll(Collection keys, Object argument) { - return loadAll(keys); - } - - public long getMsDelay() { - return msDelay; - } - - public void setMsDelay(long msDelay) { - this.msDelay = msDelay; - } - - @Override - public Map loadAll(Collection keys) { - - HashMap ret = new HashMap(); - for (Object k : keys) { - Object got = load(k); - if (got != null) { - ret.put(k, got); - } - } - return ret; - } - - @Override - public Object load(Object key, Object argument) { - return load(key); - } - - @Override - public Object load(Object key) throws CacheException { - if (getMsDelay() > 0L) { - try { - Thread.sleep(getMsDelay()); - } catch (InterruptedException e) { - } - } - if (key instanceof Number) { - int ivalue = ((Number) key).intValue(); - if ((((ivalue & 0x01) != 0) && !matchEvens) || ((ivalue & 0x01) == 0) && matchEvens) { - int next = ivalue + incrementalAmount; - return next + ""; - } else { - return null; - } - } - return key.toString(); - } - - @Override - public void init() { - // TODO Auto-generated method stub - - } - - @Override - public Status getStatus() { - // TODO Auto-generated method stub - return null; - } - - @Override - public String getName() { - // TODO Auto-generated method stub - return null; - } - - @Override - public void dispose() throws CacheException { - // TODO Auto-generated method stub - - } - - @Override - public CacheLoader clone(Ehcache cache) throws CloneNotSupportedException { - // TODO Auto-generated method stub - return null; - } - - @Override - public String toString() { - return "IncrementingCacheLoader [matchEvens=" + matchEvens + ", incrementalAmount=" + incrementalAmount + "]"; - } -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/pool/sizeof/PrimitiveType.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/pool/sizeof/PrimitiveType.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/pool/sizeof/PrimitiveType.java (revision 0) @@ -1,114 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.sf.ehcache.pool.sizeof; - -import static net.sf.ehcache.pool.sizeof.JvmInformation.CURRENT_JVM_INFORMATION; - -/** - * Primitive types in the VM type system and their sizes - * @author Alex Snaps - */ -enum PrimitiveType { - - /** - * boolean.class - */ - BOOLEAN(boolean.class, 1), - /** - * byte.class - */ - BYTE(byte.class, 1), - /** - * char.class - */ - CHAR(char.class, 2), - /** - * short.class - */ - SHORT(short.class, 2), - /** - * int.class - */ - INT(int.class, 4), - /** - * float.class - */ - FLOAT(float.class, 4), - /** - * double.class - */ - DOUBLE(double.class, 8), - /** - * long.class - */ - LONG(long.class, 8); - - private Class type; - private int size; - - - private PrimitiveType(Class type, int size) { - this.type = type; - this.size = size; - } - - /** - * Returns the size in memory this type occupies - * @return size in bytes - */ - public int getSize() { - return size; - } - - /** - * The representing type - * @return the type - */ - public Class getType() { - return type; - } - - /** - * The size of a pointer - * @return size in bytes - */ - public static int getReferenceSize() { - return CURRENT_JVM_INFORMATION.getJavaPointerSize(); - } - - /** - * The size on an array - * @return size in bytes - */ - public static long getArraySize() { - return CURRENT_JVM_INFORMATION.getObjectHeaderSize() + INT.getSize(); - } - - /** - * Finds the matching PrimitiveType for a type - * @param type the type to find the PrimitiveType for - * @return the PrimitiveType instance or null if none found - */ - public static PrimitiveType forType(final Class type) { - for (PrimitiveType primitiveType : values()) { - if (primitiveType.getType() == type) { - return primitiveType; - } - } - return null; - } -} Index: rctags/ehcache-2.10.8.0.7/management-ehcache-v2/src/main/java/net/sf/ehcache/management/resource/services/QueryResourceServiceImplV2.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/management-ehcache-v2/src/main/java/net/sf/ehcache/management/resource/services/QueryResourceServiceImplV2.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/management-ehcache-v2/src/main/java/net/sf/ehcache/management/resource/services/QueryResourceServiceImplV2.java (revision 0) @@ -1,63 +0,0 @@ -package net.sf.ehcache.management.resource.services; - -import java.util.List; - -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.UriInfo; - -import net.sf.ehcache.management.service.CacheManagerServiceV2; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.terracotta.management.ServiceExecutionException; -import org.terracotta.management.ServiceLocator; -import org.terracotta.management.resource.ResponseEntityV2; -import org.terracotta.management.resource.exceptions.ExceptionUtils; -import org.terracotta.management.resource.exceptions.ResourceRuntimeException; -import org.terracotta.management.resource.services.validator.RequestValidator; - -/** - * @author gkeim - */ -@Path("/v2/agents/cacheManagers/query") -public final class QueryResourceServiceImplV2 { - public final static String ATTR_QUERY_KEY = "text"; - - private static final Logger LOG = LoggerFactory.getLogger(QueryResourceServiceImplV2.class); - - private final RequestValidator validator; - - private final CacheManagerServiceV2 cacheMgrSvc; - - public QueryResourceServiceImplV2() { - this.validator = ServiceLocator.locate(RequestValidator.class); - this.cacheMgrSvc = ServiceLocator.locate(CacheManagerServiceV2.class); - } - - @GET - @Produces(MediaType.APPLICATION_JSON) - public ResponseEntityV2 executeQuery(@Context UriInfo info) { - LOG.debug(String.format("Invoking executeQuery: %s", info.getRequestUri())); - - validator.validateSafe(info); - - String cacheManagerName = info.getPathSegments().get(2).getMatrixParameters().getFirst("names"); - - MultivaluedMap qParams = info.getQueryParameters(); - List querys = qParams.get(ATTR_QUERY_KEY); - String queryString = querys.size() > 0 ? querys.get(0) : null; - - try { - return cacheMgrSvc.executeQuery(cacheManagerName, queryString); - } catch (ServiceExecutionException e) { - Throwable t = ExceptionUtils.getRootCause(e); - throw new ResourceRuntimeException("Failed to execute query", t, Response.Status.BAD_REQUEST.getStatusCode()); - } - } -} Index: rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/modules/ehcache/writebehind/BasicDeadBucketWriteBehindTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/modules/ehcache/writebehind/BasicDeadBucketWriteBehindTest.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/system-tests/src/test/java/org/terracotta/modules/ehcache/writebehind/BasicDeadBucketWriteBehindTest.java (revision 0) @@ -1,89 +0,0 @@ -/* - * All content copyright (c) 2003-2008 Terracotta, Inc., except as may otherwise be noted in a separate copyright - * notice. All rights reserved. - */ -package org.terracotta.modules.ehcache.writebehind; - -import org.terracotta.ehcache.tests.AbstractCacheTestBase; -import org.terracotta.modules.ehcache.async.AsyncCoordinatorImpl; - -import com.tc.l2.L2DebugLogging.LogLevel; -import com.tc.test.config.model.TestConfig; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileReader; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -public class BasicDeadBucketWriteBehindTest extends AbstractCacheTestBase { - private int totalWriteCount = 0; - private int totalDeleteCount = 0; - - public BasicDeadBucketWriteBehindTest(TestConfig testConfig) { - super("basic-writebehind-test.xml", testConfig, WriteBehindClient1.class, WriteBehindClient2.class); - testConfig.getClientConfig().setParallelClients(false); - configureTCLogging(AsyncCoordinatorImpl.class.getName(), LogLevel.DEBUG); - } - - @Override - protected void postClientVerification() { - System.out.println("[Clients processed a total of " + totalWriteCount + " writes]"); - if (totalWriteCount < 1001 || totalWriteCount > 1900) { throw new AssertionError(totalWriteCount); } - - System.out.println("[Clients processed a total of " + totalDeleteCount + " deletes]"); - if (totalDeleteCount < 101 || totalDeleteCount > 190) { throw new AssertionError(totalDeleteCount); } - } - - @Override - protected void evaluateClientOutput(String clientName, int exitCode, File output) throws Throwable { - super.evaluateClientOutput(clientName, exitCode, output); - - FileReader fr = null; - BufferedReader reader = null; - StringBuilder strBuilder = new StringBuilder(); - try { - fr = new FileReader(output); - reader = new BufferedReader(fr); - String st = ""; - while ((st = reader.readLine()) != null) { - strBuilder.append(st); - } - } catch (Exception e) { - throw new AssertionError(e); - } finally { - try { - fr.close(); - reader.close(); - } catch (Exception e) { - // - } - } - - // Detect the number of writes that have happened - int writeCount = detectLargestCount(strBuilder.toString(), - Pattern.compile("\\[WriteBehindCacheWriter written (\\d+) for " + clientName - + "\\]")); - totalWriteCount += writeCount; - System.out.println("[" + clientName + " processed " + writeCount + " writes]"); - - // Detect the number of deletes that have happened - int deleteCount = detectLargestCount(strBuilder.toString(), - Pattern.compile("\\[WriteBehindCacheWriter deleted (\\d+) for " + clientName - + "\\]")); - totalDeleteCount += deleteCount; - System.out.println("[" + clientName + " processed " + deleteCount + " deletes]"); - } - - private int detectLargestCount(String clientOutput, Pattern pattern) { - Matcher matcher = pattern.matcher(clientOutput); - int count = 0; - while (matcher.find()) { - int parsedCount = Integer.parseInt(matcher.group(1)); - if (parsedCount > count) { - count = parsedCount; - } - } - return count; - } -} \ No newline at end of file Index: rctags/ehcache-2.10.8.0.7/distribution/colorcache/src/assemble/bin/start-sample-server.sh =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/distribution/colorcache/src/assemble/bin/start-sample-server.sh (revision 11085) +++ rctags/ehcache-2.10.8.0.7/distribution/colorcache/src/assemble/bin/start-sample-server.sh (revision 0) @@ -1,14 +0,0 @@ -#!/bin/sh -# -# All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved. -# - -if test "$#" != "0"; then - echo "Usage:" - echo " $0" - exit 1 -fi - -root=`dirname $0`/.. -tc_install_dir=$root/bin/`$root/bin/relative-paths.sh tc_install_dir` -exec $tc_install_dir/bin/start-tc-server.sh& Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/pool/sizeof/FlyweightType.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/pool/sizeof/FlyweightType.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/pool/sizeof/FlyweightType.java (revision 0) @@ -1,269 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.sf.ehcache.pool.sizeof; - -import net.sf.ehcache.util.FindBugsSuppressWarnings; - -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; -import java.math.BigDecimal; -import java.math.BigInteger; -import java.math.MathContext; -import java.net.Proxy; -import java.nio.charset.CodingErrorAction; -import java.util.Collections; -import java.util.HashMap; -import java.util.IdentityHashMap; -import java.util.Locale; -import java.util.Map; -import java.util.Set; -import java.util.logging.Logger; - -import javax.xml.datatype.DatatypeConstants; -import javax.xml.namespace.QName; - -/** - * Enum with all the flyweight types that we check for sizeOf measurements - * - * @author Alex Snaps - */ -@FindBugsSuppressWarnings("RC_REF_COMPARISON") -enum FlyweightType { - - /** - * java.lang.Enum - */ - ENUM(Enum.class) { - @Override - boolean isShared(final Object obj) { return true; } - }, - /** - * java.lang.Class - */ - CLASS(Class.class) { - @Override - boolean isShared(final Object obj) { return true; } - }, - // XXX There is no nullipotent way of determining the interned status of a string - // There are numerous String constants within the JDK (see list at http://docs.oracle.com/javase/7/docs/api/constant-values.html), - // but enumerating all of them would lead to lots of == tests. - /** - * java.lang.String - */ - //STRING(String.class) { - // @Override - // boolean isShared(final Object obj) { return obj == ((String)obj).intern(); } - //}, - /** - * java.lang.Boolean - */ - BOOLEAN(Boolean.class) { - @Override - boolean isShared(final Object obj) { return obj == Boolean.TRUE || obj == Boolean.FALSE; } - }, - /** - * java.lang.Integer - */ - INTEGER(Integer.class) { - @Override - boolean isShared(final Object obj) { - int value = ((Integer)obj).intValue(); - return value >= Byte.MIN_VALUE && value <= Byte.MAX_VALUE && obj == Integer.valueOf(value); - } - }, - /** - * java.lang.Short - */ - SHORT(Short.class) { - @Override - boolean isShared(final Object obj) { - short value = ((Short)obj).shortValue(); - return value >= Byte.MIN_VALUE && value <= Byte.MAX_VALUE && obj == Short.valueOf(value); - } - }, - /** - * java.lang.Byte - */ - BYTE(Byte.class) { - @Override - boolean isShared(final Object obj) { return obj == Byte.valueOf((Byte)obj); } - }, - /** - * java.lang.Long - */ - LONG(Long.class) { - @Override - boolean isShared(final Object obj) { - long value = ((Long)obj).longValue(); - return value >= Byte.MIN_VALUE && value <= Byte.MAX_VALUE && obj == Long.valueOf(value); - } - }, - /** - * java.math.BigInteger - */ - BIGINTEGER(BigInteger.class) { - @Override - boolean isShared(final Object obj) { - return obj == BigInteger.ZERO || obj == BigInteger.ONE || obj == BigInteger.TEN; - } - }, - /** - * java.math.BigDecimal - */ - BIGDECIMAL(BigDecimal.class) { - @Override - boolean isShared(final Object obj) { - return obj == BigDecimal.ZERO || obj == BigDecimal.ONE || obj == BigDecimal.TEN; - } - }, - /** - * java.math.MathContext - */ - MATHCONTEXT(MathContext.class) { - @Override - boolean isShared(final Object obj) { - return obj == MathContext.UNLIMITED || obj == MathContext.DECIMAL32 || obj == MathContext.DECIMAL64 || obj == MathContext.DECIMAL128; - } - }, - /** - * java.lang.Character - */ - CHARACTER(Character.class) { - @Override - boolean isShared(final Object obj) { return ((Character)obj).charValue() <= Byte.MAX_VALUE && obj == Character.valueOf((Character)obj); } - }, - /** - * java.lang.Locale - */ - LOCALE(Locale.class) { - @Override - boolean isShared(final Object obj) { - return GLOBAL_LOCALES.contains(obj); - } - }, - /** - * java.util.Logger - */ - LOGGER(Logger.class) { - @Override - @SuppressWarnings("deprecation") - boolean isShared(final Object obj) { return obj == Logger.global; } - }, - /** - * java.net.Proxy - */ - PROXY(Proxy.class) { - @Override - boolean isShared(final Object obj) { return obj == Proxy.NO_PROXY; } - }, - /** - * java.nio.charset.CodingErrorAction - */ - CODINGERRORACTION(CodingErrorAction.class) { - @Override - boolean isShared(final Object obj) { return true; } - }, - /** - * javax.xml.datatype.DatatypeConstants.Field - */ - DATATYPECONSTANTS_FIELD(DatatypeConstants.Field.class) { - @Override - boolean isShared(final Object obj) { return true; } - }, - /** - * javax.xml.namespace.QName - */ - QNAME(QName.class) { - @Override - boolean isShared(final Object obj) { - return obj == DatatypeConstants.DATETIME - || obj == DatatypeConstants.TIME - || obj == DatatypeConstants.DATE - || obj == DatatypeConstants.GYEARMONTH - || obj == DatatypeConstants.GMONTHDAY - || obj == DatatypeConstants.GYEAR - || obj == DatatypeConstants.GMONTH - || obj == DatatypeConstants.GDAY - || obj == DatatypeConstants.DURATION - || obj == DatatypeConstants.DURATION_DAYTIME - || obj == DatatypeConstants.DURATION_YEARMONTH; - } - }, - /** - * misc comparisons that can not rely on the object's class. - */ - MISC(Void.class) { - @Override - boolean isShared(final Object obj) { - boolean emptyCollection = obj == Collections.EMPTY_SET || obj == Collections.EMPTY_LIST || obj == Collections.EMPTY_MAP; - boolean systemStream = obj == System.in || obj == System.out || obj == System.err; - return emptyCollection || systemStream || obj == String.CASE_INSENSITIVE_ORDER; - } - }; - - private static final Map, FlyweightType> TYPE_MAPPINGS = new HashMap, FlyweightType>(); - static { - for (FlyweightType type : FlyweightType.values()) { - TYPE_MAPPINGS.put(type.clazz, type); - } - } - - private static final Set GLOBAL_LOCALES; - static { - Map locales = new IdentityHashMap(); - for (Field f : Locale.class.getFields()) { - int modifiers = f.getModifiers(); - if (Modifier.isPublic(modifiers) && Modifier.isStatic(modifiers) && Locale.class.equals(f.getType())) { - try { - locales.put((Locale) f.get(null), null); - } catch (IllegalArgumentException e) { - continue; - } catch (IllegalAccessException e) { - continue; - } - } - } - GLOBAL_LOCALES = locales.keySet(); - } - - private final Class clazz; - - private FlyweightType(final Class clazz) { - this.clazz = clazz; - } - - /** - * Whether this is a shared object - * @param obj the object to check for - * @return true, if shared - */ - abstract boolean isShared(Object obj); - - /** - * Will return the Flyweight enum instance for the flyweight Class, or null if type isn't flyweight - * @param aClazz the class we need the FlyweightType instance for - * @return the FlyweightType, or null - */ - static FlyweightType getFlyweightType(final Class aClazz) { - if (aClazz.isEnum() || (aClazz.getSuperclass() != null && aClazz.getSuperclass().isEnum())) { - return ENUM; - } else { - FlyweightType flyweightType = TYPE_MAPPINGS.get(aClazz); - return flyweightType != null ? flyweightType : MISC; - } - } -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/util/FailSafeTimer.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/util/FailSafeTimer.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/util/FailSafeTimer.java (revision 0) @@ -1,178 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.sf.ehcache.util; - -import java.util.Date; -import java.util.Timer; -import java.util.TimerTask; - -/** - * A fail-safe timer in the sense that if the runtime environment restricts - * creating new threads, it doesn't blow up with an exception. TimerTasks that are - * scheduled will run at least once (inline when they are scheduled) if creating - * threads is not allowed. - * For example, Google App Engine does not allow creation of new threads. - *

- * Clients should not use this as a general purpose timing service. To do so could - * interfere with the running of the Cache. - * - * @author Abhishek Sanoujam - * @since 1.7 - * - */ -public class FailSafeTimer { - - private final Timer timer; - private final boolean timerThreadRunning; - - /** - * Constructor accepting a name for the timer. The scheduling thread is - * created as a daemon - * - * @param name - */ - public FailSafeTimer(String name) { - boolean threadRunning; - Timer localTimer = null; - try { - localTimer = new Timer(name, true); - threadRunning = true; - } catch (Exception e) { - localTimer = null; - threadRunning = false; - } - this.timerThreadRunning = threadRunning; - this.timer = localTimer; - } - - /** - * If the runtime environment restricts thread creation, this method does - * nothing. - * - * @see java.util.Timer#cancel() - */ - public void cancel() { - if (timerThreadRunning) { - timer.cancel(); - } - } - - /** - * If the runtime environment restricts thread creation, this method does - * nothing. - * - * @see java.util.Timer#purge() - */ - public int purge() { - if (timerThreadRunning) { - return timer.purge(); - } else { - return 0; - } - } - - /** - * If the runtime environment restricts thread creation, the task is run - * inline for only one time. No further repeated execution happens for the - * task - * - * @see java.util.Timer#schedule(java.util.TimerTask, java.util.Date, long) - */ - public void schedule(TimerTask task, Date firstTime, long period) { - if (timerThreadRunning) { - timer.schedule(task, firstTime, period); - } else { - task.run(); - } - } - - /** - * If the runtime environment restricts thread creation, the task is run - * inline for only one time. No further repeated execution happens for the - * task - * - * @see java.util.Timer#schedule(java.util.TimerTask, java.util.Date) - */ - public void schedule(TimerTask task, Date time) { - if (timerThreadRunning) { - timer.schedule(task, time); - } else { - task.run(); - } - } - - /** - * If the runtime environment restricts thread creation, the task is run - * inline for only one time. No further repeated execution happens for the - * task - * - * @see java.util.Timer#schedule(java.util.TimerTask, long, long) - */ - public void schedule(TimerTask task, long delay, long period) { - if (timerThreadRunning) { - timer.schedule(task, delay, period); - } else { - task.run(); - } - } - - /** - * If the runtime environment restricts thread creation, the task is run - * inline for only one time. No further repeated execution happens for the - * task - * - * @see java.util.Timer#schedule(java.util.TimerTask, long) - */ - public void schedule(TimerTask task, long delay) { - if (timerThreadRunning) { - timer.schedule(task, delay); - } else { - task.run(); - } - } - - /** - * If the runtime environment restricts thread creation, the task is run - * inline for only one time. No further repeated execution happens for the - * task - * - * @see java.util.Timer#scheduleAtFixedRate(java.util.TimerTask, java.util.Date, long) - */ - public void scheduleAtFixedRate(TimerTask task, Date firstTime, long period) { - if (timerThreadRunning) { - timer.scheduleAtFixedRate(task, firstTime, period); - } else { - task.run(); - } - } - - /** - * If the runtime environment restricts thread creation, the task is run - * inline for only one time. No further repeated execution happens for the - * task - * - * @see java.util.Timer#scheduleAtFixedRate(java.util.TimerTask, long, long) - */ - public void scheduleAtFixedRate(TimerTask task, long delay, long period) { - if (timerThreadRunning) { - timer.scheduleAtFixedRate(task, delay, period); - } else { - task.run(); - } - } - -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/management/sampled/SampledCacheManager.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/management/sampled/SampledCacheManager.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/management/sampled/SampledCacheManager.java (revision 0) @@ -1,457 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.sf.ehcache.management.sampled; - -import net.sf.ehcache.CacheException; -import net.sf.ehcache.CacheManager; -import net.sf.ehcache.hibernate.management.impl.BaseEmitterBean; - -import java.util.HashMap; -import java.util.Map; - -import javax.management.MBeanNotificationInfo; -import javax.management.NotCompliantMBeanException; -import javax.management.Notification; - -/** - * An implementation of {@link SampledCacheManagerMBean} - * - * @author Abhishek Sanoujam - * @author byoukste - */ -public class SampledCacheManager extends BaseEmitterBean implements SampledCacheManagerMBean { - private static final MBeanNotificationInfo[] NOTIFICATION_INFO; - - private final CacheManagerSampler sampledCacheManagerDelegate; - private String mbeanRegisteredName; - private volatile boolean mbeanRegisteredNameSet; - - static { - final String[] notifTypes = new String[] {CACHES_ENABLED, CACHES_CLEARED, STATISTICS_ENABLED, STATISTICS_RESET}; - final String name = Notification.class.getName(); - final String description = "Ehcache SampledCacheManager Event"; - NOTIFICATION_INFO = new MBeanNotificationInfo[] {new MBeanNotificationInfo(notifTypes, name, description)}; - } - - /** - * Constructor taking the backing {@link CacheManager} - * - * @param cacheManager the cacheManager to wrap - * @throws javax.management.NotCompliantMBeanException - * if invalid object is registered - */ - public SampledCacheManager(CacheManager cacheManager) throws NotCompliantMBeanException { - super(SampledCacheManagerMBean.class); - sampledCacheManagerDelegate = new CacheManagerSamplerImpl(cacheManager); - } - - /** - * {@inheritDoc} - */ - @Override - protected void doDispose() { - - } - - /** - * Set the name used to register this mbean. Can be called only once. - * Package protected method - * - * @param name the MBean name to be registered. - */ - void setMBeanRegisteredName(String name) { - if (mbeanRegisteredNameSet) { - throw new IllegalStateException("Name used for registering this mbean is already set"); - } - mbeanRegisteredNameSet = true; - mbeanRegisteredName = name; - } - - /** - * {@inheritDoc} - */ - public void clearAll() { - sampledCacheManagerDelegate.clearAll(); - sendNotification(CACHES_CLEARED); - } - - /** - * {@inheritDoc} - */ - public String[] getCacheNames() throws IllegalStateException { - return sampledCacheManagerDelegate.getCacheNames(); - } - - /** - * {@inheritDoc} - */ - public String getStatus() { - return sampledCacheManagerDelegate.getStatus(); - } - - /** - * {@inheritDoc} - */ - public void shutdown() { - // no-op - } - - /** - * @return map of cache metrics (hits, misses) - */ - public Map getCacheMetrics() { - return sampledCacheManagerDelegate.getCacheMetrics(); - } - - /** - * @return aggregate hit rate - */ - public long getCacheHitRate() { - return sampledCacheManagerDelegate.getCacheHitRate(); - } - - /** - * @return aggregate in-memory hit rate - */ - public long getCacheInMemoryHitRate() { - return sampledCacheManagerDelegate.getCacheInMemoryHitRate(); - } - - /** - * @return aggregate off-heap hit rate - */ - public long getCacheOffHeapHitRate() { - return sampledCacheManagerDelegate.getCacheOffHeapHitRate(); - } - - /** - * @return aggregate on-disk hit rate - */ - public long getCacheOnDiskHitRate() { - return sampledCacheManagerDelegate.getCacheOnDiskHitRate(); - } - - /** - * @return aggregate miss rate - */ - public long getCacheMissRate() { - return sampledCacheManagerDelegate.getCacheMissRate(); - } - - /** - * @return aggregate in-memory miss rate - */ - public long getCacheInMemoryMissRate() { - return sampledCacheManagerDelegate.getCacheInMemoryMissRate(); - } - - /** - * @return aggregate off-heap miss rate - */ - public long getCacheOffHeapMissRate() { - return sampledCacheManagerDelegate.getCacheOffHeapMissRate(); - } - - /** - * @return aggregate on-disk miss rate - */ - public long getCacheOnDiskMissRate() { - return sampledCacheManagerDelegate.getCacheOnDiskMissRate(); - } - - /** - * @return aggregate put rate - */ - public long getCachePutRate() { - return sampledCacheManagerDelegate.getCachePutRate(); - } - - /** - * @return aggregate update rate - */ - public long getCacheUpdateRate() { - return sampledCacheManagerDelegate.getCacheUpdateRate(); - } - - /** - * @return aggregate remove rate - */ - public long getCacheRemoveRate() { - return sampledCacheManagerDelegate.getCacheRemoveRate(); - } - - /** - * @return aggregate eviction rate - */ - public long getCacheEvictionRate() { - return sampledCacheManagerDelegate.getCacheEvictionRate(); - } - - /** - * @return aggregate expiration rate - */ - public long getCacheExpirationRate() { - return sampledCacheManagerDelegate.getCacheExpirationRate(); - } - - /** - * @return aggregate average get time (ms.) - */ - public float getCacheAverageGetTime() { - return sampledCacheManagerDelegate.getCacheAverageGetTime(); - } - - /** - * @return aggregate search rate - */ - public long getCacheSearchRate() { - return sampledCacheManagerDelegate.getCacheSearchRate(); - } - - /** - * @return aggregate search time - */ - public long getCacheAverageSearchTime() { - return sampledCacheManagerDelegate.getCacheAverageSearchTime(); - } - - /** - * {@inheritDoc} - */ - public boolean getHasWriteBehindWriter() { - return sampledCacheManagerDelegate.getHasWriteBehindWriter(); - } - - /** - * @return aggregate writer queue length - */ - public long getWriterQueueLength() { - return sampledCacheManagerDelegate.getWriterQueueLength(); - } - - /** - * {@inheritDoc} - */ - public int getWriterMaxQueueSize() { - return sampledCacheManagerDelegate.getWriterMaxQueueSize(); - } - - /** - * {@inheritDoc} - */ - public long getMaxBytesLocalDisk() { - return sampledCacheManagerDelegate.getMaxBytesLocalDisk(); - } - - /** - * {@inheritDoc} - */ - public String getMaxBytesLocalDiskAsString() { - return sampledCacheManagerDelegate.getMaxBytesLocalDiskAsString(); - } - - /** - * {@inheritDoc} - */ - public void setMaxBytesLocalDisk(long maxBytes) { - sampledCacheManagerDelegate.setMaxBytesLocalDisk(maxBytes); - sendNotification(CACHE_MANAGER_CHANGED, getCacheManagerAttributes(), getName()); - } - - /** - * {@inheritDoc} - */ - public void setMaxBytesLocalDiskAsString(String maxBytes) { - sampledCacheManagerDelegate.setMaxBytesLocalDiskAsString(maxBytes); - sendNotification(CACHE_MANAGER_CHANGED, getCacheManagerAttributes(), getName()); - } - - /** - * {@inheritDoc} - */ - public long getMaxBytesLocalHeap() { - return sampledCacheManagerDelegate.getMaxBytesLocalHeap(); - } - - /** - * {@inheritDoc} - */ - public String getMaxBytesLocalHeapAsString() { - return sampledCacheManagerDelegate.getMaxBytesLocalHeapAsString(); - } - - /** - * {@inheritDoc} - */ - public void setMaxBytesLocalHeap(long maxBytes) { - sampledCacheManagerDelegate.setMaxBytesLocalHeap(maxBytes); - sendNotification(CACHE_MANAGER_CHANGED, getCacheManagerAttributes(), getName()); - } - - /** - * {@inheritDoc} - */ - public void setMaxBytesLocalHeapAsString(String maxBytes) { - sampledCacheManagerDelegate.setMaxBytesLocalHeapAsString(maxBytes); - sendNotification(CACHE_MANAGER_CHANGED, getCacheManagerAttributes(), getName()); - } - - /** - * {@inheritDoc} - */ - public long getMaxBytesLocalOffHeap() { - return sampledCacheManagerDelegate.getMaxBytesLocalOffHeap(); - } - - /** - * {@inheritDoc} - */ - public String getMaxBytesLocalOffHeapAsString() { - return sampledCacheManagerDelegate.getMaxBytesLocalOffHeapAsString(); - } - - /** - * {@inheritDoc} - * - * @see net.sf.ehcache.management.sampled.SampledCacheManager#getName() - */ - public String getName() { - return sampledCacheManagerDelegate.getName(); - } - - /** - * @see net.sf.ehcache.management.sampled.SampledCacheManager#getClusterUUID() - */ - public String getClusterUUID() { - return sampledCacheManagerDelegate.getClusterUUID(); - } - - /** - * {@inheritDoc} - * - * @see net.sf.ehcache.management.sampled.SampledCacheManagerMBean#getName() - */ - public String getMBeanRegisteredName() { - return this.mbeanRegisteredName; - } - - /** - * generateActiveConfigDeclaration - * - * @return CacheManager configuration as String - */ - public String generateActiveConfigDeclaration() { - return sampledCacheManagerDelegate.generateActiveConfigDeclaration(); - } - - /** - * generateActiveConfigDeclaration - * - * @return Cache configuration as String - */ - public String generateActiveConfigDeclaration(String cacheName) { - return sampledCacheManagerDelegate.generateActiveConfigDeclaration(cacheName); - } - - /** - * {@inheritDoc} - */ - public boolean getTransactional() { - return sampledCacheManagerDelegate.getTransactional(); - } - - /** - * {@inheritDoc} - */ - public boolean getSearchable() { - return sampledCacheManagerDelegate.getSearchable(); - } - - /** - * {@inheritDoc} - */ - public long getTransactionCommittedCount() { - return sampledCacheManagerDelegate.getTransactionCommittedCount(); - } - - /** - * {@inheritDoc} - */ - public long getTransactionCommitRate() { - return sampledCacheManagerDelegate.getTransactionCommitRate(); - } - - /** - * {@inheritDoc} - */ - public long getTransactionRolledBackCount() { - return sampledCacheManagerDelegate.getTransactionRolledBackCount(); - } - - /** - * {@inheritDoc} - */ - public long getTransactionRollbackRate() { - return sampledCacheManagerDelegate.getTransactionRollbackRate(); - } - - /** - * {@inheritDoc} - */ - public long getTransactionTimedOutCount() { - return sampledCacheManagerDelegate.getTransactionTimedOutCount(); - } - - /** - * Returns if each contained cache is enabled. - */ - public boolean isEnabled() throws CacheException { - return sampledCacheManagerDelegate.isEnabled(); - } - - /** - * Enables/disables each of the contained caches. - */ - public void setEnabled(boolean enabled) { - sampledCacheManagerDelegate.setEnabled(enabled); - sendNotification(CACHES_ENABLED, enabled); - } - - /** - * @see BaseEmitterBean#getNotificationInfo() - */ - @Override - public MBeanNotificationInfo[] getNotificationInfo() { - return NOTIFICATION_INFO; - } - - private Map getCacheManagerAttributes() { - Map result = new HashMap(); - result.put("MaxBytesLocalHeapAsString", getMaxBytesLocalHeapAsString()); - result.put("MaxBytesLocalOffHeapAsString", getMaxBytesLocalOffHeapAsString()); - result.put("MaxBytesLocalDiskAsString", getMaxBytesLocalDiskAsString()); - result.put("MaxBytesLocalHeap", getMaxBytesLocalHeap()); - result.put("MaxBytesLocalOffHeap", getMaxBytesLocalOffHeap()); - result.put("MaxBytesLocalDisk", getMaxBytesLocalDisk()); - return result; - } - - @Override - public Object[][] executeQuery(String queryString) { - return sampledCacheManagerDelegate.executeQuery(queryString); - } -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/resources/resourceclassloader/private-classpath.jar =================================================================== diff -u -N -r11085 -r11127 Binary files differ Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/util/MergedEnumeration.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/util/MergedEnumeration.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/util/MergedEnumeration.java (revision 0) @@ -1,61 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.sf.ehcache.util; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Enumeration; -import java.util.List; -/** - * - * An utility class to merge several enumerations into a single one - * - * @author Anthony Dahanne - * - * @param - */ -public class MergedEnumeration implements Enumeration { - - private final Enumeration enumeration; - - /** - * Merges all enumerations found as constructor arguments into a single one - * - * @param enumerations - */ - public MergedEnumeration(Enumeration... enumerations) { - List list = new ArrayList(); - for (Enumeration element : enumerations) { - while (element.hasMoreElements()) { - E e = element.nextElement(); - list.add(e); - } - } - enumeration = Collections.enumeration(list); - } - - @Override - public boolean hasMoreElements() { - return enumeration.hasMoreElements(); - } - - @Override - public E nextElement() { - return enumeration.nextElement(); - } - -} Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/hibernate/management/impl/EntityStats.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/hibernate/management/impl/EntityStats.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/hibernate/management/impl/EntityStats.java (revision 0) @@ -1,266 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.sf.ehcache.hibernate.management.impl; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import javax.management.openmbean.CompositeData; -import javax.management.openmbean.CompositeDataSupport; -import javax.management.openmbean.CompositeType; -import javax.management.openmbean.OpenDataException; -import javax.management.openmbean.OpenType; -import javax.management.openmbean.SimpleType; -import javax.management.openmbean.TabularData; -import javax.management.openmbean.TabularDataSupport; -import javax.management.openmbean.TabularType; - -import org.hibernate.stat.EntityStatistics; - -/** - * When we only support Java 6, all of this OpenMBean scaffolding can be removed in favor or MXBeans. - * - * @author gkeim - */ -public class EntityStats implements Serializable { - private static final String COMPOSITE_TYPE_NAME = "EntityStats"; - private static final String COMPOSITE_TYPE_DESCRIPTION = "Statistics per Entity"; - private static final String[] ITEM_NAMES = new String[] {"name", "shortName", "loadCount", - "updateCount", "insertCount", "deleteCount", "fetchCount", "optimisticFailureCount", }; - private static final String[] ITEM_DESCRIPTIONS = new String[] {"name", "shortName", "loadCount", - "updateCount", "insertCount", "deleteCount", "fetchCount", "optimisticFailureCount", }; - private static final OpenType[] ITEM_TYPES = new OpenType[] {SimpleType.STRING, - SimpleType.STRING, SimpleType.LONG, SimpleType.LONG, SimpleType.LONG, SimpleType.LONG, SimpleType.LONG, - SimpleType.LONG, }; - private static final CompositeType COMPOSITE_TYPE; - private static final String TABULAR_TYPE_NAME = "Statistics by Entity"; - private static final String TABULAR_TYPE_DESCRIPTION = "All Entity Statistics"; - private static final String[] INDEX_NAMES = new String[] {"name", }; - private static final TabularType TABULAR_TYPE; - - static { - try { - COMPOSITE_TYPE = new CompositeType(COMPOSITE_TYPE_NAME, COMPOSITE_TYPE_DESCRIPTION, ITEM_NAMES, - ITEM_DESCRIPTIONS, ITEM_TYPES); - TABULAR_TYPE = new TabularType(TABULAR_TYPE_NAME, TABULAR_TYPE_DESCRIPTION, COMPOSITE_TYPE, INDEX_NAMES); - } catch (OpenDataException e) { - throw new RuntimeException(e); - } - } - - /** - * name - */ - protected final String name; - - /** - * shortName - */ - protected final String shortName; - - /** - * loadCount - */ - protected long loadCount; - - /** - * updateCount - */ - protected long updateCount; - - /** - * insertCount - */ - protected long insertCount; - - /** - * deleteCount - */ - protected long deleteCount; - - /** - * fetchCount - */ - protected long fetchCount; - - /** - * optimisticFailureCount - */ - protected long optimisticFailureCount; - - /** - * @param name - */ - public EntityStats(String name) { - this.name = name; - this.shortName = CacheRegionUtils.determineShortName(name); - } - - /** - * @param name - * @param src - */ - public EntityStats(String name, EntityStatistics src) { - this(name); - - try { - this.loadCount = BeanUtils.getLongBeanProperty(src, "loadCount"); - this.updateCount = BeanUtils.getLongBeanProperty(src, "updateCount"); - this.insertCount = BeanUtils.getLongBeanProperty(src, "insertCount"); - this.deleteCount = BeanUtils.getLongBeanProperty(src, "deleteCount"); - this.fetchCount = BeanUtils.getLongBeanProperty(src, "fetchCount"); - this.optimisticFailureCount = BeanUtils.getLongBeanProperty(src, "optimisticFailureCount"); - } catch (Exception e) { - e.printStackTrace(); - throw new RuntimeException("Exception retrieving statistics", e); - } - } - - /** - * @param cData - */ - public EntityStats(final CompositeData cData) { - int i = 0; - name = (String) cData.get(ITEM_NAMES[i++]); - shortName = (String) cData.get(ITEM_NAMES[i++]); - loadCount = (Long) cData.get(ITEM_NAMES[i++]); - updateCount = (Long) cData.get(ITEM_NAMES[i++]); - insertCount = (Long) cData.get(ITEM_NAMES[i++]); - deleteCount = (Long) cData.get(ITEM_NAMES[i++]); - fetchCount = (Long) cData.get(ITEM_NAMES[i++]); - optimisticFailureCount = (Long) cData.get(ITEM_NAMES[i++]); - } - - private static int safeParseInt(String s) { - try { - return Integer.parseInt(s); - } catch (Exception e) { - return -1; - } - } - - /** - * @param stats - */ - public void add(EntityStats stats) { - loadCount += stats.getLoadCount(); - updateCount += stats.getUpdateCount(); - insertCount += stats.getInsertCount(); - deleteCount += stats.getDeleteCount(); - fetchCount += stats.getFetchCount(); - optimisticFailureCount += stats.getOptimisticFailureCount(); - } - - /** - * toString - */ - @Override - public String toString() { - return "name=" + name + ", shortName=" + shortName + ",loadCount=" + loadCount + ", updateCount=" + updateCount - + ", insertCount=" + insertCount + ", deleteCount=" + deleteCount + ", fetchCount=" + fetchCount - + ", optimisticFailureCount" + optimisticFailureCount; - } - - /** - * getName - */ - public String getName() { - return name; - } - - /** - * getShortName - */ - public String getShortName() { - return shortName; - } - - /** - * getLoadCount - */ - public long getLoadCount() { - return loadCount; - } - - /** - * getUpdateCount - */ - public long getUpdateCount() { - return updateCount; - } - - /** - * getInsertCount - */ - public long getInsertCount() { - return insertCount; - } - - /** - * getDeleteCount - */ - public long getDeleteCount() { - return deleteCount; - } - - /** - * getFetchCount - */ - public long getFetchCount() { - return fetchCount; - } - - /** - * getOptimisticFailureCount - */ - public long getOptimisticFailureCount() { - return optimisticFailureCount; - } - - /** - * toCompositeData - */ - public CompositeData toCompositeData() { - try { - return new CompositeDataSupport(COMPOSITE_TYPE, ITEM_NAMES, new Object[] {name, shortName, loadCount, - updateCount, insertCount, deleteCount, fetchCount, optimisticFailureCount, }); - } catch (OpenDataException e) { - throw new RuntimeException(e); - } - } - - /** - * newTabularDataInstance - */ - public static TabularData newTabularDataInstance() { - return new TabularDataSupport(TABULAR_TYPE); - } - - /** - * fromTabularData - */ - public static EntityStats[] fromTabularData(final TabularData tabularData) { - final List countList = new ArrayList(tabularData.size()); - for (final Iterator pos = tabularData.values().iterator(); pos.hasNext();) { - countList.add(new EntityStats((CompositeData) pos.next())); - } - return countList.toArray(new EntityStats[countList.size()]); - } - -} Index: rctags/ehcache-2.10.8.0.7/ehcache-search-parser/.project =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-search-parser/.project (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-search-parser/.project (revision 0) @@ -1,23 +0,0 @@ - - - server-main - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.m2e.core.maven2Builder - - - - - - org.eclipse.m2e.core.maven2Nature - org.eclipse.jdt.core.javanature - - Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/terracotta/RotatingSnapshotFile.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/terracotta/RotatingSnapshotFile.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/main/java/net/sf/ehcache/terracotta/RotatingSnapshotFile.java (revision 0) @@ -1,279 +0,0 @@ -/** - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.sf.ehcache.terracotta; - -import java.io.EOFException; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; -import java.util.concurrent.locks.Lock; -import java.util.concurrent.locks.ReadWriteLock; -import java.util.concurrent.locks.ReentrantReadWriteLock; - -import net.sf.ehcache.DiskStorePathManager; -import net.sf.ehcache.util.PreferredLoaderObjectInputStream; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * A file will rotate on every write, so to never loose older values in case of a JVM crash - * - * @author Alex Snaps - */ -class RotatingSnapshotFile { - - private static final Logger LOG = LoggerFactory.getLogger(RotatingSnapshotFile.class); - - private static final String SUFFIX_OK = ".keySet"; - private static final String SUFFIX_PROGRESS = SUFFIX_OK + ".temp"; - private static final String SUFFIX_MOVE = SUFFIX_OK + ".old"; - - private volatile boolean shutdownOnThreadInterrupted; - private final String cacheName; - - private final Lock readLock; - private final Lock writeLock; - private final DiskStorePathManager diskStorePathManager; - - private final ClassLoader classLoader; - - { - ReadWriteLock rwl = new ReentrantReadWriteLock(); - readLock = rwl.readLock(); - writeLock = rwl.writeLock(); - } - - /** - * Constructor - * - * @param cacheName use as base name of the files - */ - RotatingSnapshotFile(final DiskStorePathManager diskStorePathManager, final String cacheName, final ClassLoader classLoader) { - this.diskStorePathManager = diskStorePathManager; - this.cacheName = cacheName; - this.classLoader = classLoader; - } - - /** - * Writes all values of the iterable to a new file and does the necessary clean up when done - * - * @param localKeys the iterable of entries to write to disk - * @throws IOException If the underlying OutputStream do throw - */ - void writeAll(final Iterable localKeys) throws IOException { - writeLock.lock(); - long writtenKeys = 0; - try { - File inProgress = newSnapshotFile(); - - cleanUp(inProgress); - if (!inProgress.createNewFile()) { - throw new AssertionError("The file '" + inProgress.getAbsolutePath() + "' exists already!"); - } - - final FileOutputStream fileOutputStream = new FileOutputStream(inProgress); - final ObjectOutputStream oos = new ObjectOutputStream(fileOutputStream); - - try { - for (Object localKey : localKeys) { - if (shutdownOnThreadInterrupted && Thread.currentThread().isInterrupted()) { - return; - } - oos.writeObject(localKey); - ++writtenKeys; - } - } finally { - fileOutputStream.close(); - } - - swapForOldWithNewSnapshot(inProgress); - } finally { - LOG.info("Did a snapshot of " + writtenKeys + " local keys"); - writeLock.unlock(); - } - } - - /** - * Reads all the keys from the file on disk, doing cleanup if required of previously unterminated file written to - * - * @param the type of the each element - * @return the Set of all entries in the latest uncorrupted file on disk - * @throws IOException If the underlying FileInputStream does throw - */ - Set readAll() throws IOException { - - cleanUp(); - - readLock.lock(); - try { - - final File currentSnapshot = currentSnapshotFile(); - if (!currentSnapshot.exists()) { - return Collections.emptySet(); - } - - final Set values = new HashSet(); - FileInputStream fis = new FileInputStream(currentSnapshot); - try { - ObjectInputStream ois = new PreferredLoaderObjectInputStream(fis, classLoader); - boolean eof = false; - while (!eof) { - try { - values.add((T)ois.readObject()); - } catch (Exception e) { - if (e instanceof EOFException) { - eof = true; - } - // Ignore all other errors, and keep on trying to load keys - } - } - try { - ois.close(); - } catch (IOException e) { - LOG.error("Error closing ObjectInputStream", e); - closeAndDeleteAssociatedFileOnFailure(fis, currentSnapshot); - } - - } catch (IOException e) { - closeAndDeleteAssociatedFileOnFailure(fis, currentSnapshot); - } - return Collections.unmodifiableSet(values); - } finally { - readLock.unlock(); - } - } - - private void cleanUp() { - if (requiresCleanUp()) { - writeLock.lock(); - try { - cleanUp(newSnapshotFile()); - } finally { - writeLock.unlock(); - } - } - } - - private void cleanUp(final File inProgress) { - if (requiresCleanUp()) { - final File dest = currentSnapshotFile(); - if (dest.exists() && !inProgress.delete()) { - throw new RuntimeException("Couldn't cleanup old file " + inProgress.getAbsolutePath()); - } else { - final File tempFile = tempSnapshotFile(); - if (tempFile.exists() && !tempFile.delete()) { - throw new RuntimeException("Couldn't cleanup temp file " + tempFile.getAbsolutePath()); - } - if (inProgress.exists() && !inProgress.renameTo(dest)) { - throw new RuntimeException("Couldn't rename new snapshot: " + dest.getAbsolutePath()); - } - } - } - } - - private boolean requiresCleanUp() { - return newSnapshotFile().exists(); - } - - private void swapForOldWithNewSnapshot(final File inProgress) { - File currentSnapshot = currentSnapshotFile(); - final File tempFile = tempSnapshotFile(); - if (currentSnapshot.exists() && !currentSnapshot.renameTo(tempFile)) { - throw new RuntimeException("Couldn't rename previous snapshot: " + currentSnapshot.getAbsolutePath()); - } - if (!inProgress.renameTo(currentSnapshot)) { - throw new RuntimeException("Couldn't rename new snapshot: " + currentSnapshot.getAbsolutePath()); - } - if (tempFile.exists() && !tempFile.delete()) { - throw new RuntimeException("Couldn't delete temp file " + tempFile.getAbsolutePath()); - } - } - - /** - * Creates a File representing the uncorrupted file on disk - * - * @return the file to read from - */ - File currentSnapshotFile() { - return diskStorePathManager.getFile(cacheName, SUFFIX_OK); - } - - /** - * Creates a File representing the one to write new entries to - * - * @return the File to write to - */ - File newSnapshotFile() { - return diskStorePathManager.getFile(cacheName, SUFFIX_PROGRESS); - } - - /** - * Creates a File representing the old uncorrupted file, when the new one has successfully been written to disk - * - * @return the File representing the previous successful snapshot (temp file to be deleted) - */ - File tempSnapshotFile() { - return diskStorePathManager.getFile(cacheName, SUFFIX_MOVE); - } - - /** - * Whether to shutdown as soon as the writer Thread is interrupted, or to let all keys be written to disk first - * - * @param shutdownOnThreadInterrupted true, if shutdown needs to happen in the middle of a write - */ - void setShutdownOnThreadInterrupted(final boolean shutdownOnThreadInterrupted) { - this.shutdownOnThreadInterrupted = shutdownOnThreadInterrupted; - } - - private void closeAndDeleteAssociatedFileOnFailure(final FileInputStream fis, final File associatedFile) { - try { - fis.close(); - } catch (IOException e) { - LOG.error("Couldn't close FileInputStream on {}, deleting the file!", associatedFile.getAbsolutePath(), e); - if (associatedFile.exists() && !associatedFile.delete()) { - LOG.error("Couldn't delete file {}", associatedFile.getAbsolutePath(), e); - } - } - } - - /** - * Calling this method will result in writing all keys to be written to disk - * or wait for the one in progress to finish - * - * @param localKeys the latest current local set - * @throws IOException On exception being thrown while doing the snapshot - */ - void snapshotNowOrWaitForCurrentToFinish(final Set localKeys) throws IOException { - if (writeLock.tryLock()) { - try { - writeAll(localKeys); - } finally { - writeLock.unlock(); - } - } else { - writeLock.lock(); - writeLock.unlock(); - } - } -} Index: rctags/ehcache-2.10.8.0.7/system-tests/src/test/resources/hibernate-config/shutdowntest/domain/Person.hbm.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/system-tests/src/test/resources/hibernate-config/shutdowntest/domain/Person.hbm.xml (revision 11085) +++ rctags/ehcache-2.10.8.0.7/system-tests/src/test/resources/hibernate-config/shutdowntest/domain/Person.hbm.xml (revision 0) @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Index: rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/pool/sizeof/FilteredSizeOfTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/pool/sizeof/FilteredSizeOfTest.java (revision 11085) +++ rctags/ehcache-2.10.8.0.7/ehcache-core/src/test/java/net/sf/ehcache/pool/sizeof/FilteredSizeOfTest.java (revision 0) @@ -1,269 +0,0 @@ -package net.sf.ehcache.pool.sizeof; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.InputStream; -import java.net.URLClassLoader; - -import net.sf.ehcache.pool.SizeOfEngine; -import net.sf.ehcache.pool.impl.DefaultSizeOfEngine; -import net.sf.ehcache.pool.sizeof.annotationfiltered.AnnotationFilteredPackage; -import net.sf.ehcache.pool.sizeof.annotationfiltered.custom.CustomAnnotationFilteredPackage; -import net.sf.ehcache.pool.sizeof.filter.AnnotationSizeOfFilter; -import net.sf.ehcache.pool.sizeof.annotations.IgnoreSizeOf; -import net.sf.ehcache.pool.sizeof.filter.ResourceSizeOfFilter; -import net.sf.ehcache.pool.sizeof.resourcefiltered.ResourceFilteredPackage; - -import org.junit.Assume; -import org.junit.BeforeClass; -import org.junit.Test; - -import static org.hamcrest.CoreMatchers.allOf; -import static org.hamcrest.core.IsEqual.equalTo; -import static org.hamcrest.core.IsInstanceOf.instanceOf; -import static org.hamcrest.number.OrderingComparison.greaterThan; -import static org.hamcrest.number.OrderingComparison.lessThan; -import static org.junit.Assert.assertThat; - -public class FilteredSizeOfTest extends AbstractSizeOfTest { - - private static long deepSizeOf(SizeOf sizeOf, Object... obj) { - return sizeOf.deepSizeOf(1000, true, obj).getCalculated(); - } - - @BeforeClass - public static void setup() { - deepSizeOf(new CrossCheckingSizeOf(), new Object()); - System.out.println("Testing for a " + System.getProperty("java.version") + " JDK " -