Index: rctags/ehcache-2.10.9.1.33/terracotta/pom.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/terracotta/pom.xml (revision 11516) +++ rctags/ehcache-2.10.9.1.33/terracotta/pom.xml (revision 0) @@ -1,74 +0,0 @@ - - - 4.0.0 - - - net.sf.ehcache - ehcache-root - 2.10.9.1.33 - - - 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.9.1.33/system-tests/pom.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/system-tests/pom.xml (revision 11516) +++ rctags/ehcache-2.10.9.1.33/system-tests/pom.xml (revision 0) @@ -1,291 +0,0 @@ - - 4.0.0 - - org.terracotta - system-tests-parent - 4.3.9.1.7 - - - net.sf.ehcache.internal - ehcache-terracotta-system-tests - 2.10.9.1.33 - ehcache-terracotta-system-tests - System tests for ehcache-terracotta - - 512m - 1024m - -XX:MaxPermSize=512m - true - 10.10.1.1 - 2.2.3 - 1.7.25 - 1.9 - - - - org.terracotta - terracotta - ${terracotta.core.version} - - - javax.servlet - 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.terracotta - terracotta-toolkit-runtime - ${terracotta.core.version} - test - - - org.ow2.asm - asm - 7.2 - test - - - org.hibernate - hibernate-core - 3.3.2.GA - test - - - org.javassist - javassist - 3.19.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 - - - commons-logging - commons-logging - - - commons-logging - commons-logging-api - - - - - org.terracotta.test - container-test-framework - - - org.quartz-scheduler - quartz - ${quartz.version} - - - io.rest-assured - rest-assured - - - org.codehaus.groovy - groovy - - - org.codehaus.groovy - groovy-json - - - org.codehaus.groovy - groovy-xml - - - 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 - - - - - - - - - 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.9.1.33/ehcache-search-parser/pom.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-search-parser/pom.xml (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-search-parser/pom.xml (revision 0) @@ -1,56 +0,0 @@ - - - 4.0.0 - - net.sf.ehcache - ehcache-root - 2.10.9.1.33 - .. - - - 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 - - - org.hamcrest - hamcrest - - - net.sf.ehcache.internal - ehcache-core - test-jar - ${project.version} - test - - - Index: rctags/ehcache-2.10.9.1.33/terracotta/bootstrap/pom.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/terracotta/bootstrap/pom.xml (revision 11516) +++ rctags/ehcache-2.10.9.1.33/terracotta/bootstrap/pom.xml (revision 0) @@ -1,98 +0,0 @@ - - - 4.0.0 - - - net.sf.ehcache.internal - ehcache-terracotta-root - 2.10.9.1.33 - - - ehcache-terracotta-bootstrap - ehcache-terracotta-bootstrap - jar - - - false - 1.19 - 0.11.1 - - - - - net.sf.ehcache.internal - ehcache-core - ${project.version} - provided - - - org.terracotta.toolkit - terracotta-toolkit-api-internal - ${terracotta-toolkit-api-internal.version} - - - com.terracotta - clustered-entity-management - ${clustered-entity-management.version} - - - org.mockito - mockito-core - 3.0.0 - test - - - junit - junit - 4.12 - test - - - org.hamcrest - hamcrest-core - - - - - org.hamcrest - hamcrest - - - 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.9.1.33/distribution/colorcache/pom.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/distribution/colorcache/pom.xml (revision 11516) +++ rctags/ehcache-2.10.9.1.33/distribution/colorcache/pom.xml (revision 0) @@ -1,153 +0,0 @@ - - 4.0.0 - - org.terracotta.forge - forge-parent - 4.16 - - - net.sf.ehcache.examples - colorcache - 2.10.9.1.33 - colorcache - war - Clustered Ehcache sample with Terracotta - - 4.3.9.1.7 - true - 9.4.38.v20210224 - 2.8.0 - - - ${project.name} - - - maven-assembly-plugin - 2.3 - - ${project.name} - - src/assemble/distribution.xml - - gnu - - - - package - - single - - - - - - jetty-maven-plugin - ${jetty.version} - org.eclipse.jetty - - - ${project.name} - - STOP - - - - org.terracotta.maven.plugins - tc-maven-plugin - - - org.terracotta - terracotta - ${terracotta.version} - - - - - - - - net.sf.ehcache - ehcache - ${project.version} - - - org.terracotta - terracotta-toolkit-runtime - ${terracotta.version} - - - javax.servlet - javax.servlet-api - 3.1.0 - - - org.slf4j - slf4j-jdk14 - 1.7.25 - - - - - 9081 - - - - jetty-maven-plugin - ${jetty.version} - org.eclipse.jetty - - - - jetty.port - 9081 - - - 9981 - - - - - - - 9082 - - - - jetty-maven-plugin - ${jetty.version} - org.eclipse.jetty - - - - jetty.port - 9082 - - - 9982 - - - - - - - - - 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.9.1.33/distribution/events/pom.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/distribution/events/pom.xml (revision 11516) +++ rctags/ehcache-2.10.9.1.33/distribution/events/pom.xml (revision 0) @@ -1,249 +0,0 @@ - - 4.0.0 - - org.terracotta.forge - forge-parent - 4.16 - - - net.sf.ehcache.examples - events - 2.10.9.1.33 - events - war - Clustered Ehcache Terracotta as second level cache for Hibernate - - 4.3.9.1.7 - 1.1.116 - 1.1 - true - 9.4.38.v20210224 - 2.8.0 - - - - org.slf4j - slf4j-api - 1.7.25 - - - ch.qos.logback - logback-classic - 1.2.3 - - - org.javassist - javassist - 3.19.0-GA - - - h2 - ${h2.version} - com.h2database - - - net.sf.ehcache - ehcache - ${project.version} - - - org.terracotta - terracotta-toolkit-runtime - ${terracotta.version} - - - javax.servlet - 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 - - - - - - jetty-maven-plugin - ${jetty.version} - org.eclipse.jetty - - - ${project.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 - - - 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 - - - - jetty-maven-plugin - ${jetty.version} - org.eclipse.jetty - - - - jetty.port - 9081 - - - 9981 - - - - - - - 9082 - - - - jetty-maven-plugin - ${jetty.version} - org.eclipse.jetty - - - - jetty.port - 9082 - - - 9982 - - - - - - - - - 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.9.1.33/management-ehcache-v1/pom.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/management-ehcache-v1/pom.xml (revision 11516) +++ rctags/ehcache-2.10.9.1.33/management-ehcache-v1/pom.xml (revision 0) @@ -1,72 +0,0 @@ - - - 4.0.0 - - - net.sf.ehcache - ehcache-root - 2.10.9.1.33 - .. - - - 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.9.1.33/ehcache-scheduled-refresh/pom.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-scheduled-refresh/pom.xml (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-scheduled-refresh/pom.xml (revision 0) @@ -1,49 +0,0 @@ - - - 4.0.0 - - - net.sf.ehcache - ehcache-root - 2.10.9.1.33 - .. - - - 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 - - - org.hamcrest - hamcrest - - - net.sf.ehcache.internal - ehcache-core - test-jar - ${project.version} - test - - - Index: rctags/ehcache-2.10.9.1.33/management-ehcache-v2/pom.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/management-ehcache-v2/pom.xml (revision 11516) +++ rctags/ehcache-2.10.9.1.33/management-ehcache-v2/pom.xml (revision 0) @@ -1,72 +0,0 @@ - - - 4.0.0 - - - net.sf.ehcache - ehcache-root - 2.10.9.1.33 - .. - - - 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.9.1.33/management-ehcache-impl/pom.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/management-ehcache-impl/pom.xml (revision 11516) +++ rctags/ehcache-2.10.9.1.33/management-ehcache-impl/pom.xml (revision 0) @@ -1,43 +0,0 @@ - - - 4.0.0 - - - net.sf.ehcache - ehcache-root - 2.10.9.1.33 - .. - - - 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.9.1.33/management-ehcache-impl/management-ehcache-impl-v2/pom.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/management-ehcache-impl/management-ehcache-impl-v2/pom.xml (revision 11516) +++ rctags/ehcache-2.10.9.1.33/management-ehcache-impl/management-ehcache-impl-v2/pom.xml (revision 0) @@ -1,137 +0,0 @@ - - - 4.0.0 - - - net.sf.ehcache - management-ehcache-impl-parent - 2.10.9.1.33 - .. - - - 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.10 - provided - - - org.terracotta.toolkit - terracotta-toolkit-api-internal - provided - - - javax.servlet - javax.servlet-api - runtime - - - 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 - 2.1 - 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.9.1.33/management-ehcache-impl/management-ehcache-common/pom.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/management-ehcache-impl/management-ehcache-common/pom.xml (revision 11516) +++ rctags/ehcache-2.10.9.1.33/management-ehcache-impl/management-ehcache-common/pom.xml (revision 0) @@ -1,87 +0,0 @@ - - - 4.0.0 - - - net.sf.ehcache - management-ehcache-impl-parent - 2.10.9.1.33 - .. - - - management-ehcache-common - management-ehcache-common - A common library shared between different management-ehcache implementation versions - - - - org.terracotta - management-core-resources - - - net.sf.ehcache.internal - ehcache-core - ${project.version} - provided - - - javax.servlet - javax.servlet-api - - - org.eclipse.jetty - jetty-servlet - - - commons-io - commons-io - 2.6 - test - - - org.easymock - easymock - 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.9.1.33/pom.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/pom.xml (revision 11516) +++ rctags/ehcache-2.10.9.1.33/pom.xml (revision 0) @@ -1,486 +0,0 @@ - - - 4.0.0 - - - net.sf.ehcache - ehcache-parent - 2.25 - - - - ehcache-root - net.sf.ehcache - ehcache-root - pom - 2.10.9.1.33 - - - scm:svn:https://svn.terracotta.org/repo/ehcache/trunk/ehcache - - - - 1.7.25 - 1.0.1 - 2.1.1 - 1.19 - 2.1.25.2 - 0.11.1 - 1.0.5 - 2.2.3 - 9.4.38.v20210224 - 2.3.2 - 3.5.1-Final - 1.2 - false - - - - 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 - - - - - - - - - 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 - ${sizeof-agent.version} - provided - - - - - org.slf4j - slf4j-jdk14 - ${slf4j.version} - test - - - commons-logging - commons-logging - ${commons-logging.version} - test - - - org.codehaus.btm - btm - 2.1.3 - test - - - net.sf.hibernate - hibernate - 2.1.8 - test - - - org.hamcrest - hamcrest - 2.1 - test - - - junit - junit - 4.12 - test - - - hamcrest-core - org.hamcrest - - - - - dom4j - dom4j - 1.6.1 - test - - - org.javassist - javassist - 3.19.0-GA - test - - - org.hibernate - hibernate-ehcache - 3.3.2.GA - test - - - ehcache - net.sf.ehcache - - - - - org.apache.derby - derby - 10.5.3.0_1 - test - - - org.mockito - mockito-core - 3.0.0 - test - - - com.sun.xsom - xsom - 20100725 - test - - - org.beanshell - bsh - 1.3.0 - test - - - org.quartz-scheduler - quartz - ${quartz.version} - - - org.easymock - easymock - 4.0.2 - test - - - org.powermock - powermock-api-easymock - 2.0.2 - test - - - org.powermock - powermock-module-junit4 - 2.0.2 - test - - - - - - - - - org.apache.maven.plugins - maven-jar-plugin - 3.1.2 - - - - true - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - 3.1.1 - - ${skipJavadoc} - 8 - -Xdoclint:all,-Xdoclint:-missing - true - - - - org.apache.maven.plugins - maven-checkstyle-plugin - 3.1.0 - - - org.apache.maven.plugins - maven-dependency-plugin - 3.1.1 - - - 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 - groovy-maven-plugin - ${groovy-maven-plugin.version} - - - org.codehaus.mojo - rmic-maven-plugin - 1.3 - - - - - - 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.9.1.33/ehcache-core/pom.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/pom.xml (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/pom.xml (revision 0) @@ -1,537 +0,0 @@ - - - 4.0.0 - - - net.sf.ehcache - ehcache-root - 2.10.9.1.33 - - - 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 - - - commons-logging - commons-logging - - - org.codehaus.btm - btm - - - net.sf.hibernate - hibernate - - - org.hamcrest - hamcrest - - - junit - junit - - - hamcrest-core - org.hamcrest - - - - - dom4j - dom4j - - - org.javassist - javassist - - - org.hibernate - hibernate-ehcache - - - 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 - - 1 - false - ${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 - - - - - build-info - generate-resources - - buildinfo - - - ${basedir}/.. - - - - - 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 - false - false - false - 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.glassfish.corba - rmic - 4.2.1 - - - - - - - - - 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.9.1.33/ehcache/pom.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache/pom.xml (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache/pom.xml (revision 0) @@ -1,418 +0,0 @@ - - - 4.0.0 - - - net.sf.ehcache - ehcache-root - 2.10.9.1.33 - .. - - - 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 - 2.1.1 - 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 - - - org.terracotta - product-upgradability-testing-utils - 0.9.4 - test - - - org.codehaus.btm - btm - 2.1.3 - test - - - org.quartz-scheduler - quartz - 2.2.3 - test - - - org.slf4j - slf4j-jdk14 - - - - - - - ${basedir}/src/main/resources - true - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - copy-TIMs - - org.terracotta.modules - ${project.build.outputDirectory}/META-INF/terracotta/TIMs - - 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} - - - - - - - - - - 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 - 3.1.1 - - - create-javadoc - prepare-package - - jar - - - - - org.hibernate - hibernate-core - ${hibernate-core.version} - - - none - ${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 - - 8 -
-
-
-
- - - 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 - 4.2.1 - - ${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;resolution:=optional, - javax.xml.transform.sax;resolution:=optional, - javax.xml.transform.dom;resolution:=optional, - javax.xml.transform.stream;resolution:=optional, - org.w3c.dom;resolution:=optional, - org.hibernate.*;resolution:=optional, - org.terracotta.toolkit.*;resolution:=optional, - org.quartz.*;resolution:=optional, - org.terracotta.quartz.*;resolution:=optional, - com.sun.management.*;resolution:="optional", - net.sf.ehcache.terracotta.security;resolution:=optional, - org.jboss.vfs;resolution:=optional, - sun.management.*;resolution:=optional, - !com.google.apphosting.api, - !sun.misc,* - - net.sf.ehcache.* - org.terracotta.* - JavaSE-1.8 - - *;scope=provided|runtime - - - - generate-osgi-headers - package - - manifest - - - - - - org.codehaus.gmaven - groovy-maven-plugin - ${groovy-maven-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.9.1.33/README.txt =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/README.txt (revision 11516) +++ rctags/ehcache-2.10.9.1.33/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.9.1.33/management-ehcache-impl/management-ehcache-impl-v1/pom.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/management-ehcache-impl/management-ehcache-impl-v1/pom.xml (revision 11516) +++ rctags/ehcache-2.10.9.1.33/management-ehcache-impl/management-ehcache-impl-v1/pom.xml (revision 0) @@ -1,110 +0,0 @@ - - - 4.0.0 - - - net.sf.ehcache - management-ehcache-impl-parent - 2.10.9.1.33 - .. - - - 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 - - - javax.servlet - javax.servlet-api - - - org.easymock - easymock - test - - - org.eclipse.jetty - jetty-servlet - test - - - org.mockito - mockito-core - - - org.powermock - powermock-api-easymock - test - - - org.powermock - powermock-module-junit4 - test - - - org.hamcrest - hamcrest - - - 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.9.1.33/third-party.txt =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/third-party.txt (revision 11516) +++ rctags/ehcache-2.10.9.1.33/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.9.1.33/distribution/pom.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/distribution/pom.xml (revision 11516) +++ rctags/ehcache-2.10.9.1.33/distribution/pom.xml (revision 0) @@ -1,298 +0,0 @@ - - - 4.0.0 - - - net.sf.ehcache - ehcache-root - 2.10.9.1.33 - - - 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 - groovy-maven-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.9.1.33/TestCategories.properties =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/TestCategories.properties (revision 11516) +++ rctags/ehcache-2.10.9.1.33/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.9.1.33/management-ehcache-impl/ehcache-rest-agent/pom.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/management-ehcache-impl/ehcache-rest-agent/pom.xml (revision 11516) +++ rctags/ehcache-2.10.9.1.33/management-ehcache-impl/ehcache-rest-agent/pom.xml (revision 0) @@ -1,223 +0,0 @@ - - - 4.0.0 - - - net.sf.ehcache - management-ehcache-impl-parent - 2.10.9.1.33 - .. - - - net.sf.ehcache.internal - ehcache-rest-agent - ehcache-rest-agent - - Ehcache REST implementation - - - rest-management-private-classpath - .class_terracotta - true - false - 2.3.2 - - - - - net.sf.ehcache - management-ehcache-impl-v1 - ${project.version} - - - net.sf.ehcache - management-ehcache-impl-v2 - ${project.version} - - - javax.servlet - javax.servlet-api - 3.1.0 - runtime - - - org.eclipse.jetty - jetty-servlet - - - org.glassfish.jaxb - jaxb-runtime - ${jaxb-runtime.version} - runtime - - - - - - - org.apache.maven.plugins - maven-jar-plugin - - - - - - - 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 - groovy-maven-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.9.1.33/ehcache/src/test/java/net/sf/ehcache/terracotta/upgradability/serialization/ClusteredTransactionIDSerializationTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache/src/test/java/net/sf/ehcache/terracotta/upgradability/serialization/ClusteredTransactionIDSerializationTest.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache/src/test/java/net/sf/ehcache/terracotta/upgradability/serialization/ClusteredTransactionIDSerializationTest.java (revision 0) @@ -1,59 +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.lang.reflect.Field; -import java.util.Comparator; -import java.util.Map; - -import net.sf.ehcache.CacheManager; -import net.sf.ehcache.transaction.TransactionIDFactory; -import net.sf.ehcache.transaction.TransactionIDSerializedForm; -import org.junit.Test; -import org.terracotta.modules.ehcache.transaction.ClusteredTransactionID; - -import static org.mockito.Matchers.refEq; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; -import static org.terracotta.upgradability.serialization.SerializationUpgradabilityTesting.validateSerializedForm; - -/** - * - * @author cdennis - */ -public class ClusteredTransactionIDSerializationTest { - - private static final Comparator COMPARATOR = new Comparator() { - @Override - public int compare(ClusteredTransactionID o1, ClusteredTransactionID o2) { - return o1.equals(o2) && o1.getOwnerID().equals(o2.getOwnerID()) ? 0 : -1; - } - }; - - @Test - public void testBasic() throws Exception { - Field MANAGERS_MAP = CacheManager.class.getDeclaredField("CACHE_MANAGERS_MAP"); - MANAGERS_MAP.setAccessible(true); - CacheManager manager = mock(CacheManager.class); - ((Map) MANAGERS_MAP.get(null)).put("manager", manager); - TransactionIDFactory txnIdFactory = mock(TransactionIDFactory.class); - when(txnIdFactory.restoreTransactionID(refEq(new TransactionIDSerializedForm("manager", "cluster", "owner", 42L, 2)))) - .thenReturn(new ClusteredTransactionID("owner", "cluster", "manager", 42L, 2)); - when(manager.getOrCreateTransactionIDFactory()).thenReturn(txnIdFactory); - validateSerializedForm(new ClusteredTransactionID("owner", "cluster", "manager", 42L, 2), COMPARATOR, "serializedforms/ClusteredTransactionIDSerializationTest.testBasic.ser"); - } -} Index: rctags/ehcache-2.10.9.1.33/system-tests/src/test/resources/servermap/servermap-l2-eviction-reaches-l1-test.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/system-tests/src/test/resources/servermap/servermap-l2-eviction-reaches-l1-test.xml (revision 11516) +++ rctags/ehcache-2.10.9.1.33/system-tests/src/test/resources/servermap/servermap-l2-eviction-reaches-l1-test.xml (revision 0) @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - - - - - - Index: rctags/ehcache-2.10.9.1.33/terracotta/bootstrap/src/test/java/org/terracotta/modules/ehcache/store/ClusteredStoreTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/terracotta/bootstrap/src/test/java/org/terracotta/modules/ehcache/store/ClusteredStoreTest.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/terracotta/bootstrap/src/test/java/org/terracotta/modules/ehcache/store/ClusteredStoreTest.java (revision 0) @@ -1,173 +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 net.sf.ehcache.CacheManager; -import net.sf.ehcache.CacheStoreHelper; -import net.sf.ehcache.Ehcache; -import net.sf.ehcache.Element; -import net.sf.ehcache.NonEternalElementData; -import net.sf.ehcache.Status; -import net.sf.ehcache.cluster.CacheCluster; -import net.sf.ehcache.cluster.ClusterNode; -import net.sf.ehcache.cluster.ClusterTopologyListener; -import net.sf.ehcache.config.CacheConfiguration; -import net.sf.ehcache.config.Configuration; -import net.sf.ehcache.config.TerracottaClientConfiguration; -import net.sf.ehcache.config.TerracottaConfiguration; -import net.sf.ehcache.event.CacheEventListener; -import net.sf.ehcache.event.CacheEventListenerAdapter; -import net.sf.ehcache.event.RegisteredEventListeners; -import net.sf.ehcache.store.DefaultElementValueComparator; - -import org.junit.Before; -import org.junit.Test; -import org.terracotta.modules.ehcache.ToolkitInstanceFactory; -import org.terracotta.toolkit.cache.ToolkitCacheListener; -import org.terracotta.toolkit.collections.ToolkitMap; -import org.terracotta.toolkit.concurrent.locks.ToolkitLock; -import org.terracotta.toolkit.events.ToolkitNotifier; -import org.terracotta.toolkit.internal.ToolkitInternal; -import org.terracotta.toolkit.internal.ToolkitProperties; -import org.terracotta.toolkit.internal.cache.ToolkitCacheInternal; -import org.terracotta.toolkit.internal.cache.ToolkitValueComparator; - -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyString; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -/** - * Test that asserts quickSize is not called when {@link Ehcache} sizing methods are called. - * - * @author Ludovic Orban - */ -public class ClusteredStoreTest { - - private Ehcache cache = mock(Ehcache.class); - private CacheConfiguration cacheConfiguration = new CacheConfiguration().terracotta(new TerracottaConfiguration().clustered(true).consistency(TerracottaConfiguration.Consistency.EVENTUAL)); - private Configuration configuration = new Configuration().name("ClusteredStoreTest-cm").terracotta(new TerracottaClientConfiguration()); - private ToolkitCacheInternal toolkitCacheInternal = mock(ToolkitCacheInternal.class); - private ClusteredStore clusteredStore; - private ToolkitInstanceFactory toolkitInstanceFactory = mock(ToolkitInstanceFactory.class); - private CacheCluster cacheCluster = mockCacheCluster("abc"); - private CacheManager cacheManager = when(mock(CacheManager.class).getConfiguration()).thenReturn(configuration).getMock(); - private ToolkitMap configMap = mock(ToolkitMap.class); - private ToolkitInternal toolkitInternal = mock(ToolkitInternal.class); - private ToolkitProperties toolkitProperties = mock(ToolkitProperties.class); - private org.terracotta.toolkit.config.Configuration toolkitCacheConfiguration = mock(org.terracotta.toolkit.config.Configuration.class); - private ToolkitNotifier toolkitNotifier = mock(ToolkitNotifier.class); - private CacheStoreHelper cacheStoreHelper = mock(CacheStoreHelper.class); - private ToolkitLock toolkitLock = mock(ToolkitLock.class); - - @Before - public void setUpClusteredStore() { - when(cache.getCacheConfiguration()).thenReturn(cacheConfiguration); - when(cache.getCacheManager()).thenReturn(cacheManager); - when(cache.getName()).thenReturn("ClusteredStoreTest-cache"); - when(cache.getStatus()).thenReturn(Status.STATUS_ALIVE); - when(cache.getCacheEventNotificationService()).thenReturn(new RegisteredEventListeners(cache, cacheStoreHelper)); - when(cacheManager.getName()).thenReturn("ClusteredStoreTest-cm"); - when(toolkitInstanceFactory.getOrCreateClusteredStoreConfigMap(eq("ClusteredStoreTest-cm"), eq("ClusteredStoreTest-cache"))).thenReturn(configMap); - when(toolkitInstanceFactory.getToolkit()).thenReturn(toolkitInternal); - when(toolkitInstanceFactory.getLockForCache(any(Ehcache.class), anyString())).thenReturn(toolkitLock); - when(toolkitInternal.getProperties()).thenReturn(toolkitProperties); - when(toolkitProperties.getBoolean(anyString())).thenReturn(false); - when(toolkitInstanceFactory.getOrCreateToolkitCache(cache)).thenReturn(toolkitCacheInternal); - when(toolkitCacheInternal.getConfiguration()).thenReturn(toolkitCacheConfiguration); - when(toolkitCacheConfiguration.getInt(anyString())).thenReturn(1); - when(toolkitInstanceFactory.getOrCreateConfigChangeNotifier(eq(cache))).thenReturn(toolkitNotifier); - clusteredStore = new ClusteredStore(toolkitInstanceFactory, cache, cacheCluster) { - @Override - void setUpWanConfig() { - // Do Nothing - } - }; - when(cacheStoreHelper.getStore()).thenReturn(clusteredStore); - } - - private static CacheCluster mockCacheCluster(String thisNode) { - CacheCluster cacheCluster = mock(CacheCluster.class); - ClusterNode node = when(mock(ClusterNode.class).getId()).thenReturn(thisNode).getMock(); - when(cacheCluster.getCurrentNode()).thenReturn(node); - return cacheCluster; - } - - @Test - public void clusteredStore_getSize_calls_size_not_quickSize() throws Exception { - clusteredStore.getSize(); - verify(toolkitCacheInternal, times(1)).size(); - verify(toolkitCacheInternal, times(0)).quickSize(); - } - - @Test - public void clusteredStore_getTerracottaClusteredSize_calls_size_not_quickSize() throws Exception { - clusteredStore.getTerracottaClusteredSize(); - verify(toolkitCacheInternal, times(1)).size(); - verify(toolkitCacheInternal, times(0)).quickSize(); - } - - @Test - public void clusteredStore_putIfAbsent_enabled_in_eventual_consistency() { - clusteredStore.putIfAbsent(new Element("key", "value")); - verify(toolkitCacheInternal).putIfAbsent(eq("key"), any(NonEternalElementData.class)); - } - - @Test - public void clusteredStore_replace_1_arg_enabled_in_eventual_consistency() { - clusteredStore.replace(new Element("key", "value")); - verify(toolkitCacheInternal).replace(any(), any()); - } - - @Test - public void clusteredStore_replace_2_args_enabled_in_eventual_consistency() { - clusteredStore.replace(new Element("key", "value"), new Element("key", "other"), new DefaultElementValueComparator(cacheConfiguration)); - verify(toolkitCacheInternal).replace(any(), any(), any(), any(ToolkitValueComparator.class)); - } - - @Test - public void clusteredStore_removeElement_enabled_in_eventual_consistency() { - clusteredStore.removeElement(new Element("key", "value"), new DefaultElementValueComparator(cacheConfiguration)); - verify(toolkitCacheInternal).remove(any(), any(), any(ToolkitValueComparator.class)); - } - - @Test - public void testDispose() throws Exception { - clusteredStore.dispose(); - verify(toolkitCacheInternal).disposeLocally(); - verify(cacheCluster).removeTopologyListener(any(ClusterTopologyListener.class)); - verify(toolkitCacheInternal).removeListener(any(ToolkitCacheListener.class)); - } - - @Test - public void testRegisterToolkitCacheEventListener() throws Exception { - verify(toolkitCacheInternal, never()).addListener(any(ToolkitCacheListener.class)); - cache.getCacheEventNotificationService().registerListener(new CacheEventListenerAdapter()); - cache.getCacheEventNotificationService().registerListener(new CacheEventListenerAdapter()); - verify(toolkitCacheInternal, times(1)).addListener(any(ToolkitCacheListener.class)); - } - - @Test - public void testUnregisterToolkitCacheEventListener() throws Exception { - String thisNodeId = cacheCluster.getCurrentNode().getId(); - when(configMap.get(ClusteredStore.LEADER_NODE_ID)).thenReturn(thisNodeId); // make this node the leader - verify(toolkitCacheInternal, never()).addListener(any(ToolkitCacheListener.class)); - CacheEventListener listener = new CacheEventListenerAdapter(); - cache.getCacheEventNotificationService().registerListener(listener); - cache.getCacheEventNotificationService().registerListener(listener); - cache.getCacheEventNotificationService().unregisterListener(listener); - cache.getCacheEventNotificationService().unregisterListener(listener); - verify(toolkitCacheInternal, times(1)).removeListener(any(ToolkitCacheListener.class)); - verify(configMap).remove(ClusteredStore.LEADER_NODE_ID); // make sure we drop leader status - } -} Index: rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/org/terracotta/ehcache/tests/servermap/ServerMapL2EvictionReachesL1Test.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/org/terracotta/ehcache/tests/servermap/ServerMapL2EvictionReachesL1Test.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/org/terracotta/ehcache/tests/servermap/ServerMapL2EvictionReachesL1Test.java (revision 0) @@ -1,21 +0,0 @@ -package org.terracotta.ehcache.tests.servermap; - -import org.terracotta.ehcache.tests.AbstractCacheTestBase; - -import com.tc.test.config.model.TestConfig; - -public class ServerMapL2EvictionReachesL1Test extends AbstractCacheTestBase { - - public ServerMapL2EvictionReachesL1Test(TestConfig testConfig) { - super("/servermap/servermap-l2-eviction-reaches-l1-test.xml", testConfig, - ServerMapL2EvictionReachesL1TestClient.class); - testConfig.setDgcEnabled(true); - testConfig.setDgcIntervalInSec(60); - testConfig.addTcProperty("ehcache.evictor.logging.enabled", "true"); - - testConfig.getClientConfig().addExtraClientJvmArg("-Dcom.tc.l1.cachemanager.enabled=false"); - testConfig.getClientConfig().addExtraClientJvmArg("-Dcom.tc.ehcache.evictor.logging.enabled=true"); - testConfig.getClientConfig().addExtraClientJvmArg("-Dcom.tc.l1.lockmanager.timeout.interval=60000"); - } - -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/writer/writebehind/OperationConverter.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/writer/writebehind/OperationConverter.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/writer/writebehind/OperationConverter.java (revision 0) @@ -1,34 +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.writebehind; - -/** - * Interface that allows an converter to be implemented that can create an operation based - * on an arbitrary object. - * - * @param the operation type that should be converted to - * @author Geert Bevin - * @version $Id: OperationConverter.java 5594 2012-05-07 16:04:31Z cdennis $ - */ -public interface OperationConverter { - /** - * Convert an arbitrary object - * - * @param source the object to convert - * @return the converted operation instance - */ - public T convert(Object source); -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/distribution/RMICacheReplicatorWithLargePayloadIT.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/distribution/RMICacheReplicatorWithLargePayloadIT.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/distribution/RMICacheReplicatorWithLargePayloadIT.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.distribution; - -import static net.sf.ehcache.util.RetryAssert.assertBy; -import static org.hamcrest.collection.IsCollectionWithSize.hasSize; -import static org.hamcrest.core.Is.is; -import static org.hamcrest.core.IsNull.notNullValue; -import static org.hamcrest.core.IsNull.nullValue; -import static org.hamcrest.number.OrderingComparison.greaterThan; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.fail; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.Callable; -import java.util.concurrent.TimeUnit; -import java.util.logging.Level; -import java.util.logging.Logger; - -import net.sf.ehcache.AbstractCacheTest; -import net.sf.ehcache.CacheException; -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.util.RetryAssert; - -import org.hamcrest.collection.IsEmptyCollection; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -/** - * Tests replication of Cache events with large payloads exceeding MTU - *

- * Note these tests need a live network interface running in multicast mode to work - *

- * - * @author Abhishek Sanoujam - */ -public class RMICacheReplicatorWithLargePayloadIT extends AbstractRMITest { - - private static final Logger LOG = Logger.getLogger(RMICacheReplicatorWithLargePayloadIT.class.getName()); - - private static int MB = 1024 * 1024; - - /** - * {@inheritDoc} Sets up two caches: cache1 is local. cache2 is to be receive updates - * - * @throws Exception - */ - @Before - public void setUp() throws Exception { - failFastInsufficientMemory(); - assertThat(getActiveReplicationThreads(), IsEmptyCollection.empty()); - } - - private void failFastInsufficientMemory() { - // fail fast if running with insufficient heap - long totalMemory = Runtime.getRuntime().totalMemory(); - if (totalMemory < 200 * MB) { - String msg = "Insufficient heap (approx. " + (totalMemory / MB) + " MB detected), this test requires at least 256 MB to run.\n"; - msg += "Steps to take:\n"; - msg += " 1) If you are running with eclipse: specify \"-Xms256m -Xmx256m\" as VM arguments in the \"Run Confuguration\" for this test\n"; - msg += " 2) If you are running using mvn with \"mvn test -Dtest=" + this.getClass().getSimpleName() - + "\", add this in the command line: -DargLine=\"-Xms256m -Xmx256m\"\n"; - msg += " Run the test like: mvn test -Dtest=" + this.getClass().getSimpleName() + " -DargLine=\"-Xms256m -Xmx256m\""; - LOG.log(Level.WARNING, msg); - fail(msg); - } - } - - @After - public void noReplicationThreads() throws Exception { - RetryAssert.assertBy(30, TimeUnit.SECONDS, new Callable>() { - @Override - public Set call() throws Exception { - return getActiveReplicationThreads(); - } - }, IsEmptyCollection.empty()); - } - - private static List createCluster(int size, String ... caches){ - LOG.info("Creating Cluster"); - Collection required = Arrays.asList(caches); - List configurations = new ArrayList(size); - for (int i = 1; i <= size; i++) { - Configuration config = getConfiguration(AbstractCacheTest.TEST_CONFIG_DIR + "distribution/ehcache-distributed-big-payload-" + i + ".xml").name("cm" + i); - if (!required.isEmpty()) { - for (Iterator> it = config.getCacheConfigurations().entrySet().iterator(); it.hasNext(); ) { - if (!required.contains(it.next().getKey())) { - it.remove(); - } - } - } - configurations.add(config); - } - LOG.info("Created Configurations"); - - List members = startupManagers(configurations); - try { - LOG.info("Created Managers"); - if (required.isEmpty()) { - waitForClusterMembership(10, TimeUnit.SECONDS, members); - LOG.info("Cluster Membership Complete"); - emptyCaches(10, TimeUnit.SECONDS, members); - LOG.info("Caches Emptied"); - } else { - waitForClusterMembership(10, TimeUnit.SECONDS, required, members); - emptyCaches(10, TimeUnit.SECONDS, required, members); - } - return members; - } catch (RuntimeException e) { - destroyCluster(members); - throw e; - } catch (Error e) { - destroyCluster(members); - throw e; - } - } - - private static void destroyCluster(List members) { - for (CacheManager manager : members) { - if (manager != null) { - manager.shutdown(); - } - } - } - - @Test - public void testAssertBigPayload() { - List cluster = createCluster(3); - try { - for (CacheManager manager : cluster) { - List localPeers = cluster.get(0).getCachePeerListener("RMI").getBoundCachePeers(); - List payloadList = PayloadUtil.createCompressedPayloadList(localPeers, 150); - assertThat(manager.getName(), payloadList, hasSize(greaterThan(1))); - } - - cluster.add(new CacheManager(AbstractCacheTest.TEST_CONFIG_DIR + "distribution/ehcache-distributed-big-payload-4.xml")); - - List localPeers = cluster.get(3).getCachePeerListener("RMI").getBoundCachePeers(); - List payloadList = PayloadUtil.createCompressedPayloadList(localPeers, 150); - assertThat(payloadList, hasSize(greaterThan(1))); - } finally { - destroyCluster(cluster); - } - } - - /** - * Does a new cache manager in the cluster get detected? - */ - @Test - public void testRemoteCachePeersDetectsNewCacheManager() throws InterruptedException { - List cluster = createCluster(3); - try { - //Add new CacheManager to cluster - cluster.add(new CacheManager(AbstractCacheTest.TEST_CONFIG_DIR + "distribution/ehcache-distributed-big-payload-4.xml")); - - //Allow detection to occur - waitForClusterMembership(10020, TimeUnit.MILLISECONDS, cluster); - } finally { - destroyCluster(cluster); - } - } - - /** - * Does a down cache manager in the cluster get removed? - */ - @Test - public void testRemoteCachePeersDetectsDownCacheManager() throws InterruptedException { - List cluster = createCluster(3); - try { - MulticastKeepaliveHeartbeatSender.setHeartBeatStaleTime(3000); - //Drop a CacheManager from the cluster - cluster.remove(2).shutdown(); - assertThat(cluster, hasSize(2)); - - //Allow change detection to occur. Heartbeat 1 second and is not stale until 5000 - waitForClusterMembership(11020, TimeUnit.MILLISECONDS, cluster); - } finally { - destroyCluster(cluster); - } - } - - /** - * Does a down cache manager in the cluster get removed? - */ - @Test - public void testRemoteCachePeersDetectsDownCacheManagerSlow() throws InterruptedException { - List cluster = createCluster(3); - try { - CacheManager manager = cluster.get(0); - - Thread.sleep(2000); - - //Drop a CacheManager from the cluster - cluster.remove(2).shutdown(); - - //Insufficient time for it to timeout - CacheManagerPeerProvider provider = manager.getCacheManagerPeerProvider("RMI"); - for (String cacheName : manager.getCacheNames()) { - List remotePeersOfCache1 = provider.listRemoteCachePeers(manager.getCache(cacheName)); - assertThat((List) remotePeersOfCache1, hasSize(2)); - } - } finally { - destroyCluster(cluster); - } - } - - /** - * Tests put and remove initiated from cache1 in a cluster - *

- * This test goes into an infinite loop if the chain of notifications is not somehow broken. - */ - @Test - public void testPutProgagatesFromAndToEveryCacheManagerAndCache() throws CacheException, InterruptedException { - final List cluster = createCluster(3); - try { - final CacheManager manager0 = cluster.get(0); - //Put - final String[] cacheNames = manager0.getCacheNames(); - Arrays.sort(cacheNames); - for (int i = 0; i < cacheNames.length; i++) { - String name = cacheNames[i]; - manager0.getCache(name).put(new Element(Integer.toString(i), Integer.valueOf(i))); - //Add some non serializable elements that should not get propagated - manager0.getCache(name).put(new Element("nonSerializable" + i, new Object())); - } - - assertBy(10, TimeUnit.SECONDS, new Callable() { - - public Boolean call() throws Exception { - for (int i = 0; i < cacheNames.length; i++) { - String name = cacheNames[i]; - for (CacheManager manager : cluster.subList(1, cluster.size())) { - assertThat("Cache : " + name, manager.getCache(name).get(Integer.toString(i)), notNullValue()); - assertThat(manager.getCache(name).get("nonSerializable" + i), nullValue()); - } - } - return Boolean.TRUE; - } - }, is(Boolean.TRUE)); - } finally { - destroyCluster(cluster); - } - - } -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/hibernate/management/impl/AggregateCacheRegionStats.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/hibernate/management/impl/AggregateCacheRegionStats.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/hibernate/management/impl/AggregateCacheRegionStats.java (revision 0) @@ -1,62 +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; - -/** - * @author gkeim - * - */ -public class AggregateCacheRegionStats extends CacheRegionStats { - private int nodeCount; - - /** - * @param region - */ - public AggregateCacheRegionStats(String region) { - super(region); - } - - /** - * @param stats - */ - public void aggregate(CacheRegionStats stats) { - nodeCount++; - hitCount += stats.getHitCount(); - missCount += stats.getMissCount(); - putCount += stats.getPutCount(); - hitRatio = determineHitRatio(); - - // just add the in memory count together, an average will be returned when the getter is used - elementCountInMemory += stats.getElementCountInMemory(); - - // the largest element count on disk is the one that is the most correct - if (stats.getElementCountOnDisk() > elementCountOnDisk) { - elementCountOnDisk = stats.getElementCountOnDisk(); - } - // elementCountTotal is the same for each node, since it's the total count in the cluster - // no real aggregation is needed, just use the same total count - elementCountTotal = stats.getElementCountTotal(); - } - - /** - * @see net.sf.ehcache.hibernate.management.impl.CacheRegionStats#getElementCountInMemory() - */ - @Override - public long getElementCountInMemory() { - return elementCountInMemory / nodeCount; - } -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/terracotta/ClusteredInstanceFactoryWrapper.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/terracotta/ClusteredInstanceFactoryWrapper.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/terracotta/ClusteredInstanceFactoryWrapper.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.terracotta; - -import net.sf.ehcache.Ehcache; -import net.sf.ehcache.cluster.CacheCluster; -import net.sf.ehcache.config.Configuration; -import net.sf.ehcache.event.CacheEventListener; -import net.sf.ehcache.management.event.ManagementEventSink; -import net.sf.ehcache.store.Store; -import net.sf.ehcache.store.TerracottaStore; -import net.sf.ehcache.transaction.SoftLockManager; -import net.sf.ehcache.transaction.TransactionIDFactory; -import net.sf.ehcache.writer.writebehind.WriteBehind; - -import java.util.concurrent.Callable; - -/** - * A {@link ClusteredInstanceFactory} implementation that delegates all operations to an underlying delegate except for the following - * operations: - *

    - *
  • {@link #getTopology()} : Delegates to the {@link TerracottaClient#getCacheCluster()}
  • - *
- * - * @author Abhishek Sanoujam - * - */ -public class ClusteredInstanceFactoryWrapper implements ClusteredInstanceFactory { - - private final TerracottaClient client; - private final ClusteredInstanceFactory delegate; - - /** - * Constructor accepting the TerracottaClient and the actual factory - * - * @param client - * @param delegate - */ - public ClusteredInstanceFactoryWrapper(TerracottaClient client, ClusteredInstanceFactory delegate) { - this.client = client; - this.delegate = delegate; - - } - - /** - * Returns the actual underlying factory - * - * @return the actual underlying factory - */ - protected ClusteredInstanceFactory getActualFactory() { - return delegate; - } - - /** - * {@inheritDoc} - */ - public CacheCluster getTopology() { - return client.getCacheCluster(); - } - - // all methods below delegate to the real factory - - /** - * {@inheritDoc} - */ - public String getUUID() { - return delegate.getUUID(); - } - - /** - * {@inheritDoc} - */ - @Override - public void enableNonStopForCurrentThread(boolean enable) { - delegate.enableNonStopForCurrentThread(enable); - } - - /** - * {@inheritDoc} - */ - public CacheEventListener createEventReplicator(Ehcache cache) { - return delegate.createEventReplicator(cache); - } - - /** - * {@inheritDoc} - */ - public Store createStore(Ehcache cache) { - return delegate.createStore(cache); - } - - /** - * {@inheritDoc} - */ - public TransactionIDFactory createTransactionIDFactory(String uuid, String cacheManagerName) { - return delegate.createTransactionIDFactory(uuid, cacheManagerName); - } - - /** - * {@inheritDoc} - */ - public WriteBehind createWriteBehind(Ehcache cache) { - return delegate.createWriteBehind(cache); - } - - /** - * {@inheritDoc} - */ - public SoftLockManager getOrCreateSoftLockManager(Ehcache cache) { - return delegate.getOrCreateSoftLockManager(cache); - } - - /** - * {@inheritDoc} - */ - public void shutdown() { - delegate.shutdown(); - } - - @Override - public TerracottaStore createNonStopStore(Callable store, Ehcache cache) { - return delegate.createNonStopStore(store, cache); - } - - @Override - public boolean destroyCache(final String cacheManagerName, final String cacheName) { - return delegate.destroyCache(cacheManagerName, cacheName); - } - - @Override - public void linkClusteredCacheManager(String cacheManagerName, Configuration configuration) { - delegate.linkClusteredCacheManager(cacheManagerName, configuration); - } - - @Override - public void unlinkCache(String cacheName) { - delegate.unlinkCache(cacheName); - } - - @Override - public ManagementEventSink createEventSink() { - return delegate.createEventSink(); - } - - /** - * {@inheritDoc} - */ - public void waitForOrchestrator(String cacheManagerName) { - delegate.waitForOrchestrator(cacheManagerName); - } -} Index: rctags/ehcache-2.10.9.1.33/management-ehcache-impl/management-ehcache-impl-v1/src/main/java/net/sf/ehcache/management/service/impl/CacheManagerEntityBuilder.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/management-ehcache-impl/management-ehcache-impl-v1/src/main/java/net/sf/ehcache/management/service/impl/CacheManagerEntityBuilder.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/management-ehcache-impl/management-ehcache-impl-v1/src/main/java/net/sf/ehcache/management/service/impl/CacheManagerEntityBuilder.java (revision 0) @@ -1,85 +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.management.resource.CacheManagerEntity; -import net.sf.ehcache.management.sampled.CacheManagerSampler; -import net.sf.ehcache.management.service.AccessorPrefix; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.terracotta.management.resource.AgentEntity; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Set; - -/** - * @author brandony - */ -final class CacheManagerEntityBuilder extends ConstrainableEntityBuilderSupport { - private static final Logger LOG = LoggerFactory.getLogger(CacheManagerEntityBuilder.class); - - private static final String CM_NAME_ACCESSOR = AccessorPrefix.get + "Name"; - - private final List cmSamplers = new ArrayList(); - - static CacheManagerEntityBuilder createWith(CacheManagerSampler sampler) { - return new CacheManagerEntityBuilder(sampler); - } - - CacheManagerEntityBuilder(CacheManagerSampler sampler) { - addSampler(sampler); - } - - CacheManagerEntityBuilder add(CacheManagerSampler sampler) { - addSampler(sampler); - return this; - } - - CacheManagerEntityBuilder add(Set constraintAttributes) { - addConstraints(constraintAttributes); - return this; - } - - Collection build() { - Collection cmes = new ArrayList(cmSamplers.size()); - - for (CacheManagerSampler cms : cmSamplers) { - CacheManagerEntity cme = new CacheManagerEntity(); - cme.setName(cms.getName()); - cme.setAgentId(AgentEntity.EMBEDDED_AGENT_ID); - cme.setVersion(this.getClass().getPackage().getImplementationVersion()); - - if (getAttributeConstraints() != null && !getAttributeConstraints().isEmpty() && getAttributeConstraints() - .size() < CacheManagerSampler.class.getMethods().length) { - buildAttributeMapByAttribute(CacheManagerSampler.class, cms, cme.getAttributes(), getAttributeConstraints(), - CM_NAME_ACCESSOR); - } else { - buildAttributeMapByApi(CacheManagerSampler.class, cms, cme.getAttributes(), getAttributeConstraints(), - CM_NAME_ACCESSOR); - } - - cmes.add(cme); - } - - return cmes; - } - - Logger getLog() { - return LOG; - } - - @Override - protected Set getExcludedAttributeNames(CacheManagerSampler cacheManagerSampler) { - return Collections.emptySet(); - } - - private void addSampler(CacheManagerSampler sampler) { - if (sampler == null) throw new IllegalArgumentException("sampler == null"); - cmSamplers.add(sampler); - } -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/search/query/QueryManagerBuilder.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/search/query/QueryManagerBuilder.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/search/query/QueryManagerBuilder.java (revision 0) @@ -1,121 +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 java.lang.reflect.Constructor; -import java.util.ArrayList; -import java.util.Collection; - -import net.sf.ehcache.CacheException; -import net.sf.ehcache.CacheManager; -import net.sf.ehcache.Ehcache; - -import java.lang.reflect.Constructor; -import java.util.ArrayList; -import java.util.Collection; - -/** - * A {@link net.sf.ehcache.search.query.QueryManager Query Manager} builder providing methods to add caches which - * can be queried. - * The Query Manager instance returned by this builder can be used to execute - * search queries expressed as Big Memory Structured Query Language (BMSQL) statements. - * - * @author dkumar - */ -public final class QueryManagerBuilder { - - private final Collection caches = new ArrayList(); - private final Class defaultClass; - - - private QueryManagerBuilder() { - this(getImplementationClass()); - } - - /** - * Package-local constructor for testing purposes. - * - * @param implementationClass a concrete implementation of the {@link net.sf.ehcache.search.query.QueryManager Query Manager} interface - */ - QueryManagerBuilder(Class implementationClass) { - this.defaultClass = implementationClass; - } - - private static Class getImplementationClass() { - try { - return (Class)Class.forName("net.sf.ehcache.search.parser.QueryManagerImpl"); - } catch (ClassNotFoundException e) { - throw new CacheException(e); - } - } - - /** - * Creates a new {@link net.sf.ehcache.search.query.QueryManager Query Manager} builder. - * - * @return this for the builder pattern - */ - public static QueryManagerBuilder newQueryManagerBuilder() { - return new QueryManagerBuilder(); - } - - /** - * Adds a {@link net.sf.ehcache.Ehcache Cache} to the internal state and allows it to be used as a target in a - * BMSQL statement's FROM clause. - * - * @param cache a {@link net.sf.ehcache.Ehcache cache} instance to be added - * @return this for the builder pattern - */ - public QueryManagerBuilder addCache(Ehcache cache) { - this.caches.add(cache); - return this; - } - - /** - * Adds all {@link net.sf.ehcache.Ehcache Caches} present in a {@link net.sf.ehcache.CacheManager Cache Manager} to - * the internal state of the query manager. - * The added caches can be used in a BMSQL statement's FROM clause. - * - * @param cacheManager a {@link net.sf.ehcache.CacheManager Cache Manager} whose - * {@link net.sf.ehcache.Ehcache caches} need to be added - * @return this for the builder pattern - */ - public QueryManagerBuilder addAllCachesCurrentlyIn(CacheManager cacheManager) { - for (String s : cacheManager.getCacheNames()) { - final Ehcache cache = cacheManager.getEhcache(s); - if (cache != null) { - this.caches.add(cache); - } - } - return this; - } - - /** - * Returns a new {@link net.sf.ehcache.search.query.QueryManager Query Manager} using the options supplied during the building - * process. - * - * @return the fully constructed {@link net.sf.ehcache.search.query.QueryManager Query Manager} - */ - public QueryManager build() { - try { - final Constructor constructor = defaultClass.getConstructor(Collection.class); - return constructor.newInstance(this.caches); - } catch (Exception e) { - throw new CacheException(e); - } - } - -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/util/MemorySizeParser.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/util/MemorySizeParser.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/util/MemorySizeParser.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.util; - -/** - * Memory size parser using the letter k or K to indicate kilobytes, the letter m or M to indicate megabytes, - * the letter g or G to indicate gigabytes and the letter t or T to indicate terabytes. - * - * @author Ludovic Orban - */ -public class MemorySizeParser { - private static final long BYTE = 1; - private static final long KILOBYTE = 1024; - private static final long MEGABYTE = 1024 * KILOBYTE; - private static final long GIGABYTE = 1024 * MEGABYTE; - private static final long TERABYTE = 1024 * GIGABYTE; - - /** - * Parse a String containing a human-readable memory size. - * - * @param configuredMemorySize the String containing a human-readable memory size. - * @return the memory size in bytes. - * @throws IllegalArgumentException thrown when the configured memory size cannot be parsed. - */ - public static long parse(String configuredMemorySize) throws IllegalArgumentException { - MemorySize size = parseIncludingUnit(configuredMemorySize); - return size.calculateMemorySizeInBytes(); - } - - private static MemorySize parseIncludingUnit(String configuredMemorySize) throws IllegalArgumentException { - if (configuredMemorySize == null || "".equals(configuredMemorySize)) { - return new MemorySize("0", BYTE); - } - - char unit = configuredMemorySize.charAt(configuredMemorySize.length() - 1); - MemorySize memorySize; - - switch (unit) { - case 'k': - case 'K': - memorySize = toMemorySize(configuredMemorySize, KILOBYTE); - break; - case 'm': - case 'M': - memorySize = toMemorySize(configuredMemorySize, MEGABYTE); - break; - case 'g': - case 'G': - memorySize = toMemorySize(configuredMemorySize, GIGABYTE); - break; - case 't': - case 'T': - memorySize = toMemorySize(configuredMemorySize, TERABYTE); - break; - default: - try { - Integer.parseInt("" + unit); - } catch (NumberFormatException e) { - throw new IllegalArgumentException("invalid format for memory size [" + configuredMemorySize + "]"); - } - memorySize = new MemorySize(configuredMemorySize, BYTE); - } - - return memorySize; - } - - private static MemorySize toMemorySize(String configuredMemorySize, long unitMultiplier) { - if (configuredMemorySize.length() < 2) { - throw new IllegalArgumentException("invalid format for memory size [" + configuredMemorySize + "]"); - } - return new MemorySize(configuredMemorySize.substring(0, configuredMemorySize.length() - 1), unitMultiplier); - } - - /** - * Memory size calculator. - */ - private static final class MemorySize { - private String configuredMemorySizeWithoutUnit; - private long multiplicationFactor; - - private MemorySize(String configuredMemorySizeWithoutUnit, long multiplicationFactor) { - this.configuredMemorySizeWithoutUnit = configuredMemorySizeWithoutUnit; - this.multiplicationFactor = multiplicationFactor; - } - - public long calculateMemorySizeInBytes() throws IllegalArgumentException { - try { - long memorySizeLong = Long.parseLong(configuredMemorySizeWithoutUnit); - long result = memorySizeLong * multiplicationFactor; - if (result < 0) { - throw new IllegalArgumentException("memory size cannot be negative"); - } - return result; - } catch (NumberFormatException e) { - throw new IllegalArgumentException("invalid format for memory size"); - } - } - } - -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/pool/impl/StrictlyBoundedPool.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/pool/impl/StrictlyBoundedPool.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/pool/impl/StrictlyBoundedPool.java (revision 0) @@ -1,52 +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 net.sf.ehcache.pool.PoolAccessor; -import net.sf.ehcache.pool.PoolEvictor; -import net.sf.ehcache.pool.PoolParticipant; -import net.sf.ehcache.pool.SizeOfEngine; - -/** - * A pool which strictly obeys to its bound: it will never allow the accessors to consume more bytes than what - * has been configured. - * - * @author Ludovic Orban - * @author Alex Snaps - */ -public class StrictlyBoundedPool extends AbstractPool { - - /** - * Create a StrictlyBoundedPool instance - * - * @param maximumPoolSize the maximum size of the pool, in bytes. - * @param evictor the pool evictor, for cross-store eviction. - * @param defaultSizeOfEngine the default SizeOf engine used by the accessors. - */ - public StrictlyBoundedPool(long maximumPoolSize, PoolEvictor evictor, SizeOfEngine defaultSizeOfEngine) { - super(maximumPoolSize, evictor, defaultSizeOfEngine); - } - - /** - * {@inheritDoc} - */ - public PoolAccessor createPoolAccessor(PoolParticipant participant, SizeOfEngine sizeOfEngine) { - LockedPoolAccessor accessor = new LockedPoolAccessor(this, participant, sizeOfEngine, 0); - registerPoolAccessor(accessor); - return accessor; - } -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/statistics/extended/CompoundOperationImpl.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/statistics/extended/CompoundOperationImpl.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/statistics/extended/CompoundOperationImpl.java (revision 0) @@ -1,285 +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.EnumMap; -import java.util.EnumSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; - -import net.sf.ehcache.statistics.extended.ExtendedStatistics.Operation; -import net.sf.ehcache.statistics.extended.ExtendedStatistics.Result; -import net.sf.ehcache.statistics.extended.ExtendedStatistics.Statistic; - -import org.terracotta.statistics.OperationStatistic; -import org.terracotta.statistics.ValueStatistic; - -/** - * The Class CompoundOperationImpl. - * - * @param the generic type - * @author cdennis - */ -class CompoundOperationImpl> implements Operation { - - private final OperationStatistic source; - - private final Class type; - private final Map> operations; - private final ConcurrentMap, OperationImpl> compounds = new ConcurrentHashMap, OperationImpl>(); - private final ConcurrentMap>, ExpiringStatistic> ratios = new ConcurrentHashMap>, ExpiringStatistic>(); - - private final ScheduledExecutorService executor; - - private volatile long averageNanos; - private volatile int historySize; - private volatile long historyNanos; - - private volatile boolean alwaysOn = false; - - /** - * Instantiates a new compound operation impl. - * - * @param source the source - * @param type the type - * @param averagePeriod the average period - * @param averageUnit the average unit - * @param executor the executor - * @param historySize the history size - * @param historyPeriod the history period - * @param historyUnit the history unit - */ - public CompoundOperationImpl(OperationStatistic source, Class type, long averagePeriod, TimeUnit averageUnit, - ScheduledExecutorService executor, int historySize, long historyPeriod, TimeUnit historyUnit) { - this.type = type; - this.source = source; - - this.averageNanos = averageUnit.toNanos(averagePeriod); - this.executor = executor; - this.historySize = historySize; - this.historyNanos = historyUnit.toNanos(historyPeriod); - - this.operations = new EnumMap(type); - for (T result : type.getEnumConstants()) { - operations.put(result, new OperationImpl(source, EnumSet.of(result), averageNanos, executor, historySize, historyNanos)); - } - } - - /* - * (non-Javadoc) - * - * @see net.sf.ehcache.statistics.extended.ExtendedStatistics.Operation#type() - */ - @Override - public Class type() { - return type; - } - - /* - * (non-Javadoc) - * - * @see net.sf.ehcache.statistics.extended.ExtendedStatistics.Operation#component(java.lang.Enum) - */ - @Override - public Result component(T result) { - return operations.get(result); - } - - /* - * (non-Javadoc) - * - * @see net.sf.ehcache.statistics.extended.ExtendedStatistics.Operation#compound(java.util.Set) - */ - @Override - public Result compound(Set results) { - if (results.size() == 1) { - return component(results.iterator().next()); - } else { - Set key = EnumSet.copyOf(results); - OperationImpl existing = compounds.get(key); - if (existing == null) { - OperationImpl created = new OperationImpl(source, key, averageNanos, executor, historySize, historyNanos); - OperationImpl racer = compounds.putIfAbsent(key, created); - if (racer == null) { - return created; - } else { - return racer; - } - } else { - return existing; - } - } - } - - /* - * (non-Javadoc) - * - * @see net.sf.ehcache.statistics.extended.ExtendedStatistics.Operation#ratioOf(java.util.Set, java.util.Set) - */ - @Override - public Statistic ratioOf(Set numerator, Set denominator) { - List> key = Arrays.> asList(EnumSet.copyOf(numerator), EnumSet.copyOf(denominator)); - ExpiringStatistic existing = ratios.get(key); - if (existing == null) { - final Statistic numeratorRate = compound(numerator).rate(); - final Statistic denominatorRate = compound(denominator).rate(); - ExpiringStatistic created = new ExpiringStatistic(new ValueStatistic() { - @Override - public Double value() { - return numeratorRate.value() / denominatorRate.value(); - } - }, executor, historySize, historyNanos); - ExpiringStatistic racer = ratios.putIfAbsent(key, created); - if (racer == null) { - return created; - } else { - return racer; - } - } else { - return existing; - } - } - - /* - * (non-Javadoc) - * - * @see net.sf.ehcache.statistics.extended.ExtendedStatistics.Operation#setAlwaysOn(boolean) - */ - @Override - public void setAlwaysOn(boolean enable) { - alwaysOn = enable; - if (enable) { - for (OperationImpl op : operations.values()) { - op.start(); - } - for (OperationImpl op : compounds.values()) { - op.start(); - } - for (ExpiringStatistic ratio : ratios.values()) { - ratio.start(); - } - } - } - - /* - * (non-Javadoc) - * - * @see net.sf.ehcache.statistics.extended.ExtendedStatistics.Operation#isAlwaysOn() - */ - @Override - public boolean isAlwaysOn() { - return alwaysOn; - } - - /* - * (non-Javadoc) - * - * @see net.sf.ehcache.statistics.extended.ExtendedStatistics.Operation#setWindow(long, java.util.concurrent.TimeUnit) - */ - @Override - public void setWindow(long time, TimeUnit unit) { - averageNanos = unit.toNanos(time); - for (OperationImpl op : operations.values()) { - op.setWindow(averageNanos); - } - for (OperationImpl op : compounds.values()) { - op.setWindow(averageNanos); - } - } - - /* - * (non-Javadoc) - * - * @see net.sf.ehcache.statistics.extended.ExtendedStatistics.Operation#setHistory(int, long, java.util.concurrent.TimeUnit) - */ - @Override - public void setHistory(int samples, long time, TimeUnit unit) { - historySize = samples; - historyNanos = unit.toNanos(time); - for (OperationImpl op : operations.values()) { - op.setHistory(historySize, historyNanos); - } - for (OperationImpl op : compounds.values()) { - op.setHistory(historySize, historyNanos); - } - for (ExpiringStatistic ratio : ratios.values()) { - ratio.setHistory(historySize, historyNanos); - } - } - - /* - * (non-Javadoc) - * - * @see net.sf.ehcache.statistics.extended.ExtendedStatistics.Operation#getWindowSize(java.util.concurrent.TimeUnit) - */ - @Override - public long getWindowSize(TimeUnit unit) { - return unit.convert(averageNanos, TimeUnit.NANOSECONDS); - } - - /** - * Get the history sample size. - */ - @Override - public int getHistorySampleSize() { - return historySize; - } - - /** - * Get the history sample time. - */ - @Override - public long getHistorySampleTime(TimeUnit unit) { - return unit.convert(historySize, TimeUnit.NANOSECONDS); - } - - /** - * Expire. - * - * @param expiryTime the expiry time - * @return true, if successful - */ - boolean expire(long expiryTime) { - if (alwaysOn) { - return false; - } else { - boolean expired = true; - for (OperationImpl o : operations.values()) { - expired &= o.expire(expiryTime); - } - for (Iterator> it = compounds.values().iterator(); it.hasNext();) { - if (it.next().expire(expiryTime)) { - it.remove(); - } - } - for (Iterator> it = ratios.values().iterator(); it.hasNext();) { - if (it.next().expire(expiryTime)) { - it.remove(); - } - } - return expired & compounds.isEmpty() & ratios.isEmpty(); - } - } - -} Index: rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/net/sf/ehcache/osgi/SimpleOsgiTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/net/sf/ehcache/osgi/SimpleOsgiTest.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/net/sf/ehcache/osgi/SimpleOsgiTest.java (revision 0) @@ -1,126 +0,0 @@ -/* - * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved. - */ -package net.sf.ehcache.osgi; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; -import static org.ops4j.pax.exam.CoreOptions.bootDelegationPackages; -import static org.ops4j.pax.exam.CoreOptions.options; -import static org.terracotta.test.OsgiUtil.commonOptions; -import static org.terracotta.test.OsgiUtil.getMavenBundle; - -import net.sf.ehcache.Cache; -import net.sf.ehcache.CacheManager; -import net.sf.ehcache.Element; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.ops4j.pax.exam.Configuration; -import org.ops4j.pax.exam.Option; -import org.ops4j.pax.exam.junit.PaxExam; -import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy; -import org.ops4j.pax.exam.spi.reactors.PerMethod; -import org.terracotta.context.ContextManager; - -import java.io.BufferedReader; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.Serializable; -import java.net.URL; - -/** - * Test a simple BigMemory usage with BM Go license key. The product name should include "BigMemory" and not "Ehcache" - * NOTE: this test only works in fullmode - * - * @author hhuynh - */ -@RunWith(PaxExam.class) -@ExamReactorStrategy(PerMethod.class) -public class SimpleOsgiTest { - - @Configuration - public Option[] config() { - return options(bootDelegationPackages("sun.*,jdk.*"), - // need this for REST agent test - getMavenBundle("net.sf.ehcache", "ehcache-ee", "ehcache"), - commonOptions()); - } - - @Test - public void testSimpleCache() throws Exception { - CacheManager manager = new CacheManager(SimpleOsgiTest.class.getResource("/net/sf/ehcache/osgi/simple-ehcache.xml")); - try { - Cache cache = manager.getCache("sampleCache1"); - Element element = new Element("key1", "value1"); - cache.put(element); - Element element1 = cache.get("key1"); - assertEquals("value1", element1.getObjectValue()); - assertEquals(1, cache.getSize()); - } finally { - manager.shutdown(); - } - } - - @Test - public void testValueClass() throws Exception { - CacheManager manager = new CacheManager(SimpleOsgiTest.class.getResource("/net/sf/ehcache/osgi/simple-ehcache.xml")); - try { - Cache cache = manager.getCache("sampleCache1"); - Element element = new Element("key1", new Value("value1")); - cache.put(element); - Element element1 = cache.get("key1"); - assertEquals("value1", ((Value) element1.getObjectValue()).v); - assertEquals(1, cache.getSize()); - } finally { - manager.shutdown(); - } - } - - @Test - public void testUsingNonExportedClass() { - try { - ContextManager cm = new ContextManager(); - fail("Expected class not found exception"); - } catch (Throwable e) { - // expected - } - } - - @Test - public void testRestAgent() throws Exception { - CacheManager manager = new CacheManager( - SimpleOsgiTest.class - .getResource("/net/sf/ehcache/osgi/rest-enabled-ehcache.xml")); - InputStream in = null; - try { - Cache testCache = manager.getCache("testCache"); - testCache.put(new Element("k", "v")); - assertEquals(1, testCache.getSize()); - URL url = new URL("http://localhost:9888/tc-management-api/agents"); - in = url.openStream(); - BufferedReader reader = new BufferedReader(new InputStreamReader(in)); - String line = null; - StringBuilder sb = new StringBuilder(); - while ((line = reader.readLine()) != null) { - sb.append(line.trim()).append("\n"); - } - System.out.println("Rest response: " + sb); - assertTrue(sb.toString().contains("\"agentId\":\"embedded\"")); - } finally { - manager.shutdown(); - if (in != null) { - in.close(); - } - } - } - - private static class Value implements Serializable { - public String v; - - public Value(String value) { - v = value; - } - } -} \ No newline at end of file Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/management/provider/package.html =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/management/provider/package.html (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/management/provider/package.html (revision 0) @@ -1,8 +0,0 @@ - - - - -This package contains classes related to MBeanRegistrationProvider and its implementation. -

- - Index: rctags/ehcache-2.10.9.1.33/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/store/TerracottaStoreInitializationService.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/store/TerracottaStoreInitializationService.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/store/TerracottaStoreInitializationService.java (revision 0) @@ -1,101 +0,0 @@ -/* - * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved. - */ -package org.terracotta.modules.ehcache.store; - -import net.sf.ehcache.config.NonstopConfiguration; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.terracotta.toolkit.cluster.ClusterInfo; - -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; -import java.util.concurrent.ThreadFactory; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; -import java.util.concurrent.atomic.AtomicInteger; - -public class TerracottaStoreInitializationService { - private static final Logger LOGGER = LoggerFactory.getLogger(TerracottaStoreInitializationService.class); - private final ExecutorService threadPool; - private final ClusterInfo clusterInfo; - - - public TerracottaStoreInitializationService(ClusterInfo clusterInfo) { - this.clusterInfo = clusterInfo; - this.threadPool = getThreadPool(); - } - - /** - * This method should be called when the associated CacheManager is shutdown. Once shutdowm, the initialization - * service cannot be started again. - */ - public void shutdown() { - threadPool.shutdownNow(); - } - - public void initialize(Runnable runnable, NonstopConfiguration nonStopConfiguration) { - - // Submit the Thread for execution - Future future = threadPool.submit(runnable); - - // wait for initialization to complete (until operations are enabled) - waitForInitialization(future, nonStopConfiguration.getTimeoutMillis()); - } - - /** - * This method holds the calling thread until the given Future returns the result or the Cluster operations get/are - * disabled. In case the Cluster operations get disabled while waiting, the method call returns honoring the nonstop - * timeout. - * - */ - private void waitForInitialization(Future future, long nonStopTimeOutInMillis) { - boolean interrupted = false; - boolean initializationCompleted = false; - try { - do { - try { - future.get(nonStopTimeOutInMillis, TimeUnit.MILLISECONDS); - initializationCompleted = true; - } catch (InterruptedException e) { - interrupted = true; - } catch (ExecutionException e) { - throw new RuntimeException(e.getCause()); - } catch (TimeoutException e) { - // Retry if operations are enabled - } - } while (!initializationCompleted && areOperationsEnabled()); - - } finally { - if (interrupted) Thread.currentThread().interrupt(); - } - - if (!initializationCompleted) { - LOGGER.debug("Returning without completing TerracottaStore initialization. Operations Enabled = {}", - areOperationsEnabled()); - } - } - - private boolean areOperationsEnabled() { - return clusterInfo.areOperationsEnabled(); - } - - private ExecutorService getThreadPool() { - ThreadFactory daemonThreadFactory = new ThreadFactory() { - private final AtomicInteger threadID = new AtomicInteger(); - - @Override - public Thread newThread(Runnable runnable) { - Thread thread = new Thread(runnable, "TerracottaStoreInitializationThread_" + threadID.incrementAndGet()); - thread.setDaemon(true); - return thread; - } - }; - - return Executors.newCachedThreadPool(daemonThreadFactory); - } - -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/constructs/readthrough/ReadThroughCache.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/constructs/readthrough/ReadThroughCache.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/constructs/readthrough/ReadThroughCache.java (revision 0) @@ -1,77 +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.readthrough; - -import java.io.Serializable; - -import net.sf.ehcache.Cache; -import net.sf.ehcache.CacheException; -import net.sf.ehcache.Ehcache; -import net.sf.ehcache.Element; -import net.sf.ehcache.constructs.EhcacheDecoratorAdapter; - -/** - * This class implements the simplest of all possible read through cache - * behaviors, where a call the get() will delegate to a call to getWithLoader(). - * This means that a get() call can take a long time; beware. It also does no more - * locking than {@link Cache} implements; each separate cache may try to load - * a key at the same time. - * - * @author cschanck - * - */ -public class ReadThroughCache extends EhcacheDecoratorAdapter { - - private final ReadThroughCacheConfiguration readThroughCacheConfig; - private final boolean isModeGet; - - /** - * - * @param underlyingCache - * @param config - */ - public ReadThroughCache(Ehcache underlyingCache, ReadThroughCacheConfiguration config) { - super(underlyingCache); - this.readThroughCacheConfig = config; - this.isModeGet = readThroughCacheConfig.isModeGet(); - } - - @Override - public Element get(Object key) throws IllegalStateException, CacheException { - if (isModeGet) { - return super.getWithLoader(key, null, null); - } - return super.get(key); - } - - @Override - public Element get(Serializable key) throws IllegalStateException, CacheException { - if (isModeGet) { - return super.getWithLoader(key, null, null); - } - return super.get(key); - } - - @Override - public String getName() { - if (readThroughCacheConfig.getName() != null) { - return readThroughCacheConfig.getName(); - } - return super.getName(); - } - -} Index: rctags/ehcache-2.10.9.1.33/distribution/events/src/assemble/bin/start-jetty.bat =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/distribution/events/src/assemble/bin/start-jetty.bat (revision 11516) +++ rctags/ehcache-2.10.9.1.33/distribution/events/src/assemble/bin/start-jetty.bat (revision 0) @@ -1,40 +0,0 @@ -@echo off - -if not defined JAVA_HOME ( - echo JAVA_HOME is not defined - exit /b 1 -) - -setlocal - -set jetty_instance=%1 - -if "%jetty_instance%" == "" ( - echo Need to specify which instance of Jetty: 9081 or 9082 - exit /b 1 -) - -pushd "%~d0%~p0" -for /f "tokens=*" %%a in ('call relative-paths.bat tc_install_dir') do set tc_install_dir=%%a -pushd -cd %tc_install_dir% -set tc_install_dir=%CD% -set tc_install_dir="%tc_install_dir:"=%" -popd -popd - -set JAVA_HOME="%JAVA_HOME:"=%" -set root=%~d0%~p0.. -set root="%root:"=%" -set jetty_work_dir=%root%\jetty6.1\%jetty_instance% -set jetty_home=%tc_install_dir%\third-party\jetty-6.1.15 -set start_jar=%jetty_home%\start.jar -set /a stop_port=jetty_instance + 2 - -cd %jetty_work_dir% -mkdir logs -echo Starting Jetty %jetty_instance%... -start "Jetty %jetty_instance%" %JAVA_HOME%\bin\java -Dtc.install-root=%tc_install_dir% -Xmx256m -XX:MaxPermSize=128m -Dconfig.home=%jetty_work_dir% -Djetty.home=%jetty_home% -DSTOP.PORT=%stop_port% -DSTOP.KEY=secret -jar %start_jar% conf.xml -echo. - -endlocal Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/util/WeakIdentityConcurrentMapTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/util/WeakIdentityConcurrentMapTest.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/util/WeakIdentityConcurrentMapTest.java (revision 0) @@ -1,62 +0,0 @@ -package net.sf.ehcache.util; - -import org.hamcrest.core.Is; -import org.junit.Test; - -import java.util.concurrent.Callable; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; -import java.util.concurrent.atomic.AtomicLong; - -import static java.util.concurrent.TimeUnit.SECONDS; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.Matchers.notNullValue; -import static org.hamcrest.Matchers.nullValue; -import static org.junit.Assert.assertThat; - -/** - * @author Alex Snaps - */ -public class WeakIdentityConcurrentMapTest { - - private Long someKey = 1024L; - - @Test - public void testReturnsValueAndCleanUpsProperly() { - - final ConcurrentMap cleanedUpValues = new ConcurrentHashMap(); - - final WeakIdentityConcurrentMap map = new WeakIdentityConcurrentMap(new WeakIdentityConcurrentMap.CleanUpTask() { - public void cleanUp(final String value) { - final AtomicLong previous = cleanedUpValues.putIfAbsent(value, new AtomicLong(1)); - if(previous != null) { - previous.incrementAndGet(); - } - } - }); - - final String value1 = "someValue for 1"; - final String value2 = "someValue for 1024"; - assertThat(map.putIfAbsent(1L, value1), nullValue()); - assertThat(map.putIfAbsent(someKey, value2), nullValue()); - assertThat(map.putIfAbsent(someKey, value2), equalTo(value2)); - assertThat(map.get(1L), equalTo(value1)); - assertThat(map.get(someKey), equalTo(value2)); - someKey = null; - - RetryAssert.assertBy(10, SECONDS, new Callable() { - public Integer call() throws Exception { - int i = 0; - while (i++ < 50) { - System.gc(); - assertThat(map.get(someKey), nullValue()); - } - return cleanedUpValues.size(); - } - }, Is.is(1)); - - assertThat(cleanedUpValues.get(value2), notNullValue()); - assertThat(cleanedUpValues.get(value2).get(), is(1L)); - } -} Index: rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/org/terracotta/modules/ehcache/event/ClusteredEventsSerializationTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/org/terracotta/modules/ehcache/event/ClusteredEventsSerializationTest.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/org/terracotta/modules/ehcache/event/ClusteredEventsSerializationTest.java (revision 0) @@ -1,142 +0,0 @@ -/* - * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved. - */ -package org.terracotta.modules.ehcache.event; - -import net.sf.ehcache.Cache; -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 com.tc.test.config.model.TestConfig; - -import java.io.Serializable; -import java.util.Set; - -import junit.framework.Assert; - -public class ClusteredEventsSerializationTest extends AbstractCacheTestBase { - - private static final int NODE_COUNT = 5; - - public ClusteredEventsSerializationTest(TestConfig testConfig) { - super("clustered-events-test.xml", testConfig, App.class, App.class, App.class, App.class, App.class); - testConfig.getClientConfig().addExtraClientJvmArg("-Dcom.tc.ehcache.clusteredStore.checkContainsKeyOnPut=true"); - } - - public static class App extends ClientBase { - private final ToolkitBarrier barrier; - - public App(String[] args) { - super("testSerialization", args); - this.barrier = getClusteringToolkit().getBarrier("test-barrier", NODE_COUNT); - } - - @Override - protected void runTest(Cache cache, Toolkit clusteringToolkit) throws Throwable { - final int index = barrier.await(); - - Assert.assertEquals(0, cache.getSize()); - - barrier.await(); - - NonPortable key = new NonPortable("key" + index); - NonPortable valuePut = new NonPortable("value" + index); - NonPortable valueUpdate = new NonPortable("valueUpdated" + index); - cache.put(new Element(key, valuePut)); - cache.put(new Element(key, valueUpdate)); - cache.remove(key); - - barrier.await(); - - cache.removeAll(); - - barrier.await(); - - Thread.sleep(10000); - - EhcacheTerracottaEventListener listener = null; - Set listeners = cache.getCacheEventNotificationService().getCacheEventListeners(); - for (CacheEventListener l : listeners) { - if (l instanceof EhcacheTerracottaEventListener) { - listener = (EhcacheTerracottaEventListener) l; - break; - } - } - - Assert.assertNotNull(listener); - - Assert.assertEquals(NODE_COUNT, listener.getPut().size()); - Assert.assertEquals(NODE_COUNT, listener.getUpdate().size()); - Assert.assertEquals(NODE_COUNT, listener.getRemove().size()); - Assert.assertEquals(NODE_COUNT, listener.getRemoveAll()); - - boolean foundPutKey = false; - for (Element element : listener.getPut()) { - if (element.getObjectKey().equals(key)) { - foundPutKey = true; - Assert.assertEquals(valuePut, element.getObjectValue()); - } else { - Assert.assertEquals("value" + element.getObjectKey().toString().substring("key".length()), element - .getObjectValue().toString()); - } - } - Assert.assertTrue(foundPutKey); - - boolean foundUpdateKey = false; - for (Element element : listener.getUpdate()) { - if (element.getObjectKey().equals(key)) { - foundUpdateKey = true; - Assert.assertEquals(valueUpdate, element.getObjectValue()); - } else { - Assert.assertEquals("valueUpdated" + element.getObjectKey().toString().substring("key".length()), element - .getObjectValue().toString()); - } - } - Assert.assertTrue(foundUpdateKey); - - boolean foundRemoveKey = false; - for (Element element : listener.getRemove()) { - if (element.getObjectKey().equals(key)) { - foundRemoveKey = true; - } - } - Assert.assertTrue(foundRemoveKey); - } - - } - - public static class NonPortable implements Serializable { - private final String value; - - public NonPortable(String value) { - this.value = value; - } - - @Override - public String toString() { - return value; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - NonPortable that = (NonPortable) o; - - if (value != null ? !value.equals(that.value) : that.value != null) return false; - - return true; - } - - @Override - public int hashCode() { - return value != null ? value.hashCode() : 0; - } - } -} Index: rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/org/terracotta/modules/ehcache/store/StorageStrategyNotSupportedTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/org/terracotta/modules/ehcache/store/StorageStrategyNotSupportedTest.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/org/terracotta/modules/ehcache/store/StorageStrategyNotSupportedTest.java (revision 0) @@ -1,69 +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.CacheManager; -import net.sf.ehcache.config.CacheConfiguration; -import net.sf.ehcache.config.TerracottaConfiguration; - -import org.terracotta.ehcache.tests.AbstractCacheTestBase; -import org.terracotta.ehcache.tests.ClientBase; -import org.terracotta.toolkit.Toolkit; - -import com.tc.test.config.model.TestConfig; - -import junit.framework.Assert; - -public class StorageStrategyNotSupportedTest extends AbstractCacheTestBase { - - public StorageStrategyNotSupportedTest(TestConfig testConfig) { - super("ehcache-not-supported.xml", testConfig, App.class); - } - - public static class App extends ClientBase { - - public App(String[] args) { - super(args); - } - - public static void main(String[] args) { - new App(args).run(); - } - - @Override - protected void runTest(Cache cache, Toolkit clusteringToolkit) throws Throwable { - - CacheManager cm = getCacheManager(); - - try { - Assert.assertEquals(1, cm.getCacheNames().length); - Assert.assertTrue(cm.getCacheNames()[0].equals("test")); - } catch (CacheException e) { - fail("Using storageStrategy=dcv2 should work even without ee"); - } - - // test programmatic way - cm.shutdown(); - setupCacheManager(); - cm = getCacheManager(); - CacheConfiguration cacheConfiguration = new CacheConfiguration("testCache", 100); - TerracottaConfiguration tc = new TerracottaConfiguration().clustered(true); - cacheConfiguration.addTerracotta(tc); - cache = new Cache(cacheConfiguration); - - cm.removeCache("test"); - - try { - cm.addCache(cache); - Assert.assertEquals(1, cm.getCacheNames().length); - Assert.assertTrue(cm.getCacheNames()[0].equals("testCache")); - } catch (CacheException e) { - e.printStackTrace(); - fail("Using storageStrategy=dcv2 should work even without ee"); - } - } - } -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/statistics/beans/AttributeProxy.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/statistics/beans/AttributeProxy.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/statistics/beans/AttributeProxy.java (revision 0) @@ -1,116 +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; - -/** - * The Class AttributeProxy, used to proxy operations from a dynamic mbean to a POJO object. - * Override get()/set() as needed. - * - * @param the return type/set type for the attribute - * - * @author cschanck - */ -public abstract class AttributeProxy { - private final String name; - private final Class clazz; - private final boolean isWrite; - private final boolean isRead; - private final String description; - - /** - * Instantiates a new attribute proxy. - * - * @param clazz the clazz of the return type - * @param name the name - * @param description the description - * @param isRead readable - * @param isWrite writable - */ - public AttributeProxy(Class clazz, String name, String description, boolean isRead, boolean isWrite) { - this.name = name; - this.description = description; - this.clazz = clazz; - this.isWrite = isWrite; - this.isRead = isRead; - } - - /** - * Gets the description. - * - * @return the description - */ - public String getDescription() { - return description; - } - - /** - * Gets the type class. - * - * @return the type class - */ - public Class getTypeClass() { - return clazz; - } - - /** - * Gets the name. - * - * @return the name - */ - public String getName() { - return name; - } - - /** - * Gets the value. - * - * @param name the name - * @return the value - */ - public T get(String name) { - throw new UnsupportedOperationException(); - } - - /** - * Sets the value. - * - * @param name the name - * @param t the value - */ - public void set(String name, T t) { - throw new UnsupportedOperationException(); - } - - /** - * Checks if is readable. - * - * @return true, if is read - */ - public boolean isRead() { - return isRead; - } - - /** - * Checks if is writable. - * - * @return true, if is writable - */ - public boolean isWrite() { - return isWrite; - } - -} Index: rctags/ehcache-2.10.9.1.33/management-ehcache-v2/src/main/java/net/sf/ehcache/management/resource/CacheEntityV2.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/management-ehcache-v2/src/main/java/net/sf/ehcache/management/resource/CacheEntityV2.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/management-ehcache-v2/src/main/java/net/sf/ehcache/management/resource/CacheEntityV2.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 CacheEntityV2 extends AbstractCacheEntityV2 { - private Map attributes = new HashMap(); - - public Map getAttributes() { - return attributes; - } -} Index: rctags/ehcache-2.10.9.1.33/distribution/colorcache/src/assemble/bin/stop-sample.sh =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/distribution/colorcache/src/assemble/bin/stop-sample.sh (revision 11516) +++ rctags/ehcache-2.10.9.1.33/distribution/colorcache/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.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/transaction/TransactionTimeoutException.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/transaction/TransactionTimeoutException.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/transaction/TransactionTimeoutException.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.transaction; - -/** - * This exception is thrown when a transactional operation times out - * - * @author Ludovic Orban - */ -public class TransactionTimeoutException extends TransactionException { - - /** - * Create a new TransactionTimeoutException - * @param message the error message - */ - public TransactionTimeoutException(String message) { - super(message); - } -} Index: rctags/ehcache-2.10.9.1.33/ehcache/src/main/resources/META-INF/terracotta/public-api-types =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache/src/main/resources/META-INF/terracotta/public-api-types (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache/src/main/resources/META-INF/terracotta/public-api-types (revision 0) @@ -1 +0,0 @@ -# Don't remove this line -- if file is empty then everything will become an API type Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/pool/sizeof/SizeOf.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/pool/sizeof/SizeOf.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/pool/sizeof/SizeOf.java (revision 0) @@ -1,113 +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.pool.Size; -import net.sf.ehcache.pool.sizeof.ObjectGraphWalker.Visitor; -import net.sf.ehcache.pool.sizeof.filter.SizeOfFilter; -import net.sf.ehcache.util.WeakIdentityConcurrentMap; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - -/** - * Abstract sizeOf for Java. It will rely on a proper sizeOf to measure sizes of entire object graphs - * @author Alex Snaps - */ -public abstract class SizeOf { - - private static final Logger LOG = LoggerFactory.getLogger(SizeOf.class.getName()); - - private final ObjectGraphWalker walker; - - /** - * Builds a new SizeOf that will filter fields according to the provided filter - * @param fieldFilter The filter to apply - * @param caching whether to cache reflected fields - * @see SizeOfFilter - */ - public SizeOf(SizeOfFilter fieldFilter, boolean caching) { - ObjectGraphWalker.Visitor visitor; - if (caching) { - visitor = new CachingSizeOfVisitor(); - } else { - visitor = new SizeOfVisitor(); - } - this.walker = new ObjectGraphWalker(visitor, fieldFilter); - } - - /** - * Calculates the size in memory (heap) of the instance passed in, not navigating the down graph - * - * @param obj the object to measure the size of - * @return the object size in memory in bytes - */ - public abstract long sizeOf(Object obj); - - /** - * Measures the size in memory (heap) of the objects passed in, walking their graph down - * Any overlap of the graphs being passed in will be recognized and only measured once - * - * @param maxDepth maximum depth of the object graph to traverse - * @param abortWhenMaxDepthExceeded true if the object traversal should be aborted when the max depth is exceeded - * @param obj the root objects of the graphs to measure - * @return the total size in bytes for these objects - * @see #sizeOf(Object) - */ - public Size deepSizeOf(int maxDepth, boolean abortWhenMaxDepthExceeded, Object... obj) { - return new Size(walker.walk(maxDepth, abortWhenMaxDepthExceeded, obj), true); - } - - /** - * Will return the sizeOf each instance - */ - private class SizeOfVisitor implements Visitor { - - /** - * {@inheritDoc} - */ - public long visit(Object object) { - return sizeOf(object); - } - } - - /** - * Will Cache already visited types - */ - private class CachingSizeOfVisitor implements Visitor { - private final WeakIdentityConcurrentMap, Long> cache = new WeakIdentityConcurrentMap, Long>(); - - /** - * {@inheritDoc} - */ - public long visit(final Object object) { - Class klazz = object.getClass(); - Long cachedSize = cache.get(klazz); - if (cachedSize == null) { - if (klazz.isArray()) { - return sizeOf(object); - } else { - long size = sizeOf(object); - cache.put(klazz, size); - return size; - } - } else { - return cachedSize.longValue(); - } - } - } -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/search/attribute/KeyObjectAttributeExtractor.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/search/attribute/KeyObjectAttributeExtractor.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/search/attribute/KeyObjectAttributeExtractor.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.attribute; - -import net.sf.ehcache.Element; - -/** - * Attempt to use the element key object itself as a search attribute. If the key is not a legal type it is omitted - * - * @author teck - */ -public class KeyObjectAttributeExtractor implements AttributeExtractor { - - /** - * {@inheritDoc} - */ - public Object attributeFor(Element element, String attributeName) throws AttributeExtractorException { - Object key = element.getObjectKey(); - - if (AttributeType.isSupportedType(key)) { - return key; - } - - // not a supported type return null to not define anything in the index - return null; - } - -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/config/ehcache.xsd =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/config/ehcache.xsd (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/config/ehcache.xsd (revision 0) @@ -1,422 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/writer/MapCacheWriterFactory.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/writer/MapCacheWriterFactory.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/writer/MapCacheWriterFactory.java (revision 0) @@ -1,76 +0,0 @@ -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; -import java.util.Properties; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; -import java.util.concurrent.atomic.AtomicInteger; - -/** - * @author Alex Snaps - */ -public class MapCacheWriterFactory extends CacheWriterFactory { - - public static final ConcurrentMap map = new ConcurrentHashMap(); - public static final AtomicInteger writes = new AtomicInteger(0); - public static final AtomicInteger deletes = new AtomicInteger(0); - - @Override - public CacheWriter createCacheWriter(final Ehcache cache, final Properties properties) { - return new CacheWriter() { - @Override - public CacheWriter clone(final Ehcache cache) throws CloneNotSupportedException { - throw new UnsupportedOperationException("Someone... i.e. YOU! should think about implementing this someday!"); - } - - @Override - public void init() { - - } - - @Override - public void dispose() throws CacheException { - - } - - @Override - public void write(final Element element) throws CacheException { - System.out.println("PUT " + element); - map.put(element.getKey(), element); - writes.getAndIncrement(); - } - - @Override - public void writeAll(final Collection elements) throws CacheException { - for (Element element : elements) { - write(element); - } - } - - @Override - public void delete(final CacheEntry entry) throws CacheException { - System.out.println("DELETE " + entry.getKey()); - map.remove(entry.getKey()); - deletes.getAndIncrement(); - } - - @Override - public void deleteAll(final Collection entries) throws CacheException { - for (CacheEntry entry : entries) { - delete(entry); - } - } - - @Override - public void throwAway(final Element element, final SingleOperationType operationType, final RuntimeException e) { - throw new UnsupportedOperationException("Someone... i.e. YOU! should think about implementing this someday!"); - } - }; - } -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/util/LongSequence.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/util/LongSequence.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/util/LongSequence.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.util; - -/** - * A sequence producing longs - * - * @author teck - */ -public interface LongSequence { - - /** - * Get the next value in the sequence - * - * @return the next value - */ - long next(); -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/loader/CacheLoaderFactory.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/loader/CacheLoaderFactory.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/loader/CacheLoaderFactory.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.loader; - -import net.sf.ehcache.Ehcache; - -import java.util.Properties; - -/** - * An abstract factory for creating cache loaders. Implementers should provide their own - * concrete factory extending this factory. - *

- * Note that Ehcache API also allows the CacheLoader to be set programmatically. - * @author Greg Luck - * @version $Id: CacheLoaderFactory.java 10789 2018-04-26 02:08:13Z adahanne $ - */ -public abstract class CacheLoaderFactory { - - /** - * Creates a CacheLoader using the Ehcache configuration mechanism at the time the associated cache - * is created. - * @param cache a reference to the owning cache, this cache isn't yet initialized nor wired to a particular CacheManager - * @param properties implementation specific properties configured as delimiter - * separated name value pairs in ehcache.xml - * @return a constructed CacheLoader - */ - public abstract CacheLoader createCacheLoader(Ehcache cache, Properties properties); - -} Index: rctags/ehcache-2.10.9.1.33/distribution/colorcache/src/main/webapp/WEB-INF/web.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/distribution/colorcache/src/main/webapp/WEB-INF/web.xml (revision 11516) +++ rctags/ehcache-2.10.9.1.33/distribution/colorcache/src/main/webapp/WEB-INF/web.xml (revision 0) @@ -1,16 +0,0 @@ - - - - - - Web Application: org.terracotta.ColorCache - - Index: rctags/ehcache-2.10.9.1.33/system-tests/src/test/resources/batch-writebehind-test.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/system-tests/src/test/resources/batch-writebehind-test.xml (revision 11516) +++ rctags/ehcache-2.10.9.1.33/system-tests/src/test/resources/batch-writebehind-test.xml (revision 0) @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/hibernate/management/impl/CacheRegionUtils.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/hibernate/management/impl/CacheRegionUtils.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/hibernate/management/impl/CacheRegionUtils.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.hibernate.management.impl; - -import java.awt.Color; - -/** - * CacheRegionUtils - * - * @author gkeim - */ -public abstract class CacheRegionUtils { - /** - * HIT_COLOR - */ - public static final Color HIT_COLOR = Color.green; - - /** - * MISS_COLOR - */ - public static final Color MISS_COLOR = Color.red; - - /** - * PUT_COLOR - */ - public static final Color PUT_COLOR = Color.blue; - - /** - * HIT_FILL_COLOR - */ - public static final Color HIT_FILL_COLOR = CacheRegionUtils.HIT_COLOR.brighter().brighter().brighter(); - - /** - * MISS_FILL_COLOR - */ - public static final Color MISS_FILL_COLOR = CacheRegionUtils.MISS_COLOR.brighter().brighter().brighter(); - - /** - * PUT_FILL_COLOR - */ - public static final Color PUT_FILL_COLOR = CacheRegionUtils.PUT_COLOR.brighter().brighter().brighter(); - - /** - * HIT_DRAW_COLOR - */ - public static final Color HIT_DRAW_COLOR = CacheRegionUtils.HIT_COLOR.darker(); - - /** - * MISS_DRAW_COLOR - */ - public static final Color MISS_DRAW_COLOR = CacheRegionUtils.MISS_COLOR.darker(); - - /** - * PUT_DRAW_COLOR - */ - public static final Color PUT_DRAW_COLOR = CacheRegionUtils.PUT_COLOR.darker(); - - - /** - * determineShortName - * - * @param fullName - */ - public static String determineShortName(String fullName) { - String result = fullName; - - if (fullName != null) { - String[] comps = fullName.split("\\."); - if (comps.length == 1) { - return fullName; - } - boolean truncate = true; - for (int i = 0; i < comps.length; i++) { - String comp = comps[i]; - char c = comp.charAt(0); - if (truncate && Character.isUpperCase(c)) { - truncate = false; - } - if (truncate) { - comps[i] = Character.toString(c); - } - } - result = join(comps, '.'); - } - - return result; - } - - /** - * join - * - * @param elements - * @param c - */ - private static String join(String[] elements, char c) { - if (elements == null) { return null; } - StringBuilder sb = new StringBuilder(); - for (String s : elements) { - sb.append(s).append(c); - } - return sb.length() > 0 ? sb.substring(0, sb.length() - 1) : ""; - } -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/pool/PoolAccessor.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/pool/PoolAccessor.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/pool/PoolAccessor.java (revision 0) @@ -1,123 +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; - -/** - * PoolAccessors are used by stores to tell the pools about their resource consumption - * - * @param Type representing this "other" side of this accessor (i.e. a store), so the evictor can interact with it - * - * @author Ludovic Orban - * @author Alex Snaps - * - */ -public interface PoolAccessor { - - /** - * Add an element to the pool. - * - * @param key the key of the element - * @param value the value of the element - * @param container the element-container object - * @param force true if the pool should accept adding the element, even if it's out of resources - * @return how many bytes have been added to the pool or -1 if add failed. - */ - long add(Object key, Object value, Object container, boolean force); - - /** - * Check if there is enough room in the pool to add an element without provoking any eviction - * @param key the key of the element - * @param value the value of the element - * @param container the element-container object - * @return true if there is enough room left - */ - boolean canAddWithoutEvicting(Object key, Object value, Object container); - - /** - * Delete a fixed number of bytes from the pool. - * - * @param size number of bytes - * @return how many bytes have been freed from the pool. - * @throws IllegalArgumentException when sizeOf is negative - */ - long delete(long size) throws IllegalArgumentException; - - /** - * Delete a fixed number of bytes from the pool with the given objects. - * - * @param currentSize the size of the object(s) being replaced - * @param key the key of the element - * @param value the value of the element - * @param container the element-container object - * @param force true if the pool should accept replacing the element, even if it's out of resources - * @return the change in size of the pool, or {@link Long#MIN_VALUE} if replace failed. - */ - long replace(long currentSize, Object key, Object value, Object container, boolean force); - - /** - * Return how many bytes this accessor consumes from the pool. - * - * @return how many bytes this accessor consumes from the pool. - */ - long getSize(); - - /** - * unlink this PoolAccessor from its pool. - */ - void unlink(); - - /** - * Free resources used by this accessor. - */ - void clear(); - - /** - * Return the store that uses this accessor - * - * @return store using this accessor - */ - T getParticipant(); - - /** - * Sets the max size for this pool - * - * @param newValue the value in bytes - */ - void setMaxSize(long newValue); - - /** - * Returns the occupied size for this pool. - * - * @return occupied pool size - */ - long getPoolOccupancy(); - - /** - * Returns the size of this pool. - * - * @return pool size - */ - long getPoolSize(); - - /** - * Check if the store may contain elements which the SizeOf engine could not fully size. - * - * @return true if the store may contain partially sized objects - */ - boolean hasAbortedSizeOf(); - -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/distribution/ManualRMIPeerProviderIT.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/distribution/ManualRMIPeerProviderIT.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/distribution/ManualRMIPeerProviderIT.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.distribution; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.TimeUnit; - -import net.sf.ehcache.CacheManager; -import net.sf.ehcache.config.Configuration; -import net.sf.ehcache.config.FactoryConfiguration; - -import org.junit.Before; - -import static net.sf.ehcache.distribution.AbstractRMITest.createAsynchronousCache; - -/** - * @author Greg Luck - * @version $Id: ManualRMIPeerProviderIT.java 8870 2014-04-03 20:27:43Z cdennis $ - */ -public class ManualRMIPeerProviderIT extends MulticastRMIPeerProviderIT { - - /** - * {@inheritDoc} - */ - @Override - @Before - public void setUp() throws Exception { - List configurations = new ArrayList(); - configurations.add(new Configuration() - .cacheManagerPeerListenerFactory(new FactoryConfiguration() - .className("net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory") - .properties("hostName=localhost, port=5011, socketTimeoutMillis=2000")) - .cacheManagerPeerProviderFactory(new FactoryConfiguration() - .className("net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory") - .properties("peerDiscovery=manual,rmiUrls=//localhost:5012/asynchronousCache|//localhost:5013/asynchronousCache")) - .cache(createAsynchronousCache().name("asynchronousCache")) - .name("ManualRMIPeerProviderTest-1")); - - configurations.add(new Configuration() - .cacheManagerPeerListenerFactory(new FactoryConfiguration() - .className("net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory") - .properties("hostName=localhost, port=5012, socketTimeoutMillis=2000")) - .cacheManagerPeerProviderFactory(new FactoryConfiguration() - .className("net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory") - .properties("peerDiscovery=manual,rmiUrls=//localhost:5011/asynchronousCache|//localhost:5013/asynchronousCache")) - .cache(createAsynchronousCache().name("asynchronousCache")) - .name("ManualRMIPeerProviderTest-2")); - - configurations.add(new Configuration() - .cacheManagerPeerListenerFactory(new FactoryConfiguration() - .className("net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory") - .properties("hostName=localhost, port=5013, socketTimeoutMillis=2000")) - .cacheManagerPeerProviderFactory(new FactoryConfiguration() - .className("net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory") - .properties("peerDiscovery=manual")) - .cache(createAsynchronousCache().name("asynchronousCache")) - .name("ManualRMIPeerProviderTest-3")); - - List managers = startupManagers(configurations); - manager1 = managers.get(0); - manager2 = managers.get(1); - manager3 = managers.get(2); - - /* manager3 has an empty manual configuration, which is topped up by adding manual entries. - * The sampleCache1 from manager3 is added to the rmiUrls list for manager1 and manager2 - */ - CacheManagerPeerProvider peerProvider = manager3.getCacheManagerPeerProvider("RMI"); - peerProvider.registerPeer("//localhost:5011/asynchronousCache"); - peerProvider.registerPeer("//localhost:5012/asynchronousCache"); - - //Allow cluster setup - waitForClusterMembership(10, TimeUnit.SECONDS, manager1, manager2, manager3); - } -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/config/generator/model/elements/ConfigurationElement.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/config/generator/model/elements/ConfigurationElement.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/config/generator/model/elements/ConfigurationElement.java (revision 0) @@ -1,197 +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.generator.model.elements; - -import java.util.List; - -import net.sf.ehcache.CacheManager; -import net.sf.ehcache.Ehcache; -import net.sf.ehcache.config.CacheConfiguration; -import net.sf.ehcache.config.Configuration; -import net.sf.ehcache.config.DiskStoreConfiguration; -import net.sf.ehcache.config.FactoryConfiguration; -import net.sf.ehcache.config.ManagementRESTServiceConfiguration; -import net.sf.ehcache.config.SizeOfPolicyConfiguration; -import net.sf.ehcache.config.TerracottaClientConfiguration; -import net.sf.ehcache.config.generator.model.SimpleNodeAttribute; -import net.sf.ehcache.config.generator.model.SimpleNodeElement; - -/** - * Element representing the {@link Configuration}. This element does not have a parent and is always null. - * - * @author Abhishek Sanoujam - * - */ -public class ConfigurationElement extends SimpleNodeElement { - - private final CacheManager cacheManager; - private final Configuration configuration; - - /** - * Constructor accepting the {@link Configuration}. This element does not have a parent and is always null. - * - * @param configuration - */ - public ConfigurationElement(Configuration configuration) { - super(null, "ehcache"); - this.cacheManager = null; - this.configuration = configuration; - init(); - } - - /** - * Constructor accepting the {@link CacheManager}. This element does not have a parent and is always null. - * - * @param cacheManager - */ - public ConfigurationElement(CacheManager cacheManager) { - super(null, "ehcache"); - this.cacheManager = cacheManager; - this.configuration = cacheManager.getConfiguration(); - init(); - } - - private void init() { - if (configuration == null) { - return; - } - // add the attributes - addAttribute(new SimpleNodeAttribute("name", configuration.getName()).optional(true)); - addAttribute(new SimpleNodeAttribute("monitoring", configuration.getMonitoring()).optional(true).defaultValue( - Configuration.DEFAULT_MONITORING.name().toLowerCase())); - addAttribute(new SimpleNodeAttribute("dynamicConfig", configuration.getDynamicConfig()).optional(true).defaultValue( - String.valueOf(Configuration.DEFAULT_DYNAMIC_CONFIG))); - addAttribute(new SimpleNodeAttribute("defaultTransactionTimeoutInSeconds", configuration.getDefaultTransactionTimeoutInSeconds()) - .optional(true).defaultValue(String.valueOf(Configuration.DEFAULT_TRANSACTION_TIMEOUT))); - testAddMaxBytesLocalHeapAttribute(); - testAddMaxBytesLocalOffHeapAttribute(); - testAddMaxBytesLocalDiskAttribute(); - - // add the child elements - testAddDiskStoreElement(); - testAddSizeOfPolicyElement(); - testAddTransactionManagerLookupElement(); - testAddManagementRESTService(); - testAddCacheManagerEventListenerFactoryElement(); - testAddCacheManagerPeerProviderFactoryElement(); - testAddCacheManagerPeerListenerFactoryElement(); - - addChildElement(new DefaultCacheConfigurationElement(this, configuration, configuration.getDefaultCacheConfiguration())); - - if (cacheManager != null) { - for (String cacheName : cacheManager.getCacheNames()) { - boolean decoratedCache = false; - Ehcache cache = cacheManager.getCache(cacheName); - if (cache == null) { - cache = cacheManager.getEhcache(cacheName); - decoratedCache = true; - } - CacheConfiguration config = decoratedCache ? cache.getCacheConfiguration().clone().name(cacheName) : cache.getCacheConfiguration(); - addChildElement(new CacheConfigurationElement(this, configuration, config)); - } - } else { - for (CacheConfiguration cacheConfiguration : configuration.getCacheConfigurations().values()) { - addChildElement(new CacheConfigurationElement(this, configuration, cacheConfiguration)); - } - } - - testAddTerracottaElement(); - } - - private void testAddMaxBytesLocalHeapAttribute() { - if (configuration.getMaxBytesLocalHeap() > 0) { - addAttribute(new SimpleNodeAttribute("maxBytesLocalHeap", configuration.getMaxBytesLocalHeapAsString()) - .optional(true).defaultValue(String.valueOf(Configuration.DEFAULT_MAX_BYTES_ON_HEAP))); - } - } - - private void testAddMaxBytesLocalOffHeapAttribute() { - if (configuration.getMaxBytesLocalOffHeap() > 0) { - addAttribute(new SimpleNodeAttribute("maxBytesLocalOffHeap", configuration.getMaxBytesLocalOffHeapAsString()) - .optional(true).defaultValue(String.valueOf(Configuration.DEFAULT_MAX_BYTES_OFF_HEAP))); - } - } - - private void testAddMaxBytesLocalDiskAttribute() { - if (configuration.getMaxBytesLocalDisk() > 0) { - addAttribute(new SimpleNodeAttribute("maxBytesLocalDisk", configuration.getMaxBytesLocalDiskAsString()) - .optional(true).defaultValue(String.valueOf(Configuration.DEFAULT_MAX_BYTES_ON_DISK))); - } - } - - private void testAddDiskStoreElement() { - DiskStoreConfiguration diskStoreConfiguration = configuration.getDiskStoreConfiguration(); - if (diskStoreConfiguration != null) { - addChildElement(new DiskStoreConfigurationElement(this, diskStoreConfiguration)); - } - } - - private void testAddSizeOfPolicyElement() { - SizeOfPolicyConfiguration sizeOfPolicyConfiguration = configuration.getSizeOfPolicyConfiguration(); - if (sizeOfPolicyConfiguration != null && - !Configuration.DEFAULT_SIZEOF_POLICY_CONFIGURATION.equals(sizeOfPolicyConfiguration)) { - addChildElement(new SizeOfPolicyConfigurationElement(this, sizeOfPolicyConfiguration)); - } - } - - private void testAddTransactionManagerLookupElement() { - FactoryConfiguration transactionManagerLookupConfiguration = configuration.getTransactionManagerLookupConfiguration(); - if (transactionManagerLookupConfiguration != null - && !transactionManagerLookupConfiguration.equals(Configuration.DEFAULT_TRANSACTION_MANAGER_LOOKUP_CONFIG)) { - addChildElement(new FactoryConfigurationElement(this, "transactionManagerLookup", transactionManagerLookupConfiguration)); - } - } - - private void testAddManagementRESTService() { - ManagementRESTServiceConfiguration managementRESTServiceConfiguration = configuration.getManagementRESTService(); - if (managementRESTServiceConfiguration != null) { - addChildElement(new ManagementRESTServiceConfigurationElement(this, managementRESTServiceConfiguration)); - } - } - - private void testAddCacheManagerEventListenerFactoryElement() { - FactoryConfiguration cacheManagerEventListenerFactoryConfiguration = configuration - .getCacheManagerEventListenerFactoryConfiguration(); - if (cacheManagerEventListenerFactoryConfiguration != null) { - addChildElement(new FactoryConfigurationElement(this, "cacheManagerEventListenerFactory", - cacheManagerEventListenerFactoryConfiguration)); - } - } - - private void testAddCacheManagerPeerProviderFactoryElement() { - List cacheManagerPeerProviderFactoryConfiguration = configuration - .getCacheManagerPeerProviderFactoryConfiguration(); - if (cacheManagerPeerProviderFactoryConfiguration != null) { - addAllFactoryConfigsAsChildElements(this, "cacheManagerPeerProviderFactory", cacheManagerPeerProviderFactoryConfiguration); - } - } - - private void testAddCacheManagerPeerListenerFactoryElement() { - List cacheManagerPeerListenerFactoryConfigurations = configuration - .getCacheManagerPeerListenerFactoryConfigurations(); - if (cacheManagerPeerListenerFactoryConfigurations != null && !cacheManagerPeerListenerFactoryConfigurations.isEmpty()) { - addAllFactoryConfigsAsChildElements(this, "cacheManagerPeerListenerFactory", cacheManagerPeerListenerFactoryConfigurations); - } - } - - private void testAddTerracottaElement() { - TerracottaClientConfiguration terracottaConfiguration = configuration.getTerracottaConfiguration(); - if (terracottaConfiguration != null) { - addChildElement(new TerracottaConfigConfigurationElement(this, terracottaConfiguration)); - } - } -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/exceptionhandler/CountingExceptionHandler.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/exceptionhandler/CountingExceptionHandler.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/exceptionhandler/CountingExceptionHandler.java (revision 0) @@ -1,95 +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.exceptionhandler; - -import net.sf.ehcache.Ehcache; - -import java.util.ArrayList; -import java.util.List; - -/** - * A test handler, used to test the Exception handling mechanism - * - * @author Greg Luck - * @version $Id: CountingExceptionHandler.java 5594 2012-05-07 16:04:31Z cdennis $ - */ -public class CountingExceptionHandler implements CacheExceptionHandler { - - /** - * the list of handled exceptions, static so you can get them without a reference - */ - public static final List HANDLED_EXCEPTIONS = new ArrayList(); - - /** - * Called if an Exception occurs in a Cache method. This method is not called - * if an Error occurs. - * - * @param ehcache the cache in which the Exception occurred - * @param key the key used in the operation, or null if the operation does not use a key - * @param exception the exception caught - */ - public void onException(Ehcache ehcache, Object key, Exception exception) { - - HandledException handledException = new HandledException(ehcache, key, exception); - HANDLED_EXCEPTIONS.add(handledException); - } - - /** - * Clear counter - */ - public static void resetCounters() { - HANDLED_EXCEPTIONS.clear(); - } - - /** - * A value object for each exception handled - */ - public static class HandledException { - private final Ehcache ehcache; - private final Object key; - private final Exception exception; - - /** - * Constructor - * - * @param ehcache - * @param key - * @param exception - */ - public HandledException(Ehcache ehcache, Object key, Exception exception) { - this.ehcache = ehcache; - this.key = key; - this.exception = exception; - } - - /** - * @return - */ - public Object getKey() { - return key; - } - - /** - * @return underlying exception - */ - public Exception getException() { - return exception; - } - } - - -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/event/CacheEventListenerFactory.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/event/CacheEventListenerFactory.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/event/CacheEventListenerFactory.java (revision 0) @@ -1,39 +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 java.util.Properties; - -/** - * An abstract factory for creating listeners. Implementers should provide their own - * concrete factory extending this factory. It can then be configured in ehcache.xml. - * - * @author Greg Luck - * @version $Id: CacheEventListenerFactory.java 5594 2012-05-07 16:04:31Z cdennis $ - */ -public abstract class CacheEventListenerFactory { - - /** - * Create a CacheEventListener - * - * @param properties implementation specific properties. These are configured as comma - * separated name value pairs in ehcache.xml - * @return a constructed CacheEventListener - */ - public abstract CacheEventListener createCacheEventListener(Properties properties); - -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/util/ClassLoaderUtil.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/util/ClassLoaderUtil.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/util/ClassLoaderUtil.java (revision 0) @@ -1,98 +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.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; - -import net.sf.ehcache.CacheException; - -/** - * Keeps all classloading in ehcache consistent. - * - * @author Greg Luck - * @version $Id: ClassLoaderUtil.java 8764 2014-02-18 23:08:43Z teck $ - */ -public final class ClassLoaderUtil { - - /** - * Utility class. - */ - private ClassLoaderUtil() { - //noop - } - - /** - * Creates a new class instance with the given loader. Logs errors along the way. - * - * @param loader the classloader to load the class - * @param className a fully qualified class name - * @return the newly created instance - * @throws CacheException if instance cannot be created due to a missing class or exception - */ - public static Object createNewInstance(ClassLoader loader, String className) throws CacheException { - return createNewInstance(loader, className, new Class[0], new Object[0]); - } - - /** - * Creates a new class instance and passes args to the constructor call. Logs errors along the way. - * - * @param loader the classloader to load the class - * @param className a fully qualified class name - * @param argTypes Types for constructor argument parameters - * @param args Values for constructor argument parameters - * @return the newly created instance - * @throws CacheException if instance cannot be created due to a missing class or exception - */ - public static Object createNewInstance(ClassLoader loader, String className, Class[] argTypes, Object[] args) throws CacheException { - Class clazz; - Object newInstance; - try { - clazz = loader.loadClass(className); - } catch (ClassNotFoundException e) { - throw new CacheException("Unable to load class " + className + - ". Initial cause was " + e.getMessage(), e); - } - - try { - Constructor constructor = clazz.getConstructor(argTypes); - newInstance = constructor.newInstance(args); - } catch (IllegalAccessException e) { - throw new CacheException("Unable to load class " + className + - ". Initial cause was " + e.getMessage(), e); - } catch (InstantiationException e) { - throw new CacheException("Unable to load class " + className + - ". Initial cause was " + e.getMessage(), e); - } catch (NoSuchMethodException e) { - throw new CacheException("Unable to load class " + className + - ". Initial cause was " + e.getMessage(), e); - } catch (SecurityException e) { - throw new CacheException("Unable to load class " + className + - ". Initial cause was " + e.getMessage(), e); - } catch (IllegalArgumentException e) { - throw new CacheException("Unable to load class " + className + - ". Initial cause was " + e.getMessage(), e); - } catch (InvocationTargetException e) { - throw new CacheException("Unable to load class " + className + - ". Initial cause was " + e.getCause().getMessage(), e.getCause()); - } - return newInstance; - } - - - -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/constructs/CacheDecoratorFactoryTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/constructs/CacheDecoratorFactoryTest.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/constructs/CacheDecoratorFactoryTest.java (revision 0) @@ -1,99 +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 org.junit.Test; -import org.junit.experimental.categories.Category; - -import junit.framework.TestCase; -import net.sf.ehcache.CacheManager; -import net.sf.ehcache.constructs.MockDecoratorFactory.MockDecoratorFactoryCache; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.terracotta.test.categories.CheckShorts; - -/** - * @author Abhishek Sanoujam - */ -@Category(CheckShorts.class) -public class CacheDecoratorFactoryTest extends TestCase { - - private static final Logger LOG = LoggerFactory.getLogger(CacheDecoratorFactoryTest.class); - - @Test - public void testCacheDecoratorFactory() { - CacheManager cacheManager = new CacheManager(getClass().getResourceAsStream("/ehcache-decorator-test.xml")); - List cacheNames = Arrays.asList(cacheManager.getCacheNames()); - LOG.info("" + cacheNames); - - assertEquals(12, cacheNames.size()); - - assertTrue(cacheNames.contains("noDecoratorCache")); - assertTrue(cacheNames.contains("oneDecoratorCache")); - assertTrue(cacheNames.contains("oneDecoratorFirst")); - assertTrue(cacheNames.contains("twoDecoratorCache")); - assertTrue(cacheNames.contains("twoDecoratorFirst")); - assertTrue(cacheNames.contains("twoDecoratorSecond")); - assertTrue(cacheNames.contains("fiveDecoratorCache")); - assertTrue(cacheNames.contains("fiveDecoratorFirst")); - assertTrue(cacheNames.contains("fiveDecoratorSecond")); - assertTrue(cacheNames.contains("fiveDecoratorThird")); - assertTrue(cacheNames.contains("fiveDecoratorFourth")); - assertTrue(cacheNames.contains("fiveDecoratorFifth")); - - cacheManager.shutdown(); - - } - - @Test - public void testCacheDecoratorFactoryProperties() { - CacheManager cacheManager = new CacheManager(getClass().getResourceAsStream("/ehcache-decorator-test.xml")); - List cacheNames = Arrays.asList(cacheManager.getCacheNames()); - assertEquals(12, cacheNames.size()); - - MockDecoratorFactoryCache cache = (MockDecoratorFactoryCache) cacheManager.getEhcache("oneDecoratorFirst"); - assertEquals("oneFirst", cache.getProperties().getProperty("someKey")); - - cache = (MockDecoratorFactoryCache) cacheManager.getEhcache("twoDecoratorFirst"); - assertEquals("twoFirst", cache.getProperties().getProperty("someKey")); - - cache = (MockDecoratorFactoryCache) cacheManager.getEhcache("twoDecoratorSecond"); - assertEquals("twoSecond", cache.getProperties().getProperty("someKey")); - - cache = (MockDecoratorFactoryCache) cacheManager.getEhcache("fiveDecoratorFirst"); - assertEquals("fiveFirst", cache.getProperties().getProperty("someKey")); - - cache = (MockDecoratorFactoryCache) cacheManager.getEhcache("fiveDecoratorSecond"); - assertEquals("fiveSecond", cache.getProperties().getProperty("someKey")); - - cache = (MockDecoratorFactoryCache) cacheManager.getEhcache("fiveDecoratorThird"); - assertEquals("fiveThird", cache.getProperties().getProperty("someKey")); - - cache = (MockDecoratorFactoryCache) cacheManager.getEhcache("fiveDecoratorFourth"); - assertEquals("fiveFourth", cache.getProperties().getProperty("someKey")); - - cache = (MockDecoratorFactoryCache) cacheManager.getEhcache("fiveDecoratorFifth"); - assertEquals("fiveFifth", cache.getProperties().getProperty("someKey")); - - cacheManager.shutdown(); - - } -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/management/sampled/CacheSamplerImpl.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/management/sampled/CacheSamplerImpl.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/management/sampled/CacheSamplerImpl.java (revision 0) @@ -1,2134 +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.CacheOperationOutcomes; -import net.sf.ehcache.CacheOperationOutcomes.ClusterEventOutcomes; -import net.sf.ehcache.CacheOperationOutcomes.NonStopOperationOutcomes; -import net.sf.ehcache.CacheStoreHelper; -import net.sf.ehcache.Ehcache; -import net.sf.ehcache.config.CacheConfiguration; -import net.sf.ehcache.config.CacheConfigurationListener; -import net.sf.ehcache.config.PersistenceConfiguration; -import net.sf.ehcache.config.PinningConfiguration; -import net.sf.ehcache.config.SearchAttribute; -import net.sf.ehcache.config.TerracottaConfiguration.Consistency; -import net.sf.ehcache.search.Attribute; -import net.sf.ehcache.store.Store; -import net.sf.ehcache.store.TerracottaStore; -import net.sf.ehcache.util.CacheTransactionHelper; -import net.sf.ehcache.util.counter.sampled.SampledCounter; -import net.sf.ehcache.util.counter.sampled.SampledRateCounter; -import net.sf.ehcache.util.counter.sampled.TimeStampedCounterValue; -import net.sf.ehcache.writer.writebehind.WriteBehindManager; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.terracotta.statistics.archive.Timestamped; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; - -/** - * An implementation of {@link CacheSampler} - * - * @author Abhishek Sanoujam - * @author byoukste - * - * There is stupid here -- *Sample() is the same as *Rate() - */ -public class CacheSamplerImpl implements CacheSampler, CacheConfigurationListener { - private static final double ONE_HUNDRED = 100.0d; - - private static final int PERCENTAGE_DIVISOR = 100; - - private static final Logger LOG = LoggerFactory.getLogger(CacheSamplerImpl.class); - - private final Ehcache cache; - - /** - * Constructor accepting the backing {@link Ehcache} - * - * @param cache the cache object to use in initializing this sampled representation - */ - public CacheSamplerImpl(Ehcache cache) { - this.cache = cache; - cache.getCacheConfiguration().addConfigurationListener(this); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean isEnabled() { - return !cache.isDisabled(); - } - - /** - * {@inheritDoc} - */ - @Override - public void setEnabled(boolean enabled) { - try { - cache.setDisabled(!enabled); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - - /** - * {@inheritDoc} - */ - @Override - public boolean isClusterBulkLoadEnabled() { - try { - return cache.isClusterBulkLoadEnabled(); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - - /** - * {@inheritDoc} - */ - @Override - public boolean isNodeBulkLoadEnabled() { - return cache.getCacheConfiguration().isTerracottaClustered() && cache.isNodeBulkLoadEnabled(); - } - - /** - * {@inheritDoc} - */ - @Override - public void setNodeBulkLoadEnabled(boolean bulkLoadEnabled) { - if (bulkLoadEnabled && getTransactional()) { - LOG.warn("a transactional cache cannot be put into bulk-load mode"); - return; - } - cache.setNodeBulkLoadEnabled(bulkLoadEnabled); - } - - /** - * {@inheritDoc} - */ - @Override - public void flush() { - try { - cache.flush(); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - - /** - * {@inheritDoc} - */ - @Override - public String getCacheName() { - return cache.getName(); - } - - /** - * {@inheritDoc} - */ - @Override - public String getStatus() { - return cache.getStatus().toString(); - } - - /** - * {@inheritDoc} - */ - @Override - public void removeAll() { - if (cache instanceof Cache) { - Store store = new CacheStoreHelper((Cache)cache).getStore(); - if (store instanceof TerracottaStore) { - ((TerracottaStore)store).quickClear(); - cache.getCacheEventNotificationService().notifyRemoveAll(false); - PinningConfiguration pinningConfiguration = cache.getCacheConfiguration().getPinningConfiguration(); - if (pinningConfiguration != null && PinningConfiguration.Store.INCACHE.equals(pinningConfiguration.getStore())) { - LOG.warn("Data availability impacted:\n" + - "****************************************************************************************\n" + - "************************** removeAll called on a pinned cache **************************\n" + - "****************************************************************************************"); - } - return; - } - } - - CacheTransactionHelper.beginTransactionIfNeeded(cache); - try { - cache.removeAll(); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } finally { - try { - CacheTransactionHelper.commitTransactionIfNeeded(cache); - } catch (RuntimeException e2) { - throw Utils.newPlainException(e2); - } - } - } - - /** - * {@inheritDoc} - */ - @Override - public long getAverageGetTimeNanosMostRecentSample() { - return getAverageGetTimeNanos(); - } - - /** - * {@inheritDoc} - */ - @Override - public long getCacheEvictionRate() { - return cache.getStatistics().cacheEvictionOperation().rate().value().longValue(); - } - - /** - * {@inheritDoc} - */ - @Override - public long getCacheElementEvictedMostRecentSample() { - return getCacheEvictionRate(); - } - - /** - * {@inheritDoc} - */ - @Override - public long getCacheExpirationRate() { - return cache.getStatistics().cacheExpiredOperation().rate().value().longValue(); - } - - /** - * {@inheritDoc} - */ - @Override - public long getCacheElementExpiredMostRecentSample() { - return getCacheExpirationRate(); - } - - /** - * {@inheritDoc} - */ - @Override - public long getCachePutRate() { - return cache.getStatistics().cachePutOperation().rate().value().longValue(); - } - - /** - * {@inheritDoc} - */ - @Override - public long getCacheElementPutMostRecentSample() { - return getCachePutRate(); - } - - /** - * {@inheritDoc} - */ - @Override - public long getCacheRemoveRate() { - return cache.getStatistics().cacheRemoveOperation().rate().value().longValue(); - } - - /** - * {@inheritDoc} - */ - @Override - public long getCacheElementRemovedMostRecentSample() { - return getCacheRemoveRate(); - } - - /** - * {@inheritDoc} - */ - @Override - public long getCacheUpdateRate() { - return cache.getStatistics().cachePutReplacedOperation().rate().value().longValue(); - } - - /** - * {@inheritDoc} - */ - @Override - public long getCacheElementUpdatedMostRecentSample() { - return getCacheUpdateRate(); - } - - /** - * {@inheritDoc} - */ - @Override - public long getCacheInMemoryHitRate() { - return cache.getStatistics().localHeapHitOperation().rate().value().longValue(); - } - - /** - * {@inheritDoc} - */ - @Override - public long getCacheHitInMemoryMostRecentSample() { - return getCacheInMemoryHitRate(); - } - - /** - * {@inheritDoc} - */ - @Override - public long getCacheOffHeapHitRate() { - return cache.getStatistics().localOffHeapHitOperation().rate().value().longValue(); - } - - /** - * {@inheritDoc} - */ - @Override - public long getCacheHitOffHeapMostRecentSample() { - return getCacheOffHeapHitRate(); - } - - /** - * {@inheritDoc} - */ - @Override - public long getCacheHitRate() { - return cache.getStatistics().cacheHitOperation().rate().value().longValue(); - } - - /** - * {@inheritDoc} - */ - @Override - public long getCacheHitMostRecentSample() { - return getCacheHitRate(); - } - - /** - * {@inheritDoc} - */ - @Override - public long getCacheOnDiskHitRate() { - return cache.getStatistics().localDiskHitOperation().rate().value().longValue(); - } - - /** - * {@inheritDoc} - */ - @Override - public long getCacheHitOnDiskMostRecentSample() { - return getCacheOnDiskHitRate(); - } - - /** - * {@inheritDoc} - */ - @Override - public long getCacheMissExpiredMostRecentSample() { - return cache.getStatistics().cacheMissExpiredOperation().rate().value().longValue(); - } - - /** - * {@inheritDoc} - */ - @Override - public long getCacheMissRate() { - return cache.getStatistics().cacheMissOperation().rate().value().longValue(); - } - - /** - * {@inheritDoc} - */ - @Override - public long getCacheMissMostRecentSample() { - return getCacheMissRate(); - } - - /** - * {@inheritDoc} - */ - @Override - public long getCacheInMemoryMissRate() { - return cache.getStatistics().localHeapMissOperation().rate().value().longValue(); - } - - /** - * {@inheritDoc} - */ - @Override - public long getCacheMissInMemoryMostRecentSample() { - return getCacheInMemoryMissRate(); - } - - /** - * {@inheritDoc} - */ - @Override - public long getCacheOffHeapMissRate() { - return cache.getStatistics().localOffHeapMissOperation().rate().value().longValue(); - } - - /** - * {@inheritDoc} - */ - @Override - public long getCacheMissOffHeapMostRecentSample() { - return getCacheOffHeapMissRate(); - } - - /** - * {@inheritDoc} - */ - @Override - public long getCacheOnDiskMissRate() { - return cache.getStatistics().localDiskMissOperation().rate().value().longValue(); - } - - /** - * {@inheritDoc} - */ - @Override - public long getCacheMissOnDiskMostRecentSample() { - return getCacheOnDiskMissRate(); - } - - /** - * {@inheritDoc} - */ - @Override - public long getCacheMissNotFoundMostRecentSample() { - return cache.getStatistics().cacheMissNotFoundOperation().rate().value().longValue(); - } - - /** - * {@inheritDoc} - */ - @Override - public void dispose() { - cache.getCacheConfiguration().removeConfigurationListener(this); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean isTerracottaClustered() { - return this.cache.getCacheConfiguration().isTerracottaClustered(); - } - - /** - * {@inheritDoc} - */ - @Override - public String getTerracottaConsistency() { - Consistency consistency = this.cache.getCacheConfiguration().getTerracottaConsistency(); - return consistency != null ? consistency.name() : "na"; - } - - /** - * {@inheritDoc} - */ - @Override - public long getAverageGetTime() { - try { - return cache.getStatistics().cacheGetOperation().latency().average().value().longValue(); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - - /** - * {@inheritDoc} - */ - @Override - public Long getMaxGetTimeNanos() { - try { - return (Long)cache.getStatistics().cacheGetOperation().latency().maximum().value(); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - - /** - * {@inheritDoc} - */ - @Override - public Long getMinGetTimeNanos() { - try { - return (Long)cache.getStatistics().cacheGetOperation().latency().minimum().value(); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - - /** - * {@inheritDoc} - */ - @Override - public long getXaCommitCount() { - try { - return cache.getStatistics().xaCommitCount(); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - - /** - * {@inheritDoc} - */ - @Override - public long getXaRollbackCount() { - try { - return cache.getStatistics().xaRollbackCount(); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - - /** - * {@inheritDoc} - */ - @Override - public long getXaRecoveredCount() { - try { - return cache.getStatistics().xaRecoveryCount(); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - - /** - * {@inheritDoc} - */ - @Override - public boolean getHasWriteBehindWriter() { - return cache.getWriterManager() instanceof WriteBehindManager && cache.getRegisteredCacheWriter() != null; - } - - /** - * {@inheritDoc} - */ - @Override - public long getWriterQueueLength() { - try { - return cache.getStatistics().getWriterQueueLength(); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - - /** - * {@inheritDoc} - */ - @Override - public int getWriterMaxQueueSize() { - return cache.getCacheConfiguration().getCacheWriterConfiguration().getWriteBehindMaxQueueSize(); - } - - /** - * {@inheritDoc} - */ - @Override - public int getWriterConcurrency() { - return cache.getCacheConfiguration().getCacheWriterConfiguration().getWriteBehindConcurrency(); - } - - /** - * {@inheritDoc} - */ - @Override - public long getCacheHitCount() { - try { - return cache.getStatistics().cacheHitCount(); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - - /** - * {@inheritDoc} - */ - @Override - public long getCacheMissCount() { - try { - return cache.getStatistics().cacheMissCount(); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - - /** - * {@inheritDoc} - */ - @Override - public long getInMemoryMissCount() { - try { - return cache.getStatistics().localHeapMissCount(); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - - /** - * {@inheritDoc} - */ - @Override - public long getOffHeapMissCount() { - try { - return cache.getStatistics().localOffHeapMissCount(); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - - /** - * {@inheritDoc} - */ - @Override - public long getOnDiskMissCount() { - try { - return cache.getStatistics().localDiskMissCount(); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - - /** - * {@inheritDoc} - */ - @Override - public long getCacheMissCountExpired() { - try { - return cache.getStatistics().cacheMissExpiredCount(); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - - /** - * {@inheritDoc} - */ - @Override - public long getDiskExpiryThreadIntervalSeconds() { - return cache.getCacheConfiguration().getDiskExpiryThreadIntervalSeconds(); - } - - /** - * {@inheritDoc} - */ - @Override - public void setDiskExpiryThreadIntervalSeconds(long seconds) { - if (getDiskExpiryThreadIntervalSeconds() != seconds) { - try { - cache.getCacheConfiguration().setDiskExpiryThreadIntervalSeconds(seconds); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - } - - /** - * {@inheritDoc} - */ - @Override - public long getMaxEntriesLocalHeap() { - return cache.getCacheConfiguration().getMaxEntriesLocalHeap(); - } - - /** - * {@inheritDoc} - */ - @Override - public void setMaxEntriesLocalHeap(long maxEntries) { - if (getMaxEntriesLocalHeap() != maxEntries) { - try { - cache.getCacheConfiguration().setMaxEntriesLocalHeap(maxEntries); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - } - - /** - * {@inheritDoc} - */ - @Override - public long getMaxBytesLocalHeap() { - return cache.getCacheConfiguration().getMaxBytesLocalHeap(); - } - - /** - * {@inheritDoc} - */ - @Override - public void setMaxBytesLocalHeap(long maxBytes) { - try { - if (cache.getCacheManager().getConfiguration().isMaxBytesLocalHeapSet()) { - long heapPoolSize = cache.getCacheManager().getConfiguration().getMaxBytesLocalHeap(); - if (maxBytes > heapPoolSize) { - throw new IllegalArgumentException("Requested maxBytesLocalHeap (" + maxBytes - + ") greater than available CacheManager heap pool size (" + heapPoolSize + ")"); - } - } - cache.getCacheConfiguration().setMaxBytesLocalHeap(maxBytes); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void setMaxBytesLocalHeapAsString(String maxBytes) { - try { - cache.getCacheConfiguration().setMaxBytesLocalHeap(maxBytes); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - - if (cache.getCacheConfiguration().isMaxBytesLocalHeapPercentageSet()) { - long cacheAssignedMem = cache.getCacheManager().getConfiguration().getMaxBytesLocalHeap() - * cache.getCacheConfiguration().getMaxBytesLocalHeapPercentage() / PERCENTAGE_DIVISOR; - setMaxBytesLocalHeap(cacheAssignedMem); - } - - } - - /** - * {@inheritDoc} - */ - @Override - public String getMaxBytesLocalHeapAsString() { - return cache.getCacheConfiguration().getMaxBytesLocalHeapAsString(); - } - - /** - * {@inheritDoc} - */ - @Override - public long getMaxEntriesLocalDisk() { - return cache.getCacheConfiguration().getMaxEntriesLocalDisk(); - } - - /** - * {@inheritDoc} - */ - @Override - public void setMaxEntriesLocalDisk(long maxEntries) { - if (getMaxEntriesLocalDisk() != maxEntries) { - try { - cache.getCacheConfiguration().setMaxEntriesLocalDisk(maxEntries); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - } - - /** - * {@inheritDoc} - */ - @Override - public void setMaxBytesLocalDisk(long maxBytes) { - try { - if (cache.getCacheManager().getConfiguration().isMaxBytesLocalDiskSet()) { - long diskPoolSize = cache.getCacheManager().getConfiguration().getMaxBytesLocalDisk(); - if (maxBytes > diskPoolSize) { - throw new IllegalArgumentException("Requested maxBytesLocalDisk (" + maxBytes - + ") greater than available CacheManager disk pool size (" + diskPoolSize + ")"); - } - } - cache.getCacheConfiguration().setMaxBytesLocalDisk(maxBytes); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void setMaxBytesLocalDiskAsString(String maxBytes) { - try { - cache.getCacheConfiguration().setMaxBytesLocalDisk(maxBytes); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - - if (cache.getCacheConfiguration().isMaxBytesLocalDiskPercentageSet()) { - long cacheAssignedMem = cache.getCacheManager().getConfiguration().getMaxBytesLocalDisk() - * cache.getCacheConfiguration().getMaxBytesLocalDiskPercentage() / PERCENTAGE_DIVISOR; - setMaxBytesLocalDisk(cacheAssignedMem); - } - } - - /** - * {@inheritDoc} - */ - @Override - public String getMaxBytesLocalDiskAsString() { - return cache.getCacheConfiguration().getMaxBytesLocalDiskAsString(); - } - - /** - * {@inheritDoc} - */ - @Override - public int getMaxElementsOnDisk() { - return cache.getCacheConfiguration().getMaxElementsOnDisk(); - } - - /** - * {@inheritDoc} - */ - @Override - public long getMaxEntriesInCache() { - return cache.getCacheConfiguration().getMaxEntriesInCache(); - } - - /** - * {@inheritDoc} - */ - @Override - public void setMaxElementsOnDisk(int maxElements) { - if (getMaxElementsOnDisk() != maxElements) { - try { - cache.getCacheConfiguration().setMaxElementsOnDisk(maxElements); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - } - - /** - * {@inheritDoc} - */ - @Override - public void setMaxEntriesInCache(long maxEntries) { - if (getMaxEntriesInCache() != maxEntries) { - try { - cache.getCacheConfiguration().setMaxEntriesInCache(maxEntries); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - } - - /** - * {@inheritDoc} - */ - @Override - public long getMaxBytesLocalDisk() { - return cache.getCacheConfiguration().getMaxBytesLocalDisk(); - } - - /** - * {@inheritDoc} - */ - @Override - public long getMaxBytesLocalOffHeap() { - return cache.getCacheConfiguration().getMaxBytesLocalOffHeap(); - } - - /** - * {@inheritDoc} - */ - @Override - public String getMaxBytesLocalOffHeapAsString() { - return cache.getCacheConfiguration().getMaxBytesLocalOffHeapAsString(); - } - - /** - * {@inheritDoc} - */ - @Override - public String getMemoryStoreEvictionPolicy() { - return cache.getCacheConfiguration().getMemoryStoreEvictionPolicy().toString(); - } - - /** - * {@inheritDoc} - */ - @Override - public void setMemoryStoreEvictionPolicy(String evictionPolicy) { - if (!getMemoryStoreEvictionPolicy().equals(evictionPolicy)) { - try { - cache.getCacheConfiguration().setMemoryStoreEvictionPolicy(evictionPolicy); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - } - - /** - * {@inheritDoc} - */ - @Override - public long getTimeToIdleSeconds() { - return cache.getCacheConfiguration().getTimeToIdleSeconds(); - } - - /** - * {@inheritDoc} - */ - @Override - public void setTimeToIdleSeconds(long tti) { - if (getTimeToIdleSeconds() != tti) { - try { - cache.getCacheConfiguration().setTimeToIdleSeconds(tti); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - } - - /** - * {@inheritDoc} - */ - @Override - public long getTimeToLiveSeconds() { - return cache.getCacheConfiguration().getTimeToLiveSeconds(); - } - - /** - * {@inheritDoc} - */ - @Override - public void setTimeToLiveSeconds(long ttl) { - if (getTimeToLiveSeconds() != ttl) { - try { - cache.getCacheConfiguration().setTimeToLiveSeconds(ttl); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - } - - /** - * {@inheritDoc} - */ - @Override - public boolean isDiskPersistent() { - return cache.getCacheConfiguration().isDiskPersistent(); - } - - /** - * {@inheritDoc} - */ - @Override - public String getPersistenceStrategy() { - PersistenceConfiguration pc = cache.getCacheConfiguration().getPersistenceConfiguration(); - return pc != null ? pc.getStrategy().name() : ""; - } - - /** - * {@inheritDoc} - */ - @Override - public void setDiskPersistent(boolean diskPersistent) { - if (isDiskPersistent() != diskPersistent) { - try { - cache.getCacheConfiguration().setDiskPersistent(diskPersistent); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - } - - /** - * {@inheritDoc} - */ - @Override - public boolean isOverflowToOffHeap() { - return cache.getCacheConfiguration().isOverflowToOffHeap(); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean isEternal() { - return cache.getCacheConfiguration().isEternal(); - } - - /** - * {@inheritDoc} - */ - @Override - public void setEternal(boolean eternal) { - if (isEternal() != eternal) { - try { - cache.getCacheConfiguration().setEternal(eternal); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - } - - /** - * {@inheritDoc} - */ - @Override - public boolean isOverflowToDisk() { - return cache.getCacheConfiguration().isOverflowToDisk(); - } - - /** - * {@inheritDoc} - */ - @Override - public void setOverflowToDisk(boolean overflowToDisk) { - if (isOverflowToDisk() != overflowToDisk) { - try { - cache.getCacheConfiguration().setOverflowToDisk(overflowToDisk); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - } - - /** - * {@inheritDoc} - */ - @Override - public boolean isLoggingEnabled() { - return cache.getCacheConfiguration().getLogging(); - } - - /** - * {@inheritDoc} - */ - @Override - public void setLoggingEnabled(boolean enabled) { - if (isLoggingEnabled() != enabled) { - try { - cache.getCacheConfiguration().setLogging(enabled); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - } - - /** - * {@inheritDoc} - */ - @Override - public boolean isPinned() { - return cache.getCacheConfiguration().getPinningConfiguration() != null; - } - - /** - * {@inheritDoc} - */ - @Override - public String getPinnedToStore() { - PinningConfiguration pinningConfig = cache.getCacheConfiguration().getPinningConfiguration(); - return pinningConfig != null ? pinningConfig.getStore().name() : "na"; - } - - /** - * {@inheritDoc} - */ - @Override - public long getEvictedCount() { - try { - return cache.getStatistics().cacheEvictedCount(); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - - /** - * {@inheritDoc} - */ - @Override - public long getExpiredCount() { - try { - return cache.getStatistics().cacheExpiredCount(); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - - /** - * {@inheritDoc} - */ - @Override - public long getInMemoryHitCount() { - try { - return cache.getStatistics().localHeapHitCount(); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - - /** - * {@inheritDoc} - */ - @Override - public long getOffHeapHitCount() { - try { - return cache.getStatistics().localOffHeapHitCount(); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - - /** - * {@inheritDoc} - * - * @deprecated use {@link #getLocalOffHeapSize()} - */ - @Deprecated - @Override - public long getOffHeapSize() { - return getLocalOffHeapSize(); - } - - /** - * {@inheritDoc} - */ - @Override - public long getOnDiskHitCount() { - try { - return cache.getStatistics().localDiskHitCount(); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - - /** - * {@inheritDoc} - * - * @deprecated use {@link #getLocalDiskSize()} - */ - @Deprecated - @Override - public long getOnDiskSize() { - return getLocalDiskSize(); - } - - /** - * {@inheritDoc} - */ - @Override - public long getLocalDiskSize() { - try { - return cache.getStatistics().getLocalDiskSize(); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - - /** - * {@inheritDoc} - */ - @Override - public long getLocalHeapSize() { - try { - return cache.getStatistics().getLocalHeapSize(); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - - /** - * {@inheritDoc} - */ - @Override - public long getLocalOffHeapSize() { - try { - return cache.getStatistics().getLocalOffHeapSize(); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - - /** - * {@inheritDoc} - */ - @Override - public long getLocalDiskSizeInBytes() { - try { - return cache.getStatistics().getLocalDiskSizeInBytes(); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - - /** - * {@inheritDoc} - */ - @Override - public long getLocalHeapSizeInBytes() { - try { - return cache.getStatistics().getLocalHeapSizeInBytes(); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - - /** - * {@inheritDoc} - */ - @Override - public long getLocalOffHeapSizeInBytes() { - try { - return cache.getStatistics().getLocalOffHeapSizeInBytes(); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - - /** - * {@inheritDoc} - */ - @Override - public long getPutCount() { - try { - return cache.getStatistics().cachePutCount(); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - - /** - * {@inheritDoc} - */ - @Override - public long getRemovedCount() { - try { - return cache.getStatistics().cacheRemoveCount(); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - - /** - * {@inheritDoc} - */ - @Override - public long getSize() { - if (cache.getCacheConfiguration().isTerracottaClustered()) { - return getRemoteSizeSample().getMostRecentSample().getCounterValue(); - } - CacheTransactionHelper.beginTransactionIfNeeded(cache); - try { - return cache.getStatistics().getSize(); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } finally { - try { - CacheTransactionHelper.commitTransactionIfNeeded(cache); - } catch (RuntimeException re) { - throw Utils.newPlainException(re); - } - } - } - - /** - * {@inheritDoc} - */ - @Override - public long getInMemorySize() { - return getLocalHeapSize(); - } - - /** - * {@inheritDoc} - */ - @Override - public long getUpdateCount() { - try { - return cache.getStatistics().cachePutUpdatedCount(); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - - @Override - public long getReplaceOneArgSuccessCount() { - try { - return cache.getStatistics().getExtended().replaceOneArg().component(CacheOperationOutcomes.ReplaceOneArgOutcome.SUCCESS).count().value(); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - - @Override - public long getReplaceOneArgSuccessRate() { - try { - return cache.getStatistics().getExtended().replaceOneArg().component(CacheOperationOutcomes.ReplaceOneArgOutcome.SUCCESS).rate().value().longValue(); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - - @Override - public long getReplaceOneArgMissCount() { - try { - return cache.getStatistics().getExtended().replaceOneArg().component(CacheOperationOutcomes.ReplaceOneArgOutcome.FAILURE).count().value(); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - - @Override - public long getReplaceOneArgMissRate() { - try { - return cache.getStatistics().getExtended().replaceOneArg().component(CacheOperationOutcomes.ReplaceOneArgOutcome.FAILURE).rate().value().longValue(); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - - @Override - public long getReplaceTwoArgSuccessCount() { - try { - return cache.getStatistics().getExtended().replaceTwoArg().component(CacheOperationOutcomes.ReplaceTwoArgOutcome.SUCCESS).count().value(); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - - @Override - public long getReplaceTwoArgSuccessRate() { - try { - return cache.getStatistics().getExtended().replaceTwoArg().component(CacheOperationOutcomes.ReplaceTwoArgOutcome.SUCCESS).rate().value().longValue(); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - - @Override - public long getReplaceTwoArgMissCount() { - try { - return cache.getStatistics().getExtended().replaceTwoArg().component(CacheOperationOutcomes.ReplaceTwoArgOutcome.SUCCESS).count().value(); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - - @Override - public long getReplaceTwoArgMissRate() { - try { - return cache.getStatistics().getExtended().replaceTwoArg().component(CacheOperationOutcomes.ReplaceTwoArgOutcome.FAILURE).rate().value().longValue(); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - - @Override - public long getPutIfAbsentSuccessCount() { - try { - return cache.getStatistics().getExtended().putIfAbsent().component(CacheOperationOutcomes.PutIfAbsentOutcome.SUCCESS).count().value(); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - - @Override - public long getPutIfAbsentSuccessRate() { - try { - return cache.getStatistics().getExtended().putIfAbsent().component(CacheOperationOutcomes.PutIfAbsentOutcome.SUCCESS).rate().value().longValue(); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - - @Override - public long getPutIfAbsentMissCount() { - try { - return cache.getStatistics().getExtended().putIfAbsent().component( - CacheOperationOutcomes.PutIfAbsentOutcome.FAILURE).count().value(); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - - @Override - public long getPutIfAbsentMissRate() { - try { - return cache.getStatistics().getExtended().putIfAbsent().component(CacheOperationOutcomes.PutIfAbsentOutcome.FAILURE).rate().value().longValue(); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - - @Override - public long getRemoveElementSuccessCount() { - try { - return cache.getStatistics().getExtended().removeElement().component( - CacheOperationOutcomes.RemoveElementOutcome.SUCCESS).count().value(); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - - @Override - public long getRemoveElementSuccessRate() { - try { - return cache.getStatistics().getExtended().removeElement().component(CacheOperationOutcomes.RemoveElementOutcome.SUCCESS).rate().value().longValue(); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - - @Override - public long getRemoveElementMissCount() { - try { - return cache.getStatistics().getExtended().removeElement().component( - CacheOperationOutcomes.RemoveElementOutcome.FAILURE).count().value(); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - - @Override - public long getRemoveElementMissRate() { - try { - return cache.getStatistics().getExtended().removeElement().component(CacheOperationOutcomes.RemoveElementOutcome.FAILURE).rate().value().longValue(); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void deregistered(CacheConfiguration config) { - /**/ - } - - /** - * {@inheritDoc} - */ - @Override - public void maxBytesLocalHeapChanged(final long oldValue, final long newValue) { - if (oldValue != newValue) { - setMaxBytesLocalHeap(newValue); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void maxBytesLocalDiskChanged(final long oldValue, final long newValue) { - if (oldValue != newValue) { - setMaxBytesLocalDisk(newValue); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void diskCapacityChanged(int oldCapacity, int newCapacity) { - if (oldCapacity != newCapacity) { - setMaxElementsOnDisk(newCapacity); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void maxEntriesInCacheChanged(long oldCapacity, long newCapacity) { - if (oldCapacity != newCapacity) { - setMaxEntriesInCache(newCapacity); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void loggingChanged(boolean oldValue, boolean newValue) { - if (oldValue != newValue) { - setLoggingEnabled(newValue); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void memoryCapacityChanged(int oldCapacity, int newCapacity) { - if (oldCapacity != newCapacity) { - setMaxEntriesLocalHeap(newCapacity); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void registered(CacheConfiguration config) { - /**/ - } - - /** - * {@inheritDoc} - */ - @Override - public void timeToIdleChanged(long oldTimeToIdle, long newTimeToIdle) { - if (oldTimeToIdle != newTimeToIdle) { - setTimeToIdleSeconds(newTimeToIdle); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void timeToLiveChanged(long oldTimeToLive, long newTimeToLive) { - if (oldTimeToLive != newTimeToLive) { - setTimeToLiveSeconds(newTimeToLive); - } - } - - /** - * {@inheritDoc} - */ - @Override - public long getAverageSearchTime() { - return cache.getStatistics().cacheSearchOperation().latency().average().value().longValue(); - } - - /** - * {@inheritDoc} - */ - @Override - public long getSearchesPerSecond() { - return getCacheSearchRate(); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean getTransactional() { - return cache.getCacheConfiguration().getTransactionalMode().isTransactional(); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean getSearchable() { - return cache.getCacheConfiguration().getSearchable() != null; - } - - @Override - public Map getSearchAttributes() { - Map result = new HashMap(); - - if (cache != null && cache.getCacheConfiguration().getSearchable() != null) { - Map attrMap = new HashMap(); - - for (Attribute attr : cache.getSearchAttributes()) { - attrMap.put(attr.getAttributeName(), attr); - } - - for (SearchAttribute sa : cache.getCacheConfiguration().getSearchAttributes().values()) { - String saName = sa.getName(); - String typeName = sa.getTypeName(); - - if (attrMap.containsKey(saName) && typeName != null) { - result.put(saName, typeName); - } - } - } - return result; - } - - /** - * {@inheritDoc} - */ - @Override - public long getCacheSearchRate() { - return cache.getStatistics().cacheSearchOperation().rate().value().longValue(); - } - - /** - * {@inheritDoc} - */ - @Override - public long getTransactionCommitRate() { - return cache.getStatistics().xaRecoveryOperation().rate().value().longValue(); - } - - /** - * {@inheritDoc} - */ - @Override - public long getCacheXaCommitsMostRecentSample() { - return getTransactionCommitRate(); - } - - /** - * {@inheritDoc} - */ - @Override - public long getTransactionRollbackRate() { - return cache.getStatistics().xaRollbackOperation().rate().value().longValue(); - } - - /** - * {@inheritDoc} - */ - @Override - public long getCacheXaRollbacksMostRecentSample() { - return getTransactionRollbackRate(); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean isLocalHeapCountBased() { - return cache.getCacheConfiguration() - .getMaxBytesLocalHeap() <= 0 && !(cache.getCacheManager() != null && cache.getCacheManager() - .getConfiguration() - .isMaxBytesLocalHeapSet()); - } - - /** - * A package friendly method to allow dependants access to the underlying {@link Ehcache} object. This is available - * in order to allow {@link SampledCache} objects to continue to provide deprecated methods on the {@link SampledCacheMBean} interface, - * rather than burdening {@link CacheSampler} with these now irrelevant methods. This helper method - * should be removed if we are ever able to discontinue support for the deprecated methods on dependant interfaces. - * - * @return the underlying {@code Ehcache} object - */ - Ehcache getCache() { - return cache; - } - - /** - * {@inheritDoc} - */ - @Override - public int getCacheHitRatio() { - return (int) (cache.getStatistics().getExtended().cacheHitRatio().value().doubleValue() * ONE_HUNDRED); - } - - /** - * {@inheritDoc} - */ - @Override - public int getCacheHitRatioMostRecentSample() { - return getCacheHitRatio(); - } - - /** - * {@inheritDoc} - */ - @Override - public SampledCounter getCacheHitRatioSample() { - return new SampledCounterProxy(cache.getStatistics().getExtended().cacheHitRatio()) { - - @Override - public TimeStampedCounterValue getMostRecentSample() { - return new TimeStampedCounterValue(System.currentTimeMillis(), getValue()); - } - - @Override - public TimeStampedCounterValue[] getAllSampleValues() { - ArrayList arr = new ArrayList(); - for (Timestamped ts : rate.history()) { - arr.add(new TimeStampedCounterValue(ts.getTimestamp(), (int) (ts.getSample().doubleValue() * ONE_HUNDRED))); - } - return sortAndPresent(arr); - } - - @Override - public long getValue() { - return (long) (rate.value().doubleValue() * ONE_HUNDRED); - } - - }; - } - - @Override - public long getAverageGetTimeNanos() { - return cache.getStatistics().cacheGetOperation().latency().average().value().longValue(); - } - - /** - * {@inheritDoc} - */ - @Override - public SampledCounter getCacheHitSample() { - return new SampledCounterProxy(cache.getStatistics().cacheHitOperation().rate()); - } - - /** - * {@inheritDoc} - */ - @Override - public SampledCounter getCacheHitInMemorySample() { - return new SampledCounterProxy(cache.getStatistics().localHeapHitOperation().rate()); - } - - /** - * {@inheritDoc} - */ - @Override - public SampledCounter getCacheHitOffHeapSample() { - return new SampledCounterProxy(cache.getStatistics().localOffHeapHitOperation().rate()); - } - - /** - * {@inheritDoc} - */ - @Override - public SampledCounter getCacheHitOnDiskSample() { - return new SampledCounterProxy(cache.getStatistics().localDiskHitOperation().rate()); - } - - /** - * {@inheritDoc} - */ - @Override - public SampledCounter getCacheMissSample() { - return new SampledCounterProxy(cache.getStatistics().cacheMissOperation().rate()); - } - - /** - * {@inheritDoc} - */ - @Override - public SampledCounter getCacheMissInMemorySample() { - return new SampledCounterProxy(cache.getStatistics().localHeapMissOperation().rate()); - } - - /** - * {@inheritDoc} - */ - @Override - public SampledCounter getCacheMissOffHeapSample() { - return new SampledCounterProxy(cache.getStatistics().localOffHeapMissOperation().rate()); - } - - /** - * {@inheritDoc} - */ - @Override - public SampledCounter getCacheMissOnDiskSample() { - return new SampledCounterProxy(cache.getStatistics().localDiskMissOperation().rate()); - } - - /** - * {@inheritDoc} - */ - @Override - public SampledCounter getCacheMissExpiredSample() { - return new SampledCounterProxy(cache.getStatistics().cacheMissExpiredOperation().rate()); - } - - /** - * {@inheritDoc} - */ - @Override - public SampledCounter getCacheMissNotFoundSample() { - return new SampledCounterProxy(cache.getStatistics().cacheMissNotFoundOperation().rate()); - } - - /** - * {@inheritDoc} - */ - @Override - public SampledCounter getCacheElementEvictedSample() { - return new SampledCounterProxy(cache.getStatistics().cacheEvictionOperation().rate()); - } - - /** - * {@inheritDoc} - */ - @Override - public SampledCounter getCacheElementRemovedSample() { - return new SampledCounterProxy(cache.getStatistics().cacheRemoveOperation().rate()); - } - - /** - * {@inheritDoc} - */ - @Override - public SampledCounter getCacheElementExpiredSample() { - return new SampledCounterProxy(cache.getStatistics().cacheExpiredOperation().rate()); - } - - /** - * {@inheritDoc} - */ - @Override - public SampledCounter getCacheElementPutSample() { - return new SampledCounterProxy(cache.getStatistics().cachePutOperation().rate()); - } - - /** - * {@inheritDoc} - */ - @Override - public SampledCounter getCacheElementUpdatedSample() { - return new SampledCounterProxy(cache.getStatistics().cachePutReplacedOperation().rate()); - } - - /** - * {@inheritDoc} - */ - @Override - public SampledRateCounter getAverageGetTimeSample() { - return new SampledRateCounterProxy(cache.getStatistics().cacheGetOperation().latency().average()); - } - - /** - * {@inheritDoc} - */ - @Override - public SampledRateCounter getAverageSearchTimeSample() { - return new SampledRateCounterProxy(cache.getStatistics().cacheSearchOperation().latency().average()); - } - - /** - * {@inheritDoc} - */ - @Override - public SampledCounter getSearchesPerSecondSample() { - return new SampledRateCounterProxy(cache.getStatistics().cacheSearchOperation().rate()); - } - - /** - * {@inheritDoc} - */ - @Override - public SampledCounter getCacheXaCommitsSample() { - return new SampledRateCounterProxy(cache.getStatistics().xaCommitSuccessOperation().rate()); - } - - /** - * {@inheritDoc} - */ - @Override - public SampledCounter getCacheXaRollbacksSample() { - return new SampledRateCounterProxy(cache.getStatistics().xaRollbackOperation().rate()); - } - - /** - * {@inheritDoc} - */ - @Override - public SampledCounter getSizeSample() { - return new SampledRateCounterProxy(cache.getStatistics().getExtended().size()); - } - - /** - * {@inheritDoc} - */ - @Override - public SampledCounter getLocalHeapSizeSample() { - return new SampledRateCounterProxy(cache.getStatistics().getExtended().localHeapSize()); - } - - /** - * {@inheritDoc} - */ - @Override - public SampledCounter getLocalHeapSizeInBytesSample() { - return new SampledRateCounterProxy(cache.getStatistics().getExtended().localHeapSizeInBytes()); - } - - /** - * {@inheritDoc} - */ - @Override - public SampledCounter getLocalOffHeapSizeSample() { - return new SampledRateCounterProxy(cache.getStatistics().getExtended().localOffHeapSize()); - } - - /** - * {@inheritDoc} - */ - @Override - public SampledCounter getLocalOffHeapSizeInBytesSample() { - return new SampledRateCounterProxy(cache.getStatistics().getExtended().localOffHeapSizeInBytes()); - } - - /** - * {@inheritDoc} - */ - @Override - public SampledCounter getLocalDiskSizeSample() { - return new SampledRateCounterProxy(cache.getStatistics().getExtended().localDiskSize()); - } - - /** - * {@inheritDoc} - */ - @Override - public SampledCounter getLocalDiskSizeInBytesSample() { - return new SampledRateCounterProxy(cache.getStatistics().getExtended().localDiskSizeInBytes()); - } - - /** - * {@inheritDoc} - */ - @Override - public SampledCounter getRemoteSizeSample() { - return new SampledRateCounterProxy(cache.getStatistics().getExtended().remoteSize()); - } - - /** - * {@inheritDoc} - */ - @Override - public SampledCounter getWriterQueueLengthSample() { - return new SampledRateCounterProxy(cache.getStatistics().getExtended().writerQueueLength()); - } - - @Override - public long getAverageSearchTimeNanos() { - return getAverageSearchTime(); - } - - @Override - public long getCacheClusterOfflineCount() { - try { - return cache.getStatistics().getExtended().clusterEvent().component(ClusterEventOutcomes.OFFLINE).count().value(); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - - @Override - public long getCacheClusterRejoinCount() { - try { - return cache.getStatistics().getExtended().clusterEvent().component(ClusterEventOutcomes.REJOINED).count().value(); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - - @Override - public long getCacheClusterOnlineCount() { - try { - return cache.getStatistics().getExtended().clusterEvent().component(ClusterEventOutcomes.ONLINE).count().value(); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - - @Override - public long getCacheClusterOfflineMostRecentSample() { - return cache.getStatistics().getExtended().clusterEvent().component(ClusterEventOutcomes.OFFLINE).rate().value().longValue(); - } - - @Override - public long getCacheClusterRejoinMostRecentSample() { - return cache.getStatistics().getExtended().clusterEvent().component(ClusterEventOutcomes.REJOINED).rate().value().longValue(); - } - - @Override - public long getCacheClusterOnlineMostRecentSample() { - return cache.getStatistics().getExtended().clusterEvent().component(ClusterEventOutcomes.ONLINE).rate().value().longValue(); - } - - @Override - public SampledCounter getCacheClusterOfflineSample() { - return new SampledRateCounterProxy(cache.getStatistics().getExtended().clusterEvent().component(ClusterEventOutcomes.OFFLINE).rate()); - } - - @Override - public SampledCounter getCacheClusterOnlineSample() { - return new SampledRateCounterProxy(cache.getStatistics().getExtended().clusterEvent().component(ClusterEventOutcomes.ONLINE).rate()); - } - - @Override - public SampledCounter getCacheClusterRejoinSample() { - return new SampledRateCounterProxy(cache.getStatistics().getExtended().clusterEvent().component(ClusterEventOutcomes.REJOINED).rate()); - } - - @Override - public long getMostRecentRejoinTimeStampMillis() { - try { - return cache.getStatistics().getExtended().mostRecentRejoinTimeStampMillis().value().longValue(); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - - @Override - public SampledCounter getMostRecentRejoinTimestampMillisSample() { - return new SampledRateCounterProxy(cache.getStatistics().getExtended().mostRecentRejoinTimeStampMillis()); - } - - @Override - public long getNonStopSuccessCount() { - try { - return cache.getStatistics().getExtended().nonstop().component(NonStopOperationOutcomes.SUCCESS).count().value(); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - - @Override - public long getNonStopFailureCount() { - try { - return cache.getStatistics().getExtended().nonstop().component(NonStopOperationOutcomes.FAILURE).count().value(); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - - @Override - public long getNonStopRejoinTimeoutCount() { - try { - return cache.getStatistics().getExtended().nonstop().component(NonStopOperationOutcomes.REJOIN_TIMEOUT).count().value(); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - - @Override - public long getNonStopTimeoutCount() { - try { - return cache.getStatistics().getExtended().nonstop().component(NonStopOperationOutcomes.TIMEOUT).count().value(); - } catch (RuntimeException e) { - throw Utils.newPlainException(e); - } - } - - @Override - public long getNonStopSuccessMostRecentSample() { - return cache.getStatistics().getExtended().nonstop().component(NonStopOperationOutcomes.SUCCESS).rate().value().longValue(); - } - - @Override - public long getNonStopFailureMostRecentSample() { - return cache.getStatistics().getExtended().nonstop().component(NonStopOperationOutcomes.FAILURE).rate().value().longValue(); - } - - @Override - public long getNonStopRejoinTimeoutMostRecentSample() { - return cache.getStatistics().getExtended().nonstop().component(NonStopOperationOutcomes.REJOIN_TIMEOUT).rate().value().longValue(); - } - - @Override - public long getNonStopTimeoutMostRecentSample() { - return cache.getStatistics().getExtended().nonstop().component(NonStopOperationOutcomes.TIMEOUT).rate().value().longValue(); - } - - @Override - public SampledCounter getNonStopSuccessSample() { - return new SampledRateCounterProxy(cache.getStatistics().getExtended().nonstop().component(NonStopOperationOutcomes.SUCCESS).rate()); - } - - @Override - public SampledCounter getNonStopFailureSample() { - return new SampledRateCounterProxy(cache.getStatistics().getExtended().nonstop().component(NonStopOperationOutcomes.FAILURE).rate()); - } - - @Override - public SampledCounter getNonStopRejoinTimeoutSample() { - return new SampledRateCounterProxy(cache.getStatistics().getExtended().nonstop().component(NonStopOperationOutcomes.REJOIN_TIMEOUT).rate()); - } - - @Override - public SampledCounter getNonStopTimeoutSample() { - return new SampledRateCounterProxy(cache.getStatistics().getExtended().nonstop().component(NonStopOperationOutcomes.TIMEOUT).rate()); - } - - @Override - public long getNonStopSuccessRate() { - return getNonStopSuccessMostRecentSample(); - } - - @Override - public long getNonStopFailureRate() { - return getNonStopFailureMostRecentSample(); - } - - @Override - public long getNonStopRejoinTimeoutRate() { - return getNonStopRejoinTimeoutMostRecentSample(); - } - - @Override - public long getNonStopTimeoutRate() { - return getNonStopTimeoutMostRecentSample(); - } - - @Override - public SampledCounter getReplaceOneArgSuccessSample() { - return new SampledCounterProxy(cache.getStatistics().getExtended().replaceOneArg().component( - CacheOperationOutcomes.ReplaceOneArgOutcome.SUCCESS).rate()); - } - - @Override - public SampledCounter getReplaceOneArgMissSample() { - return new SampledCounterProxy(cache.getStatistics().getExtended().replaceOneArg().component( - CacheOperationOutcomes.ReplaceOneArgOutcome.FAILURE).rate()); - } - - @Override - public SampledCounter getReplaceTwoArgSuccessSample() { - return new SampledCounterProxy(cache.getStatistics().getExtended().replaceTwoArg().component( - CacheOperationOutcomes.ReplaceTwoArgOutcome.SUCCESS).rate()); - } - - @Override - public SampledCounter getReplaceTwoArgMissSample() { - return new SampledCounterProxy(cache.getStatistics().getExtended().replaceTwoArg().component( - CacheOperationOutcomes.ReplaceTwoArgOutcome.FAILURE).rate()); - } - - @Override - public SampledCounter getPutIfAbsentSuccessSample() { - return new SampledCounterProxy(cache.getStatistics().getExtended().putIfAbsent().component( - CacheOperationOutcomes.PutIfAbsentOutcome.SUCCESS).rate()); - } - - @Override - public SampledCounter getPutIfAbsentMissSample() { - return new SampledCounterProxy(cache.getStatistics().getExtended().putIfAbsent().component( - CacheOperationOutcomes.PutIfAbsentOutcome.FAILURE).rate()); - } - - @Override - public SampledCounter getRemoveElementSuccessSample() { - return new SampledCounterProxy(cache.getStatistics().getExtended().removeElement().component( - CacheOperationOutcomes.RemoveElementOutcome.SUCCESS).rate()); - } - - @Override - public SampledCounter getRemoveElementMissSample() { - return new SampledCounterProxy(cache.getStatistics().getExtended().removeElement().component( - CacheOperationOutcomes.RemoveElementOutcome.FAILURE).rate()); - } - - @Override - public int getNonstopTimeoutRatio() { - return (int) (cache.getStatistics().getExtended().nonstopTimeoutRatio().value().doubleValue() * ONE_HUNDRED); - } -} Index: rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/net/sf/ehcache/util/RetryAssert.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/net/sf/ehcache/util/RetryAssert.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/net/sf/ehcache/util/RetryAssert.java (revision 0) @@ -1,80 +0,0 @@ -/* - * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved. - */ - -package net.sf.ehcache.util; - -import net.sf.ehcache.Ehcache; -import net.sf.ehcache.Element; -import net.sf.ehcache.store.Store; - -import org.hamcrest.Matcher; -import org.junit.Assert; - -import java.util.concurrent.Callable; -import java.util.concurrent.TimeUnit; - -public class RetryAssert { - protected RetryAssert() { - // static only class - } - - public static void assertBy(long time, TimeUnit unit, Callable value, Matcher matcher) { - boolean interrupted = false; - long start = System.nanoTime(); - long end = start + unit.toNanos(time); - long sleep = Math.max(50, unit.toMillis(time) / 10); - AssertionError latest; - try { - while (true) { - try { - Assert.assertThat(value.call(), matcher); - return; - } catch (AssertionError e) { - latest = e; - } catch (Exception e) { - latest = new AssertionError(e); - } - - if (System.nanoTime() > end) { - break; - } else { - try { - Thread.sleep(sleep); - } catch (InterruptedException e) { - interrupted = true; - } - } - } - } finally { - if (interrupted) { - Thread.currentThread().interrupt(); - } - } - throw latest; - } - - public static Callable elementAt(final Ehcache cache, final Object key) { - return new Callable() { - public Element call() { - return cache.get(key); - } - }; - } - - public static Callable sizeOf(final Ehcache cache) { - return new Callable() { - public Integer call() throws Exception { - return cache.getSize(); - } - }; - } - - public static Callable sizeOnDiskOf(final Store store) { - return new Callable() { - public Integer call() throws Exception { - return store.getOnDiskSize(); - } - }; - } -} Index: rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/org/terracotta/ehcache/tests/container/hibernate/domain/Person.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/org/terracotta/ehcache/tests/container/hibernate/domain/Person.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/org/terracotta/ehcache/tests/container/hibernate/domain/Person.java (revision 0) @@ -1,108 +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.ehcache.tests.container.hibernate.domain; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -public class Person { - - private Long id; - private int age; - private String firstname; - private String lastname; - private List events = new ArrayList(); // list semantics, e.g., indexed - private Set emailAddresses = new HashSet(); - private Set phoneNumbers = new HashSet(); - private List talismans = new ArrayList(); // a Bag of good-luck charms. - - public Person() { - // - } - - public List getEvents() { - return events; - } - - protected void setEvents(List events) { - this.events = events; - } - - public void addToEvent(Event event) { - this.getEvents().add(event); - event.getParticipants().add(this); - } - - public void removeFromEvent(Event event) { - this.getEvents().remove(event); - event.getParticipants().remove(this); - } - - public int getAge() { - return age; - } - - public void setAge(int age) { - this.age = age; - } - - public String getFirstname() { - return firstname; - } - - public void setFirstname(String firstname) { - this.firstname = firstname; - } - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getLastname() { - return lastname; - } - - public void setLastname(String lastname) { - this.lastname = lastname; - } - - public Set getEmailAddresses() { - return emailAddresses; - } - - public void setEmailAddresses(Set emailAddresses) { - this.emailAddresses = emailAddresses; - } - - public Set getPhoneNumbers() { - return phoneNumbers; - } - - public void setPhoneNumbers(Set phoneNumbers) { - this.phoneNumbers = phoneNumbers; - } - - public void addTalisman(String name) { - talismans.add(name); - } - - public List getTalismans() { - return talismans; - } - - public void setTalismans(List talismans) { - this.talismans = talismans; - } - - public String toString() { - return getFirstname() + " " + getLastname(); - } -} Index: rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/org/terracotta/ehcache/tests/container/BasicContainerJTATest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/org/terracotta/ehcache/tests/container/BasicContainerJTATest.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/org/terracotta/ehcache/tests/container/BasicContainerJTATest.java (revision 0) @@ -1,63 +0,0 @@ -/* - * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved. - */ -package org.terracotta.ehcache.tests.container; - -import com.gargoylesoftware.htmlunit.WebClient; -import com.gargoylesoftware.htmlunit.WebResponse; -import com.tc.test.AppServerInfo; -import com.tc.test.server.appserver.deployment.AbstractStandaloneTwoServerDeploymentTest; -import com.tc.test.server.appserver.deployment.DeploymentBuilder; -import com.tc.test.server.appserver.deployment.WebApplicationServer; - -import junit.framework.Test; - -public class BasicContainerJTATest extends AbstractStandaloneTwoServerDeploymentTest { - - private static final String CONTEXT = "BasicContainerJTATest"; - - public BasicContainerJTATest() { - if (appServerInfo().getId() == AppServerInfo.JETTY || appServerInfo().getId() == AppServerInfo.TOMCAT - || appServerInfo().getId() == AppServerInfo.WEBSPHERE) { - // Jetty and Tomcat have no TM and we know the Websphere one is not compatible - disableTest(); - } - } - - public static Test suite() { - return new BasicContainerJTATestSetup(); - } - - public void testBasics() throws Exception { - System.out.println("Running test"); - WebClient conversation = new WebClient(); - - // do insert on server0 - WebResponse response1 = request(server0, "cmd=insert", conversation); - assertEquals("OK", response1.getContentAsString().trim()); - - // do query on server1 - response1 = request(server1, "cmd=query", conversation); - assertEquals("OK", response1.getContentAsString().trim()); - System.out.println("Test finished"); - } - - private WebResponse request(WebApplicationServer server, String params, WebClient con) throws Exception { - return server.ping("/" + CONTEXT + "/BasicJTATestServlet?" + params, con); - } - - private static class BasicContainerJTATestSetup extends AbstractStandaloneContainerJTATestSetup { - - public BasicContainerJTATestSetup() { - super(BasicContainerJTATest.class, "basic-xa-appserver-test.xml", CONTEXT); - } - - @Override - protected void configureWar(DeploymentBuilder builder) { - super.configureWar(builder); - builder.addServlet("BasicTestJTAServlet", "/BasicJTATestServlet/*", BasicJTATestServlet.class, null, false); - } - - } - -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/statistics/beans/package.html =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/statistics/beans/package.html (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/statistics/beans/package.html (revision 0) @@ -1,8 +0,0 @@ - - - - -This package contains classes related to statistics mbean implementation. -

- - Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/management/Cache.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/management/Cache.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/management/Cache.java (revision 0) @@ -1,161 +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 javax.management.NotCompliantMBeanException; -import net.sf.ehcache.CacheException; -import net.sf.ehcache.Ehcache; -import net.sf.ehcache.hibernate.management.impl.EhcacheHibernateMbeanNames; -import net.sf.ehcache.util.CacheTransactionHelper; - -import javax.management.MalformedObjectNameException; -import javax.management.ObjectName; -import java.io.Serializable; - -/** - * A Cache implementation that supports JMX MBeans - * @author Greg Luck - * @version $Id: Cache.java 10789 2018-04-26 02:08:13Z adahanne $ - * @since 1.3 - */ -public class Cache implements CacheMBean, Serializable { - - private static final long serialVersionUID = 3477287016924524437L; - - - /** - * An Ehcache backing instance - */ - private transient Ehcache cache; - private ObjectName objectName; - - - /** - * A constructor for JCache. - * - * JCache is an adaptor for an Ehcache, and therefore requires an Ehcace in its constructor. - *

- * The {@link net.sf.ehcache.config.ConfigurationFactory} and clients can create these. - *

- * A client can specify their own settings here and pass the {@link Ehcache} object - * into {@link net.sf.ehcache.CacheManager#addCache} to specify parameters other than the defaults. - *

- * Only the CacheManager can initialise them. - * - * @param cache An ehcache - * @throws net.sf.ehcache.CacheException - */ - public Cache(Ehcache cache) throws CacheException { - this.cache = cache; - objectName = createObjectName(cache.getCacheManager().toString(), cache.getName()); - } - - /** - * Creates an object name using the scheme "net.sf.ehcache:type=Cache,CacheManager=,name=" - */ - static ObjectName createObjectName(String cacheManagerName, String cacheName) { - ObjectName objectName; - try { - objectName = new ObjectName("net.sf.ehcache:type=Cache,CacheManager=" + cacheManagerName + ",name=" - + EhcacheHibernateMbeanNames.mbeanSafe(cacheName)); - } catch (MalformedObjectNameException e) { - throw new CacheException(e); - } - return objectName; - } - - /** - * Removes all cached items. - * - * @throws IllegalStateException if the cache is not {@link net.sf.ehcache.Status#STATUS_ALIVE} - */ - public void removeAll() throws IllegalStateException, CacheException { - CacheTransactionHelper.beginTransactionIfNeeded(cache); - try { - cache.removeAll(); - } finally { - CacheTransactionHelper.commitTransactionIfNeeded(cache); - } - } - - /** - * Flushes all cache items from memory to the disk store, and from the DiskStore to disk. - * - * @throws IllegalStateException if the cache is not {@link net.sf.ehcache.Status#STATUS_ALIVE} - */ - public void flush() throws IllegalStateException, CacheException { - cache.flush(); - } - - /** - * Gets the status attribute of the Cache. - * - * @return The status value as a String from the Status enum class - */ - public String getStatus() { - return cache.getStatus().toString(); - } - - /** - * Gets the cache name. - */ - public String getName() { - return cache.getName(); - } - - /** - * Is the cache configured with Terracotta clustering? - */ - public boolean isTerracottaClustered() { - return cache.getCacheConfiguration().isTerracottaClustered(); - } - - /** - * May the cache contain elements which the SizeOf engine could not fully size? - */ - public boolean hasAbortedSizeOf() { - return cache.hasAbortedSizeOf(); - } - - /** - * Gets the JMX read-only CacheConfiguration - */ - public CacheConfiguration getCacheConfiguration() { - return new CacheConfiguration(cache); - } - - /** - * Gets the JMX cache statistics - */ - public CacheStatistics getStatistics() { - return new CacheStatistics(cache); - } - - /** - * Gets the JMX store bean - */ - Store getStore() throws NotCompliantMBeanException { - return Store.getBean(cache); - } - - /** - * @return the object name for this MBean - */ - ObjectName getObjectName() { - return objectName; - } -} Index: rctags/ehcache-2.10.9.1.33/distribution/events/src/main/resources/ehcache.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/distribution/events/src/main/resources/ehcache.xml (revision 11516) +++ rctags/ehcache-2.10.9.1.33/distribution/events/src/main/resources/ehcache.xml (revision 0) @@ -1,12 +0,0 @@ - - - - - - - - Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/pool/sizeof/filter/annotations/CustomAnnotation.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/pool/sizeof/filter/annotations/CustomAnnotation.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/pool/sizeof/filter/annotations/CustomAnnotation.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.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 CustomAnnotation { - boolean deprecated() default true; - short differentReturnType() default 10; - Class aClass() default Integer.class; - ExampleEnum anEnum() default ExampleEnum.TWO; - Deprecated anAnnotation() default @Deprecated; -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/event/NullCacheEventListenerFactory.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/event/NullCacheEventListenerFactory.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/event/NullCacheEventListenerFactory.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.event; - -import java.util.Properties; - -/** - * A factory for NullCacheEventListener - * - * @author Greg Luck - * @version $Id: NullCacheEventListenerFactory.java 5594 2012-05-07 16:04:31Z cdennis $ - */ -public class NullCacheEventListenerFactory extends CacheEventListenerFactory { - - /** - * Create a CacheEventListener - * - * @param properties implementation specific properties. These are configured as comma - * separated name value pairs in ehcache.xml - * @return a constructed CacheEventListener - */ - public CacheEventListener createCacheEventListener(Properties properties) { - return new NullCacheEventListener(); - } - -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/config/package.html =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/config/package.html (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/config/package.html (revision 0) @@ -1,7 +0,0 @@ - - - - - This package contains the cache configuration code. - - Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/util/counter/CounterImpl.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/util/counter/CounterImpl.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/util/counter/CounterImpl.java (revision 0) @@ -1,97 +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.counter; - -import java.io.Serializable; -import java.util.concurrent.atomic.AtomicLong; - -/** - * A simple counter implementation - * - * @author Abhishek Sanoujam - * @since 1.7 - * - */ -public class CounterImpl implements Counter, Serializable { - private AtomicLong value; - - /** - * Default Constructor - */ - public CounterImpl() { - this(0L); - } - - /** - * Constructor with initial value - * - * @param initialValue - */ - public CounterImpl(long initialValue) { - this.value = new AtomicLong(initialValue); - } - - /** - * {@inheritDoc} - */ - public long increment() { - return value.incrementAndGet(); - } - - /** - * {@inheritDoc} - */ - public long decrement() { - return value.decrementAndGet(); - } - - /** - * {@inheritDoc} - */ - public long getAndSet(long newValue) { - return value.getAndSet(newValue); - } - - /** - * {@inheritDoc} - */ - public long getValue() { - return value.get(); - } - - /** - * {@inheritDoc} - */ - public long increment(long amount) { - return value.addAndGet(amount); - } - - /** - * {@inheritDoc} - */ - public long decrement(long amount) { - return value.addAndGet(amount * -1); - } - - /** - * {@inheritDoc} - */ - public void setValue(long newValue) { - value.set(newValue); - } - -} Index: rctags/ehcache-2.10.9.1.33/ehcache-search-parser/src/test/resources/unparseable.txt =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-search-parser/src/test/resources/unparseable.txt (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-search-parser/src/test/resources/unparseable.txt (revision 0) @@ -1,58 +0,0 @@ -// things which should not be parsed. - -// simplest -slect * from foo - -// really simple from foo where clause -select foo from foo where name = foo -select * from foo where name' != foo -select * from foo where (name < foo -select key from foo where name & foo - -// add some aggregators to the target list -select key,summer(foo) from foo - -// ok, some casting. note that no parsing is done in quoted string which is being cast. -select * from foo where age = bool 'true' -select * from foo where age = (string)10 -select * from foo where age = (long)'11' - -// some ands -select key,value from foo where (age > 100 and zip=20144 -select key,value from foo where (age > 100 and zip=20144 and time) -select key,value from foo where ((age > 100 and zip=20144 and time > 10 and fun>100) - -// some ors -select key,value from foo where (age > 100 or zip=20144 -select key,value from foo where (age > 100 or zip=20144 or > 10) -select key,value from foo where (age > 100 or zip=20144) or time > 10 or fun>100) - -// ors and ands, partying together -select key,value from foo where (age > 100 and zip=20144) or time > 10) -select key,value from foo where ((age > 100 or zip=20144 and (time > 10 or fun>100)) -select key,value from foo where ((age > 100 or zip=20144) time > 10) -select key,value from foo where ((age > 100 and zip'=20144) or (time > 10 and fun>100)) - -// group by? -select * from foo where ((age > 100 and zip=20144) or time > 10) groupby age -select * from foo where ((age > 100 and zip=20144) or time > 10) group by - -// order by? -select * from foo where ((age > 100 and zip=20144) or time > 10) orderby age -select * from foo where ((age > 100 and zip=20144) or time > 10) order by age order by - -// order and group by, mixing order -select * from foo where ((age > 100 and zip=20144) or time > 10) group age order age - -// limit must go on the end! -select * from foo where ((age > 100 and zip=20144) or time > 10) order by age group by age order by zip limit 10 group by zip - -// some quoting chicanery -select * from foo where foo='tom\' -select * from foo where foo=\'tom\foo -select * from foo where foo='tom\u04' - -select * from foo where name = (date)'abcde' -select * from foo where name = (date)'12-20' - -select a, b from foo where bar is not not null \ No newline at end of file Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/RecalculateSizeTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/RecalculateSizeTest.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/RecalculateSizeTest.java (revision 0) @@ -1,346 +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.ArrayList; -import java.util.List; -import java.util.Random; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicLong; -import java.util.concurrent.atomic.AtomicReference; - -import junit.framework.Assert; -import junit.framework.TestCase; -import net.sf.ehcache.config.CacheConfiguration; -import net.sf.ehcache.config.Configuration; -import net.sf.ehcache.config.MemoryUnit; -import net.sf.ehcache.pool.SizeOfEngine; -import net.sf.ehcache.pool.impl.DefaultSizeOfEngine; - -public class RecalculateSizeTest extends TestCase { - private static final Random random; - - static { - final long seed = System.currentTimeMillis(); - System.out.println("*** RANDOM SEEDED WITH " + seed + " ***"); - random = new Random(seed); - } - - private final SizeOfEngine engine = new DefaultSizeOfEngine(1000, true); - - public void testCustomValue() { - DynamicSizedValue value = new DynamicSizedValue('A'); - - value.shrinkSize(); - long shrinkedSize = engine.sizeOf(value, null, null).getCalculated(); - - value.expandSize(); - long expandedSize = engine.sizeOf(value, null, null).getCalculated(); - - System.out.println("Shrinked size: " + shrinkedSize + ", expanded size: " + expandedSize); - - Assert.assertTrue(expandedSize > shrinkedSize); - // consumes 6mb, assert diff is at least 5mb - Assert.assertTrue(expandedSize - shrinkedSize > MemoryUnit.MEGABYTES.toBytes(5)); - - value.shrinkSize(); - long shrinkedSize2 = engine.sizeOf(value, null, null).getCalculated(); - - value.expandSize(); - long expandedSize2 = engine.sizeOf(value, null, null).getCalculated(); - System.out.println("Shrinked size2: " + shrinkedSize2 + ", expanded size2: " + expandedSize2); - - Assert.assertEquals(shrinkedSize, shrinkedSize2); - Assert.assertEquals(expandedSize, expandedSize2); - - value.shrinkSize(); - value = null; - } - - public void testRecalculateSizeGrowing() { - CacheManager cm = createCacheManager(); - cm.addCache(createCache("test-cache-growing")); - - Cache cache = cm.getCache("test-cache-growing"); - Assert.assertEquals(0, cache.getStatistics().getLocalHeapSizeInBytes()); - - DynamicSizedValue value = new DynamicSizedValue('A'); - value.shrinkSize(); - long valueShrinkedSize = engine.sizeOf(value, null, null).getCalculated(); - value.expandSize(); - long valueExpandedSize = engine.sizeOf(value, null, null).getCalculated(); - long valueSizeDiff = valueExpandedSize - valueShrinkedSize; - - value.shrinkSize(); - cache.put(new Element("key", value)); - long shrinkedSize = cache.getStatistics().getLocalHeapSizeInBytes(); - - value.expandSize(); - long expandedSizeBeforeRecalculate = cache.getStatistics().getLocalHeapSizeInBytes(); - - cache.recalculateSize("key"); - long expandedSize = cache.getStatistics().getLocalHeapSizeInBytes(); - - long expectedExpandedSize = shrinkedSize + valueSizeDiff; - - System.out.println("Shrinked size: " + shrinkedSize + ", expandedSizeBeforeRecalculate: " + expandedSizeBeforeRecalculate - + ", expandedSize: " + expandedSize + ", expectedExpandedSize: " + expectedExpandedSize + ", valueShrinkedSize: " - + valueShrinkedSize + ", valueExpandedSize: " + valueExpandedSize); - Assert.assertEquals(shrinkedSize, expandedSizeBeforeRecalculate); - Assert.assertTrue(expandedSize > shrinkedSize); - Assert.assertEquals(valueSizeDiff, expandedSize - expandedSizeBeforeRecalculate); - Assert.assertEquals(expectedExpandedSize, expandedSize); - - cache.remove("key"); - cm.shutdown(); - } - - public void testRecalculateSizeShrinking() { - CacheManager cm = createCacheManager(); - cm.addCache(createCache("test-cache-shrinking")); - - Cache cache = cm.getCache("test-cache-shrinking"); - Assert.assertEquals(0, cache.getStatistics().getLocalHeapSizeInBytes()); - - DynamicSizedValue value = new DynamicSizedValue('A'); - value.shrinkSize(); - long valueShrinkedSize = engine.sizeOf(value, null, null).getCalculated(); - value.expandSize(); - long valueExpandedSize = engine.sizeOf(value, null, null).getCalculated(); - long valueSizeDiff = valueExpandedSize - valueShrinkedSize; - - value.expandSize(); - cache.put(new Element("key", value)); - long expandedSize = cache.getStatistics().getLocalHeapSizeInBytes(); - - value.shrinkSize(); - long shrinkedSizeBeforeRecalculate = cache.getStatistics().getLocalHeapSizeInBytes(); - - cache.recalculateSize("key"); - long shrinkedSize = cache.getStatistics().getLocalHeapSizeInBytes(); - - long expectedShrinkedSize = expandedSize - valueSizeDiff; - - System.out.println("Shrinked size: " + shrinkedSize + ", shrinkedSizeBeforeRecalculate: " + shrinkedSizeBeforeRecalculate - + ", expandedSize: " + expandedSize + ", expectedShrinkedSize: " + expectedShrinkedSize + ", valueShrinkedSize: " - + valueShrinkedSize + ", valueExpandedSize: " + valueExpandedSize); - Assert.assertEquals(expandedSize, shrinkedSizeBeforeRecalculate); - Assert.assertTrue(expandedSize > shrinkedSize); - Assert.assertEquals(valueSizeDiff, expandedSize - shrinkedSize); - Assert.assertEquals(expectedShrinkedSize, shrinkedSize); - - cache.remove("key"); - cm.shutdown(); - } - - private Cache createCache(String name) { - return new Cache(new CacheConfiguration().name(name)); - } - - private CacheManager createCacheManager() { - return CacheManager.create(new Configuration().name("test-cm").maxBytesLocalHeap(40, MemoryUnit.MEGABYTES)); - } - - public void testMultipleRecalculates() throws Exception { - System.out.println("Testing multiple recalculates..."); - final CacheManager cacheManager = createCacheManager(); - cacheManager.addCache(createCache("test-cache")); - final Cache cache = cacheManager.getCache("test-cache"); - final AtomicBoolean stop = new AtomicBoolean(false); - final AtomicReference error = new AtomicReference(); - final AtomicLong numRecalculates = new AtomicLong(); - - final String key = "the-key"; - DynamicSizedValue value = new DynamicSizedValue('A'); - value.setSize(random.nextInt(100000) + 100000); - cache.put(new Element(key, value)); - long initialInMemorySizeBytes = cache.getStatistics().getLocalHeapSizeInBytes(); - System.out.println("Initial: inMemorySizeBytes: " + initialInMemorySizeBytes); - - final int numThreads = 50; - final Thread[] threads = new Thread[numThreads]; - for (int i = 0; i < numThreads; i++) { - threads[i] = new Thread(new Runnable() { - - public void run() { - try { - while (!stop.get()) { - cache.recalculateSize(key); - numRecalculates.incrementAndGet(); - } - } catch (Throwable e) { - error.set(e); - stop.set(true); - } - } - - }, "Test thread - " + i); - - threads[i].setDaemon(true); - threads[i].start(); - } - - for (int i = 0; i < 10; i++) { - cache.recalculateSize(key); - long inMemorySizeBytes = cache.getStatistics().getLocalHeapSizeInBytes(); - System.out.println("initialInMemorySizeBytes: " + initialInMemorySizeBytes + ", calculatedInMemorySizeBytes: " - + inMemorySizeBytes + ", numRecalculates: " + numRecalculates.get()); - Assert.assertEquals(initialInMemorySizeBytes, cache.getStatistics().getLocalHeapSizeInBytes()); - Thread.sleep(1000); - } - - stop.set(true); - for (Thread t : threads) { - t.join(); - } - - Assert.assertEquals(initialInMemorySizeBytes, cache.getStatistics().getLocalHeapSizeInBytes()); - - cacheManager.shutdown(); - } - - public void testMultipleRecalculatesAndMutates() throws Exception { - System.out.println("Testing multiple recalculates with mutation..."); - final CacheManager cacheManager = createCacheManager(); - cacheManager.addCache(createCache("test-cache")); - final Cache cache = cacheManager.getCache("test-cache"); - final AtomicBoolean stop = new AtomicBoolean(false); - final AtomicReference error = new AtomicReference(); - final AtomicLong numRecalculates = new AtomicLong(); - - final String key = "the-key"; - DynamicSizedValue value = new DynamicSizedValue('A'); - value.setSize(random.nextInt(100000)); - cache.put(new Element(key, value)); - - final int numThreads = 50; - final Thread[] threads = new Thread[numThreads]; - for (int i = 0; i < numThreads; i++) { - threads[i] = new Thread(new Runnable() { - - public void run() { - try { - while (!stop.get()) { - cache.recalculateSize(key); - numRecalculates.incrementAndGet(); - } - } catch (Throwable e) { - error.set(e); - stop.set(true); - } - } - - }, "Test thread - " + i); - - threads[i].setDaemon(true); - threads[i].start(); - } - int numChanges = 1; - final int maxNumChanges = 100; - int lastValueSize = 0; - List valueSizeToCalculatedSizeList = new ArrayList(); - while (numChanges <= maxNumChanges && !stop.get()) { - lastValueSize = random.nextInt((int) MemoryUnit.KILOBYTES.toBytes(30)); - value = new DynamicSizedValue('A'); - value.setSize(lastValueSize); - cache.put(new Element(key, value)); - long calculatedInMemorySizeBytes = cache.getStatistics().getLocalHeapSizeInBytes(); - if (numChanges % 10 == 0) { - System.out.println("numChanges: " + numChanges + ", numRecalculates: " + numRecalculates.get() + ", InMemorySizeBytes: " - + calculatedInMemorySizeBytes + ", lastValueSize: " + lastValueSize); - } - valueSizeToCalculatedSizeList.add(new ValueSizeToCalculatedSizeTuple(lastValueSize, calculatedInMemorySizeBytes)); - numChanges++; - } - - for (int i = 0; i < 3; i++) { - cache.recalculateSize(key); - long calculatedMemorySizeBytes = cache.getStatistics().getLocalHeapSizeInBytes(); - System.out.println("calculatedMemorySizeBytes: " + calculatedMemorySizeBytes + ", lastValueSize: " + lastValueSize - + ", numRecalculates: " + numRecalculates.get()); - valueSizeToCalculatedSizeList.add(new ValueSizeToCalculatedSizeTuple(lastValueSize, calculatedMemorySizeBytes)); - Thread.sleep(1000); - } - - System.out.println("Done with changing size randomly. Waiting for all test threads to finish"); - - stop.set(true); - for (Thread t : threads) { - t.join(); - } - - cache.remove(key); - long sizeAfterRemove = cache.getStatistics().getLocalHeapSizeInBytes(); - Assert.assertEquals(0, sizeAfterRemove); - - for (ValueSizeToCalculatedSizeTuple tuple : valueSizeToCalculatedSizeList) { - int valueSize = tuple.valueSize; - long calculatedMemorySizeBytes = tuple.calculatedInMemorySizeBytes; - - Assert.assertEquals(0, cache.getStatistics().getLocalHeapSizeInBytes()); - DynamicSizedValue v = new DynamicSizedValue('A'); - v.setSize(valueSize); - cache.put(new Element(key, v)); - long actualCaculatedInMemorySize = cache.getStatistics().getLocalHeapSizeInBytes(); - System.out.println("valueSize: " + valueSize + ", expectedCalculatedMemorySizeBytes: " + calculatedMemorySizeBytes - + ", actual: " + actualCaculatedInMemorySize); - Assert.assertEquals(calculatedMemorySizeBytes, actualCaculatedInMemorySize); - - cache.remove(key); - } - - cacheManager.shutdown(); - } - - private static class ValueSizeToCalculatedSizeTuple { - final int valueSize; - final long calculatedInMemorySizeBytes; - - public ValueSizeToCalculatedSizeTuple(int valueSize, long calculatedInMemorySizeBytes) { - this.valueSize = valueSize; - this.calculatedInMemorySizeBytes = calculatedInMemorySizeBytes; - } - - } - - public static class DynamicSizedValue { - private volatile char[] chars; - private final char singleChar; - - public DynamicSizedValue(char singleChar) { - this.singleChar = singleChar; - } - - public void shrinkSize() { - this.chars = null; - } - - public void expandSize() { - setSize((int) MemoryUnit.MEGABYTES.toBytes(3)); - } - - private void setSize(int bytes) { - this.chars = null; - this.chars = new char[bytes]; - for (int i = 0; i < chars.length; i++) { - chars[i] = singleChar; - } - } - - } - -} Index: rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/org/terracotta/ehcache/tests/AbstractWriteBehindAtomicityTestBase.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/org/terracotta/ehcache/tests/AbstractWriteBehindAtomicityTestBase.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/org/terracotta/ehcache/tests/AbstractWriteBehindAtomicityTestBase.java (revision 0) @@ -1,73 +0,0 @@ -/* - * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved. - */ -package org.terracotta.ehcache.tests; - -import org.terracotta.tests.base.AbstractClientBase; - -import com.tc.test.config.model.TestConfig; -import com.tc.util.Assert; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileReader; - -public abstract class AbstractWriteBehindAtomicityTestBase extends AbstractCacheTestBase { - - public AbstractWriteBehindAtomicityTestBase(final String ehcacheConfigPath, TestConfig testConfig, - Class... c) { - super(ehcacheConfigPath, testConfig, c); - testConfig.getClientConfig().getBytemanConfig().setScript("/byteman/writeBehindAtomicity.btm"); - // disableTest(); - } - - // 1) Begin putWithWriter - // 2) lock() putWithWriter - // 3) Begin Transaction - // 4) Commit Transaction - // 5) unlock() putWithWriter - // 6) Done putWithWriter - @Override - protected void evaluateClientOutput(String clientName, int exitCode, File output) throws Throwable { - super.evaluateClientOutput(clientName, exitCode, output); - int txnCount = 0; - boolean underExplicitLock = false; - FileReader fr = null; - BufferedReader reader = null; - try { - fr = new FileReader(output); - reader = new BufferedReader(fr); - String st = ""; - while ((st = reader.readLine()) != null) { - // only check for main thread - if (st.contains("main")) { - if (st.contains("BEGINOPERATION")) { - Assert.assertEquals(false, underExplicitLock); - underExplicitLock = true; - } else if (st.contains("COMMITTRANSACTION") && underExplicitLock) { - txnCount++; - Assert.assertEquals(txnCount, 1); - } else if (st.contains("ENDOPERATION")) { - Assert.assertEquals(true, underExplicitLock); - underExplicitLock = false; - Assert.assertEquals(txnCount, 1); - txnCount = 0; - } - } - } - } catch (Exception e) { - throw new AssertionError(e); - } finally { - try { - fr.close(); - reader.close(); - } catch (Exception e) { - // - } - } - - Assert.assertEquals(false, underExplicitLock); - Assert.assertEquals(txnCount, 0); - } - -} \ No newline at end of file Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/util/counter/sampled/TimeStampedCounterValue.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/util/counter/sampled/TimeStampedCounterValue.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/util/counter/sampled/TimeStampedCounterValue.java (revision 0) @@ -1,68 +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.counter.sampled; - -import java.io.Serializable; - -/** - * A counter value at a particular time instance - * - * @author Abhishek Sanoujam - * @since 1.7 - */ -public class TimeStampedCounterValue implements Serializable { - private final long counterValue; - private final long timestamp; - - /** - * Constructor accepting the value of both timestamp and the counter value. - * - * @param timestamp - * @param value - */ - public TimeStampedCounterValue(long timestamp, long value) { - this.timestamp = timestamp; - this.counterValue = value; - } - - /** - * Get the counter value - * - * @return The counter value - */ - public long getCounterValue() { - return this.counterValue; - } - - /** - * Get value of the timestamp - * - * @return the timestamp associated with the current value - */ - public long getTimestamp() { - return this.timestamp; - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return "value: " + this.counterValue + ", timestamp: " + this.timestamp; - } - -} Index: rctags/ehcache-2.10.9.1.33/management-ehcache-v2/src/main/java/net/sf/ehcache/management/resource/CacheStatisticSampleEntityV2.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/management-ehcache-v2/src/main/java/net/sf/ehcache/management/resource/CacheStatisticSampleEntityV2.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/management-ehcache-v2/src/main/java/net/sf/ehcache/management/resource/CacheStatisticSampleEntityV2.java (revision 0) @@ -1,33 +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.Map; - -/** - * @author brandony - */ -public class CacheStatisticSampleEntityV2 extends AbstractCacheEntityV2{ - - private String statName; - - private Map statValueByTimeMillis; - - public String getStatName() { - return statName; - } - - public void setStatName(String statName) { - this.statName = statName; - } - - public Map getStatValueByTimeMillis() { - return statValueByTimeMillis; - } - - public void setStatValueByTimeMillis(Map statValueByTimeMillis) { - this.statValueByTimeMillis = statValueByTimeMillis; - } -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/hibernate/nonstop/NonstopAwareCollectionRegionAccessStrategy.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/hibernate/nonstop/NonstopAwareCollectionRegionAccessStrategy.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/hibernate/nonstop/NonstopAwareCollectionRegionAccessStrategy.java (revision 0) @@ -1,209 +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.nonstop; - -import net.sf.ehcache.constructs.nonstop.NonStopCacheException; - -import org.hibernate.cache.CacheException; -import org.hibernate.cache.CollectionRegion; -import org.hibernate.cache.access.CollectionRegionAccessStrategy; -import org.hibernate.cache.access.SoftLock; - -/** - * Implementation of {@link CollectionRegionAccessStrategy} that handles {@link NonStopCacheException} using - * {@link HibernateNonstopCacheExceptionHandler} - * - * @author Abhishek Sanoujam - * - */ -public class NonstopAwareCollectionRegionAccessStrategy implements CollectionRegionAccessStrategy { - - private final CollectionRegionAccessStrategy actualStrategy; - private final HibernateNonstopCacheExceptionHandler hibernateNonstopExceptionHandler; - - /** - * Constructor accepting the actual {@link CollectionRegionAccessStrategy} and the {@link HibernateNonstopCacheExceptionHandler} - * - * @param actualStrategy - * @param hibernateNonstopExceptionHandler - */ - public NonstopAwareCollectionRegionAccessStrategy(CollectionRegionAccessStrategy actualStrategy, - HibernateNonstopCacheExceptionHandler hibernateNonstopExceptionHandler) { - this.actualStrategy = actualStrategy; - this.hibernateNonstopExceptionHandler = hibernateNonstopExceptionHandler; - } - - /** - * {@inheritDoc} - * - * @see org.hibernate.cache.access.EntityRegionAccessStrategy#getRegion() - */ - public CollectionRegion getRegion() { - return actualStrategy.getRegion(); - } - - /** - * {@inheritDoc} - * - * @see org.hibernate.cache.access.EntityRegionAccessStrategy#evict(java.lang.Object) - */ - public void evict(Object key) throws CacheException { - try { - actualStrategy.evict(key); - } catch (NonStopCacheException nonStopCacheException) { - hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException); - } - } - - /** - * {@inheritDoc} - * - * @see org.hibernate.cache.access.EntityRegionAccessStrategy#evictAll() - */ - public void evictAll() throws CacheException { - try { - actualStrategy.evictAll(); - } catch (NonStopCacheException nonStopCacheException) { - hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException); - } - } - - /** - * {@inheritDoc} - * - * @see org.hibernate.cache.access.EntityRegionAccessStrategy#get(java.lang.Object, long) - */ - public Object get(Object key, long txTimestamp) throws CacheException { - try { - return actualStrategy.get(key, txTimestamp); - } catch (NonStopCacheException nonStopCacheException) { - hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException); - return null; - } - } - - /** - * {@inheritDoc} - * - * @see org.hibernate.cache.access.EntityRegionAccessStrategy#lockItem(java.lang.Object, java.lang.Object) - */ - public SoftLock lockItem(Object key, Object version) throws CacheException { - try { - return actualStrategy.lockItem(key, version); - } catch (NonStopCacheException nonStopCacheException) { - hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException); - return null; - } - } - - /** - * {@inheritDoc} - * - * @see org.hibernate.cache.access.EntityRegionAccessStrategy#lockRegion() - */ - public SoftLock lockRegion() throws CacheException { - try { - return actualStrategy.lockRegion(); - } catch (NonStopCacheException nonStopCacheException) { - hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException); - return null; - } - } - - /** - * {@inheritDoc} - * - * @see org.hibernate.cache.access.EntityRegionAccessStrategy#putFromLoad(java.lang.Object, java.lang.Object, long, java.lang.Object, - * boolean) - */ - public boolean putFromLoad(Object key, Object value, long txTimestamp, Object version, boolean minimalPutOverride) - throws CacheException { - try { - return actualStrategy.putFromLoad(key, value, txTimestamp, version, minimalPutOverride); - } catch (NonStopCacheException nonStopCacheException) { - hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException); - return false; - } - } - - /** - * {@inheritDoc} - * - * @see org.hibernate.cache.access.EntityRegionAccessStrategy#putFromLoad(java.lang.Object, java.lang.Object, long, java.lang.Object) - */ - public boolean putFromLoad(Object key, Object value, long txTimestamp, Object version) throws CacheException { - try { - return actualStrategy.putFromLoad(key, value, txTimestamp, version); - } catch (NonStopCacheException nonStopCacheException) { - hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException); - return false; - } - } - - /** - * {@inheritDoc} - * - * @see org.hibernate.cache.access.EntityRegionAccessStrategy#remove(java.lang.Object) - */ - public void remove(Object key) throws CacheException { - try { - actualStrategy.remove(key); - } catch (NonStopCacheException nonStopCacheException) { - hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException); - } - } - - /** - * {@inheritDoc} - * - * @see org.hibernate.cache.access.EntityRegionAccessStrategy#removeAll() - */ - public void removeAll() throws CacheException { - try { - actualStrategy.removeAll(); - } catch (NonStopCacheException nonStopCacheException) { - hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException); - } - } - - /** - * {@inheritDoc} - * - * @see org.hibernate.cache.access.EntityRegionAccessStrategy#unlockItem(java.lang.Object, org.hibernate.cache.access.SoftLock) - */ - public void unlockItem(Object key, SoftLock lock) throws CacheException { - try { - actualStrategy.unlockItem(key, lock); - } catch (NonStopCacheException nonStopCacheException) { - hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException); - } - } - - /** - * {@inheritDoc} - * - * @see org.hibernate.cache.access.EntityRegionAccessStrategy#unlockRegion(org.hibernate.cache.access.SoftLock) - */ - public void unlockRegion(SoftLock lock) throws CacheException { - try { - actualStrategy.unlockRegion(lock); - } catch (NonStopCacheException nonStopCacheException) { - hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException); - } - } - -} Index: rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/net/sf/ehcache/osgi/EvenCacheLoaderFactory.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/net/sf/ehcache/osgi/EvenCacheLoaderFactory.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/net/sf/ehcache/osgi/EvenCacheLoaderFactory.java (revision 0) @@ -1,19 +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.loader.CacheLoader; -import net.sf.ehcache.loader.CacheLoaderFactory; - -import java.util.Properties; - -public class EvenCacheLoaderFactory extends CacheLoaderFactory { - - @Override - public CacheLoader createCacheLoader(Ehcache cache, Properties properties) { - return new EvenCacheLoader(); - } - -} Index: rctags/ehcache-2.10.9.1.33/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/writebehind/operations/WriteAsyncOperation.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/writebehind/operations/WriteAsyncOperation.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/writebehind/operations/WriteAsyncOperation.java (revision 0) @@ -1,51 +0,0 @@ -/* - * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved. - */ -package org.terracotta.modules.ehcache.writebehind.operations; - -import net.sf.ehcache.Element; -import net.sf.ehcache.writer.CacheWriter; -import net.sf.ehcache.writer.writebehind.operations.SingleOperationType; - -public class WriteAsyncOperation implements SingleAsyncOperation { - - private static final long serialVersionUID = 1631728715404189659L; - - private final Element snapshot; - private final long creationTime; - - public WriteAsyncOperation(Element snapshot) { - this(snapshot, System.currentTimeMillis()); - } - - public WriteAsyncOperation(Element snapshot, long creationTime) { - this.snapshot = snapshot; - this.creationTime = creationTime; - } - - @Override - public Element getElement() { - return snapshot; - } - - @Override - public void performSingleOperation(CacheWriter cacheWriter) { - cacheWriter.write(snapshot); - } - - @Override - public Object getKey() { - return snapshot.getObjectKey(); - } - - @Override - public long getCreationTime() { - return creationTime; - } - - @Override - public void throwAwayElement(CacheWriter cacheWriter, RuntimeException e) { - cacheWriter.throwAway(snapshot, SingleOperationType.WRITE, e); - } - -} Index: rctags/ehcache-2.10.9.1.33/ehcache-scheduled-refresh/.project =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-scheduled-refresh/.project (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-scheduled-refresh/.project (revision 0) @@ -1,23 +0,0 @@ - - - ehcache-scheduled-refresh - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.m2e.core.maven2Builder - - - - - - org.eclipse.jdt.core.javanature - org.eclipse.m2e.core.maven2Nature - - Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/resources/ehcache-disk.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/resources/ehcache-disk.xml (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/resources/ehcache-disk.xml (revision 0) @@ -1,75 +0,0 @@ - - - - - - - - - - - - - - - - - Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/pool/PoolEvictor.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/pool/PoolEvictor.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/pool/PoolEvictor.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.pool; - -import java.util.Collection; - -/** - * PoolEvictors are responsible for finding the best candidates in a collection of resources using a shared - * resource pool and performing eviction on them. - * - * @param The type of the resources to free space on. - * @author Ludovic Orban - * @author Alex Snaps - */ -public interface PoolEvictor { - - /** - * Free at least N bytes from a collection of resources - * - * @param from a collection of resources to free from - * @param bytes the number of bytes to free up - * @return true if at least N bytes could be freed - */ - boolean freeSpace(Collection> from, long bytes); - -} Index: rctags/ehcache-2.10.9.1.33/management-ehcache-v2/src/main/java/net/sf/ehcache/management/service/CacheManagerServiceV2.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/management-ehcache-v2/src/main/java/net/sf/ehcache/management/service/CacheManagerServiceV2.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/management-ehcache-v2/src/main/java/net/sf/ehcache/management/service/CacheManagerServiceV2.java (revision 0) @@ -1,37 +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.management.resource.CacheManagerEntityV2; - -import org.terracotta.management.ServiceExecutionException; -import org.terracotta.management.resource.ResponseEntityV2; - -/** - * An interface for service implementations providing operations on CacheManager objects. - * - * @author brandony - */ -public interface CacheManagerServiceV2 { - - /** - * Update a cache manager represented by the submitted entity. - * - * @param cacheManagerName the name of the CacheManager to be updated - * @param resource the representation of the resource informing this update - * @throws ServiceExecutionException if the update fails - */ - void updateCacheManager(String cacheManagerName, - CacheManagerEntityV2 resource) throws ServiceExecutionException; - /** - * Execute query against cache manager and returns results array - * - * @param queryString - * @return {@code ResponseEntityV2} containing {@code QueryResultsEntityV2} entities - * @throws ServiceExecutionException - */ - ResponseEntityV2 executeQuery(String cacheManagerName, String queryString) throws ServiceExecutionException; -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/resources/nonstop/basic-cache-test.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/resources/nonstop/basic-cache-test.xml (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/resources/nonstop/basic-cache-test.xml (revision 0) @@ -1,17 +0,0 @@ - - - - - - - - - - - - - Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/store/disk/DiskStoreHelper.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/store/disk/DiskStoreHelper.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/store/disk/DiskStoreHelper.java (revision 0) @@ -1,59 +0,0 @@ -package net.sf.ehcache.store.disk; - -import net.sf.ehcache.Cache; -import net.sf.ehcache.CacheStoreHelper; -import net.sf.ehcache.store.CacheStore; -import net.sf.ehcache.store.LegacyStoreWrapper; -import net.sf.ehcache.store.Store; - -import java.lang.reflect.Field; -import java.util.concurrent.Future; - -/** - * @author Alex Snaps - */ -public class DiskStoreHelper { - - public static Future flushAllEntriesToDisk(final Cache cache) { - CacheStoreHelper cacheStoreHelper = new CacheStoreHelper(cache); - return flushAllEntriesToDisk(cacheStoreHelper.getStore()); - } - - public static Future flushAllEntriesToDisk(final Store store) { - if (store instanceof CacheStore) { - final DiskStore authority = getField("authoritativeTier", store); - return flushAllEntriesToDisk(authority); - } else if (store instanceof LegacyStoreWrapper) { - final DiskStore authority = getField("disk", store); - return flushAllEntriesToDisk(authority); - } else if (store instanceof DiskStore) { - final DiskStorageFactory factory = getField("disk", store); - return factory.flush(); - } else if (store instanceof LegacyStoreWrapper) { - final DiskStore disk = getField("disk", store); - return flushAllEntriesToDisk(disk); - } else { - return null; - } - } - - private static T getField(final String fieldName, final Object obj) { - try { - Field field = null; - Class clazz = obj.getClass(); - while(field == null && clazz != null) { - try { - field = clazz.getDeclaredField(fieldName); - } catch (NoSuchFieldException e) { - clazz = clazz.getSuperclass(); - } catch (SecurityException e) { - throw new RuntimeException(e); - } - } - field.setAccessible(true); - return (T) field.get(obj); - } catch (IllegalAccessException e) { - throw new RuntimeException(e); - } - } -} Index: rctags/ehcache-2.10.9.1.33/system-tests/src/test/resources/servermap/servermap-l1-capacity-test.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/system-tests/src/test/resources/servermap/servermap-l1-capacity-test.xml (revision 11516) +++ rctags/ehcache-2.10.9.1.33/system-tests/src/test/resources/servermap/servermap-l1-capacity-test.xml (revision 0) @@ -1,34 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - Index: rctags/ehcache-2.10.9.1.33/distribution/src/main/assembly/root/QUICK-START.html =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/distribution/src/main/assembly/root/QUICK-START.html (revision 11516) +++ rctags/ehcache-2.10.9.1.33/distribution/src/main/assembly/root/QUICK-START.html (revision 0) @@ -1,20 +0,0 @@ - - - - - - - - -Ehcache Quickstart - - - - - Index: rctags/ehcache-2.10.9.1.33/system-tests/src/test/resources/hibernate-config/nontransactional/domain/HolidayCalendar.hbm.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/system-tests/src/test/resources/hibernate-config/nontransactional/domain/HolidayCalendar.hbm.xml (revision 11516) +++ rctags/ehcache-2.10.9.1.33/system-tests/src/test/resources/hibernate-config/nontransactional/domain/HolidayCalendar.hbm.xml (revision 0) @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - - Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/store/LruMemoryStore.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/store/LruMemoryStore.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/store/LruMemoryStore.java (revision 0) @@ -1,719 +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.CacheEntry; -import net.sf.ehcache.CacheException; -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.PinningConfiguration; -import net.sf.ehcache.config.SizeOfPolicyConfiguration; -import net.sf.ehcache.pool.Size; -import net.sf.ehcache.pool.SizeOfEngine; -import net.sf.ehcache.pool.SizeOfEngineLoader; -import net.sf.ehcache.writer.CacheWriterManager; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import net.sf.ehcache.CacheOperationOutcomes.EvictionOutcome; -import net.sf.ehcache.statistics.StatisticBuilder; -import net.sf.ehcache.store.StoreOperationOutcomes.GetOutcome; -import org.terracotta.statistics.Statistic; -import org.terracotta.statistics.observer.OperationObserver; - -import net.sf.ehcache.store.StoreOperationOutcomes.PutOutcome; -import net.sf.ehcache.store.StoreOperationOutcomes.RemoveOutcome; - -/** - * An implementation of a LruMemoryStore. - *

- * This uses {@link java.util.LinkedHashMap} as its backing map. It uses the {@link java.util.LinkedHashMap} LRU - * feature. LRU for this implementation means least recently accessed. - * - * @author Greg Luck - * @version $Id$ - */ -public class LruMemoryStore extends AbstractStore { - - private static final Logger LOG = LoggerFactory.getLogger(LruMemoryStore.class.getName()); - - /** - * The cache this store is associated with. - */ - protected Ehcache cache; - - /** - * Map where items are stored by key. - */ - protected Map map; - - /** - * The DiskStore associated with this MemoryStore. - */ - protected final Store diskStore; - - /** - * status. - */ - protected Status status; - - /** - * The maximum size of the store (0 == no limit) - */ - protected long maximumSize; - - private final boolean cachePinned; - private final boolean elementPinningEnabled; - - private final CopyStrategyHandler copyStrategyHandler; - - - private final OperationObserver getObserver = StatisticBuilder.operation(GetOutcome.class).named("get").of(this) - .tag("local-heap").build(); - private final OperationObserver putObserver = StatisticBuilder.operation(PutOutcome.class).named("put").of(this) - .tag("local-heap").build(); - private final OperationObserver removeObserver = StatisticBuilder.operation(RemoveOutcome.class).named("remove").of(this) - .tag("local-heap").build(); - private final OperationObserver evictionObserver; - - - /** - * Constructor for the LruMemoryStore object - * The backing {@link java.util.LinkedHashMap} is created with LRU by access order. - */ - public LruMemoryStore(Ehcache cache, Store diskStore) { - status = Status.STATUS_UNINITIALISED; - this.maximumSize = cache.getCacheConfiguration().getMaxEntriesLocalHeap(); - this.cachePinned = determineCachePinned(cache.getCacheConfiguration()); - this.elementPinningEnabled = !cache.getCacheConfiguration().isOverflowToOffHeap(); - this.cache = cache; - this.diskStore = diskStore; - if (cache.getCacheConfiguration().isOverflowToDisk()) { - evictionObserver = null; - } else { - evictionObserver = StatisticBuilder.operation(EvictionOutcome.class).named("eviction").of(this).build(); - } - map = new SpoolingLinkedHashMap(); - status = Status.STATUS_ALIVE; - copyStrategyHandler = MemoryStore.getCopyStrategyHandler(cache); - } - - private boolean determineCachePinned(CacheConfiguration cacheConfiguration) { - PinningConfiguration pinningConfiguration = cacheConfiguration.getPinningConfiguration(); - if (pinningConfiguration == null) { - return false; - } - - switch (pinningConfiguration.getStore()) { - case LOCALMEMORY: - return false; - - case INCACHE: - return !cacheConfiguration.isOverflowToOffHeap() && !cacheConfiguration.isOverflowToDisk(); - - default: - throw new IllegalArgumentException(); - } - } - - /** - * Puts an item in the cache. Note that this automatically results in - * {@link net.sf.ehcache.store.LruMemoryStore.SpoolingLinkedHashMap#removeEldestEntry} being called. - * - * @param element the element to add - */ - public final boolean put(Element element) throws CacheException { - return putInternal(element, null); - } - - /** - * {@inheritDoc} - */ - public final boolean putWithWriter(Element element, CacheWriterManager writerManager) throws CacheException { - return putInternal(element, writerManager); - } - - private synchronized boolean putInternal(Element element, CacheWriterManager writerManager) throws CacheException { - putObserver.begin(); - boolean newPut = true; - if (element != null) { - newPut = map.put(element.getObjectKey(), element) == null; - if (writerManager != null) { - writerManager.put(element); - } - doPut(element); - } - if (newPut) { - putObserver.end(PutOutcome.ADDED); - } else { - putObserver.end(PutOutcome.UPDATED); - } - return newPut; - } - - /** - * Allow specialised actions over adding the element to the map. - * - * @param element - */ - protected void doPut(Element element) throws CacheException { - //empty - } - - /** - * Gets an item from the cache. - *

- * The last access time in {@link net.sf.ehcache.Element} is updated. - * - * @param key the cache key - * @return the element, or null if there was no match for the key - */ - public final synchronized Element get(Object key) { - getObserver.begin(); - Element e = (Element) map.get(key); - if (e == null) { - getObserver.end(GetOutcome.MISS); - return null; - } else { - getObserver.end(GetOutcome.HIT); - return e; - } - } - - /** - * Gets an item from the cache, without updating statistics. - * - * @param key the cache key - * @return the element, or null if there was no match for the key - */ - public final synchronized Element getQuiet(Object key) { - return (Element) map.get(key); - } - - /** - * Removes an Element from the store. - * - * @param key the key of the Element, usually a String - * @return the Element if one was found, else null - */ - public final Element remove(Object key) { - return removeInternal(key, null); - } - - /** - * {@inheritDoc} - */ - public final Element removeWithWriter(Object key, CacheWriterManager writerManager) throws CacheException { - return removeInternal(key, writerManager); - } - - private synchronized Element removeInternal(Object key, CacheWriterManager writerManager) throws CacheException { - // remove single item. - removeObserver.begin(); - Element element = (Element) map.remove(key); - if (writerManager != null) { - writerManager.remove(new CacheEntry(key, element)); - } - removeObserver.end(RemoveOutcome.SUCCESS); - if (element != null) { - return element; - } else { - return null; - } - } - - /** - * Remove all of the elements from the store. - */ - public final synchronized void removeAll() throws CacheException { - clear(); - } - - /** - * Clears any data structures and places it back to its state when it was first created. - */ - protected final void clear() { - map.clear(); - } - - /** - * Prepares for shutdown. - */ - public final synchronized void dispose() { - if (status.equals(Status.STATUS_SHUTDOWN)) { - return; - } - status = Status.STATUS_SHUTDOWN; - flush(); - - //release reference to cache - cache = null; - } - - - /** - * Flush to disk only if the cache is diskPersistent. - */ - public final void flush() { - if (cache.getCacheConfiguration().isDiskPersistent()) { - if (LOG.isDebugEnabled()) { - LOG.debug(cache.getName() + " is persistent. Spooling " + map.size() + " elements to the disk store."); - } - spoolAllToDisk(); - } - - //should be emptied if clearOnFlush is true - if (cache.getCacheConfiguration().isClearOnFlush()) { - clear(); - } - } - - - /** - * Spools all elements to disk, in preparation for shutdown. - *

- * This revised implementation is a little slower but avoids using increased memory during the method. - */ - protected final void spoolAllToDisk() { - boolean clearOnFlush = cache.getCacheConfiguration().isClearOnFlush(); - for (Object key : getKeys()) { - Element element = (Element) map.get(key); - if (element != null) { - if (!element.isSerializable()) { - if (LOG.isWarnEnabled()) { - LOG.warn("Object with key " + element.getObjectKey() - + " is not Serializable and is not being overflowed to disk."); - } - } else { - spoolToDisk(element); - //Don't notify listeners. They are not being removed from the cache, only a store - //Leave it in the memory store for performance if do not want to clear on flush - if (clearOnFlush) { - remove(key); - } - } - } - } - } - - /** - * Puts the element in the DiskStore. - * Should only be called if isOverflowToDisk is true - *

- * Relies on being called from a synchronized method - * - * @param element The Element - */ - protected void spoolToDisk(Element element) { - diskStore.put(element); - if (LOG.isDebugEnabled()) { - LOG.debug(cache.getName() + "Cache: spool to disk done for: " + element.getObjectKey()); - } - } - - /** - * Gets the status of the MemoryStore. - */ - public final Status getStatus() { - return status; - } - - /** - * Gets an Array of the keys for all elements in the memory cache. - *

- * Does not check for expired entries - * - * @return An Object[] - */ - public final synchronized List getKeys() { - return new ArrayList(map.keySet()); - } - - /** - * Returns the current cache size. - * - * @return The size value - */ - public final int getSize() { - return map.size(); - } - - /** - * Returns nothing since a disk store isn't clustered - * - * @return returns 0 - */ - public final int getTerracottaClusteredSize() { - return 0; - } - - - /** - * An unsynchronized check to see if a key is in the Store. No check is made to see if the Element is expired. - * - * @param key The Element key - * @return true if found. If this method return false, it means that an Element with the given key is definitely not in the MemoryStore. - * If it returns true, there is an Element there. An attempt to get it may return null if the Element has expired. - */ - public final boolean containsKey(Object key) { - return map.containsKey(key); - } - - - /** - * Measures the size of the memory store by using the sizeof engine. - *

- * Warning: This method can be very expensive to run. Allow approximately 1 second - * per 1MB of entries. Running this method could create liveness problems - * because the object lock is held for a long period - * - * @return the size, in bytes - */ - public final synchronized long getSizeInBytes() throws CacheException { - SizeOfEngine defaultSizeOfEngine = SizeOfEngineLoader.newSizeOfEngine( - SizeOfPolicyConfiguration.resolveMaxDepth(cache), - SizeOfPolicyConfiguration.resolveBehavior(cache) - .equals(SizeOfPolicyConfiguration.MaxDepthExceededBehavior.ABORT), - true - ); - long sizeInBytes = 0; - for (Object o : map.entrySet()) { - Map.Entry entry = (Map.Entry)o; - Element element = (Element) entry.getValue(); - if (element != null) { - Size size = defaultSizeOfEngine.sizeOf(entry.getKey(), element, null); - sizeInBytes += size.getCalculated(); - } - } - return sizeInBytes; - } - - - /** - * Evict the Element. - *

- * Evict means that the Element is: - *

    - *
  • if, the store is diskPersistent, the Element is spooled to the DiskStore - *
  • if not, the Element is removed. - *
- * - * @param element the Element to be evicted. - */ - protected final void evict(Element element) throws CacheException { - if (cache.getCacheConfiguration().isOverflowToDisk()) { - if (!element.isSerializable()) { - if (LOG.isWarnEnabled()) { - LOG.warn(new StringBuilder("Object with key ").append(element.getObjectKey()) - .append(" is not Serializable and cannot be overflowed to disk").toString()); - } - cache.getCacheEventNotificationService().notifyElementEvicted(copyStrategyHandler.copyElementForReadIfNeeded(element), false); - } else { - spoolToDisk(element); - } - } else { - evictionObserver.begin(); - evictionObserver.end(EvictionOutcome.SUCCESS); - cache.getCacheEventNotificationService().notifyElementEvicted(copyStrategyHandler.copyElementForReadIfNeeded(element), false); - } - } - - /** - * Before eviction elements are checked. - * - * @param element - */ - protected final void notifyExpiry(Element element) { - cache.getCacheEventNotificationService().notifyElementExpiry(copyStrategyHandler.copyElementForReadIfNeeded(element), false); - } - - - /** - * An algorithm to tell if the MemoryStore is at or beyond its carrying capacity. - */ - protected final boolean isFull() { - return maximumSize > 0 && map.size() > maximumSize; - } - - /** - * Expire all elsments. - *

- * This is a default implementation which does nothing. Expiry on demand is only - * implemented for disk stores. - */ - public void expireElements() { - //empty implementation - } - - /** - * Memory stores are never backed up and always return false - */ - public boolean bufferFull() { - return false; - } - - - /** - * Package local access to the map for testing - */ - Map getBackingMap() { - return map; - } - - /** - * {@inheritDoc} - */ - public Object getMBean() { - return null; - } - - /** - * An extension of LinkedHashMap which overrides {@link #removeEldestEntry} - * to persist cache entries to the auxiliary cache before they are removed. - *

- * This implementation also provides LRU by access order. - */ - public final class SpoolingLinkedHashMap extends java.util.LinkedHashMap { - private static final int INITIAL_CAPACITY = 100; - private static final float GROWTH_FACTOR = .75F; - - /** - * Default constructor. - * Will create an initial capacity of 100, a loading of .75 and - * LRU by access order. - */ - public SpoolingLinkedHashMap() { - super(INITIAL_CAPACITY, GROWTH_FACTOR, true); - } - - /** - * Returns true if this map should remove its eldest entry. - * This method is invoked by put and putAll after - * inserting a new entry into the map. It provides the implementer - * with the opportunity to remove the eldest entry each time a new one - * is added. This is useful if the map represents a cache: it allows - * the map to reduce memory consumption by deleting stale entries. - *

- * Will return true if: - *

    - *
  1. the element has expired - *
  2. the cache size is greater than the in-memory actual. - * In this case we spool to disk before returning. - *
- * - * @param eldest The least recently inserted entry in the map, or if - * this is an access-ordered map, the least recently accessed - * entry. This is the entry that will be removed it this - * method returns true. If the map was empty prior - * to the put or putAll invocation resulting - * in this invocation, this will be the entry that was just - * inserted; in other words, if the map contains a single - * entry, the eldest entry is also the newest. - * @return true if the eldest entry should be removed - * from the map; false if it should be retained. - */ - @Override - protected final boolean removeEldestEntry(Map.Entry eldest) { - Element element = (Element) eldest.getValue(); - return element != null && removeLeastRecentlyUsedElement(element); - } - - /** - * {@inheritDoc} - */ - @Override - public Object put(Object key, Object value) { - Object put = super.put(key, value); - - Iterator it = entrySet().iterator(); - while (isFull() && it.hasNext()) { - Map.Entry entry = (Map.Entry) it.next(); - if (removeEldestEntry(entry)) { - it.remove(); - } - } - - return put; - } - - /** - * Relies on being called from a synchronized method - * - * @param element - * @return true if the LRU element should be removed - */ - private boolean removeLeastRecentlyUsedElement(Element element) throws CacheException { - //check for expiry and remove before going to the trouble of spooling it - if (element.isExpired()) { - notifyExpiry(element); - return true; - } - - if (isFull() && !cachePinned) { - evict(element); - return true; - } else { - return false; - } - - } - } - - - /** - * @return the current eviction policy. This may not be the configured policy, if it has been - * dynamically set. - * @see #setEvictionPolicy(Policy) - */ - public Policy getEvictionPolicy() { - return new LruPolicy(); - } - - /** - * Sets the eviction policy strategy. The Store will use a policy at startup. The store may allow changing - * the eviction policy strategy dynamically. Otherwise implementations will throw an exception if this method - * is called. - * - * @param policy the new policy - */ - public void setEvictionPolicy(Policy policy) { - throw new UnsupportedOperationException("This store is LRU only. It does not support changing the eviction" + - " strategy."); - } - - /** - * {@inheritDoc} - */ - public Object getInternalContext() { - return null; - } - - /** - * {@inheritDoc} - */ - public boolean containsKeyInMemory(Object key) { - return containsKey(key); - } - - /** - * {@inheritDoc} - */ - public boolean containsKeyOffHeap(Object key) { - return false; - } - - /** - * {@inheritDoc} - */ - public boolean containsKeyOnDisk(Object key) { - return false; - } - - /** - * {@inheritDoc} - */ - public Policy getInMemoryEvictionPolicy() { - return getEvictionPolicy(); - } - - /** - * {@inheritDoc} - */ - @Statistic(name = "size", tags = "local-heap") - public int getInMemorySize() { - return getSize(); - } - - /** - * {@inheritDoc} - */ - @Statistic(name = "size-in-bytes", tags = "local-heap") - public long getInMemorySizeInBytes() { - return getSizeInBytes(); - } - - /** - * {@inheritDoc} - */ - public int getOffHeapSize() { - return 0; - } - - /** - * {@inheritDoc} - */ - public long getOffHeapSizeInBytes() { - return 0; - } - - /** - * {@inheritDoc} - */ - public int getOnDiskSize() { - return 0; - } - - /** - * {@inheritDoc} - */ - public long getOnDiskSizeInBytes() { - return 0; - } - - /** - * {@inheritDoc} - */ - public void setInMemoryEvictionPolicy(Policy policy) { - setEvictionPolicy(policy); - } - - /** - * Unsupported in LruMemoryStore - */ - public Element putIfAbsent(Element element) throws NullPointerException { - throw new UnsupportedOperationException(); - } - - /** - * Unsupported in LruMemoryStore - */ - public Element removeElement(Element element, ElementValueComparator comparator) throws NullPointerException { - throw new UnsupportedOperationException(); - } - - /** - * Unsupported in LruMemoryStore - */ - public boolean replace(Element old, Element element, ElementValueComparator comparator) - throws NullPointerException, IllegalArgumentException { - throw new UnsupportedOperationException(); - } - - /** - * Unsupported in LruMemoryStore - */ - public Element replace(Element element) throws NullPointerException { - throw new UnsupportedOperationException(); - } -} - Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/writer/TestCacheWriterRetries.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/writer/TestCacheWriterRetries.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/writer/TestCacheWriterRetries.java (revision 0) @@ -1,237 +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 java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import net.sf.ehcache.CacheEntry; -import net.sf.ehcache.CacheException; -import net.sf.ehcache.Element; -import net.sf.ehcache.writer.writebehind.operations.SingleOperationType; - -public class TestCacheWriterRetries extends AbstractTestCacheWriter { - private final int retries; - private final List writerEvents = new ArrayList(); - private final Map retryCount = new HashMap(); - private final Map writeCount = new HashMap(); - private final Map deleteCount = new HashMap(); - private final Map> thrownAwayElements = new HashMap>(); - private volatile boolean throwing = true; - - { - for (SingleOperationType singleOperationType : SingleOperationType.values()) { - thrownAwayElements.put(singleOperationType, new ArrayList()); - } - } - - public TestCacheWriterRetries(int retries) { - this.retries = retries; - } - - public List getWriterEvents() { - return writerEvents; - } - - public Map getWriteCount() { - return writeCount; - } - - public Map getDeleteCount() { - return deleteCount; - } - - private void failUntilNoMoreRetries(Object key) { - int remainingRetries; - if (!retryCount.containsKey(key)) { - remainingRetries = retries; - } else { - remainingRetries = retryCount.get(key); - } - if (remainingRetries-- > 0) { - retryCount.put(key, remainingRetries); - throw new RuntimeException("Throwing exception to test retries, " + remainingRetries + " remaining for " + key); - } - retryCount.remove(key); - } - - private void increaseWriteCount(Object key) { - if (!writeCount.containsKey(key)) { - writeCount.put(key, 1); - } else { - writeCount.put(key, writeCount.get(key) + 1); - } - } - - private void increaseDeleteCount(Object key) { - if (!deleteCount.containsKey(key)) { - deleteCount.put(key, 1); - } else { - deleteCount.put(key, deleteCount.get(key) + 1); - } - } - - private void put(Object key, Element element) { - writerEvents.add(new WriterEvent(element)); - increaseWriteCount(key); - } - - @Override - public synchronized void write(Element element) throws CacheException { - final Object key = element.getObjectKey(); - if (throwing) { - failUntilNoMoreRetries(key); - } - put(key, element); - } - - @Override - public synchronized void writeAll(Collection elements) throws CacheException { - Iterator it = elements.iterator(); - while (it.hasNext()) { - Element element = it.next(); - // fail on the last item in the batch - final Object key = element.getObjectKey(); - if (!it.hasNext() && throwing) { - failUntilNoMoreRetries(key); - } - put(key, element); - } - } - - private void remove(Object key) { - writerEvents.add(new WriterEvent(key)); - increaseDeleteCount(key); - } - - @Override - public synchronized void delete(CacheEntry entry) throws CacheException { - Object key = entry.getKey(); - if (throwing) { - failUntilNoMoreRetries(key); - } - remove(key); - } - - @Override - public synchronized void deleteAll(Collection entries) throws CacheException { - Iterator it = entries.iterator(); - while (it.hasNext()) { - CacheEntry entry = it.next(); - Object key = entry.getKey(); - if (!it.hasNext() && throwing) { - failUntilNoMoreRetries(key); - } - remove(key); - } - } - - @Override - public void throwAway(final Element element, final SingleOperationType operationType, final RuntimeException e) { - thrownAwayElements.get(operationType).add(element); - } - - public void setThrowing(final boolean throwing) { - this.throwing = throwing; - } - - public boolean isThrowing() { - return throwing; - } - - public List getThrownAwayElements(SingleOperationType type) { - return Collections.unmodifiableList(thrownAwayElements.get(type)); - } - - class WriterEvent { - - private final Object removedKey; - private final Element addedElement; - private final long time; - private final int writtenSize; - private final Map writeCount; - private final Map deleteCount; - - WriterEvent(Object key) { - this.removedKey = key; - this.addedElement = null; - time = System.nanoTime(); - writtenSize = TestCacheWriterRetries.this.writerEvents.size(); - writeCount = new HashMap(TestCacheWriterRetries.this.writeCount); - deleteCount = new HashMap(TestCacheWriterRetries.this.deleteCount); - } - - WriterEvent(Element element) { - this.removedKey = null; - this.addedElement = element; - time = System.nanoTime(); - writtenSize = TestCacheWriterRetries.this.writerEvents.size(); - writeCount = new HashMap(TestCacheWriterRetries.this.writeCount); - deleteCount = new HashMap(TestCacheWriterRetries.this.deleteCount); - } - - int getWrittenSize() { - return writtenSize; - } - - int getWriteCount(Object key) { - Integer value = writeCount.get(key); - if (value == null) { - return 0; - } else { - return value; - } - } - - int getDeleteCount(Object key) { - Integer value = deleteCount.get(key); - if (value == null) { - return 0; - } else { - return value; - } - } - - long getTime() { - return time; - } - - Element getAddedElement() { - return addedElement; - } - - Object getRemovedKey() { - return removedKey; - } - - @Override - public String toString() { - if (addedElement != null) { - return "ADDED : " + addedElement.getObjectKey() + " @ " + time; - } else if (removedKey != null) { - return "REMOVED : " + removedKey + " @ " + time; - } else { - return "UNKNOWN : @ " + time; - } - } - } -} Index: rctags/ehcache-2.10.9.1.33/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/writebehind/operations/WriteAllAsyncOperation.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/writebehind/operations/WriteAllAsyncOperation.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/writebehind/operations/WriteAllAsyncOperation.java (revision 0) @@ -1,28 +0,0 @@ -/* - * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved. - */ -package org.terracotta.modules.ehcache.writebehind.operations; - - -import net.sf.ehcache.Element; -import net.sf.ehcache.writer.CacheWriter; - -import java.util.Collection; - -/** - * Implements the write all operation for write behind - * - * @author Abhishek Maheshwari - */ - -public class WriteAllAsyncOperation implements BatchAsyncOperation { - private final Collection elements; - - public WriteAllAsyncOperation(Collection elements) { - this.elements = elements; - } - - public void performBatchOperation(CacheWriter cacheWriter) { - cacheWriter.writeAll(elements); - } -} Index: rctags/ehcache-2.10.9.1.33/ehcache/src/test/java/net/sf/ehcache/terracotta/upgradability/serialization/LegacyCopyStrategyAdapterSerializationTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache/src/test/java/net/sf/ehcache/terracotta/upgradability/serialization/LegacyCopyStrategyAdapterSerializationTest.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache/src/test/java/net/sf/ehcache/terracotta/upgradability/serialization/LegacyCopyStrategyAdapterSerializationTest.java (revision 0) @@ -1,56 +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 net.sf.ehcache.store.compound.CopyStrategy; -import net.sf.ehcache.store.compound.LegacyCopyStrategyAdapter; -import org.junit.Test; - -import static org.terracotta.upgradability.serialization.SerializationUpgradabilityTesting.validateSerializedForm; - -/** - * - * @author cdennis - */ -public class LegacyCopyStrategyAdapterSerializationTest { - - private static final Comparator COMPARATOR = new Comparator() { - - @Override - public int compare(LegacyCopyStrategyAdapter o1, LegacyCopyStrategyAdapter o2) { - ClassLoader loader = getClass().getClassLoader(); - return o1.copyForRead(null, loader).getObjectKey().equals(o2.copyForRead(null, loader).getObjectKey()) ? 0 : -1; - } - }; - - @Test - public void testBasic() throws IOException, ClassNotFoundException { - validateSerializedForm(new LegacyCopyStrategyAdapter(new DummyCopyStrategy()), COMPARATOR, "serializedforms/LegacyCopyStrategyAdapterSerializationTest.testBasic.ser"); - } - - static class DummyCopyStrategy implements CopyStrategy { - - @Override - public Object copy(Object value) { - return new Element("foo", null); - } - } -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/store/MemoryLimitedCacheLoaderTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/store/MemoryLimitedCacheLoaderTest.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/store/MemoryLimitedCacheLoaderTest.java (revision 0) @@ -1,113 +0,0 @@ -package net.sf.ehcache.store; - -import net.sf.ehcache.CacheException; -import net.sf.ehcache.Ehcache; -import net.sf.ehcache.config.CacheConfiguration; -import net.sf.ehcache.statistics.StatisticsGateway; - -import org.junit.Before; -import org.junit.Test; - -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -/** - * MemoryLimitedCacheLoaderTest - */ -public class MemoryLimitedCacheLoaderTest { - - private Ehcache cache; - private CacheConfiguration configuration; - private TestCacheLoader loader; - private StatisticsGateway statisticsGateway; - - @Before - public void setUp() { - cache = mock(Ehcache.class); - configuration = new CacheConfiguration(); - when(cache.getCacheConfiguration()).thenReturn(configuration); - statisticsGateway = mock(StatisticsGateway.class); - when(cache.getStatistics()).thenReturn(statisticsGateway); - loader = new TestCacheLoader(); - - } - - @Test - public void testCountBasedLimitSetToNoLimit() { - configuration.setOverflowToOffHeap(false); - configuration.setMaxEntriesLocalHeap(0); - - assertThat(loader.isInMemoryLimitReached(cache, 0), is(false)); - assertThat(loader.isInMemoryLimitReached(cache, Integer.MAX_VALUE), is(true)); - } - - @Test - public void testCountBasedLimitSetToSomeLimit() { - configuration.setOverflowToOffHeap(false); - int maxEntriesLocalHeap = 10; - configuration.setMaxEntriesLocalHeap(maxEntriesLocalHeap); - - assertThat(loader.isInMemoryLimitReached(cache, maxEntriesLocalHeap - 2), is(false)); - assertThat(loader.isInMemoryLimitReached(cache, maxEntriesLocalHeap), is(true)); - assertThat(loader.isInMemoryLimitReached(cache, maxEntriesLocalHeap + 2), is(true)); - } - - @Test - public void testLocalHeapSizeBased() { - configuration.setOverflowToOffHeap(false); - configuration.setMaxBytesLocalHeap(1024L); - - when(statisticsGateway.getLocalHeapSize()).thenReturn(0L, 1L, 4L); - when(statisticsGateway.getLocalHeapSizeInBytes()).thenReturn(250L, 1000L); - - assertThat(loader.isInMemoryLimitReached(cache, 0), is(false)); - assertThat(loader.isInMemoryLimitReached(cache, 1), is(false)); - assertThat(loader.isInMemoryLimitReached(cache, 4), is(true)); - } - - @Test - public void testOffHeapSizeBased() { - configuration.setOverflowToOffHeap(true); - configuration.setMaxBytesLocalHeap(1024L); - configuration.setMaxBytesLocalOffHeap(2048L); - - when(statisticsGateway.getLocalOffHeapSize()).thenReturn(0L, 1L, 4L); - when(statisticsGateway.getLocalOffHeapSizeInBytes()).thenReturn(500L, 2000L); - - assertThat(loader.isInMemoryLimitReached(cache, 0), is(false)); - assertThat(loader.isInMemoryLimitReached(cache, 1), is(false)); - assertThat(loader.isInMemoryLimitReached(cache, 4), is(true)); - } - - @Test - public void testPooledOffHeapSizeBased() { - // Sizing info is in CacheManager, never consulted by MemoryLimitedCacheLoader - configuration.setOverflowToOffHeap(true); - - assertThat(loader.isInMemoryLimitReached(cache, 0), is(false)); - assertThat(loader.isInMemoryLimitReached(cache, Integer.MAX_VALUE), is(true)); - } - - @Test - public void testPooledHeapSizeBased() { - // Sizing info is in CacheManager, never consulted by MemoryLimitedCacheLoader - - assertThat(loader.isInMemoryLimitReached(cache, 0), is(false)); - assertThat(loader.isInMemoryLimitReached(cache, Integer.MAX_VALUE), is(true)); - } - - private static class TestCacheLoader extends MemoryLimitedCacheLoader { - - @Override - public void load(Ehcache cache) throws CacheException { - // no-op - } - - @Override - public boolean isAsynchronous() { - return true; // not used - } - } -} Index: rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/org/terracotta/ehcache/tests/BasicStandaloneCacheTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/org/terracotta/ehcache/tests/BasicStandaloneCacheTest.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/org/terracotta/ehcache/tests/BasicStandaloneCacheTest.java (revision 0) @@ -1,18 +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.ehcache.tests; - -import org.junit.experimental.categories.Category; -import org.terracotta.test.categories.CheckShorts; - -import com.tc.test.config.model.TestConfig; - -@Category(CheckShorts.class) -public class BasicStandaloneCacheTest extends AbstractCacheTestBase { - - public BasicStandaloneCacheTest(TestConfig testConfig) { - super("basic-cache-test.xml", testConfig); - } -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/pool/sizeof/annotations/package.html =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/pool/sizeof/annotations/package.html (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/pool/sizeof/annotations/package.html (revision 0) @@ -1,7 +0,0 @@ - - - - -This package contains annotations to control SizeOf calculations for the pooling in Ehcache. - - Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/statistics/extended/AbstractStatistic.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/statistics/extended/AbstractStatistic.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/statistics/extended/AbstractStatistic.java (revision 0) @@ -1,91 +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.List; -import java.util.concurrent.ScheduledExecutorService; - -import net.sf.ehcache.statistics.extended.ExtendedStatistics.Statistic; - -import org.terracotta.statistics.ValueStatistic; -import org.terracotta.statistics.archive.Timestamped; - -/** - * The Class AbstractStatistic. - * - * @param the generic type - * @author cdennis - */ -abstract class AbstractStatistic implements Statistic { - - /** The source. */ - private final ValueStatistic source; - - /** The history. */ - private final SampledStatistic history; - - /** - * Instantiates a new abstract statistic. - * - * @param executor the executor - * @param historySize the history size - * @param historyNanos the history nanos - */ - AbstractStatistic(ValueStatistic source, ScheduledExecutorService executor, int historySize, long historyNanos) { - this.source = source; - this.history = new SampledStatistic(source, executor, historySize, historyNanos); - } - - /** - * {@inheritDoc} - */ - @Override - public T value() { - return source.value(); - } - - /** - * {@inheritDoc} - */ - @Override - public List> history() { - return history.history(); - } - - /** - * Start sampling. - */ - final void startSampling() { - history.startSampling(); - } - - /** - * Stop sampling. - */ - final void stopSampling() { - history.stopSampling(); - } - - /** - * Sets the history. - * - * @param historySize the history size - * @param historyNanos the history nanos - */ - final void setHistory(int historySize, long historyNanos) { - history.adjust(historySize, historyNanos); - } -} Index: rctags/ehcache-2.10.9.1.33/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/store/nonstop/RejoinWithoutNonStopStore.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/store/nonstop/RejoinWithoutNonStopStore.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/store/nonstop/RejoinWithoutNonStopStore.java (revision 0) @@ -1,614 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package org.terracotta.modules.ehcache.store.nonstop; - -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import net.sf.ehcache.Element; -import net.sf.ehcache.Status; -import net.sf.ehcache.config.CacheConfiguration; -import net.sf.ehcache.constructs.nonstop.RejoinCacheException; -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; - -/** - * - * @author cdennis - */ -public final class RejoinWithoutNonStopStore implements TerracottaStore { - - /** - * the singleton instance - */ - private static final RejoinWithoutNonStopStore INSTANCE = new RejoinWithoutNonStopStore(); - - /** - * private constructor - */ - private RejoinWithoutNonStopStore() { - // - } - - /** - * returns the singleton instance - */ - public static RejoinWithoutNonStopStore getInstance() { - return INSTANCE; - } - - /** - * {@inheritDoc}. - *

- * Throws {@link RejoinCacheException} - */ - @Override - public Element get(Object key) throws RejoinCacheException { - throw new RejoinCacheException("Client started rejoin during get(Object key)"); - } - - /** - * {@inheritDoc} - */ - @Override - public Element getQuiet(Object key) throws RejoinCacheException { - throw new RejoinCacheException("Client started rejoin during getQuiet(Object key)"); - } - - /** - * {@inheritDoc} - *

- * Throws {@link RejoinCacheException} - */ - @Override - public Map getAllQuiet(Collection keys) throws RejoinCacheException { - throw new RejoinCacheException("Client started rejoin during getAllQuiet(Collection keys)"); - } - - /** - * {@inheritDoc} - *

- * Throws {@link RejoinCacheException} - */ - @Override - public Map getAll(Collection keys) throws RejoinCacheException { - throw new RejoinCacheException("Client started rejoin during getAll(Collection keys)"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link RejoinCacheException} - */ - @Override - public List getKeys() throws RejoinCacheException { - throw new RejoinCacheException("Client started rejoin during getKeys()"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link RejoinCacheException} - */ - @Override - public boolean put(Element element) throws RejoinCacheException { - throw new RejoinCacheException("Client started rejoin during put(Element element)"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link RejoinCacheException} - */ - @Override - public void putAll(Collection elements) throws RejoinCacheException { - throw new RejoinCacheException("Client started rejoin during putAll(Collection elements)"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link RejoinCacheException} - */ - @Override - public Element remove(Object key) throws RejoinCacheException { - throw new RejoinCacheException("Client started rejoin during remove(Object key)"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link RejoinCacheException} - */ - @Override - public void removeAll(Collection keys) throws RejoinCacheException { - throw new RejoinCacheException("Client started rejoin during removeAll(Collection keys)"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link RejoinCacheException} - */ - @Override - public void removeAll() throws RejoinCacheException { - throw new RejoinCacheException("Client started rejoin during removeAll()"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link RejoinCacheException} - */ - @Override - public void flush() throws RejoinCacheException { - throw new RejoinCacheException("Client started rejoin during flush()"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link RejoinCacheException} - */ - @Override - public Object getInternalContext() throws RejoinCacheException { - throw new RejoinCacheException("Client started rejoin during getInternalContext()"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link RejoinCacheException} - */ - @Override - public int getSize() throws RejoinCacheException { - throw new RejoinCacheException("Client started rejoin during getSize()"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link RejoinCacheException} - */ - @Override - public Element putIfAbsent(Element element) throws RejoinCacheException { - throw new RejoinCacheException("Client started rejoin during putIfAbsent(Element element)"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link RejoinCacheException} - */ - @Override - public Element replace(Element element) throws RejoinCacheException { - throw new RejoinCacheException("Client started rejoin during replace(Element element)"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link RejoinCacheException} - */ - @Override - public void addStoreListener(StoreListener listener) throws RejoinCacheException { - throw new RejoinCacheException("Client started rejoin during addStoreListener(StoreListener listener)"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link RejoinCacheException} - */ - @Override - public boolean bufferFull() throws RejoinCacheException { - throw new RejoinCacheException("Client started rejoin during bufferFull()"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link RejoinCacheException} - */ - @Override - public boolean containsKey(Object key) throws RejoinCacheException { - throw new RejoinCacheException("Client started rejoin during containsKey(Object key)"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link RejoinCacheException} - */ - @Override - public boolean containsKeyInMemory(Object key) throws RejoinCacheException { - throw new RejoinCacheException("Client started rejoin during containsKeyInMemory(Object key)"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link RejoinCacheException} - */ - @Override - public boolean containsKeyOffHeap(Object key) throws RejoinCacheException { - throw new RejoinCacheException("Client started rejoin during containsKeyOffHeap(Object key)"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link RejoinCacheException} - */ - @Override - public boolean containsKeyOnDisk(Object key) throws RejoinCacheException { - throw new RejoinCacheException("Client started rejoin during containsKeyOnDisk(Object key)"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link RejoinCacheException} - */ - @Override - public void dispose() throws RejoinCacheException { - throw new RejoinCacheException("Client started rejoin during dispose()"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link RejoinCacheException} - */ - @Override - public Results executeQuery(StoreQuery query) throws RejoinCacheException { - throw new RejoinCacheException("Client started rejoin during executeQuery(StoreQuery query)"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link RejoinCacheException} - */ - @Override - public void expireElements() throws RejoinCacheException { - throw new RejoinCacheException("Client started rejoin during expireElements()"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link RejoinCacheException} - */ - @Override - public Policy getInMemoryEvictionPolicy() throws RejoinCacheException { - throw new RejoinCacheException("Client started rejoin during getInMemoryEvictionPolicy()"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link RejoinCacheException} - */ - @Override - public int getInMemorySize() throws RejoinCacheException { - throw new RejoinCacheException("Client started rejoin during getInMemorySize()"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link RejoinCacheException} - */ - @Override - public long getInMemorySizeInBytes() throws RejoinCacheException { - throw new RejoinCacheException("Client started rejoin during getInMemorySizeInBytes()"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link RejoinCacheException} - */ - @Override - public Object getMBean() throws RejoinCacheException { - throw new RejoinCacheException("Client started rejoin during getMBean()"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link RejoinCacheException} - */ - @Override - public int getOffHeapSize() throws RejoinCacheException { - throw new RejoinCacheException("Client started rejoin during getOffHeapSize()"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link RejoinCacheException} - */ - @Override - public long getOffHeapSizeInBytes() throws RejoinCacheException { - throw new RejoinCacheException("Client started rejoin during getOffHeapSizeInBytes()"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link RejoinCacheException} - */ - @Override - public int getOnDiskSize() throws RejoinCacheException { - throw new RejoinCacheException("Client started rejoin during getOnDiskSize()"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link RejoinCacheException} - */ - @Override - public long getOnDiskSizeInBytes() throws RejoinCacheException { - throw new RejoinCacheException("Client started rejoin during getOnDiskSizeInBytes()"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link RejoinCacheException} - */ - @Override - public boolean hasAbortedSizeOf() throws RejoinCacheException { - throw new RejoinCacheException("Client started rejoin during hasAbortedSizeOf()"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link RejoinCacheException} - */ - @Override - public Status getStatus() throws RejoinCacheException { - throw new RejoinCacheException("Client started rejoin during getStatus()"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link RejoinCacheException} - */ - @Override - public int getTerracottaClusteredSize() throws RejoinCacheException { - throw new RejoinCacheException("Client started rejoin during getTerracottaClusteredSize()"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link RejoinCacheException} - */ - @Override - public boolean isCacheCoherent() throws RejoinCacheException { - throw new RejoinCacheException("Client started rejoin during isCacheCoherent()"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link RejoinCacheException} - */ - @Override - public boolean isClusterCoherent() throws RejoinCacheException { - throw new RejoinCacheException("Client started rejoin during isClusterCoherent()"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link RejoinCacheException} - */ - @Override - public boolean isNodeCoherent() throws RejoinCacheException { - throw new RejoinCacheException("Client started rejoin during isNodeCoherent()"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link RejoinCacheException} - */ - @Override - public boolean putWithWriter(Element element, CacheWriterManager writerManager) throws RejoinCacheException { - throw new RejoinCacheException("Client started rejoin during putWithWriter(Element element, CacheWriterManager writerManager)"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link RejoinCacheException} - */ - @Override - public Element removeElement(Element element, ElementValueComparator comparator) throws RejoinCacheException { - throw new RejoinCacheException("Client started rejoin during removeElement(Element element, ElementValueComparator comparator)"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link RejoinCacheException} - */ - @Override - public void removeStoreListener(StoreListener listener) throws RejoinCacheException { - throw new RejoinCacheException("Client started rejoin during removeStoreListener(StoreListener listener)"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link RejoinCacheException} - */ - @Override - public Element removeWithWriter(Object key, CacheWriterManager writerManager) throws RejoinCacheException { - throw new RejoinCacheException("Client started rejoin during removeWithWriter(Object key, CacheWriterManager writerManager)"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link RejoinCacheException} - */ - @Override - public boolean replace(Element old, Element element, ElementValueComparator comparator) throws NullPointerException, - IllegalArgumentException { - throw new RejoinCacheException("Client started rejoin during replace(Element old, Element element, ElementValueComparator comparator)"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link RejoinCacheException} - */ - @Override - public void setAttributeExtractors(Map extractors) throws RejoinCacheException { - throw new RejoinCacheException("Client started rejoin during setAttributeExtractors(Map extractors)"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link RejoinCacheException} - */ - @Override - public void setInMemoryEvictionPolicy(Policy policy) throws RejoinCacheException { - throw new RejoinCacheException("Client started rejoin during setInMemoryEvictionPolicy(Policy policy)"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link RejoinCacheException} - */ - @Override - public void setNodeCoherent(boolean coherent) throws RejoinCacheException { - throw new RejoinCacheException("Client started rejoin during setNodeCoherent(boolean coherent)"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link RejoinCacheException} - */ - @Override - public void waitUntilClusterCoherent() throws RejoinCacheException { - throw new RejoinCacheException("Client started rejoin during waitUntilClusterCoherent()"); - } - - @Override - public Set getSearchAttributes() throws RejoinCacheException { - throw new RejoinCacheException("Client started rejoin during getSearchAttributes()"); - } - - /** - * {@inheritDoc}. - *

- * Throws {@link RejoinCacheException} - */ - @Override - public Attribute getSearchAttribute(String attributeName) throws RejoinCacheException { - throw new RejoinCacheException("Client started rejoin during getSearchAttribute(String attributeName)"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getLocalKeys() throws RejoinCacheException { - throw new RejoinCacheException("Client started rejoin during getLocalKeys()"); - } - - /** - * {@inheritDoc} - */ - @Override - public CacheConfiguration.TransactionalMode getTransactionalMode() throws RejoinCacheException { - throw new RejoinCacheException("Client started rejoin during getTransactionalMode()"); - } - - /** - * {@inheritDoc} - */ - public Element unlockedGet(Object key) throws RejoinCacheException { - throw new RejoinCacheException("Client started rejoin during unlockedGet(Object key)"); - } - - /** - * {@inheritDoc} - */ - public Element unlockedGetQuiet(Object key) throws RejoinCacheException { - throw new RejoinCacheException("Client started rejoin during unlockedGetQuiet(Object key)"); - } - - /** - * {@inheritDoc} - */ - @Override - public Element unsafeGet(Object key) throws RejoinCacheException { - throw new RejoinCacheException("Client started rejoin during unsafeGet(Object key)"); - } - - /** - * {@inheritDoc} - */ - @Override - public void quickClear() { - throw new RejoinCacheException("Client started rejoin during quickClear()"); - } - - /** - * {@inheritDoc} - */ - @Override - public int quickSize() { - throw new RejoinCacheException("Client started rejoin during quickSize()"); - } - - /** - * {@inheritDoc} - */ - public Element unsafeGetQuiet(Object key) throws RejoinCacheException { - throw new RejoinCacheException("Client started rejoin during unsafeGetQuiet(Object key)"); - } - - /** - * {@inheritDoc} - */ - @Override - public void recalculateSize(Object key) { - throw new UnsupportedOperationException(); - } - - @Override - public WriteBehind createWriteBehind() { - throw new UnsupportedOperationException(); - } - - @Override - public void notifyCacheEventListenersChanged() { - throw new RejoinCacheException("Client started rejoin during notifyCacheEventListenersChanged()"); - } -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/statistics/extended/ExtendedStatistics.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/statistics/extended/ExtendedStatistics.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/statistics/extended/ExtendedStatistics.java (revision 0) @@ -1,552 +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 net.sf.ehcache.CacheOperationOutcomes; -import net.sf.ehcache.store.StoreOperationOutcomes; -import net.sf.ehcache.transaction.xa.XaCommitOutcome; -import net.sf.ehcache.transaction.xa.XaRecoveryOutcome; -import net.sf.ehcache.transaction.xa.XaRollbackOutcome; -import org.terracotta.statistics.archive.Timestamped; - -import java.util.EnumSet; -import java.util.List; -import java.util.Set; -import java.util.concurrent.TimeUnit; - -/** - * The ExtendedStatistics interface. - * - * @author cschanck - */ -public interface ExtendedStatistics { - - /** The Constant ALL_CACHE_PUT_OUTCOMES. */ - static final Set ALL_CACHE_PUT_OUTCOMES = EnumSet.allOf(CacheOperationOutcomes.PutOutcome.class); - - /** The Constant ALL_CACHE_GET_OUTCOMES. */ - static final Set ALL_CACHE_GET_OUTCOMES = EnumSet.allOf(CacheOperationOutcomes.GetOutcome.class); - - /** The Constant ALL_CACHE_MISS_OUTCOMES. */ - static final Set ALL_CACHE_MISS_OUTCOMES = EnumSet.of( - CacheOperationOutcomes.GetOutcome.MISS_EXPIRED, CacheOperationOutcomes.GetOutcome.MISS_NOT_FOUND); - - /** The Constant ALL_STORE_PUT_OUTCOMES. */ - static final Set ALL_STORE_PUT_OUTCOMES = EnumSet.allOf(StoreOperationOutcomes.PutOutcome.class); - - /** - * Sets the time to disable. - * - * @param time the time - * @param unit the unit - */ - void setTimeToDisable(long time, TimeUnit unit); - - /** - * Sets the always on. - * - * @param alwaysOn the new always on - */ - void setAlwaysOn(boolean alwaysOn); - - /** - * Gets the. - * - * @return the operation - */ - Operation get(); - - /** - * Put. - * - * @return the operation - */ - Operation put(); - - /** - * Removes the. - * - * @return the operation - */ - Operation remove(); - - /** - * single arg replace operation - * @return - */ - Operation replaceOneArg(); - - /** - * two arg replace operation - * @return - */ - Operation replaceTwoArg(); - - /** - * put if absent operation - * @return - */ - Operation putIfAbsent(); - - /** - * remove element operation - * @return - */ - Operation removeElement(); - - /** - * Heap get. - * - * @return the operation - */ - Operation heapGet(); - - /** - * Offheap get. - * - * @return the operation - */ - Operation offheapGet(); - - /** - * Disk get. - * - * @return the operation - */ - Operation diskGet(); - - /** - * Heap put. - * - * @return the operation - */ - Operation heapPut(); - - /** - * Offheap put. - * - * @return the operation - */ - Operation offheapPut(); - - /** - * Disk put. - * - * @return the operation - */ - Operation diskPut(); - - /** - * Heap remove. - * - * @return the operation - */ - Operation heapRemove(); - - /** - * Offheap remove. - * - * @return the operation - */ - Operation offheapRemove(); - - /** - * Disk remove. - * - * @return the operation - */ - Operation diskRemove(); - - /** - * Search. - * - * @return the operation - */ - Operation search(); - - /** - * Xa commit. - * - * @return the operation - */ - Operation xaCommit(); - - /** - * Xa rollback. - * - * @return the operation - */ - Operation xaRollback(); - - /** - * Xa recovery. - * - * @return the operation - */ - Operation xaRecovery(); - - /** - * Eviction. - * - * @return the operation - */ - Operation eviction(); - - /** - * Expiry. - * - * @return the operation - */ - Operation expiry(); - - /** - * Cluster events - * - * @return the operation - */ - Operation clusterEvent(); - - /** - * Nonstop events - * - * @return the operation - */ - Operation nonstop(); - - /** - * All get. - * - * @return the result - */ - Result allGet(); - - /** - * All miss. - * - * @return the result - */ - Result allMiss(); - - /** - * All put. - * - * @return the result - */ - Result allPut(); - - /** - * Heap all put. - * - * @return the result - */ - Result heapAllPut(); - - /** - * Off heap all put. - * - * @return the result - */ - Result offHeapAllPut(); - - /** - * Disk all put. - * - * @return the result - */ - Result diskAllPut(); - - /** - * Cache hit ratio. - * @return - */ - Statistic cacheHitRatio(); - - /** - * Nonstop timeout ratio - * @return - */ - Statistic nonstopTimeoutRatio(); - - /** - * Operations. - * - * @param the generic type - * @param outcome the outcome - * @param name the name - * @param tags the tags - * @return the sets the - */ - > Set> operations(Class outcome, String name, String... tags); - - /** - * Get the set of cache specific pass thru statistics for a nam/tags pair. Used for - * custom pass thru statistics, as opposed to well known standard ones. - * @param name name - * @param tags set of tags - * @return - */ - Set> passthru(String name, Set tags); - - /** - * The Interface Operation. - * - * @param the generic type - */ - public interface Operation> { - - /** - * Type. - * - * @return the class - */ - Class type(); - - /** - * Component. - * - * @param result the result - * @return the result - */ - Result component(T result); - - /** - * Compound. - * - * @param results the results - * @return the result - */ - Result compound(Set results); - - /** - * Ratio of. - * - * @param numerator the numerator - * @param denomiator the denomiator - * @return the statistic - */ - Statistic ratioOf(Set numerator, Set denomiator); - - /** - * Sets the always on. - * - * @param enable the new always on - */ - void setAlwaysOn(boolean enable); - - /** - * Checks if is always on. - * - * @return true, if is always on - */ - boolean isAlwaysOn(); - - /** - * Sets the window. - * - * @param time the time - * @param unit the unit - */ - void setWindow(long time, TimeUnit unit); - - /** - * Sets the history. - * - * @param samples the samples - * @param time the time - * @param unit the unit - */ - void setHistory(int samples, long time, TimeUnit unit); - - /** - * Gets the window size. - * - * @param unit the unit - * @return the window size - */ - long getWindowSize(TimeUnit unit); - - /** - * Gets the history sample size. - * - * @return the history sample size - */ - int getHistorySampleSize(); - - /** - * Gets the history sample time. - * - * @param unit the unit - * @return the history sample time - */ - long getHistorySampleTime(TimeUnit unit); - - } - - /** - * The Interface Result. - */ - public interface Result { - - /** - * Count. - * - * @return the statistic - */ - Statistic count(); - - /** - * Rate. - * - * @return the statistic - */ - Statistic rate(); - - /** - * Latency. - * - * @return the latency - */ - Latency latency(); - } - - /** - * The Latency interface. Provides min/max/average. - */ - public interface Latency { - - /** - * Minimum latency observed. - * - * @return Minimum observed latency. NULL if no operation was observed. - */ - Statistic minimum(); - - /** - * Maximum latency observed. - * - * @return Maximum observed latency. NULL if no operation was observed. - */ - Statistic maximum(); - - /** - * Average observed latency. - * - * @return Average observed latency. NULL if no operation was observed. - */ - Statistic average(); - } - - /** - * The Interface Statistic. - * - * @param the generic type - */ - public interface Statistic { - - /** - * Active. - * - * @return true, if successful - */ - boolean active(); - - /** - * Value. - * - * @return the t - */ - T value(); - - /** - * History. - * - * @return the list - */ - List> history(); - } - - /** - * Gets the size. - * - * @return the size - */ - Statistic size(); - - /** - * Gets the local heap size. - * - * @return the local heap size - */ - Statistic localHeapSize(); - - /** - * Gets the local heap size in bytes. - * - * @return the local heap size in bytes - */ - Statistic localHeapSizeInBytes(); - - /** - * Gets the local off heap size. - * - * @return the local off heap size - */ - Statistic localOffHeapSize(); - - /** - * Gets the local off heap size in bytes. - * - * @return the local off heap size in bytes - */ - Statistic localOffHeapSizeInBytes(); - - /** - * Gets the local disk size. - * - * @return the local disk size - */ - Statistic localDiskSize(); - - /** - * Gets the local disk size in bytes. - * - * @return the local disk size in bytes - */ - Statistic localDiskSizeInBytes(); - - /** - * Gets the remote size. - * - * @return the remote size - */ - Statistic remoteSize(); - - /** - * Gets the writer queue length. - * - * @return the writer queue length - */ - Statistic writerQueueLength(); - - /** - * Get the timestamp (millis) of the last cluster rejoin event - * - * @return statistic for cluster rejoin timestamp - */ - Statistic mostRecentRejoinTimeStampMillis(); - -} \ No newline at end of file Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/writer/writebehind/WriteBehindQueueManager.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/writer/writebehind/WriteBehindQueueManager.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/writer/writebehind/WriteBehindQueueManager.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.writer.writebehind; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.locks.ReentrantReadWriteLock; - -import net.sf.ehcache.CacheEntry; -import net.sf.ehcache.CacheException; -import net.sf.ehcache.Element; -import net.sf.ehcache.config.CacheConfiguration; -import net.sf.ehcache.config.CacheWriterConfiguration; -import net.sf.ehcache.writer.CacheWriter; - -/** - * @author Alex Snaps - */ -public class WriteBehindQueueManager implements WriteBehind { - - private final ReentrantReadWriteLock rwLock = new ReentrantReadWriteLock(); - private final ReentrantReadWriteLock.ReadLock readLock = rwLock.readLock(); - private final ReentrantReadWriteLock.WriteLock writeLock = rwLock.writeLock(); - - private final List queues = new ArrayList(); - - /** - * Create the write behind queue manager with queues created via the passed in {@link WriteBehindQueueFactory} - * - * @param config configuration for the cache this write behind queue manager is working with - * @param queueFactory factory used to create the write behind queues. - */ - protected WriteBehindQueueManager(CacheConfiguration config, WriteBehindQueueFactory queueFactory) { - CacheWriterConfiguration cacheWriterConfiguration = config.getCacheWriterConfiguration(); - int writeBehindConcurrency = cacheWriterConfiguration.getWriteBehindConcurrency(); - for (int i = 0; i < writeBehindConcurrency; i++) { - this.queues.add(queueFactory.createQueue(i, config)); - } - } - - /** - * Create a new write behind queue manager. Which in turn will create as many queues as - * required by the {@link net.sf.ehcache.config.CacheWriterConfiguration#getWriteBehindConcurrency} - * - * @param config the configuration for the queue - */ - public WriteBehindQueueManager(CacheConfiguration config) { - this(config, new WriteBehindQueueFactory()); - } - - /** - * {@inheritDoc} - */ - public void start(final CacheWriter writer) throws CacheException { - writeLock.lock(); - try { - for (WriteBehind queue : queues) { - queue.start(writer); - } - } finally { - writeLock.unlock(); - } - } - - /** - * {@inheritDoc} - */ - public void write(final Element element) { - readLock.lock(); - try { - getQueue(element.getKey()).write(element); - } finally { - readLock.unlock(); - } - } - - private WriteBehind getQueue(final Object key) { - return queues.get(Math.abs(key.hashCode() % queues.size())); - } - - /** - * {@inheritDoc} - */ - public void delete(final CacheEntry entry) { - readLock.lock(); - try { - getQueue(entry.getKey()).delete(entry); - } finally { - readLock.unlock(); - } - } - - /** - * {@inheritDoc} - */ - public void setOperationsFilter(final OperationsFilter filter) { - readLock.lock(); - try { - for (WriteBehind queue : queues) { - queue.setOperationsFilter(filter); - } - } finally { - readLock.unlock(); - } - } - - /** - * {@inheritDoc} - */ - public void stop() throws CacheException { - writeLock.lock(); - try { - for (WriteBehind queue : queues) { - queue.stop(); - } - } finally { - writeLock.unlock(); - } - } - - /** - * {@inheritDoc} - */ - public long getQueueSize() { - int size = 0; - readLock.lock(); - try { - for (WriteBehind queue : queues) { - size += queue.getQueueSize(); - } - } finally { - readLock.unlock(); - } - return size; - } - - /** - * Factory used to create write behind queues. - */ - protected static class WriteBehindQueueFactory { - /** - * Create a write behind queue stripe. - * - * @param index index of the stripe - * @param config cache configuration for the cache this queue will be associated with. - * @return a write behind queue - */ - protected WriteBehind createQueue(int index, CacheConfiguration config) { - return new WriteBehindQueue(config); - } - } -} Index: rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/org/terracotta/modules/ehcache/bulkops/BulkOpsExplictLockingTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/org/terracotta/modules/ehcache/bulkops/BulkOpsExplictLockingTest.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/org/terracotta/modules/ehcache/bulkops/BulkOpsExplictLockingTest.java (revision 0) @@ -1,229 +0,0 @@ -/* - * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved. - */ -package org.terracotta.modules.ehcache.bulkops; - -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.io.Serializable; -import java.util.Collection; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.BrokenBarrierException; - -import junit.framework.Assert; - -public class BulkOpsExplictLockingTest extends AbstractCacheTestBase { - private static final int NODE_COUNT = 2; - - public BulkOpsExplictLockingTest(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 dcv2Strong = createCache("dcv2Strong", cacheManager, Consistency.STRONG); - testBulkOpsWithExplictLocking(dcv2Strong); - Cache dcv2Eventual = createCache("dcv2Eventual", cacheManager, Consistency.EVENTUAL); - testBulkOpsWithExplictLocking(dcv2Eventual); - - } - - private void testBulkOpsWithExplictLocking(Cache cache) throws InterruptedException, BrokenBarrierException { - int index = barrier.await(); - int numOfElements = 100; - Set elements = new HashSet(); - for (int i = 0; i < numOfElements; i++) { - elements.add(new Element(new Key("key" + i, i), new Value("val" + i, i))); - } - Key key = new Key("key0", 0); - if (index == 0) { - cache.acquireWriteLockOnKey(key); - cache.putAll(elements); - } - - barrier.await(); - if (index == 0) { - Assert.assertTrue(cache.isWriteLockedByCurrentThread(key)); - } else { - Assert.assertFalse(cache.isWriteLockedByCurrentThread(key)); - } - - if (index == 0) { - cache.releaseWriteLockOnKey(key); - } - Assert.assertFalse(cache.isWriteLockedByCurrentThread(key)); - barrier.await(); - - while (cache.getSize() != numOfElements) { - Thread.sleep(1000); - } - Assert.assertEquals(numOfElements, cache.getSize()); - - Set keySet1 = new HashSet(); - for (int i = 0; i < numOfElements; i++) { - keySet1.add(new Key("key" + i, i)); - } - - cache.acquireReadLockOnKey(key); - Map rv = cache.getAll(keySet1); - cache.releaseReadLockOnKey(key); - Assert.assertEquals(numOfElements, rv.size()); - - for (Element element : rv.values()) { - Assert.assertTrue(elements.contains(element)); - } - - Collection values = rv.values(); - for (Element element : elements) { - Assert.assertTrue(values.contains(element)); - } - - Set keySet2 = new HashSet(); - for (int i = 0; i < numOfElements; i++) { - if (i % 2 == 0) { - keySet2.add(new Key("key" + i, i)); - } - } - - rv = cache.getAll(keySet2); - Assert.assertEquals(keySet2.size(), rv.size()); - - for (Element element : rv.values()) { - Assert.assertTrue(elements.contains(element)); - } - - Assert.assertEquals(keySet2, rv.keySet()); - System.out.println("verified by client now waiting for others..."); - barrier.await(); - - if (index != 0) { - cache.acquireWriteLockOnKey(key); - cache.removeAll(keySet2); - cache.releaseWriteLockOnKey(key); - System.out.println("removed " + keySet2.size() + " keys from " + cache.getName() - + ". Now waiting for others..."); - } - barrier.await(); - while (cache.getSize() != numOfElements - keySet2.size()) { - Thread.sleep(1000); - } - - Assert.assertEquals(numOfElements - keySet2.size(), cache.getSize()); - System.out.println("now checking removed in " + cache.getName() + " by client"); - for (Object k : keySet2) { - Assert.assertNull(cache.get(k)); - } - System.out.println("client, I am done with " + cache.getName()); - } - - private Cache createCache(String cacheName, CacheManager cm, Consistency consistency) { - CacheConfiguration cacheConfiguration = new CacheConfiguration(); - cacheConfiguration.setName(cacheName); - cacheConfiguration.setMaxElementsInMemory(100000); - cacheConfiguration.setEternal(false); - cacheConfiguration.setTimeToLiveSeconds(100000); - cacheConfiguration.setTimeToIdleSeconds(200000); - - TerracottaConfiguration tcConfiguration = new TerracottaConfiguration(); - tcConfiguration.setConsistency(Consistency.STRONG); - cacheConfiguration.addTerracotta(tcConfiguration); - - Cache cache = new Cache(cacheConfiguration); - cm.addCache(cache); - return cache; - } - } - - private static class Key implements Serializable { - private final String stringKey; - private final int intKey; - - public Key(String stringKey, int intKey) { - super(); - this.stringKey = stringKey; - this.intKey = intKey; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + intKey; - result = prime * result + ((stringKey == null) ? 0 : stringKey.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null) return false; - if (getClass() != obj.getClass()) return false; - Key other = (Key) obj; - if (intKey != other.intKey) return false; - if (stringKey == null) { - if (other.stringKey != null) return false; - } else if (!stringKey.equals(other.stringKey)) return false; - return true; - } - - } - - private static class Value implements Serializable { - private final String keyVal; - private final int intVal; - - public Value(String keyVal, int intVal) { - this.keyVal = keyVal; - this.intVal = intVal; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + intVal; - result = prime * result + ((keyVal == null) ? 0 : keyVal.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null) return false; - if (getClass() != obj.getClass()) return false; - Value other = (Value) obj; - if (intVal != other.intVal) return false; - if (keyVal == null) { - if (other.keyVal != null) return false; - } else if (!keyVal.equals(other.keyVal)) return false; - return true; - } - - } -} Index: rctags/ehcache-2.10.9.1.33/system-tests/.settings/org.eclipse.m2e.core.prefs =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/system-tests/.settings/org.eclipse.m2e.core.prefs (revision 11516) +++ rctags/ehcache-2.10.9.1.33/system-tests/.settings/org.eclipse.m2e.core.prefs (revision 0) @@ -1,5 +0,0 @@ -#Fri Jul 29 14:23:07 PDT 2011 -activeProfiles= -eclipse.preferences.version=1 -resolveWorkspaceProjects=true -version=1 Index: rctags/ehcache-2.10.9.1.33/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/event/NonStopEventReplicator.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/event/NonStopEventReplicator.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/event/NonStopEventReplicator.java (revision 0) @@ -1,141 +0,0 @@ -/* - * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved. - */ -package org.terracotta.modules.ehcache.event; - -import net.sf.ehcache.CacheException; -import net.sf.ehcache.Ehcache; -import net.sf.ehcache.Element; -import net.sf.ehcache.config.NonstopConfiguration; -import net.sf.ehcache.constructs.nonstop.NonStopCacheException; -import net.sf.ehcache.event.CacheEventListener; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.terracotta.modules.ehcache.ToolkitInstanceFactory; -import org.terracotta.modules.ehcache.store.ToolkitNonStopExceptionOnTimeoutConfiguration; -import org.terracotta.toolkit.ToolkitFeatureType; -import org.terracotta.toolkit.feature.NonStopFeature; -import org.terracotta.toolkit.nonstop.NonStopException; - -public class NonStopEventReplicator implements CacheEventListener { - - private static final Logger LOGGER = LoggerFactory - .getLogger(NonStopEventReplicator.class); - private final CacheEventListener delegate; - private final NonStopFeature nonStop; - private final ToolkitNonStopExceptionOnTimeoutConfiguration toolkitNonStopConfiguration; - private final NonstopConfiguration ehcacheNonStopConfiguration; - - public NonStopEventReplicator(CacheEventListener delegate, ToolkitInstanceFactory toolkitInstanceFactory, - NonstopConfiguration nonStopConfiguration) { - this.delegate = delegate; - this.ehcacheNonStopConfiguration = nonStopConfiguration; - this.toolkitNonStopConfiguration = new ToolkitNonStopExceptionOnTimeoutConfiguration( - this.ehcacheNonStopConfiguration); - this.nonStop = toolkitInstanceFactory.getToolkit().getFeature(ToolkitFeatureType.NONSTOP); - } - - private void handleNonStopException(NonStopException e, String eventType, Ehcache cache, Element element) { - final String cacheName = cache == null ? null : cache.getName(); - final String msg = "Terracotta clustered event notification timed out: operation: " + eventType + ", cache: " - + cacheName + ", element: " + element; - switch (ehcacheNonStopConfiguration.getTimeoutBehavior().getTimeoutBehaviorType()) { - case EXCEPTION: - throw new NonStopCacheException(msg); - default: - LOGGER.info(msg); - } - } - - @Override - public void notifyElementRemoved(Ehcache cache, Element element) throws CacheException { - nonStop.start(toolkitNonStopConfiguration); - try { - this.delegate.notifyElementRemoved(cache, element); - } catch (NonStopException e) { - handleNonStopException(e, "REMOVED", cache, element); - } finally { - nonStop.finish(); - } - } - - @Override - public void notifyElementPut(Ehcache cache, Element element) throws CacheException { - nonStop.start(toolkitNonStopConfiguration); - try { - this.delegate.notifyElementPut(cache, element); - } catch (NonStopException e) { - handleNonStopException(e, "PUT", cache, element); - } finally { - nonStop.finish(); - } - - } - - @Override - public void notifyElementUpdated(Ehcache cache, Element element) throws CacheException { - nonStop.start(toolkitNonStopConfiguration); - try { - this.delegate.notifyElementUpdated(cache, element); - } catch (NonStopException e) { - handleNonStopException(e, "UPDATED", cache, element); - } finally { - nonStop.finish(); - } - } - - @Override - public void notifyElementExpired(Ehcache cache, Element element) { - nonStop.start(toolkitNonStopConfiguration); - try { - this.delegate.notifyElementExpired(cache, element); - } catch (NonStopException e) { - handleNonStopException(e, "EXPIRED", cache, element); - } finally { - nonStop.finish(); - } - } - - @Override - public void notifyElementEvicted(Ehcache cache, Element element) { - nonStop.start(toolkitNonStopConfiguration); - try { - this.delegate.notifyElementEvicted(cache, element); - } catch (NonStopException e) { - handleNonStopException(e, "EVICTED", cache, element); - } finally { - nonStop.finish(); - } - } - - @Override - public void notifyRemoveAll(Ehcache cache) { - nonStop.start(toolkitNonStopConfiguration); - try { - this.delegate.notifyRemoveAll(cache); - } catch (NonStopException e) { - handleNonStopException(e, "REMOVEALL", cache, null); - } finally { - nonStop.finish(); - } - } - - @Override - public void dispose() { - nonStop.start(toolkitNonStopConfiguration); - try { - this.delegate.dispose(); - } catch (NonStopException e) { - handleNonStopException(e, "DISPOSE", null, null); - } finally { - nonStop.finish(); - } - } - - @Override - public NonStopEventReplicator clone() throws CloneNotSupportedException { - return (NonStopEventReplicator) super.clone(); - } - -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/loader/ComponentCLoader.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/loader/ComponentCLoader.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/loader/ComponentCLoader.java (revision 0) @@ -1,65 +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; - -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; - - -/** - * Written for Dead-lock poc - * - * @author Greg Luck - * @version $Id: ComponentCLoader.java 5594 2012-05-07 16:04:31Z cdennis $ - */ -public class ComponentCLoader extends BaseComponentLoader { - - private static final Logger LOG = LoggerFactory.getLogger(ComponentCLoader.class.getName()); - - /** - * @return - */ - public String getName() { - return "LoaderC"; - } - - /** - * @param key - * @return - * @throws net.sf.ehcache.CacheException - */ - public Object load(Object key) throws CacheException { - LOG.info("Loading Component C({})", key); - return new ComponentC(key); - } - - @Override - public Map loadAll(Collection keys, Object argument) throws CacheException { - Map result = new HashMap(); - - for (Object key : keys) { - result.put(key, load(key)); - } - - return result; - } -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/config/generator/model/elements/SearchableConfigurationElement.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/config/generator/model/elements/SearchableConfigurationElement.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/config/generator/model/elements/SearchableConfigurationElement.java (revision 0) @@ -1,62 +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.generator.model.elements; - -import net.sf.ehcache.config.SearchAttribute; -import net.sf.ehcache.config.Searchable; -import net.sf.ehcache.config.generator.model.NodeElement; -import net.sf.ehcache.config.generator.model.SimpleNodeAttribute; -import net.sf.ehcache.config.generator.model.SimpleNodeElement; - -/** - * {@link NodeElement} representing a {@link Searchable} config element - * - * @author teck - */ -public class SearchableConfigurationElement extends SimpleNodeElement { - - private final Searchable searchable; - - /** - * Constructor accepting the parent and the {@link Searchable} - * - * @param parent - * @param searchable - */ - public SearchableConfigurationElement(NodeElement parent, Searchable searchable) { - super(parent, "searchable"); - - if (searchable == null) { - throw new NullPointerException(); - } - - this.searchable = searchable; - init(); - } - - private void init() { - for (SearchAttribute sa : searchable.getUserDefinedSearchAttributes().values()) { - addChildElement(sa.asConfigElement(this)); - } - - addAttribute(new SimpleNodeAttribute("keys", searchable.keys()).optional(true).defaultValue(Searchable.KEYS_DEFAULT)); - addAttribute(new SimpleNodeAttribute("values", searchable.values()).optional(true).defaultValue(Searchable.VALUES_DEFAULT)); - addAttribute(new SimpleNodeAttribute("allowDynamicIndexing", searchable.isDynamicIndexingAllowed()).optional(true) - .defaultValue(Searchable.DYNAMIC_INDEXING_DEFAULT)); - } - -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/constructs/readthrough/ReadThroughCacheConfiguration.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/constructs/readthrough/ReadThroughCacheConfiguration.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/constructs/readthrough/ReadThroughCacheConfiguration.java (revision 0) @@ -1,176 +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.readthrough; - -import java.util.Properties; - -/** - * This classed is used to programmatically configure a {@link ReadThroughCache}. - * - * @author cschanck - * - */ -public class ReadThroughCacheConfiguration implements Cloneable { - - /** - * Properties key for the name attribute - */ - public static final String NAME_KEY = "name"; - - /** - * Properties key for the get() proxy attribute - */ - public static final String GET_KEY = "get"; - - private boolean modeGet = true; - private String name = null; - private volatile boolean valid = false; - - /** - * Create default, valid configuration. - */ - public ReadThroughCacheConfiguration() { - validate(); - } - - /** - * Create a configuration object from a properties object. Validate before returning. - * - * @param properties - * @return - */ - public ReadThroughCacheConfiguration fromProperties(Properties properties) { - valid = false; - if (properties != null) { - for (String property : properties.stringPropertyNames()) { - String stringValue = properties.getProperty(property).trim(); - if (GET_KEY.equals(property)) { - setModeGet(Boolean.parseBoolean(stringValue)); - } else if (NAME_KEY.equals(property)) { - setName(stringValue); - } else { - throw new IllegalArgumentException("Unrecognized ReadThrough cache config key: " + property); - } - } - } - return build(); - } - - /** - * Return a properties version of this configuration object. - * - * @return - */ - public Properties toProperties() { - Properties p = new Properties(); - p.setProperty(NAME_KEY, getName()); - p.setProperty(GET_KEY, Boolean.toString(isModeGet())); - return p; - } - - /** - * Validate this configuration, mark it valid if it passes. - * - * @return - */ - public ReadThroughCacheConfiguration build() { - validate(); - return this; - } - - private void validate() { - // not much here. - // removing the decorator. - valid = true; - } - - private void checkValid() { - if (!valid) { - throw new IllegalStateException("RefreshAheadCacheConfig not built yet"); - } - } - - /** - * Set whether get() methods will be transparently proxied. - * - * @param modeGet true to proxy get methods - * @return - */ - public ReadThroughCacheConfiguration modeGet(boolean modeGet) { - setModeGet(modeGet); - return this; - } - - /** - * Return whether the get() method is proxied. - * - * @return true if proxied - */ - public boolean isModeGet() { - checkValid(); - return modeGet; - } - - /** - * Set whether get() methods will be transparently proxied. - * - * @param modeGet true t pxoy the get() methods - */ - public void setModeGet(boolean modeGet) { - valid = false; - this.modeGet = modeGet; - } - - /** - * Get the name to set for this cache decorator. May be null. - * - * @return the name - */ - public String getName() { - return name; - } - - /** - * Set the name to set for this cache decorator. May be null. - * - * @param name name to use, may be null - * @return this config - */ - public ReadThroughCacheConfiguration setName(String name) { - valid = false; - this.name = name; - return this; - } - - /** - * Set the name to set for this cache decorator. May be null. - * - * @param name name to use, may be null - * @return this config - */ - public ReadThroughCacheConfiguration name(String name) { - setName(name); - return this; - } - - @Override - public String toString() { - return toProperties().toString(); - } - - -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/cluster/NoopCacheCluster.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/cluster/NoopCacheCluster.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/cluster/NoopCacheCluster.java (revision 0) @@ -1,98 +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.cluster; - -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -/** - * This is a dummy implementation of the CacheCluster (Null Object Pattern). It ignores - * all listeners and reports no nodes. - * - * @author Geert Bevin - * @since 2.0 - */ -public class NoopCacheCluster implements CacheCluster { - - /** - * A singleton instance you can use rather than constructing your own. - */ - public static final CacheCluster INSTANCE = new NoopCacheCluster(); - - /** - * {@inheritDoc} - */ - public Collection getNodes() { - return Collections.emptyList(); - } - - /** - * Always returns the ClusterScheme.NONE - * - * @return {@link ClusterScheme#NONE} - */ - public ClusterScheme getScheme() { - return ClusterScheme.NONE; - } - - /** - * {@inheritDoc} - */ - public boolean addTopologyListener(ClusterTopologyListener listener) { - return false; - } - - /** - * {@inheritDoc} - */ - public boolean removeTopologyListener(ClusterTopologyListener listener) { - return false; - } - - /** - * {@inheritDoc} - */ - public boolean isClusterOnline() { - return true; - } - - /** - * {@inheritDoc} - */ - public ClusterNode getCurrentNode() { - return null; - } - - /** - * {@inheritDoc} - */ - public ClusterNode waitUntilNodeJoinsCluster() { - return null; - } - - /** - * {@inheritDoc} - */ - public List getTopologyListeners() { - return Collections.emptyList(); - } - - @Override - public void removeAllListeners() { - // - } -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/config/generator/model/elements/package.html =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/config/generator/model/elements/package.html (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/config/generator/model/elements/package.html (revision 0) @@ -1,5 +0,0 @@ - - - This package contains utility classes encapsulating ideas of Elements and Attributes from the ehcache.xsd - - Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/constructs/refreshahead/NullLoaderFactory.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/constructs/refreshahead/NullLoaderFactory.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/constructs/refreshahead/NullLoaderFactory.java (revision 0) @@ -1,81 +0,0 @@ -package net.sf.ehcache.constructs.refreshahead; - -import java.util.Collection; -import java.util.Collections; -import java.util.Map; -import java.util.Properties; - -import net.sf.ehcache.CacheException; -import net.sf.ehcache.Ehcache; -import net.sf.ehcache.Status; -import net.sf.ehcache.loader.CacheLoader; -import net.sf.ehcache.loader.CacheLoaderFactory; - -public class NullLoaderFactory extends CacheLoaderFactory { - - @Override - public CacheLoader createCacheLoader(Ehcache cache, Properties properties) { - return new NullCacheLoader(properties); - } - - public static class NullCacheLoader implements CacheLoader { - - private long delayMS = 0; - - public NullCacheLoader(Properties properties) { - if (properties != null) { - delayMS = Long.parseLong(properties.getProperty("delayMS", "0")); - } - } - - @Override - public Map loadAll(Collection keys, Object argument) { - return loadAll(keys); - } - - @Override - public Map loadAll(Collection keys) { - return Collections.EMPTY_MAP; - } - - @Override - public Object load(Object key, Object argument) { - return null; - } - - @Override - public Object load(Object key) throws CacheException { - return null; - } - - @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; - } - } -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/loader/CompositeLoaderTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/loader/CompositeLoaderTest.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/loader/CompositeLoaderTest.java (revision 0) @@ -1,69 +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 org.junit.After; -import org.junit.Before; -import org.junit.Test; - - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - -/** - * ComponentA is composed of ComponentB and some other fields. Tests the interactions between two loaders, where the first component's - * loader loads component B by using getWithLoader, which in turn invokes component B's loader. - * - * @author Greg Luck - * @version $Id: CompositeLoaderTest.java 5594 2012-05-07 16:04:31Z cdennis $ - */ -public class CompositeLoaderTest { - - private static final Logger LOG = LoggerFactory.getLogger(CompositeLoaderTest.class.getName()); - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - */ - @Before - public void setUp() throws Exception { - CacheHelper.init(); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - */ - @After - public void tearDown() throws Exception { - CacheHelper.shutdown(); - } - - /** - * This test reproduces a deadlock found in 1.4-beta1 around loading interactions and getWithLoader. Now fixed. - */ - @Test - public void testCompositeLoad() { - LOG.info("Getting from cache"); - ComponentA compA = (ComponentA) CacheHelper.get("ehcache-loaderinteractions.xml", "ACache", "key1"); - LOG.info(compA.toString()); - - } - -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/config/generator/xsom/XSDAttributeValueType.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/config/generator/xsom/XSDAttributeValueType.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/config/generator/xsom/XSDAttributeValueType.java (revision 0) @@ -1,264 +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.generator.xsom; - -import net.sf.ehcache.config.MemoryUnit; - -import java.util.Iterator; -import java.util.Random; - -import com.sun.xml.xsom.XSAttributeDecl; -import com.sun.xml.xsom.XSFacet; -import com.sun.xml.xsom.XSRestrictionSimpleType; -import com.sun.xml.xsom.XSSimpleType; - -public abstract class XSDAttributeValueType { - - protected static final Random RANDOM = new Random(System.currentTimeMillis()); - protected String pattern; - public enum XsdType { - BOOLEAN, INTEGER, POSITIVE_INTEGER, NON_NEGATIVE_INTEGER, STRING, ANY_SIMPLE_TYPE, ENUMERATION; - } - protected String maxValue; - protected String minValue; - protected String length; - protected String maxLength; - protected String minLength; - - protected String totalDigits; - - private final XsdType type; - - public XSDAttributeValueType(XsdType type) { - this.type = type; - } - - public abstract String getRandomAllowedValue(); - - protected void fillUpRestrictions(XSAttributeDecl attributeDecl) { - XSSimpleType localType = attributeDecl.getType(); - XSRestrictionSimpleType restriction = localType.asRestriction(); - if (restriction != null) { - Iterator i = restriction.getDeclaredFacets().iterator(); - while (i.hasNext()) { - XSFacet facet = i.next(); - if (facet.getName().equals(XSFacet.FACET_MAXINCLUSIVE)) { - maxValue = facet.getValue().value; - } - if (facet.getName().equals(XSFacet.FACET_MININCLUSIVE)) { - minValue = facet.getValue().value; - } - if (facet.getName().equals(XSFacet.FACET_MAXEXCLUSIVE)) { - maxValue = String.valueOf(Integer.parseInt(facet.getValue().value) - 1); - } - if (facet.getName().equals(XSFacet.FACET_MINEXCLUSIVE)) { - minValue = String.valueOf(Integer.parseInt(facet.getValue().value) + 1); - } - if (facet.getName().equals(XSFacet.FACET_LENGTH)) { - length = facet.getValue().value; - } - if (facet.getName().equals(XSFacet.FACET_MAXLENGTH)) { - maxLength = facet.getValue().value; - } - if (facet.getName().equals(XSFacet.FACET_MINLENGTH)) { - minLength = facet.getValue().value; - } - if (facet.getName().equals(XSFacet.FACET_PATTERN)) { - pattern = facet.getValue().value; - } - if (facet.getName().equals(XSFacet.FACET_TOTALDIGITS)) { - totalDigits = facet.getValue().value; - } - } - } - } - - public static class XSDAttributeValueBooleanType extends XSDAttributeValueType { - - public XSDAttributeValueBooleanType() { - super(XsdType.BOOLEAN); - } - - @Override - public String getRandomAllowedValue() { - return RANDOM.nextInt() % 2 == 0 ? getTrue() : getFalse(); - } - - public String getTrue() { - return String.valueOf(true); - } - - public String getFalse() { - return String.valueOf(false); - } - - } - - public static class XSDAttributeValueIntegerType extends XSDAttributeValueType { - - public XSDAttributeValueIntegerType() { - super(XsdType.INTEGER); - } - - @Override - public String getRandomAllowedValue() { - return String.valueOf(RANDOM.nextInt()); - } - - } - - public static class XSDAttributeValuePositiveIntegerType extends XSDAttributeValueType { - - public XSDAttributeValuePositiveIntegerType() { - super(XsdType.POSITIVE_INTEGER); - } - - @Override - public String getRandomAllowedValue() { - return String.valueOf(Math.abs(RANDOM.nextInt() + 1)); - } - - } - - public static class XSDAttributeValueNonNegativeIntegerType extends XSDAttributeValueType { - - public XSDAttributeValueNonNegativeIntegerType() { - super(XsdType.NON_NEGATIVE_INTEGER); - } - - @Override - public String getRandomAllowedValue() { - return String.valueOf(Math.abs(RANDOM.nextInt())); - } - - } - - public static class XSDAttributeValueMemoryUnitType extends XSDAttributeValueType { - - public static final char[] unitChars; - - static { - MemoryUnit[] values = MemoryUnit.values(); - char [] chars = new char[values.length * 2]; - int i = 0; - for (MemoryUnit memoryUnit : values) { - chars[i++] = Character.toLowerCase(memoryUnit.getUnit()); - chars[i++] = Character.toUpperCase(memoryUnit.getUnit()); - } - unitChars = chars; - } - - public XSDAttributeValueMemoryUnitType() { - super(XsdType.NON_NEGATIVE_INTEGER); - } - - @Override - public String getRandomAllowedValue() { - int index = RANDOM.nextInt(unitChars.length + 1); - if(index < unitChars.length) { - return String.valueOf(Math.abs(RANDOM.nextInt())) + unitChars[index]; - } - return String.valueOf(Math.abs(RANDOM.nextInt())); - } - - } - - public static class XSDAttributeValueMemoryUnitOrPercentageType extends XSDAttributeValueType { - - public static final char[] unitChars; - - static { - MemoryUnit[] values = MemoryUnit.values(); - char [] chars = new char[values.length * 2 + 1]; - int i = 0; - for (MemoryUnit memoryUnit : values) { - chars[i++] = Character.toLowerCase(memoryUnit.getUnit()); - chars[i++] = Character.toUpperCase(memoryUnit.getUnit()); - } - chars[i] = '%'; - unitChars = chars; - } - - public XSDAttributeValueMemoryUnitOrPercentageType() { - super(XsdType.NON_NEGATIVE_INTEGER); - } - - @Override - public String getRandomAllowedValue() { - int index = RANDOM.nextInt(unitChars.length + 1); - if(index < unitChars.length) { - switch (unitChars[index]) { - case '%' : - return String.valueOf(Math.abs(RANDOM.nextInt(100) + 1)) + unitChars[index]; - default: - return String.valueOf(Math.abs(RANDOM.nextInt())) + unitChars[index]; - } - } - return String.valueOf(Math.abs(RANDOM.nextInt())); - } - - } - - public static class XSDAttributeValueStringType extends XSDAttributeValueType { - - private static final String[] RANDOM_VALUES = {"random_string_one", "random_string_two", "random_string_three", "random_string_four", - "random_string_five", }; - - public XSDAttributeValueStringType() { - super(XsdType.STRING); - } - - @Override - public String getRandomAllowedValue() { - return RANDOM_VALUES[RANDOM.nextInt(RANDOM_VALUES.length)]; - } - - } - - public static class XSDAttributeValueAnySimpleType extends XSDAttributeValueType { - - private static final String[] RANDOM_VALUES = {"any_simple_type_random_one", "any_simple_type_random_two", - "any_simple_type_random_three", "any_simple_type_random_four", "any_simple_type_random_five", }; - - public XSDAttributeValueAnySimpleType() { - super(XsdType.ANY_SIMPLE_TYPE); - } - - @Override - public String getRandomAllowedValue() { - return RANDOM_VALUES[RANDOM.nextInt(RANDOM_VALUES.length)]; - } - - } - - public static class XSDAttributeValueEnumerationType extends XSDAttributeValueType { - - private final String[] enumeration; - - public XSDAttributeValueEnumerationType(String[] enumeration) { - super(XsdType.ENUMERATION); - this.enumeration = enumeration; - } - - @Override - public String getRandomAllowedValue() { - return enumeration[RANDOM.nextInt(enumeration.length)]; - } - - } - -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/config/generator/model/elements/ElementValueComparatorConfigurationElement.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/config/generator/model/elements/ElementValueComparatorConfigurationElement.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/config/generator/model/elements/ElementValueComparatorConfigurationElement.java (revision 0) @@ -1,55 +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.generator.model.elements; - -import net.sf.ehcache.config.ElementValueComparatorConfiguration; -import net.sf.ehcache.config.generator.model.NodeElement; -import net.sf.ehcache.config.generator.model.SimpleNodeAttribute; -import net.sf.ehcache.config.generator.model.SimpleNodeElement; - -/** - * {@link net.sf.ehcache.config.generator.model.NodeElement} representing the - * {@link net.sf.ehcache.config.ElementValueComparatorConfiguration} - * - * @author Ludovic Orban - * - */ -public class ElementValueComparatorConfigurationElement extends SimpleNodeElement { - - private final ElementValueComparatorConfiguration elementValueComparatorConfiguration; - - /** - * Constructor accepting the parent and the {@link net.sf.ehcache.config.ElementValueComparatorConfiguration} - * - * @param parent - * @param elementValueComparatorConfiguration - */ - public ElementValueComparatorConfigurationElement(NodeElement parent, - ElementValueComparatorConfiguration elementValueComparatorConfiguration) { - super(parent, "elementValueComparator"); - this.elementValueComparatorConfiguration = elementValueComparatorConfiguration; - init(); - } - - private void init() { - if (elementValueComparatorConfiguration == null) { - return; - } - addAttribute(new SimpleNodeAttribute("class", elementValueComparatorConfiguration.getClassName()).optional(false)); - } - -} Index: rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/org/terracotta/ehcache/tests/container/hibernate/nontransactional/EmptySecondLevelCacheEntryTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/org/terracotta/ehcache/tests/container/hibernate/nontransactional/EmptySecondLevelCacheEntryTest.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/org/terracotta/ehcache/tests/container/hibernate/nontransactional/EmptySecondLevelCacheEntryTest.java (revision 0) @@ -1,16 +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.nontransactional; - -import junit.framework.Test; - -public class EmptySecondLevelCacheEntryTest extends NonTransactionalCacheTest { - - public static Test suite() { - return new NonTransactionalCacheTest.TestSetup(EmptySecondLevelCacheEntryTest.class, - EmptySecondLevelCacheEntryServlet.class); - } - -} Index: rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/org/terracotta/ehcache/tests/Client4.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/org/terracotta/ehcache/tests/Client4.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/org/terracotta/ehcache/tests/Client4.java (revision 0) @@ -1,23 +0,0 @@ -package org.terracotta.ehcache.tests; - -import net.sf.ehcache.Cache; -import net.sf.ehcache.Element; - -import org.terracotta.toolkit.Toolkit; - -public class Client4 extends ClientBase { - - public Client4(String[] args) { - super("test", args); - } - - @Override - protected void runTest(Cache cache, Toolkit toolkit) throws Throwable { - Element element = cache.get("key"); - - if (element == null) { throw new AssertionError(); } - - Object value = element.getObjectValue(); - if (!"value".equals(value)) { throw new AssertionError("unexpected value: " + value); } - } -} \ No newline at end of file Index: rctags/ehcache-2.10.9.1.33/distribution/events/src/assemble/bin/package.bat =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/distribution/events/src/assemble/bin/package.bat (revision 11516) +++ rctags/ehcache-2.10.9.1.33/distribution/events/src/assemble/bin/package.bat (revision 0) @@ -1,66 +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 bin_dir="%~d0%~p0" -set root=%~d0%~p0.. -set root="%root:"=%" -set jetty1=%root%\jetty6.1\9081\webapps -set jetty2=%root%\jetty6.1\9082\webapps - -cd %bin_dir% -for /f "tokens=*" %%a in ('call relative-paths.bat ehcache_jars_dir') do set ehcache_jars_dir=%%a -pushd -cd %ehcache_jars_dir% -set ehcache_jars_dir=%CD% -set ehcache_jars_dir="%ehcache_jars_dir:"=%" -popd - -cd %bin_dir% -for /f "tokens=*" %%a in ('call relative-paths.bat tc_install_dir') do set tc_install_dir=%%a -pushd -cd %tc_install_dir% -set tc_install_dir=%CD% -set tc_install_dir="%tc_install_dir:"=%" -popd - -set appname=events - -cd %root% -set webapp_lib=webapps\%appname%\WEB-INF\lib - -rem package ehcache-core and ehcache-terracotta -xcopy /y /q %ehcache_jars_dir%\lib\ehcache*.jar %webapp_lib% 1> NUL - -if exist %tc_install_dir%\common\terracotta-toolkit*-runtime*.jar ( - set toolkit_runtime=%tc_install_dir%\common\terracotta-toolkit*-runtime*.jar -) - -if exist %ehcache_jars_dir%\lib\terracotta-toolkit*-runtime*.jar ( - set toolkit_runtime=%ehcache_jars_dir%\lib\terracotta-toolkit*-runtime*.jar -) - -if not exist %toolkit_runtime% ( - echo Couldn't locate toolkit runtime jar - exit /b 1 -) - -xcopy /y /q %toolkit_runtime% %webapp_lib% 1> NUL - -if %errorlevel% == 0 ( - echo Deploying demo... - xcopy /y /q /e webapps %jetty1% 1> NUL - xcopy /y /q /e webapps %jetty2% 1> NUL - echo Done. -) else ( - echo Error packaging sample - exit /b 1 -) - -endlocal Index: rctags/ehcache-2.10.9.1.33/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/transaction/ReadCommittedClusteredSoftLockFactory.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/transaction/ReadCommittedClusteredSoftLockFactory.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/transaction/ReadCommittedClusteredSoftLockFactory.java (revision 0) @@ -1,160 +0,0 @@ -/* - * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved. - */ -package org.terracotta.modules.ehcache.transaction; - -import net.sf.ehcache.Element; -import net.sf.ehcache.store.Store; -import net.sf.ehcache.transaction.SoftLock; -import net.sf.ehcache.transaction.SoftLockID; -import net.sf.ehcache.transaction.SoftLockManager; -import net.sf.ehcache.transaction.TransactionID; -import net.sf.ehcache.transaction.local.LocalTransactionContext; - -import org.terracotta.modules.ehcache.ToolkitInstanceFactory; -import org.terracotta.modules.ehcache.collections.SerializedToolkitCache; -import org.terracotta.toolkit.collections.ToolkitMap; - -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -/** - * @author Ludovic Orban - */ -public class ReadCommittedClusteredSoftLockFactory implements SoftLockManager { - private static final Integer DEFAULT_DUMMY_VALUE = Integer - .valueOf(0); - private final String cacheName; - private final String cacheManagerName; - - private final ToolkitInstanceFactory toolkitInstanceFactory; - - // actually all we need would be a ConcurrentSet... - private final ToolkitMap newKeyLocks; - - // locks must be inserted in a clustered collection b/c they must be managed by the L1 before they are returned - private final SerializedToolkitCache allLocks; - - public ReadCommittedClusteredSoftLockFactory(ToolkitInstanceFactory toolkitInstanceFactory, String cacheManagerName, - String cacheName) { - this.toolkitInstanceFactory = toolkitInstanceFactory; - this.cacheManagerName = cacheManagerName; - this.cacheName = cacheName; - allLocks = toolkitInstanceFactory.getOrCreateAllSoftLockMap(cacheManagerName, cacheName); - newKeyLocks = toolkitInstanceFactory.getOrCreateNewSoftLocksSet(cacheManagerName, cacheName); - } - - @Override - public SoftLockID createSoftLockID(TransactionID transactionID, Object key, Element newElement, Element oldElement) { - if (newElement != null && newElement.getObjectValue() instanceof SoftLockID) { throw new AssertionError( - "newElement must not contain a soft lock ID"); } - if (oldElement != null && oldElement.getObjectValue() instanceof SoftLockID) { throw new AssertionError( - "oldElement must not contain a soft lock ID"); } - - SoftLockID lockId = new SoftLockID(transactionID, key, newElement, oldElement); - ClusteredSoftLockIDKey clusteredId = new ClusteredSoftLockIDKey(lockId); - - if (allLocks.containsKey(clusteredId)) { - return lockId; - } else { - SerializedReadCommittedClusteredSoftLock softLock = new SerializedReadCommittedClusteredSoftLock(transactionID, - key); - - if (allLocks.putIfAbsent(clusteredId, softLock) != null) { - throw new AssertionError(); - } else { - if (oldElement == null) { - newKeyLocks.put(softLock, DEFAULT_DUMMY_VALUE); - } - return lockId; - } - } - } - - @Override - public SoftLock findSoftLockById(SoftLockID softLockId) { - SerializedReadCommittedClusteredSoftLock serializedSoftLock = allLocks.get(new ClusteredSoftLockIDKey(softLockId)); - if (serializedSoftLock == null) { - return null; - } - return serializedSoftLock.getSoftLock(toolkitInstanceFactory, this); - } - - ReadCommittedClusteredSoftLock getLock(TransactionID transactionId, Object key) { - for (Map.Entry entry : allLocks.entrySet()) { - SerializedReadCommittedClusteredSoftLock serialized = entry.getValue(); - ReadCommittedClusteredSoftLock readCommittedSoftLock = serialized.getSoftLock(toolkitInstanceFactory, this); - if (readCommittedSoftLock.getTransactionID().equals(transactionId) && readCommittedSoftLock.getKey().equals(key)) { return readCommittedSoftLock; } - } - return null; - } - - @Override - public Set getKeysInvisibleInContext(LocalTransactionContext currentTransactionContext, Store underlyingStore) { - Set invisibleKeys = new HashSet(); - - // all new keys added into the store are invisible - invisibleKeys.addAll(getNewKeys()); - - List currentTransactionContextSoftLocks = currentTransactionContext.getSoftLocksForCache(cacheName); - for (SoftLock softLock : currentTransactionContextSoftLocks) { - SoftLockID softLockId = (SoftLockID) underlyingStore.getQuiet(softLock.getKey()).getObjectValue(); - - if (softLock.getElement(currentTransactionContext.getTransactionId(), softLockId) == null) { - // if the soft lock's element is null in the current transaction then the key is invisible - invisibleKeys.add(softLock.getKey()); - } else { - // if the soft lock's element is not null in the current transaction then the key is visible - invisibleKeys.remove(softLock.getKey()); - } - } - - return invisibleKeys; - } - - /** - * {@inheritDoc} - */ - @Override - public Set collectAllSoftLocksForTransactionID(TransactionID transactionID) { - Set result = new HashSet(); - - for (Map.Entry entry : allLocks.entrySet()) { - SerializedReadCommittedClusteredSoftLock serialized = entry.getValue(); - ReadCommittedClusteredSoftLock softLock = serialized.getSoftLock(toolkitInstanceFactory, this); - if (softLock.getTransactionID().equals(transactionID)) { - result.add(softLock); - } - } - - return result; - } - - @Override - public void clearSoftLock(SoftLock softLock) { - SoftLockID softLockId = new SoftLockID(((ReadCommittedClusteredSoftLock)softLock).getTransactionID(), softLock.getKey(), null, null); - ClusteredSoftLockIDKey clusteredIdKey = new ClusteredSoftLockIDKey(softLockId); - SerializedReadCommittedClusteredSoftLock serializedClusteredSoftLock = allLocks.remove(clusteredIdKey); - newKeyLocks.remove(serializedClusteredSoftLock); - } - - private Set getNewKeys() { - Set result = new HashSet(); - for (SerializedReadCommittedClusteredSoftLock serialized : newKeyLocks.keySet()) { - result.add(serialized.getSoftLock(toolkitInstanceFactory, this).getKey()); - } - - return result; - } - - String getCacheName() { - return cacheName; - } - - String getCacheManagerName() { - return cacheManagerName; - } - -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/management/sampled/package.html =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/management/sampled/package.html (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/management/sampled/package.html (revision 0) @@ -1,8 +0,0 @@ - - - - -This package contains classes related to MBeans with Sampled Statistics. -

- - Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/search/QueryExamplesTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/search/QueryExamplesTest.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/search/QueryExamplesTest.java (revision 0) @@ -1,268 +0,0 @@ -package net.sf.ehcache.search; - -import static net.sf.ehcache.search.Query.KEY; -import static org.junit.Assert.assertEquals; - -import java.util.Arrays; -import java.util.List; -import java.util.Map; - -import net.sf.ehcache.CacheManager; -import net.sf.ehcache.Ehcache; -import net.sf.ehcache.Element; -import net.sf.ehcache.config.SearchAttribute; - -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import bsh.EvalError; -import bsh.Interpreter; - -/** - * This class was used to develop the API and now that the code has been written it has been made an - * executable test. - * - * @author teck - * @author Greg Luck - */ -public class QueryExamplesTest { - - private static final Logger LOG = LoggerFactory.getLogger(QueryExamplesTest.class); - - private CacheManager cacheManager; - private Ehcache cache; - - @Before - public void before() { - cacheManager = new CacheManager(getClass().getResource("/ehcache-search.xml")); - cache = cacheManager.getCache("cache1"); - SearchTestUtil.populateData(cache); - } - - @After - public void after() { - cacheManager.shutdown(); - } - - @Test - public void testExamples() { - examples(); - } - - void examples() throws SearchException { - - Attribute age = cache.getSearchAttribute("age"); - Attribute gender = cache.getSearchAttribute("gender"); - Attribute name = cache.getSearchAttribute("name"); - - Query query; - Results results; - - // include all keys in the cache - query = cache.createQuery().includeKeys().end(); - results = query.execute(); - for (Result result : results.all()) { - LOG.info("" + result.getKey()); - } - results.discard(); // not required but will speed resource freeing - - // access results in a "paged" manner - query = cache.createQuery().includeKeys().end(); - results = query.execute(); - - int pageSize = 100; - int index = 0; - List page; - do { - page = results.range(index, pageSize); - - for (Result result : page) { - LOG.info("" + result.getKey()); - } - - index += page.size(); - } while (page.size() == pageSize); - - // select age from the cache - query = cache.createQuery().includeAttribute(age).end(); - results = query.execute(); - for (Result result : results.all()) { - LOG.info("" + result.getAttribute(age)); - } - - // select age, gender from the cache - query = cache.createQuery().includeAttribute(age, gender).end(); - results = query.execute(); - for (Result result : results.all()) { - LOG.info("" + result.getAttribute(age)); - // slf4j weirdness - Object object = result.getAttribute(gender); - LOG.info("" + object); - } - - // select max(age) -- named indexed attribute "age" - Query sumQuery = cache.createQuery().includeAggregator(age.sum()).end(); - results = sumQuery.execute(); - for (Result result : results.all()) { - Long sumResult = (Long) result.getAggregatorResults().get(0); - LOG.info("Sum is: " + sumResult); - } - - // select keys with criteria age == 12 AND gender = "timmy" - query = cache.createQuery().includeKeys().addCriteria(age.eq(12).and(gender.eq("timmy"))).end(); - - // same as above (but without AND, uses two add() -- multiple - // criteria implies AND) - query = cache.createQuery().includeKeys().addCriteria(age.eq(12)).addCriteria(gender.eq("timmy")).end(); - - // slightly more complicated expression and multiple ordering - // age = 13 OR (age == 12 AND gender = "timmy") order by age asc, gender desc limit 10 - query = cache.createQuery().includeKeys().addCriteria(age.eq(13).or(age.eq(12).and(gender.eq("timmy")))) - .addOrderBy(age, Direction.ASCENDING).addOrderBy(gender, Direction.DESCENDING).maxResults(10).end(); - } - - @Test - public void testNoIncludeSpecified() { - Attribute age = cache.getSearchAttribute("age"); - Query query = cache.createQuery().addCriteria(age.eq(35)); - try { - query.execute(); - Assert.fail(); - } catch (SearchException e) { - System.err.println("Expected " + e.toString()); - } - } - - @Test - public void testUseShorthandKeyAttribute() { - Results results = cache.createQuery().addCriteria(KEY.eq(1)).includeKeys().execute(); - assertEquals(1, results.size()); - assertEquals(1, results.all().iterator().next().getKey()); - } - - @Test - public void testUseShorthandValueAttribute() { - Object tmpKey = new Object(); - Double value = Math.PI * System.nanoTime(); - cache.put(new Element(tmpKey, value)); - - try { - Results results = cache.createQuery().addCriteria(Query.VALUE.eq(value)).includeKeys().execute(); - assertEquals(1, results.size()); - assertEquals(tmpKey, results.all().iterator().next().getKey()); - } finally { - cache.remove(tmpKey); - } - } - - @Test - public void testIncludeKeysSpecified() { - Attribute age = cache.getSearchAttribute("age"); - Results results = cache.createQuery().addCriteria(age.eq(35)).includeKeys().execute(); - assertEquals(2, results.size()); - for (Result result : results.all()) { - LOG.info("" + cache.get(result.getKey())); - } - } - - @Test - public void testSearchKeys() { - Results results = cache.createQuery().addCriteria(Query.KEY.in(Arrays.asList(1, 3))).includeKeys().execute(); - assertEquals(2, results.size()); - for (Result result : results.all()) { - LOG.info("" + cache.get(result.getKey())); - } - } - - /** - * Show how to execute a query in beanshell - */ - @Test - public void testBasicBeanShellQuery() throws EvalError { - - Interpreter i = new Interpreter(); - Query query = cache.createQuery().includeKeys(); - - Attribute age = cache.getSearchAttribute("age"); - - i.set("query", query); - Results results = null; - i.set("results", results); - i.set("age", age); - - i.eval("results = query.addCriteria(age.eq(35)).execute()"); - results = (Results) i.get("results"); - assertEquals(2, results.size()); - for (Result result : results.all()) { - LOG.info("" + result.getKey()); - } - } - - /** - * Show how to execute a query in beanshell - */ - @Test - public void testInjectedStringBeanShellQuery() throws EvalError { - - Interpreter i = new Interpreter(); - Query query = cache.createQuery().includeKeys(); - - Attribute age = cache.getSearchAttribute("age"); - - i.set("query", query); - Results results = null; - i.set("results", results); - i.set("age", age); - - String userDefinedQuery = "age.eq(35)"; - String fullQueryString = "results = query.addCriteria(" + userDefinedQuery + ").execute()"; - - i.eval(fullQueryString); - results = (Results) i.get("results"); - assertEquals(2, results.size()); - for (Result result : results.all()) { - LOG.info("" + result.getKey()); - } - } - - /** - * Show how to execute a query in beanshell using autodiscovered attributes - */ - @Test - public void testAutoDiscoveredAttributesBeanShellQuery() throws EvalError { - - Interpreter i = new Interpreter(); - - // Auto discover the search attributes and add them to the interpreter's context - Map attributes = cache.getCacheConfiguration().getSearchAttributes(); - for (Map.Entry entry : attributes.entrySet()) { - i.set(entry.getKey(), cache.getSearchAttribute(entry.getKey())); - LOG.info("Setting attribute " + entry.getKey()); - } - - // Define the query and results. Add things which would be set in the GUI i.e. includeKeys and add to context - Query query = cache.createQuery().includeKeys(); - Results results = null; - i.set("query", query); - i.set("results", results); - - // This comes from the freeform text field - String userDefinedQuery = "age.eq(35)"; - - // Add the stuff on that we need - String fullQueryString = "results = query.addCriteria(" + userDefinedQuery + ").execute()"; - - i.eval(fullQueryString); - results = (Results) i.get("results"); - assertEquals(2, results.size()); - for (Result result : results.all()) { - LOG.info("" + result.getKey()); - } - - } - -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/constructs/nonstop/concurrency/LockOperationTimedOutNonstopException.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/constructs/nonstop/concurrency/LockOperationTimedOutNonstopException.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/constructs/nonstop/concurrency/LockOperationTimedOutNonstopException.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.constructs.nonstop.concurrency; - -import net.sf.ehcache.constructs.nonstop.NonStopCacheException; - -/** - * Special class of {@link NonStopCacheException} which is thrown on timeout of lock operations - * - * @author Abhishek Sanoujam - * - */ -public class LockOperationTimedOutNonstopException extends NonStopCacheException { - - /** - * public constructor - * - * @param message - */ - public LockOperationTimedOutNonstopException(String message) { - super(message); - } - -} Index: rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/org/terracotta/ehcache/tests/ClientArrayValues1.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/org/terracotta/ehcache/tests/ClientArrayValues1.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/org/terracotta/ehcache/tests/ClientArrayValues1.java (revision 0) @@ -1,27 +0,0 @@ -package org.terracotta.ehcache.tests; - -import net.sf.ehcache.Cache; -import net.sf.ehcache.Element; - -import org.terracotta.toolkit.Toolkit; - -public class ClientArrayValues1 extends ClientBase { - - public ClientArrayValues1(String[] args) { - super("test", args); - } - - public static void main(String[] args) { - new ClientArrayValues1(args).run(); - } - - @Override - protected void runTest(Cache cache, Toolkit toolkit) throws Throwable { - cache.put(new Element("key", new String[] { "a", "b", "c" })); -// } else { -// Element elem = cache.get("key"); -// assertNotNull() -// String[] value = elem.getValue(); -// } - } -} Index: rctags/ehcache-2.10.9.1.33/system-tests/src/test/resources/net/sf/ehcache/osgi/ehcache-scheduled-refresh.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/system-tests/src/test/resources/net/sf/ehcache/osgi/ehcache-scheduled-refresh.xml (revision 11516) +++ rctags/ehcache-2.10.9.1.33/system-tests/src/test/resources/net/sf/ehcache/osgi/ehcache-scheduled-refresh.xml (revision 0) @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/resources/ehcache-no-update.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/resources/ehcache-no-update.xml (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/resources/ehcache-no-update.xml (revision 0) @@ -1,13 +0,0 @@ - - - - - - - Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/resources/ehcache-unloadablecachemanagerlistenerclass.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/resources/ehcache-unloadablecachemanagerlistenerclass.xml (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/resources/ehcache-unloadablecachemanagerlistenerclass.xml (revision 0) @@ -1,175 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/util/SetAsList.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/util/SetAsList.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/util/SetAsList.java (revision 0) @@ -1,212 +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.Collection; -import java.util.Iterator; -import java.util.List; -import java.util.ListIterator; -import java.util.Set; - -/** - * Wraps a set to provide a list interface. - * All list methods not application to set throws an {@link UnsupportedOperationException} - * - * @author Chris Dennis - * @param - */ -public class SetAsList implements List { - - private final Set set; - private transient Object[] array; - - /** - * @param set - */ - public SetAsList(Set set) { - this.set = set; - } - - /** - * {@inheritDoc} - */ - public int size() { - return set.size(); - } - - /** - * {@inheritDoc} - */ - public boolean isEmpty() { - return set.isEmpty(); - } - - /** - * {@inheritDoc} - */ - public boolean contains(Object o) { - return set.contains(o); - } - - /** - * {@inheritDoc} - */ - public Iterator iterator() { - return set.iterator(); - } - - /** - * {@inheritDoc} - */ - public Object[] toArray() { - return set.toArray(); - } - - /** - * {@inheritDoc} - */ - public T[] toArray(T[] a) { - return set.toArray(a); - } - - /** - * {@inheritDoc} - */ - public boolean add(E e) { - return set.add(e); - } - - /** - * {@inheritDoc} - */ - public boolean remove(Object o) { - return set.remove(o); - } - - /** - * {@inheritDoc} - */ - public boolean containsAll(Collection c) { - return set.containsAll(c); - } - - /** - * {@inheritDoc} - */ - public boolean addAll(Collection c) { - return set.addAll(c); - } - - /** - * Does not support List methods {@link UnsupportedOperationException}. - */ - public boolean addAll(int index, Collection c) { - throw new UnsupportedOperationException("Delegates to set, operation not supported"); - } - - /** - * {@inheritDoc} - */ - public boolean removeAll(Collection c) { - return set.removeAll(c); - } - - /** - * {@inheritDoc} - */ - public boolean retainAll(Collection c) { - return set.retainAll(c); - } - - /** - * {@inheritDoc} - */ - public void clear() { - set.clear(); - } - - /** - * Does not support List methods {@link UnsupportedOperationException}. - * - * @param index Index - */ - public E get(int index) { - if (this.array == null) { - this.array = toArray(); - } - if (array.length <= index) { - throw new IndexOutOfBoundsException(); - } - return (E) this.array[index]; - } - - /** - * Does not support List methods {@link UnsupportedOperationException}. - */ - public E set(int index, E element) { - throw new UnsupportedOperationException("Delegates to set, operation not supported"); - } - - /** - * Does not support List methods {@link UnsupportedOperationException}. - */ - public void add(int index, E element) { - throw new UnsupportedOperationException("Delegates to set, operation not supported"); - } - - /** - * Does not support List methods {@link UnsupportedOperationException}. - */ - public E remove(int index) { - throw new UnsupportedOperationException("Delegates to set, operation not supported"); - } - - /** - * Does not support List methods {@link UnsupportedOperationException}. - */ - public int indexOf(Object o) { - throw new UnsupportedOperationException("Delegates to set, operation not supported"); - } - - /** - * Does not support List methods {@link UnsupportedOperationException}. - */ - public int lastIndexOf(Object o) { - throw new UnsupportedOperationException("Delegates to set, operation not supported"); - } - - /** - * Does not support List methods {@link UnsupportedOperationException}. - */ - public ListIterator listIterator() { - throw new UnsupportedOperationException("Delegates to set, operation not supported"); - } - - /** - * Does not support List methods {@link UnsupportedOperationException}. - */ - public ListIterator listIterator(int index) { - throw new UnsupportedOperationException("Delegates to set, operation not supported"); - } - - /** - * Does not support List methods {@link UnsupportedOperationException}. - */ - public List subList(int fromIndex, int toIndex) { - throw new UnsupportedOperationException("Delegates to set, operation not supported"); - } -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/store/AbstractCopyingCacheStore.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/store/AbstractCopyingCacheStore.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/store/AbstractCopyingCacheStore.java (revision 0) @@ -1,348 +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.search.Attribute; -import net.sf.ehcache.search.Results; -import net.sf.ehcache.search.SearchException; -import net.sf.ehcache.search.attribute.AttributeExtractor; -import net.sf.ehcache.store.compound.ReadWriteCopyStrategy; -import net.sf.ehcache.terracotta.TerracottaNotRunningException; -import net.sf.ehcache.writer.CacheWriterManager; - -import org.terracotta.context.annotations.ContextChild; - -import java.io.IOException; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -/** - * Copies elements, either on read, write or both before using the underlying store to actually store things - * When copying both ways, the store might not see the same types being stored - * @param the store type it wraps - * - * @author Alex Snaps - */ -abstract class AbstractCopyingCacheStore implements Store { - - @ContextChild - private final T store; - private final CopyStrategyHandler copyStrategyHandler; - - /** - * Creates a copying instance of store, that wraps the actual storage - * @param store the real store - * @param copyOnRead whether to copy on reads - * @param copyOnWrite whether to copy on writes - * @param copyStrategyInstance the copy strategy to use on every copy operation - * @param loader classloader of the containing cache - */ - public AbstractCopyingCacheStore(final T store, final boolean copyOnRead, final boolean copyOnWrite, - final ReadWriteCopyStrategy copyStrategyInstance, ClassLoader loader) { - - this.store = store; - copyStrategyHandler = new CopyStrategyHandler(copyOnRead, copyOnWrite, copyStrategyInstance, loader); - } - - @Override - public void addStoreListener(final StoreListener listener) { - store.addStoreListener(listener); - } - - @Override - public void removeStoreListener(final StoreListener listener) { - store.removeStoreListener(listener); - } - - @Override - public boolean put(final Element e) throws CacheException { - return e == null || store.put(copyStrategyHandler.copyElementForWriteIfNeeded(e)); - } - - @Override - public void putAll(final Collection elements) throws CacheException { - for (Element element : elements) { - put(element); - } - } - - @Override - public boolean putWithWriter(final Element element, final CacheWriterManager writerManager) throws CacheException { - return store.putWithWriter(copyStrategyHandler.copyElementForWriteIfNeeded(element), writerManager); - } - - @Override - public Element get(final Object key) { - return copyStrategyHandler.copyElementForReadIfNeeded(store.get(key)); - } - - @Override - public Element getQuiet(final Object key) { - return copyStrategyHandler.copyElementForReadIfNeeded(store.getQuiet(key)); - } - - @Override - public List getKeys() { - return store.getKeys(); - } - - @Override - public Element remove(final Object key) { - return copyStrategyHandler.copyElementForReadIfNeeded(store.remove(key)); - } - - @Override - public void removeAll(final Collection keys) { - for (Object key : keys) { - remove(key); - } - } - - @Override - public Element removeWithWriter(final Object key, final CacheWriterManager writerManager) throws CacheException { - return copyStrategyHandler.copyElementForReadIfNeeded(store.removeWithWriter(key, writerManager)); - } - - @Override - public void removeAll() throws CacheException { - store.removeAll(); - } - - @Override - public Element putIfAbsent(final Element element) throws NullPointerException { - return copyStrategyHandler.copyElementForReadIfNeeded(store.putIfAbsent(copyStrategyHandler.copyElementForWriteIfNeeded(element))); - } - - @Override - public Element removeElement(final Element element, final ElementValueComparator comparator) throws NullPointerException { - Element removed = store.removeElement(copyStrategyHandler.copyElementForRemovalIfNeeded(element), comparator); - return copyStrategyHandler.copyElementForReadIfNeeded(removed); - } - - @Override - public boolean replace(final Element old, final Element element, - final ElementValueComparator comparator) throws NullPointerException, IllegalArgumentException { - Element oldElement = copyStrategyHandler.copyElementForRemovalIfNeeded(old); - Element newElement = copyStrategyHandler.copyElementForWriteIfNeeded(element); - return store.replace(oldElement, newElement, comparator); - } - - @Override - public Element replace(final Element element) throws NullPointerException { - return copyStrategyHandler.copyElementForReadIfNeeded(store.replace(copyStrategyHandler.copyElementForWriteIfNeeded(element))); - } - - @Override - public void dispose() { - store.dispose(); - } - - @Override - public int getSize() { - return store.getSize(); - } - - @Override - public int getInMemorySize() { - return store.getInMemorySize(); - } - - @Override - public int getOffHeapSize() { - return store.getOffHeapSize(); - } - - @Override - public int getOnDiskSize() { - return store.getOnDiskSize(); - } - - @Override - public int getTerracottaClusteredSize() { - return store.getTerracottaClusteredSize(); - } - - @Override - public long getInMemorySizeInBytes() { - return store.getInMemorySizeInBytes(); - } - - @Override - public long getOffHeapSizeInBytes() { - return store.getOffHeapSizeInBytes(); - } - - @Override - public long getOnDiskSizeInBytes() { - return store.getOnDiskSizeInBytes(); - } - - @Override - public boolean hasAbortedSizeOf() { - return store.hasAbortedSizeOf(); - } - - @Override - public Status getStatus() { - return store.getStatus(); - } - - @Override - public boolean containsKey(final Object key) { - return store.containsKey(key); - } - - @Override - public boolean containsKeyOnDisk(final Object key) { - return store.containsKeyOnDisk(key); - } - - @Override - public boolean containsKeyOffHeap(final Object key) { - return store.containsKeyOffHeap(key); - } - - @Override - public boolean containsKeyInMemory(final Object key) { - return store.containsKeyInMemory(key); - } - - @Override - public void expireElements() { - store.expireElements(); - } - - @Override - public void flush() throws IOException { - store.flush(); - } - - @Override - public boolean bufferFull() { - return store.bufferFull(); - } - - @Override - public Policy getInMemoryEvictionPolicy() { - return store.getInMemoryEvictionPolicy(); - } - - @Override - public void setInMemoryEvictionPolicy(final Policy policy) { - store.setInMemoryEvictionPolicy(policy); - } - - @Override - public Object getInternalContext() { - return store.getInternalContext(); - } - - @Override - public boolean isCacheCoherent() { - return store.isCacheCoherent(); - } - - @Override - public boolean isClusterCoherent() throws TerracottaNotRunningException { - return store.isClusterCoherent(); - } - - @Override - public boolean isNodeCoherent() throws TerracottaNotRunningException { - return store.isNodeCoherent(); - } - - @Override - public void setNodeCoherent(final boolean coherent) throws UnsupportedOperationException, TerracottaNotRunningException { - store.setNodeCoherent(coherent); - } - - @Override - public void waitUntilClusterCoherent() throws UnsupportedOperationException, TerracottaNotRunningException, InterruptedException { - store.waitUntilClusterCoherent(); - } - - @Override - public Object getMBean() { - return store.getMBean(); - } - - @Override - public void setAttributeExtractors(final Map extractors) { - store.setAttributeExtractors(extractors); - } - - @Override - public Results executeQuery(final StoreQuery query) throws SearchException { - return store.executeQuery(query); - } - - @Override - public Attribute getSearchAttribute(final String attributeName) { - return store.getSearchAttribute(attributeName); - } - - @Override - public Set getSearchAttributes() { - return store.getSearchAttributes(); - } - - @Override - public Map getAllQuiet(final Collection keys) { - Map elements = new HashMap(); - for (Object key : keys) { - elements.put(key, getQuiet(key)); - } - return elements; - } - - @Override - public Map getAll(final Collection keys) { - Map elements = new HashMap(); - for (Object key : keys) { - elements.put(key, get(key)); - } - return elements; - } - - @Override - public void recalculateSize(final Object key) { - store.recalculateSize(key); - } - - /** - * Accessor to the underlying store - * @return the underlying store - */ - public T getUnderlyingStore() { - return store; - } - - /** - * Accessor to the {@link CopyStrategyHandler} - * - * @return the copy strategy handler - */ - protected CopyStrategyHandler getCopyStrategyHandler() { - return copyStrategyHandler; - } -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/transaction/manager/selector/FactorySelector.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/transaction/manager/selector/FactorySelector.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/transaction/manager/selector/FactorySelector.java (revision 0) @@ -1,76 +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 java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -import javax.transaction.TransactionManager; - -/** - * Abstract selector for calling a factory method - * - * @author Ludovic Orban - */ -public abstract class FactorySelector extends Selector { - private static final Logger LOG = LoggerFactory.getLogger(FactorySelector.class); - - private final String factoryClassName; - private final String factoryMethodName; - - /** - * Constructor - * - * @param vendor the transaction manager vendor name - * @param factoryClassName the class used to lookup the transaction manager - * @param factoryMethodName the method to be called on the class used to lookup the transaction manager - */ - public FactorySelector(String vendor, String factoryClassName, String factoryMethodName) { - super(vendor); - this.factoryClassName = factoryClassName; - this.factoryMethodName = factoryMethodName; - } - - /** - * {@inheritDoc} - */ - @Override - protected TransactionManager doLookup() { - TransactionManager transactionManager = null; - - try { - Class factoryClass = Class.forName(factoryClassName); - Class[] signature = null; - Object[] args = null; - Method method = factoryClass.getMethod(factoryMethodName, signature); - transactionManager = (TransactionManager) method.invoke(null, args); - } catch (ClassNotFoundException e) { - LOG.debug("FactorySelector failed lookup: {}", (Object) e); - } catch (NoSuchMethodException e) { - LOG.debug("FactorySelector failed lookup: {}", (Object) e); - } catch (InvocationTargetException e) { - LOG.debug("FactorySelector failed lookup: {}", (Object) e); - } catch (IllegalAccessException e) { - LOG.debug("FactorySelector failed lookup: {}", (Object) e); - } - return transactionManager; - } - - -} \ No newline at end of file Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/pool/sizeof/JvmInformationTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/pool/sizeof/JvmInformationTest.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/pool/sizeof/JvmInformationTest.java (revision 0) @@ -1,71 +0,0 @@ -package net.sf.ehcache.pool.sizeof; - -import org.junit.Test; - -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; - -/** - * Basic test used during refactoring of enum to make sure no differences were introduced - */ -public class JvmInformationTest { - - @Test - public void hotspot32Bits() { - verifyJvmInfo(JvmInformation.HOTSPOT_32_BIT, 0, 0, 4, 8, 8, 8, 4, true, true, true); - verifyJvmInfo(JvmInformation.HOTSPOT_32_BIT_WITH_CONCURRENT_MARK_AND_SWEEP, 0, 0, 4, 16, 8, 8, 4, true, true, true); - } - - @Test - public void hotspot64Bits() { - verifyJvmInfo(JvmInformation.HOTSPOT_64_BIT, 0, 0, 8, 8, 8, 16, 8, true, true, true); - verifyJvmInfo(JvmInformation.HOTSPOT_64_BIT_WITH_CONCURRENT_MARK_AND_SWEEP, 0, 0, 8, 24, 8, 16, 8, true, true, true); - verifyJvmInfo(JvmInformation.HOTSPOT_64_BIT_WITH_COMPRESSED_OOPS, 0, 0, 4, 8, 8, 12, 8, true, true, true); - verifyJvmInfo(JvmInformation.HOTSPOT_64_BIT_WITH_COMPRESSED_OOPS_AND_CONCURRENT_MARK_AND_SWEEP, 0, 0, 4, 24, 8, 12, 8, true, true, true); - } - - @Test - public void openJdk32Bits() { - verifyJvmInfo(JvmInformation.OPENJDK_32_BIT, 0, 0, 4, 8, 8, 8, 4, true, true, true); - verifyJvmInfo(JvmInformation.OPENJDK_32_BIT_WITH_CONCURRENT_MARK_AND_SWEEP, 0, 0, 4, 16, 8, 8, 4, true, true, true); - } - - @Test - public void openJdk64Bits() { - verifyJvmInfo(JvmInformation.OPENJDK_64_BIT, 0, 0, 8, 8, 8, 16, 8, true, true, true); - verifyJvmInfo(JvmInformation.OPENJDK_64_BIT_WITH_CONCURRENT_MARK_AND_SWEEP, 0, 0, 8, 24, 8, 16, 8, true, true, true); - verifyJvmInfo(JvmInformation.OPENJDK_64_BIT_WITH_COMPRESSED_OOPS, 0, 0, 4, 8, 8, 12, 8, true, true, true); - verifyJvmInfo(JvmInformation.OPENJDK_64_BIT_WITH_COMPRESSED_OOPS_AND_CONCURRENT_MARK_AND_SWEEP, 0, 0, 4, 24, 8, 12, 8, true, true, true); - } - - @Test - public void ibm32Bits() { - verifyJvmInfo(JvmInformation.IBM_32_BIT, 0, 0, 4, 8, 8, 16, 4, true, false, true); - } - - @Test - public void ibm64Bits() { - verifyJvmInfo(JvmInformation.IBM_64_BIT, 0, 0, 8, 8, 8, 24, 8, true, false, true); - verifyJvmInfo(JvmInformation.IBM_64_BIT_WITH_COMPRESSED_REFS, 0, 0, 4, 16, 8, 16, 4, false, false, true); - } - - @Test - public void unknown() { - verifyJvmInfo(JvmInformation.UNKNOWN_32_BIT, 0, 0, 4, 8, 8, 8, 4, true, true, true); - verifyJvmInfo(JvmInformation.UNKNOWN_64_BIT, 0, 0, 8, 8, 8, 16, 8, true, true, true); - } - - private void verifyJvmInfo(JvmInformation jvmInfo, int agentSizeOfAdj, int fieldOffsetAdj, int javaPointerSize, int minObjSize, int objAlign, int objHeaderSize, int pointerSize, - boolean supportAgentSizeOf, boolean supportReflectionSizeOf, boolean supportUnsafeSizeOf) { - assertThat(jvmInfo.getAgentSizeOfAdjustment(), is(agentSizeOfAdj)); - assertThat(jvmInfo.getFieldOffsetAdjustment(), is(fieldOffsetAdj)); - assertThat(jvmInfo.getJavaPointerSize(), is(javaPointerSize)); - assertThat(jvmInfo.getMinimumObjectSize(), is(minObjSize)); - assertThat(jvmInfo.getObjectAlignment(), is(objAlign)); - assertThat(jvmInfo.getObjectHeaderSize(), is(objHeaderSize)); - assertThat(jvmInfo.getPointerSize(), is(pointerSize)); - assertThat(jvmInfo.supportsAgentSizeOf(), is(supportAgentSizeOf)); - assertThat(jvmInfo.supportsReflectionSizeOf(), is(supportReflectionSizeOf)); - assertThat(jvmInfo.supportsUnsafeSizeOf(), is(supportUnsafeSizeOf)); - } -} \ No newline at end of file Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/transaction/manager/selector/JndiSelector.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/transaction/manager/selector/JndiSelector.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/transaction/manager/selector/JndiSelector.java (revision 0) @@ -1,94 +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.naming.InitialContext; -import javax.naming.NamingException; -import javax.transaction.TransactionManager; - -/** - * Abstract selector performing JNDI lookup - * - * @author Ludovic Orban - */ -public abstract class JndiSelector extends Selector { - private static final Logger LOG = LoggerFactory.getLogger(JndiSelector.class); - - private volatile String jndiName; - - /** - * Constructor - * - * @param vendor the transaction manager vendor name - * @param jndiName the JNDI name to look up - */ - public JndiSelector(String vendor, String jndiName) { - super(vendor); - this.jndiName = jndiName; - } - - /** - * Get the configured JNDI name to look up - * @return the JNDI name to look up - */ - public String getJndiName() { - return jndiName; - } - - /** - * Set the configured JNDI name to look up - * @param jndiName the JNDI name to look up - */ - public void setJndiName(String jndiName) { - this.jndiName = jndiName; - } - - /** - * {@inheritDoc} - */ - @Override - protected TransactionManager doLookup() { - InitialContext initialContext; - try { - initialContext = new InitialContext(); - } catch (NamingException ne) { - LOG.debug("cannot create initial context", ne); - return null; - } - - try { - Object jndiObject; - try { - jndiObject = initialContext.lookup(getJndiName()); - if (jndiObject instanceof TransactionManager) { - return (TransactionManager) jndiObject; - } - } catch (NamingException e) { - LOG.debug("Couldn't locate TransactionManager for {} under {}", getVendor(), getJndiName()); - } - return null; - } finally { - try { - initialContext.close(); - } catch (NamingException ne) { - LOG.warn("error closing initial context", ne); - } - } - } -} \ No newline at end of file Index: rctags/ehcache-2.10.9.1.33/ehcache-scheduled-refresh/checkstyle/suppressions.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-scheduled-refresh/checkstyle/suppressions.xml (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-scheduled-refresh/checkstyle/suppressions.xml (revision 0) @@ -1,7 +0,0 @@ - - - - - - Index: rctags/ehcache-2.10.9.1.33/ehcache/src/test/java/net/sf/ehcache/terracotta/upgradability/serialization/TransactionalModeSerializationTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache/src/test/java/net/sf/ehcache/terracotta/upgradability/serialization/TransactionalModeSerializationTest.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache/src/test/java/net/sf/ehcache/terracotta/upgradability/serialization/TransactionalModeSerializationTest.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.terracotta.upgradability.serialization; - -import java.io.IOException; -import org.junit.Test; - -import static net.sf.ehcache.config.CacheConfiguration.TransactionalMode.LOCAL; -import static net.sf.ehcache.config.CacheConfiguration.TransactionalMode.XA; -import static net.sf.ehcache.config.CacheConfiguration.TransactionalMode.XA_STRICT; -import static org.terracotta.upgradability.serialization.SerializationUpgradabilityTesting.validateSerializedForm; - -/** - * - * @author cdennis - */ -public class TransactionalModeSerializationTest { - - @Test - public void testLocal() throws IOException, ClassNotFoundException { - validateSerializedForm(LOCAL, "serializedforms/TransactionalModeSerializationTest.testLocal.ser"); - } - - @Test - public void testXa() throws IOException, ClassNotFoundException { - validateSerializedForm(XA, "serializedforms/TransactionalModeSerializationTest.testXa.ser"); - } - - @Test - public void testXaStrict() throws IOException, ClassNotFoundException { - validateSerializedForm(XA_STRICT, "serializedforms/TransactionalModeSerializationTest.testXaStrict.ser"); - } -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/servermaplocalcache/TCObjectSelf.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/servermaplocalcache/TCObjectSelf.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/servermaplocalcache/TCObjectSelf.java (revision 0) @@ -1,43 +0,0 @@ -/** - * All content copyright 2010 (c) Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All - * rights reserved. - */ -package net.sf.ehcache.servermaplocalcache; - -import java.io.Serializable; - -public class TCObjectSelf implements Serializable { - private final String key; - private final String value; - private final byte[] paddingBytes; - private final long oid; - - public TCObjectSelf(String key, String value, byte[] paddingBytes, long oid) { - this.key = key; - this.value = value; - this.paddingBytes = paddingBytes; - this.oid = oid; - } - - public String getKey() { - return key; - } - - public String getValue() { - return value; - } - - public byte[] getPaddingBytes() { - return paddingBytes; - } - - public long getOid() { - return oid; - } - - @Override - public String toString() { - return "TCObjectSelf [oid=" + oid + ", key=" + key + ", value=" + value + "]"; - } - -} Index: rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/org/terracotta/modules/ehcache/event/ClusteredEventsRemoteTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/org/terracotta/modules/ehcache/event/ClusteredEventsRemoteTest.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/org/terracotta/modules/ehcache/event/ClusteredEventsRemoteTest.java (revision 0) @@ -1,77 +0,0 @@ -/* - * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved. - */ -package org.terracotta.modules.ehcache.event; - -import net.sf.ehcache.Cache; -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 com.tc.test.config.model.TestConfig; - -import java.util.Set; - -import junit.framework.Assert; - -public class ClusteredEventsRemoteTest extends AbstractCacheTestBase { - - private static final int NODE_COUNT = 5; - - public ClusteredEventsRemoteTest(TestConfig testConfig) { - super("clustered-events-test.xml", testConfig, App.class, App.class, App.class, App.class, App.class); - testConfig.getClientConfig().addExtraClientJvmArg("-Dcom.tc.ehcache.clusteredStore.checkContainsKeyOnPut=true"); - } - - public static class App extends ClientBase { - private final ToolkitBarrier barrier; - - public App(String[] args) { - super("testRemote", args); - this.barrier = getClusteringToolkit().getBarrier("test-barrier", NODE_COUNT); - } - - @Override - protected void runTest(Cache cache, Toolkit clusteringToolkit) throws Throwable { - final int index = barrier.await(); - - Assert.assertEquals(0, cache.getSize()); - - barrier.await(); - - cache.put(new Element("key" + index, "value" + index)); - cache.put(new Element("key" + index, "valueUpdated" + index)); - cache.remove("key" + index); - - barrier.await(); - - cache.removeAll(); - - barrier.await(); - - Thread.sleep(10000); - - EhcacheTerracottaEventListener listener = null; - Set listeners = cache.getCacheEventNotificationService().getCacheEventListeners(); - for (CacheEventListener l : listeners) { - if (l instanceof EhcacheTerracottaEventListener) { - listener = (EhcacheTerracottaEventListener) l; - break; - } - } - - Assert.assertNotNull(listener); - - Assert.assertEquals(NODE_COUNT - 1, listener.getPut().size()); - Assert.assertEquals(NODE_COUNT - 1, listener.getUpdate().size()); - Assert.assertEquals(NODE_COUNT - 1, listener.getRemove().size()); - Assert.assertEquals(NODE_COUNT - 1, listener.getRemoveAll()); - } - - } - -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/constructs/nonstop/NullCacheLockProvider.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/constructs/nonstop/NullCacheLockProvider.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/constructs/nonstop/NullCacheLockProvider.java (revision 0) @@ -1,27 +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.nonstop; - -import net.sf.ehcache.concurrent.CacheLockProvider; -import net.sf.ehcache.concurrent.Sync; - -public class NullCacheLockProvider implements CacheLockProvider { - - public Sync getSyncForKey(Object key) { - return null; - } -} Index: rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/org/terracotta/ehcache/tests/servermap/ServerMapL2EvictionReachesL1TestClient.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/org/terracotta/ehcache/tests/servermap/ServerMapL2EvictionReachesL1TestClient.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/org/terracotta/ehcache/tests/servermap/ServerMapL2EvictionReachesL1TestClient.java (revision 0) @@ -1,91 +0,0 @@ -package org.terracotta.ehcache.tests.servermap; - -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.toolkit.Toolkit; - -import java.util.Calendar; -import java.util.concurrent.atomic.AtomicInteger; - -public class ServerMapL2EvictionReachesL1TestClient extends ServerMapClientBase { - - public ServerMapL2EvictionReachesL1TestClient(String[] args) { - super("test", args); - } - - public static void main(String[] args) { - new ServerMapL2EvictionReachesL1TestClient(args).run(); - } - - @Override - protected void runTest(Cache cache, Toolkit clusteringToolkit) throws Throwable { - System.out.println("Running test with concurrency=1"); - testWith(cache, 3000, 100); - - System.out.println("Testing with higher concurrency value."); - // 100 maxElementsOnDisk, 50 stripes -> targetMaxTotalCount of 2 for each stripe - // add 5000 (100 per stripe), at least one per stripe should be evicted - // use 25 just in case - testWith(cache.getCacheManager().getCache("testWithConcurrency"), 5000, 50); - } - - private void testWith(final Cache cache, final int maxElements, final int expectedEvictionCount) - throws InterruptedException { - EvictionCountingEventListener countingListener = new EvictionCountingEventListener(); - cache.getCacheEventNotificationService().registerListener(countingListener); - - for (int i = 0; i < maxElements; i++) { - cache.put(new Element("key-" + i, "value-" + i)); - } - - Calendar timeoutTime = Calendar.getInstance(); - timeoutTime.add(Calendar.MINUTE, 5); - System.out.println("Waiting 5 minutes for evictions to reach the expected count of " + expectedEvictionCount); - assertRange(expectedEvictionCount, maxElements, cache); - } - - public class EvictionCountingEventListener implements CacheEventListener { - private final AtomicInteger count = new AtomicInteger(); - - public void notifyElementEvicted(Ehcache cache, Element element) { - int val = count.incrementAndGet(); - if (val % 100 == 0) { - System.out.println("EvictionListener: number of elements evicted till now: " + val); - } - } - - public void dispose() { - // - } - - public void notifyElementExpired(Ehcache cache, Element element) { - // - } - - public void notifyElementPut(Ehcache cache, Element element) throws CacheException { - // - } - - public void notifyElementRemoved(Ehcache cache, Element element) throws CacheException { - // - } - - public void notifyElementUpdated(Ehcache cache, Element element) throws CacheException { - // - } - - public void notifyRemoveAll(Ehcache cache) { - // - } - - @Override - public Object clone() throws CloneNotSupportedException { - return super.clone(); - } - - } -} Index: rctags/ehcache-2.10.9.1.33/ehcache/src/test/resources/serializedforms/SerializedReadCommittedClusteredSoftLockSerializationTest.testBasic.ser =================================================================== diff -u -N -r11516 -r11534 Binary files differ Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/AutoVersioningElementTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/AutoVersioningElementTest.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/AutoVersioningElementTest.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; - -import static org.junit.Assert.assertEquals; -import net.sf.ehcache.store.MemoryStoreEvictionPolicy; - -import org.junit.Test; - -public class AutoVersioningElementTest { - - @Test - public void testVersioningCanRevertToOldBehavior() { - System.setProperty("net.sf.ehcache.element.version.auto", "true"); - try { - CacheManager cacheManager = CacheManager.getInstance(); - cacheManager.addCache(new Cache("mltest", 50, MemoryStoreEvictionPolicy.LRU, true, null, true, 0, 0, false, 120, null, null, 0, 2, false)); - Cache cache = cacheManager.getCache("mltest"); - - Element a = new Element("a key", "a value", 1L); - cache.put(a); - Element aAfter = cache.get("a key"); - assertEquals(aAfter.getLastUpdateTime(), aAfter.getVersion()); - - Element b = new Element("a key", "a value"); - cache.put(b); - Element bAfter = cache.get("a key"); - assertEquals(bAfter.getLastUpdateTime(), bAfter.getVersion()); - - Element c = new Element("a key", "a value", 3L); - cache.put(c); - Element cAfter = cache.get("a key"); - assertEquals(cAfter.getLastUpdateTime(), cAfter.getVersion()); - } finally { - System.getProperties().remove("net.sf.ehcache.element.version.auto"); - CacheManager.getInstance().shutdown(); - } - } -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/hibernate/management/impl/EhcacheStatsImpl.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/hibernate/management/impl/EhcacheStatsImpl.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/hibernate/management/impl/EhcacheStatsImpl.java (revision 0) @@ -1,624 +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.util.ArrayList; -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.TimeUnit; - -import javax.management.MBeanNotificationInfo; -import javax.management.NotCompliantMBeanException; -import javax.management.Notification; - -import net.sf.ehcache.Cache; -import net.sf.ehcache.CacheManager; -import net.sf.ehcache.hibernate.management.api.EhcacheStats; -import net.sf.ehcache.management.sampled.SampledCacheManager; - -/** - * Implementation of {@link EhcacheStats} - * - *

- * - * @author Abhishek Sanoujam - * - */ -public class EhcacheStatsImpl extends BaseEmitterBean implements EhcacheStats { - private static final long MILLIS_PER_SECOND = 1000; - private static final MBeanNotificationInfo NOTIFICATION_INFO; - - private final SampledCacheManager sampledCacheManager; - private final CacheManager cacheManager; - private long statsSince = System.currentTimeMillis(); - - static { - final String[] notifTypes = new String[] {CACHE_ENABLED, CACHE_REGION_CHANGED, CACHE_FLUSHED, CACHE_REGION_FLUSHED, - CACHE_STATISTICS_ENABLED, CACHE_STATISTICS_RESET, }; - final String name = Notification.class.getName(); - final String description = "Ehcache Hibernate Statistics Event"; - NOTIFICATION_INFO = new MBeanNotificationInfo(notifTypes, name, description); - } - - /** - * Constructor accepting the backing {@link CacheManager} - * @throws NotCompliantMBeanException - */ - public EhcacheStatsImpl(CacheManager manager) throws NotCompliantMBeanException { - super(EhcacheStats.class); - this.sampledCacheManager = new SampledCacheManager(manager); - this.cacheManager = manager; - } - - /** - * {@inheritDoc} - */ - public void flushRegionCache(String region) { - Cache cache = this.cacheManager.getCache(region); - if (cache != null) { - cache.flush(); - } - } - - /** - * {@inheritDoc} - */ - public void flushRegionCaches() { - for (String name : cacheManager.getCacheNames()) { - Cache cache = this.cacheManager.getCache(name); - if (cache != null) { - cache.flush(); - } - } - - } - - /** - * {@inheritDoc} - */ - public String generateActiveConfigDeclaration() { - return this.cacheManager.getActiveConfigurationText(); - } - - /** - * {@inheritDoc} - */ - public String generateActiveConfigDeclaration(String region) { - return this.cacheManager.getActiveConfigurationText(region); - } - - /** - * {@inheritDoc} - */ - public long getCacheHitCount() { - long count = 0; - for (String name : cacheManager.getCacheNames()) { - Cache cache = cacheManager.getCache(name); - if (cache != null) { - count += cache.getStatistics().cacheHitCount(); - } - } - return count; - } - - /** - * {@inheritDoc} - */ - public double getCacheHitRate() { - long now = System.currentTimeMillis(); - double deltaSecs = (double) (now - statsSince) / MILLIS_PER_SECOND; - return getCacheHitCount() / deltaSecs; - } - - /** - * {@inheritDoc} - */ - public long getCacheHitSample() { - long count = 0; - for (String name : cacheManager.getCacheNames()) { - Cache cache = cacheManager.getCache(name); - if (cache != null) { - count += cache.getStatistics().cacheHitOperation().rate().value().longValue(); - } - } - return count; - } - - /** - * {@inheritDoc} - */ - public long getCacheMissCount() { - long count = 0; - for (String name : cacheManager.getCacheNames()) { - Cache cache = cacheManager.getCache(name); - if (cache != null) { - count += cache.getStatistics().cacheMissCount(); - } - } - return count; - } - - /** - * {@inheritDoc} - */ - public double getCacheMissRate() { - long now = System.currentTimeMillis(); - double deltaSecs = (double) (now - statsSince) / MILLIS_PER_SECOND; - return getCacheMissCount() / deltaSecs; - } - - /** - * {@inheritDoc} - */ - public long getCacheMissSample() { - long count = 0; - for (String name : cacheManager.getCacheNames()) { - Cache cache = cacheManager.getCache(name); - if (cache != null) { - count += cache.getStatistics().cacheMissOperation().rate().value().longValue(); - } - } - return count; - } - - /** - * {@inheritDoc} - */ - public long getCachePutCount() { - long count = 0; - for (String name : cacheManager.getCacheNames()) { - Cache cache = cacheManager.getCache(name); - if (cache != null) { - count += cache.getStatistics().cachePutCount(); - } - } - return count; - } - - /** - * {@inheritDoc} - */ - public double getCachePutRate() { - long now = System.currentTimeMillis(); - double deltaSecs = (double) (now - statsSince) / MILLIS_PER_SECOND; - return getCachePutCount() / deltaSecs; - } - - /** - * {@inheritDoc} - */ - public long getCachePutSample() { - long count = 0; - for (String name : cacheManager.getCacheNames()) { - Cache cache = cacheManager.getCache(name); - if (cache != null) { - count += cache.getStatistics().cachePutOperation().rate().value().longValue(); - } - } - return count; - } - - /** - * {@inheritDoc} - */ - public String getOriginalConfigDeclaration() { - return this.cacheManager.getOriginalConfigurationText(); - } - - /** - * {@inheritDoc} - */ - public String getOriginalConfigDeclaration(String region) { - return this.cacheManager.getOriginalConfigurationText(region); - } - - /** - * {@inheritDoc} - */ - public Map> getRegionCacheAttributes() { - Map> result = new HashMap>(); - for (String regionName : this.cacheManager.getCacheNames()) { - result.put(regionName, getRegionCacheAttributes(regionName)); - } - return result; - } - - /** - * {@inheritDoc} - */ - public Map getRegionCacheAttributes(String regionName) { - Map result = new HashMap(); - result.put("Enabled", isRegionCacheEnabled(regionName)); - result.put("LoggingEnabled", isRegionCacheLoggingEnabled(regionName)); - result.put("MaxTTISeconds", getRegionCacheMaxTTISeconds(regionName)); - result.put("MaxTTLSeconds", getRegionCacheMaxTTLSeconds(regionName)); - result.put("TargetMaxInMemoryCount", getRegionCacheTargetMaxInMemoryCount(regionName)); - result.put("TargetMaxTotalCount", getRegionCacheTargetMaxTotalCount(regionName)); - result.put("OrphanEvictionEnabled", isRegionCacheOrphanEvictionEnabled(regionName)); - result.put("OrphanEvictionPeriod", getRegionCacheOrphanEvictionPeriod(regionName)); - return result; - } - - /** - * {@inheritDoc} - */ - public int getRegionCacheMaxTTISeconds(String region) { - Cache cache = cacheManager.getCache(region); - if (cache != null) { - return (int) cache.getCacheConfiguration().getTimeToIdleSeconds(); - } else { - return -1; - } - } - - /** - * {@inheritDoc} - */ - public int getRegionCacheMaxTTLSeconds(String region) { - Cache cache = cacheManager.getCache(region); - if (cache != null) { - return (int) cache.getCacheConfiguration().getTimeToLiveSeconds(); - } else { - return -1; - } - } - - /** - * {@inheritDoc} - */ - public int getRegionCacheOrphanEvictionPeriod(String region) { - Cache cache = this.cacheManager.getCache(region); - if (cache != null && cache.isTerracottaClustered()) { - return cache.getCacheConfiguration().getTerracottaConfiguration().getOrphanEvictionPeriod(); - } else { - return -1; - } - } - - /** - * {@inheritDoc} - */ - public Map getRegionCacheSamples() { - Map rv = new HashMap(); - for (String name : cacheManager.getCacheNames()) { - Cache cache = cacheManager.getCache(name); - if (cache != null) { - rv.put(name, new int[] {cache.getStatistics().cacheHitOperation().rate().value().intValue() , - cache.getStatistics().cacheMissNotFoundOperation().rate().value().intValue() , - cache.getStatistics().cacheMissExpiredOperation().rate().value().intValue() , - cache.getStatistics().cachePutOperation().rate().value().intValue()}); - } - } - return rv; - } - - /** - * {@inheritDoc} - */ - public int getRegionCacheTargetMaxInMemoryCount(String region) { - Cache cache = cacheManager.getCache(region); - if (cache != null) { - return cache.getCacheConfiguration().getMaxElementsInMemory(); - } else { - return -1; - } - } - - /** - * {@inheritDoc} - */ - public int getRegionCacheTargetMaxTotalCount(String region) { - Cache cache = cacheManager.getCache(region); - if (cache != null) { - return cache.getCacheConfiguration().getMaxElementsOnDisk(); - } else { - return -1; - } - } - - /** - * {@inheritDoc} - */ - public String[] getTerracottaHibernateCacheRegionNames() { - ArrayList rv = new ArrayList(); - for (String name : cacheManager.getCacheNames()) { - Cache cache = cacheManager.getCache(name); - if (cache != null) { - if (cache.getCacheConfiguration().isTerracottaClustered()) { - rv.add(name); - } - } - } - return rv.toArray(new String[] {}); - } - - /** - * {@inheritDoc} - */ - public boolean isRegionCacheEnabled(String region) { - Cache cache = this.cacheManager.getCache(region); - if (cache != null) { - return !cache.isDisabled(); - } else { - return false; - } - } - - /** - * {@inheritDoc} - */ - public void setRegionCacheEnabled(String region, boolean enabled) { - Cache cache = this.cacheManager.getCache(region); - if (cache != null) { - cache.setDisabled(!enabled); - } - sendNotification(CACHE_REGION_CHANGED, getRegionCacheAttributes(region), region); - } - - /** - * {@inheritDoc} - */ - public boolean isRegionCachesEnabled() { - for (String name : this.cacheManager.getCacheNames()) { - Cache cache = this.cacheManager.getCache(name); - if (cache != null) { - if (cache.isDisabled()) { - return false; - } - } - } - return true; - } - - /** - * @see net.sf.ehcache.hibernate.management.api.EhcacheStats#setRegionCachesEnabled(boolean) - */ - public void setRegionCachesEnabled(final boolean flag) { - for (String name : this.cacheManager.getCacheNames()) { - Cache cache = this.cacheManager.getCache(name); - if (cache != null) { - cache.setDisabled(!flag); - } - } - sendNotification(CACHE_ENABLED, flag); - } - - /** - * {@inheritDoc} - */ - public boolean isRegionCacheLoggingEnabled(String region) { - Cache cache = this.cacheManager.getCache(region); - if (cache != null) { - return cache.getCacheConfiguration().getLogging(); - } else { - return false; - } - } - - /** - * {@inheritDoc} - */ - public boolean isRegionCacheOrphanEvictionEnabled(String region) { - Cache cache = this.cacheManager.getCache(region); - if (cache != null && cache.isTerracottaClustered()) { - return cache.getCacheConfiguration().getTerracottaConfiguration().getOrphanEviction(); - } else { - return false; - } - } - - /** - * {@inheritDoc} - */ - public boolean isTerracottaHibernateCache(String region) { - Cache cache = cacheManager.getCache(region); - if (cache != null) { - return cache.getCacheConfiguration().isTerracottaClustered(); - } else { - return false; - } - } - - /** - * {@inheritDoc} - */ - public void setRegionCacheLoggingEnabled(String region, boolean loggingEnabled) { - Cache cache = this.cacheManager.getCache(region); - if (cache != null) { - cache.getCacheConfiguration().setLogging(loggingEnabled); - sendNotification(CACHE_REGION_CHANGED, getRegionCacheAttributes(region), region); - } - } - - /** - * {@inheritDoc} - */ - public void setRegionCacheMaxTTISeconds(String region, int maxTTISeconds) { - Cache cache = this.cacheManager.getCache(region); - if (cache != null) { - cache.getCacheConfiguration().setTimeToIdleSeconds(maxTTISeconds); - sendNotification(CACHE_REGION_CHANGED, getRegionCacheAttributes(region), region); - } - } - - /** - * {@inheritDoc} - */ - public void setRegionCacheMaxTTLSeconds(String region, int maxTTLSeconds) { - Cache cache = this.cacheManager.getCache(region); - if (cache != null) { - cache.getCacheConfiguration().setTimeToLiveSeconds(maxTTLSeconds); - sendNotification(CACHE_REGION_CHANGED, getRegionCacheAttributes(region), region); - } - } - - /** - * {@inheritDoc} - */ - public void setRegionCacheTargetMaxInMemoryCount(String region, int targetMaxInMemoryCount) { - Cache cache = this.cacheManager.getCache(region); - if (cache != null) { - cache.getCacheConfiguration().setMaxElementsInMemory(targetMaxInMemoryCount); - sendNotification(CACHE_REGION_CHANGED, getRegionCacheAttributes(region), region); - } - } - - /** - * {@inheritDoc} - */ - public void setRegionCacheTargetMaxTotalCount(String region, int targetMaxTotalCount) { - Cache cache = this.cacheManager.getCache(region); - if (cache != null) { - cache.getCacheConfiguration().setMaxElementsOnDisk(targetMaxTotalCount); - sendNotification(CACHE_REGION_CHANGED, getRegionCacheAttributes(region), region); - } - } - - /** - * {@inheritDoc} - * - * @see net.sf.ehcache.hibernate.management.api.EhcacheStats#getNumberOfElementsInMemory(java.lang.String) - */ - public int getNumberOfElementsInMemory(String region) { - Cache cache = this.cacheManager.getCache(region); - if (cache != null) { - return (int) cache.getStatistics().getLocalHeapSize(); - } else { - return -1; - } - } - - /** - * {@inheritDoc} - * - * @see net.sf.ehcache.hibernate.management.api.EhcacheStats#getNumberOfElementsOffHeap(java.lang.String) - */ - public int getNumberOfElementsOffHeap(String region) { - Cache cache = this.cacheManager.getCache(region); - if (cache != null) { - return (int) cache.getStatistics().getLocalOffHeapSize(); - } else { - return -1; - } - } - - /** - * {@inheritDoc} - * - * @see net.sf.ehcache.hibernate.management.api.EhcacheStats#getNumberOfElementsOnDisk(java.lang.String) - */ - public int getNumberOfElementsOnDisk(String region) { - Cache cache = this.cacheManager.getCache(region); - if (cache != null) { - return (int) cache.getStatistics().getLocalDiskSize(); - } else { - return -1; - } - } - - /** - * {@inheritDoc} - */ - public long getMaxGetTimeMillis() { - long rv = 0; - for (String cacheName : cacheManager.getCacheNames()) { - Cache cache = cacheManager.getCache(cacheName); - if (cache != null) { - rv = Math.max(rv, TimeUnit.MILLISECONDS.convert(cache.getStatistics().cacheSearchOperation().latency().maximum().value().longValue(), - TimeUnit.NANOSECONDS)); - } - } - return rv; - } - - /** - * {@inheritDoc} - */ - public long getMinGetTimeMillis() { - long rv = 0; - for (String cacheName : cacheManager.getCacheNames()) { - Cache cache = cacheManager.getCache(cacheName); - if (cache != null) { - rv = Math.max(rv, TimeUnit.MILLISECONDS.convert(cache.getStatistics().cacheSearchOperation().latency().minimum().value().longValue(), - TimeUnit.NANOSECONDS)); - // TODO CRSS why max? - } - } - return rv; - } - - /** - * {@inheritDoc} - * - * @see net.sf.ehcache.hibernate.management.api.EhcacheStats#getMaxGetTimeMillis(java.lang.String) - */ - public long getMaxGetTimeMillis(String cacheName) { - Cache cache = cacheManager.getCache(cacheName); - if (cache != null) { - return TimeUnit.MILLISECONDS.convert(cache.getStatistics().cacheGetOperation().latency().maximum().value().longValue(), - TimeUnit.NANOSECONDS); - } else { - return 0; - } - } - - /** - * {@inheritDoc} - * - * @see net.sf.ehcache.hibernate.management.api.EhcacheStats#getMinGetTimeMillis(java.lang.String) - */ - public long getMinGetTimeMillis(String cacheName) { - Cache cache = cacheManager.getCache(cacheName); - if (cache != null) { - return TimeUnit.MILLISECONDS.convert(cache.getStatistics().cacheGetOperation().latency().minimum().value().longValue(), - TimeUnit.NANOSECONDS); - } else { - return 0; - } - } - - /** - * {@inheritDoc} - * - * @see net.sf.ehcache.hibernate.management.api.EhcacheStats#getAverageGetTimeMillis(java.lang.String) - */ - public float getAverageGetTimeMillis(String region) { - Cache cache = this.cacheManager.getCache(region); - if (cache != null) { - return TimeUnit.MILLISECONDS.convert(cache.getStatistics().cacheGetOperation().latency().average().value().longValue(), - TimeUnit.NANOSECONDS); - } else { - return -1f; - } - } - - /** - * {@inheritDoc} - */ - @Override - protected void doDispose() { - // no-op - } - - /** - * @see BaseEmitterBean#getNotificationInfo() - */ - @Override - public MBeanNotificationInfo[] getNotificationInfo() { - return new MBeanNotificationInfo[]{NOTIFICATION_INFO}; - } -} Index: rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/org/terracotta/ehcache/tests/OtherClassLoaderEventClient2.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/org/terracotta/ehcache/tests/OtherClassLoaderEventClient2.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/org/terracotta/ehcache/tests/OtherClassLoaderEventClient2.java (revision 0) @@ -1,136 +0,0 @@ -package org.terracotta.ehcache.tests; - -import net.sf.ehcache.Cache; - -import org.terracotta.toolkit.Toolkit; - -import com.otherclassloader.Client; -import com.otherclassloader.Value; - -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLClassLoader; -import java.util.Arrays; -import java.util.concurrent.CyclicBarrier; -import java.util.concurrent.atomic.AtomicReference; - -public class OtherClassLoaderEventClient2 extends ClientBase { - - public OtherClassLoaderEventClient2(String[] args) { - super("test", args); - } - - public static void main(String[] args) { - new OtherClassLoaderEventClient2(args).run(); - } - - @Override - protected void runTest(Cache cache, Toolkit toolkit) throws Throwable { - - String config = cache.getCacheManager().getActiveConfigurationText(); - - // This loader simulates ehcache in an isolated loader (similiar to an osgi bundle) - ClassLoader parentLoader = null; - boolean isPreJava9 = System.getProperty("java.specification.version").contains("."); - if (!isPreJava9) { - parentLoader = (ClassLoader)ClassLoader.class.getMethod("getPlatformClassLoader").invoke(null); - } - EhcacheLoader ehcacheLoader = new EhcacheLoader(parentLoader); - - // make sure the "app" types not visible to loader where ehcache is running - try { - ehcacheLoader.loadClass(Value.class.getName()); - throw new AssertionError(); - } catch (ClassNotFoundException cnfe) { - // expected - } - - // The "app" loader is like an applicatoin bundle that imports ehcache - AppLoader appLoader = new AppLoader(ehcacheLoader); - Thread.currentThread().setContextClassLoader(appLoader); - - Class clientClass = appLoader.loadClass(Client.class.getName()); - final CyclicBarrier localBarrier = new CyclicBarrier(2); - final Runnable client = (Runnable) clientClass.getConstructor(String.class, CyclicBarrier.class) - .newInstance(config, localBarrier); - final AtomicReference error = new AtomicReference(); - Thread thread = new Thread() { - @Override - public void run() { - try { - client.run(); - } catch (Throwable t) { - t.printStackTrace(); - error.set(t); - } - } - }; - thread.start(); - - localBarrier.await(); - getBarrierForAllClients().await(); - - thread.join(); - if (error.get() != null) { throw error.get(); } - } - - private static URL[] getSystemUrls() { - String pathSeparator = System.getProperty("path.separator"); - String[] classPathEntries = System.getProperty("java.class.path").split(pathSeparator); - return Arrays.stream(classPathEntries).map(s -> { - try { - return new File(s).toURI().toURL(); - } catch (MalformedURLException e) { - e.printStackTrace(); - return null; - } - }).toArray(URL[]::new); - } - - static class EhcacheLoader extends URLClassLoader { - EhcacheLoader(ClassLoader parentLoader) { - super(getSystemUrls(), parentLoader); - } - - @Override - protected Class findClass(String name) throws ClassNotFoundException { - // hide "app" classes from loader used to load ehcache - if (name.startsWith("com.otherclassloader.")) { throw new ClassNotFoundException(name); } - - return super.findClass(name); - } - - } - - static class AppLoader extends ClassLoader { - - AppLoader(EhcacheLoader ehcacheLoader) { - super(ehcacheLoader); - } - - @Override - protected Class findClass(String name) throws ClassNotFoundException { - if (name.startsWith("com.otherclassloader.")) { - InputStream in = ClassLoader.getSystemClassLoader() - .getResourceAsStream(name.replace('.', '/').concat(".class")); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - - try { - while (in.available() > 0) { - baos.write(in.read()); - } - byte[] data = baos.toByteArray(); - return defineClass(name, data, 0, data.length); - } catch (IOException ioe) { - throw new ClassNotFoundException(name, ioe); - } - } - throw new ClassNotFoundException(name); - } - } - -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/management/ManagementServerLoaderTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/management/ManagementServerLoaderTest.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/management/ManagementServerLoaderTest.java (revision 0) @@ -1,81 +0,0 @@ -package net.sf.ehcache.management; - -import net.sf.ehcache.CacheManager; -import net.sf.ehcache.config.Configuration; -import net.sf.ehcache.config.ManagementRESTServiceConfiguration; -import org.junit.Test; - -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; - -/** - * @author Ludovic Orban - */ -public class ManagementServerLoaderTest { - - @Test - public void testRegistrationLifecycleStandalone() throws Exception { - boolean managementAvailable = ManagementServerLoader.isManagementAvailable(); - assertThat(managementAvailable, is(true)); - - CacheManager cacheManager1 = createCacheManager("cm-one", "localhost:1234"); - CacheManager cacheManager2 = createCacheManager("cm-two", "localhost:1234"); - - try { - ManagementServerLoader.register(cacheManager1, null, cacheManager1.getConfiguration().getManagementRESTService()); - DummyManagementServerImpl dms = (DummyManagementServerImpl)ManagementServerLoader.MGMT_SVR_BY_BIND.get("localhost:1234").getManagementServer(); - assertThat(dms.status, is(DummyManagementServerImpl.Status.STARTED)); - ManagementServerLoader.register(cacheManager2, null, cacheManager2.getConfiguration().getManagementRESTService()); - assertThat(dms.status, is(DummyManagementServerImpl.Status.STARTED)); - - ManagementServerLoader.unregister(cacheManager2.getConfiguration() - .getManagementRESTService() - .getBind(), cacheManager2); - assertThat(dms.status, is(DummyManagementServerImpl.Status.STARTED)); - ManagementServerLoader.unregister(cacheManager1.getConfiguration() - .getManagementRESTService() - .getBind(), cacheManager1); - assertThat(dms.status, is(DummyManagementServerImpl.Status.STOPPED)); - } finally { - cacheManager2.shutdown(); - cacheManager1.shutdown(); - } - } - - @Test - public void testRegistrationLifecycleClustered() throws Exception { - boolean managementAvailable = ManagementServerLoader.isManagementAvailable(); - assertThat(managementAvailable, is(true)); - - CacheManager cacheManager1 = createCacheManager("cm-one", ""); - CacheManager cacheManager2 = createCacheManager("cm-two", ""); - - try { - ManagementServerLoader.register(cacheManager1, "uuid1", cacheManager1.getConfiguration().getManagementRESTService()); - ManagementServerLoader.ManagementServerHolder managementServerHolder = ManagementServerLoader.MGMT_SVR_BY_BIND.get(""); - DummyManagementServerImpl dms = (DummyManagementServerImpl)managementServerHolder.getManagementServer(); - assertThat(dms.status, is(DummyManagementServerImpl.Status.STARTED)); - - ManagementServerLoader.register(cacheManager2, "uuid2", cacheManager2.getConfiguration().getManagementRESTService()); - assertThat(dms.status, is(DummyManagementServerImpl.Status.STARTED)); - - ManagementServerLoader.unregister("", cacheManager1); - assertThat(dms.status, is(DummyManagementServerImpl.Status.STARTED)); - - ManagementServerLoader.unregister("", cacheManager2); - assertThat(dms.status, is(DummyManagementServerImpl.Status.STOPPED)); - } finally { - cacheManager2.shutdown(); - cacheManager1.shutdown(); - } - } - - private static net.sf.ehcache.CacheManager createCacheManager(String name, String bind) { - Configuration cfg = new Configuration().name(name); - ManagementRESTServiceConfiguration managementRESTServiceConfiguration = new ManagementRESTServiceConfiguration(); - managementRESTServiceConfiguration.setBind(bind); - cfg.managementRESTService(managementRESTServiceConfiguration); - return new net.sf.ehcache.CacheManager(cfg); - } - -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/management/package.html =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/management/package.html (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/management/package.html (revision 0) @@ -1,10 +0,0 @@ - - - - -This package contains JMX MBeans and implementations for management of ehcache. -

-The client API is exposed through the ManagementService. Use ManagementService.registerMBeans(...) -to register a selection of MBeans to the MBeanServer provided to the method. - - Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/terracotta/TerracottaClient.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/terracotta/TerracottaClient.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/terracotta/TerracottaClient.java (revision 0) @@ -1,235 +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 net.sf.ehcache.CacheException; -import net.sf.ehcache.CacheManager; -import net.sf.ehcache.cluster.CacheCluster; -import net.sf.ehcache.config.TerracottaClientConfiguration; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.lang.reflect.Method; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.ThreadFactory; - -/** - * Class encapsulating the idea of a Terracotta client. Provides access to the {@link ClusteredInstanceFactory} for the cluster - * - * @author Abhishek Sanoujam - * - */ -public class TerracottaClient { - - /** - * System property used to specify the secrect provider to use - */ - public static final String CUSTOM_SECRET_PROVIDER_SYSTEM_PROPERTY = "com.terracotta.express.SecretProvider"; - - private static final Logger LOGGER = LoggerFactory.getLogger(TerracottaClient.class); - private static final int REJOIN_SLEEP_MILLIS_ON_EXCEPTION = Integer.getInteger("net.sf.ehcache.rejoin.sleepMillisOnException", 5000); - - private static final String CUSTOM_SECRET_PROVIDER_WRAPPER_CLASSNAME = "net.sf.ehcache.terracotta.security.SingletonSecretProviderWrapper"; - - private final TerracottaClientConfiguration terracottaClientConfiguration; - private volatile ClusteredInstanceFactoryWrapper clusteredInstanceFactory; - private final TerracottaCacheCluster cacheCluster = new TerracottaCacheCluster(); - private final CacheManager cacheManager; - private ExecutorService l1TerminatorThreadPool; - - /** - * Constructor accepting the {@link CacheManager} and the {@link TerracottaClientConfiguration} - * - * @param cacheManager the cache manager to be clustered - * @param terracottaClientConfiguration the configuration for the terracotta client - */ - public TerracottaClient(CacheManager cacheManager, TerracottaClientConfiguration terracottaClientConfiguration) { - this.cacheManager = cacheManager; - this.terracottaClientConfiguration = terracottaClientConfiguration; - if (terracottaClientConfiguration != null) { - terracottaClientConfiguration.freezeConfig(); - - // If we're going clustered and secured and a secret provider is configured, it's time to wrap the - // secret provider before the L1 can use it. - // We must set this ehcache secret provider as both the L1 and the agent will use a different instance - // and will want to fetch the password. In case of a console fetcher, the password would be asked twice. - String secretProviderClassname = System.getProperty(CUSTOM_SECRET_PROVIDER_SYSTEM_PROPERTY); - String tcUrl = terracottaClientConfiguration.getUrl(); - if (tcUrl != null && tcUrl.contains("@") && secretProviderClassname != null) { - try { - System.setProperty(CUSTOM_SECRET_PROVIDER_SYSTEM_PROPERTY, CUSTOM_SECRET_PROVIDER_WRAPPER_CLASSNAME); - Class secretProviderWrapperClass = Class.forName(CUSTOM_SECRET_PROVIDER_WRAPPER_CLASSNAME); - secretProviderWrapperClass.getMethod("useAsDelegate", String.class).invoke(secretProviderWrapperClass, secretProviderClassname); - } catch (Exception e) { - throw new CacheException("Unable to initialize " + CUSTOM_SECRET_PROVIDER_WRAPPER_CLASSNAME, e); - } - } - } - } - - /* - * --------- THIS METHOD IS NOT FOR PUBLIC USE ---------- - * private method, used in unit-tests using reflection - * - * @param testHelper the mock TerracottaClusteredInstanceHelper for testing - */ - private static void setTestMode(TerracottaClusteredInstanceHelper testHelper) { - try { - Method method = TerracottaClusteredInstanceHelper.class.getDeclaredMethod("setTestMode", - TerracottaClusteredInstanceHelper.class); - method.setAccessible(true); - method.invoke(null, testHelper); - } catch (Exception e) { - // just print a stack trace and ignore - e.printStackTrace(); - } - } - - /** - * Returns the {@link ClusteredInstanceFactory} associated with this client - * - * @return The ClusteredInstanceFactory - */ - public ClusteredInstanceFactory getClusteredInstanceFactory() { - return clusteredInstanceFactory; - } - - /** - * Returns true if the clusteredInstanceFactory was created, otherwise returns false. - * Multiple threads calling this method block and only one of them creates the factory. - * - * @return true if the clusteredInstanceFactory was created, otherwise returns false - */ - public boolean createClusteredInstanceFactory() { - if (terracottaClientConfiguration == null) { - return false; - } - if (clusteredInstanceFactory != null) { - return false; - } - final boolean created; - synchronized (this) { - if (clusteredInstanceFactory == null) { - clusteredInstanceFactory = createNewClusteredInstanceFactory(); - created = true; - } else { - created = false; - } - } - return created; - } - - /** - * Get the {@link CacheCluster} associated with this client - * - * @return the {@link CacheCluster} associated with this client - */ - public TerracottaCacheCluster getCacheCluster() { - if (clusteredInstanceFactory == null) { - throw new CacheException("Cannot get CacheCluster as ClusteredInstanceFactory has not been initialized yet."); - } - return cacheCluster; - } - - /** - * Shuts down the client - */ - public synchronized void shutdown() { - if (clusteredInstanceFactory != null) { - shutdownClusteredInstanceFactoryWrapper(clusteredInstanceFactory); - } - } - - /** - * Wait for the Orchestrator for this CacheManager - * @param cacheManagerName Name of the cache manager - */ - public void waitForOrchestrator(String cacheManagerName) { - clusteredInstanceFactory.waitForOrchestrator(cacheManagerName); - } - - private void shutdownClusteredInstanceFactoryWrapper(ClusteredInstanceFactoryWrapper clusteredInstanceFactory) { - clusteredInstanceFactory.getActualFactory().getTopology().removeAllListeners(); - clusteredInstanceFactory.shutdown(); - } - - private synchronized ClusteredInstanceFactoryWrapper createNewClusteredInstanceFactory() { - // shut down the old factory - if (clusteredInstanceFactory != null) { - info("Shutting down old ClusteredInstanceFactory..."); - shutdownClusteredInstanceFactoryWrapper(clusteredInstanceFactory); - } - info("Creating new ClusteredInstanceFactory"); - ClusteredInstanceFactory factory; - factory = TerracottaClusteredInstanceHelper.getInstance().newClusteredInstanceFactory(terracottaClientConfiguration, cacheManager.getConfiguration().getClassLoader()); - CacheCluster underlyingCacheCluster = factory.getTopology(); - - cacheCluster.setUnderlyingCacheCluster(underlyingCacheCluster); - - return new ClusteredInstanceFactoryWrapper(this, factory); - } - - private synchronized ExecutorService getL1TerminatorThreadPool() { - if (l1TerminatorThreadPool == null) { - l1TerminatorThreadPool = Executors.newCachedThreadPool(new ThreadFactory() { - private final ThreadGroup threadGroup = new ThreadGroup("Rejoin Terminator Thread Group"); - - public Thread newThread(Runnable runnable) { - Thread t = new Thread(threadGroup, runnable, "L1 Terminator"); - t.setDaemon(true); - return t; - } - }); - } - return l1TerminatorThreadPool; - } - - private void info(String msg) { - info(msg, null); - } - - private void info(String msg, Throwable t) { - if (t == null) { - LOGGER.info(getLogPrefix() + msg); - } else { - LOGGER.info(getLogPrefix() + msg, t); - } - } - - private String getLogPrefix() { - return "Thread [" + Thread.currentThread().getName() + "] [cacheManager: " + getCacheManagerName() + "]: "; - } - - private void debug(String msg) { - LOGGER.debug(getLogPrefix() + msg); - } - - private void warn(String msg) { - LOGGER.warn(getLogPrefix() + msg); - } - - private String getCacheManagerName() { - if (cacheManager.isNamed()) { - return "'" + cacheManager.getName() + "'"; - } else { - return "no name"; - } - } - -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/resources/small.ico =================================================================== diff -u -N -r11516 -r11534 Binary files differ Index: rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/org/terracotta/ehcache/tests/coherence/RestartingL1ExpressTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/org/terracotta/ehcache/tests/coherence/RestartingL1ExpressTest.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/org/terracotta/ehcache/tests/coherence/RestartingL1ExpressTest.java (revision 0) @@ -1,131 +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.ehcache.tests.coherence; - -import org.terracotta.ehcache.tests.AbstractCacheTestBase; - -import com.tc.test.config.model.TestConfig; -import com.tc.util.runtime.Os; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileReader; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.atomic.AtomicReference; - -public class RestartingL1ExpressTest extends AbstractCacheTestBase { - - public static final int CLIENT_COUNT = 3; - public static final String SHOULD_CRASH = "shouldCrash"; - public static final String AFTER_RESTART = "afterRestart"; - - public RestartingL1ExpressTest(TestConfig testConfig) { - super("basic-cache-test.xml", testConfig, RestartingL1ExpressClient.class); - - if (Os.isWindows()) { - disableTest(); - } - } - - @Override - protected void startClients() throws Throwable { - // n nodes start in coherent, then setCoherent(false) - // assert coherent=false in all n nodes - // n-1 nodes call setCoherent(true) - // 1 node exits without calling setCoherent(true) - // n-1 nodes assert coherent - // 1 node restarts, asserts cache coherent - // java RestartingL1ExpressClient -> (no-args), n-1 nodes, does not crash - // java RestartingL1ExpressClient shouldCrash -> (one arg), 1 node, exits this node without calling - // setCoherent(true) - // java RestartingL1ExpressClient shouldCrash afterRestart -> (two args), 1 node, restarts and asserts cache - // coherent - Runner[] runners = new Runner[CLIENT_COUNT]; - for (int i = 0; i < runners.length; i++) { - if (i == 0) { - // start the restarting client - runners[i] = new Runner(RestartingL1ExpressClient.class, "restart-crasher-client"); - runners[i].addClientArg(SHOULD_CRASH); - } else { - runners[i] = new Runner(RestartingL1ExpressClient.class, "restart-normal-client-" + (i - 1)); - } - } - for (Runner runner : runners) { - runner.start(); - } - System.out.println("Waiting for first client to finish"); - // wait for first client to exit - runners[0].finish(); - System.out.println("done with first client"); - - // restart this client in restart - Runner runner0 = runners[0] = new Runner(RestartingL1ExpressClient.class, "restart-afterRestart-client"); - runner0.addClientArg(SHOULD_CRASH); - runner0.addClientArg(AFTER_RESTART); - runner0.start(); - - for (Runner runner : runners) { - runner.finish(); - } - } - - @Override - protected void evaluateClientOutput(String clientName, int exitCode, File output) throws Throwable { - super.evaluateClientOutput(clientName, exitCode, output); - - FileReader fr = null; - try { - fr = new FileReader(output); - BufferedReader reader = new BufferedReader(fr); - String st = ""; - while ((st = reader.readLine()) != null) { - if (st.contains(RestartingL1ExpressClient.PASS_OUTPUT)) return; - } - throw new AssertionError("Client exited without pass output string: " + RestartingL1ExpressClient.PASS_OUTPUT); - } catch (Exception e) { - throw new AssertionError(e); - } finally { - try { - fr.close(); - } catch (Exception e) { - // - } - } - } - - private class Runner extends Thread { - - private final AtomicReference error = new AtomicReference(); - private final Class clientClass; - private final String clientName; - private final List extraClientArgs; - - public Runner(Class clientClass, String clientName) { - this.clientClass = clientClass; - this.clientName = clientName; - this.extraClientArgs = new ArrayList(); - } - - @Override - public void run() { - try { - runClient(clientClass, clientName, extraClientArgs); - } catch (Throwable t) { - error.set(t); - } - } - - public void finish() throws Throwable { - join(); - Throwable t = error.get(); - if (t != null) throw t; - } - - public void addClientArg(String arg) { - extraClientArgs.add(arg); - } - } -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/config/generator/model/SimpleNodeAttribute.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/config/generator/model/SimpleNodeAttribute.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/config/generator/model/SimpleNodeAttribute.java (revision 0) @@ -1,256 +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.generator.model; - -/** - * Implementation of the {@link NodeAttribute} interface - * - * @author Abhishek Sanoujam - * - */ -public class SimpleNodeAttribute implements NodeAttribute { - - private final String name; - private String value; - private String defaultValue; - private boolean optional = true; - - /** - * Constructor accepting the name of the attribute - * - * @param name - * the name of the attribute - */ - public SimpleNodeAttribute(String name) { - this(name, (String) null); - } - - /** - * Constructor accepting name and Enum value of the attribute - * - * @param name - * the name of the attribute - * @param value - * the Enum value of the attribute - */ - public SimpleNodeAttribute(String name, Enum value) { - this(name, value.name().toLowerCase()); - } - - /** - * Constructor accepting name and int value of the attribute - * - * @param name - * the name of the attribute - * @param value - * the int value of the attribute - */ - public SimpleNodeAttribute(String name, int value) { - this(name, String.valueOf(value)); - } - - /** - * Constructor accepting name and long value of the attribute - * - * @param name - * the name of the attribute - * @param value - * the long value of the attribute - */ - public SimpleNodeAttribute(String name, long value) { - this(name, String.valueOf(value)); - } - - /** - * Constructor accepting name and boolean value of the attribute - * - * @param name - * the name of the attribute - * @param value - * the boolean value of the attribute - */ - public SimpleNodeAttribute(String name, boolean value) { - this(name, String.valueOf(value)); - } - - /** - * Constructor accepting name and String value of the attribute - * - * @param name - * the name of the attribute - * @param value - * the String value of the attribute - */ - public SimpleNodeAttribute(String name, String value) { - this.name = name; - this.value = value; - } - - /** - * {@inheritDoc} - */ - public String getName() { - return name; - } - - /** - * {@inheritDoc} - */ - public String getValue() { - return value; - } - - /** - * {@inheritDoc} - */ - public boolean isOptional() { - return optional; - } - - /** - * {@inheritDoc} - */ - public void setOptional(boolean optional) { - this.optional = optional; - } - - /** - * {@inheritDoc} - */ - public String getDefaultValue() { - return defaultValue; - } - - /** - * {@inheritDoc} - */ - public void setDefaultValue(String defaultValue) { - this.defaultValue = defaultValue; - } - - /** - * {@inheritDoc} - */ - public void setValue(String value) { - this.value = value; - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((name == null) ? 0 : name.hashCode()); - return result; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (!(obj instanceof NodeAttribute)) { - return false; - } - NodeAttribute other = (NodeAttribute) obj; - if (name == null) { - if (other.getName() != null) { - return false; - } - } else if (!name.equals(other.getName())) { - return false; - } - return true; - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return "SimpleAttribute [name=" + name + "]"; - } - - /** - * {@inheritDoc} - */ - public SimpleNodeAttribute optional(boolean optional) { - this.optional = optional; - return this; - } - - /** - * {@inheritDoc} - */ - public SimpleNodeAttribute defaultValue(String defaultValue) { - this.defaultValue = defaultValue; - return this; - } - - /** - * Same as {@link #defaultValue(String)} using String.valueOf(defaultValue) - * - * @param defaultValue - * the default value - * @return the same instance - */ - public SimpleNodeAttribute defaultValue(boolean defaultValue) { - return this.defaultValue(String.valueOf(defaultValue)); - } - - /** - * Same as {@link #defaultValue(String)} using String.valueOf(defaultValue) - * - * @param defaultValue - * the default value - * @return the same instance - */ - public SimpleNodeAttribute defaultValue(int defaultValue) { - return this.defaultValue(String.valueOf(defaultValue)); - } - - /** - * Same as {@link #defaultValue(String)} using String.valueOf(defaultValue) - * - * @param defaultValue - * the default value - * @return the same instance - */ - public SimpleNodeAttribute defaultValue(Enum defaultValue) { - return this.defaultValue(defaultValue.name().toLowerCase()); - } - - /** - * Same as {@link #defaultValue(String)} using String.valueOf(defaultValue) - * - * @param defaultValue - * the default value - * @return the same instance - */ - public SimpleNodeAttribute defaultValue(long defaultValue) { - return this.defaultValue(String.valueOf(defaultValue)); - } - -} Index: rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/org/terracotta/ehcache/tests/ExpiryListenerClient1.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/org/terracotta/ehcache/tests/ExpiryListenerClient1.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/org/terracotta/ehcache/tests/ExpiryListenerClient1.java (revision 0) @@ -1,82 +0,0 @@ -package org.terracotta.ehcache.tests; - -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.test.util.WaitUtil; -import org.terracotta.toolkit.Toolkit; - -import java.util.concurrent.Callable; -import java.util.concurrent.atomic.AtomicLong; - -import junit.framework.Assert; - -public class ExpiryListenerClient1 extends ClientBase implements CacheEventListener { - - private final AtomicLong localExpiredCount = new AtomicLong(); - - public ExpiryListenerClient1(String[] args) { - super("test", args); - } - - public static void main(String[] args) { - new ExpiryListenerClient1(args).run(); - } - - @Override - protected void runTest(final Cache cache, final Toolkit toolkit) throws Throwable { - cache.getCacheEventNotificationService().registerListener(this); - cache.put(new Element("key", "value")); - // assume the TTL of the cache is set to 3s - System.out.println("TTL value of the cache: " + cache.getCacheConfiguration().getTimeToLiveSeconds()); - Assert.assertEquals(3, cache.getCacheConfiguration().getTimeToLiveSeconds()); - - WaitUtil.waitUntilCallableReturnsTrue(new Callable() { - @Override - public Boolean call() throws Exception { - return cache.getSize() == 0 && localExpiredCount.get() > 0; - } - }); - // assert eviction has already occurred - Assert.assertEquals(0, cache.getSize()); - Assert.assertTrue(localExpiredCount.get() > 0); - } - - public void dispose() { - // - } - - public void notifyElementEvicted(Ehcache cache, Element element) { - // - } - - public void notifyElementExpired(Ehcache cache, Element element) { - localExpiredCount.incrementAndGet(); - Assert.assertNotNull(element.getKey()); - Assert.assertNull(element.getValue()); - System.out.println("Got evicted: " + element); - } - - public void notifyElementPut(Ehcache cache, Element element) throws CacheException { - // - } - - public void notifyElementRemoved(Ehcache cache, Element element) throws CacheException { - // - } - - public void notifyElementUpdated(Ehcache cache, Element element) throws CacheException { - // - } - - public void notifyRemoveAll(Ehcache cache) { - // - } - - @Override - public Object clone() throws CloneNotSupportedException { - return super.clone(); - } -} \ No newline at end of file Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/util/SlewClock.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/util/SlewClock.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/util/SlewClock.java (revision 0) @@ -1,154 +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 net.sf.ehcache.util.lang.VicariousThreadLocal; - -import java.util.concurrent.atomic.AtomicLong; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * SlewClock will return the current time in millis, but will never go back in time. - * If it detects that a back movement in time, it will slew the results while keeping them incrementing until time has caught up - * - * @author Chris Denis - * @author Alex Snaps - */ -final class SlewClock { - - private static final Logger LOG = LoggerFactory.getLogger(SlewClock.class); - - private static final TimeProvider PROVIDER = TimeProviderLoader.getTimeProvider(); - - private static final long DRIFT_MAXIMAL = Integer.getInteger("net.sf.ehcache.util.Timestamper.drift.max", 50); - - private static final long SLEEP_MAXIMAL = Integer.getInteger("net.sf.ehcache.util.Timestamper.sleep.max", 50); - - private static final int SLEEP_BASE = Integer.getInteger("net.sf.ehcache.util.Timestamper.sleep.min", 25); - - private static final AtomicLong CURRENT = new AtomicLong(Long.MIN_VALUE); - - private static final VicariousThreadLocal OFFSET = new VicariousThreadLocal(); - - private SlewClock() { - // You shall not instantiate me! - } - - /** - * For testing purposes, you probably never want to use this. - * This method will resync, basically resetting any on going slewing, its internal clock tracking with whatever value - * the provider seeds it with. - * - * @deprecated - */ - @Deprecated - static void realignWithTimeProvider() { - CURRENT.set(getCurrentTime()); - } - - /** - * Will return the difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC. - * But without ever going back. If a movement back in time is detected, the method will slew until time caught up - * @return The difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC. - */ - static long timeMillis() { - boolean interrupted = false; - try { - while (true) { - long mono = CURRENT.get(); - long wall = getCurrentTime(); - if (wall == mono) { - OFFSET.remove(); - return wall; - } else if (wall > mono) { - if (CURRENT.compareAndSet(mono, wall)) { - OFFSET.remove(); - return wall; - } - } else { - long delta = mono - wall; - if (delta < DRIFT_MAXIMAL) { - OFFSET.remove(); - return mono; - } else { - Long lastDelta = OFFSET.get(); - if (lastDelta == null || delta < lastDelta) { - if (CURRENT.compareAndSet(mono, mono + 1)) { - OFFSET.set(Long.valueOf(delta)); - return mono + 1; - } - } else { - OFFSET.set(Long.valueOf(Math.max(delta, lastDelta))); - try { - long sleep = sleepTime(delta, lastDelta); - LOG.trace("{} sleeping for {}ms to adjust for wall-clock drift.", Thread.currentThread(), sleep); - Thread.sleep(sleep); - } catch (InterruptedException e) { - interrupted = true; - } - } - } - } - } - } finally { - if (interrupted) { - Thread.currentThread().interrupt(); - } - } - } - - /** - * Verifies whether the current thread is currently catching up on time. - * To be meaning full, this method has to be called after the thread has called {@link #timeMillis()} at least once - * @return true if the thread is being marked as catching up on time - */ - static boolean isThreadCatchingUp() { - return OFFSET.get() != null; - } - - /** - * The method will check how much behind is the current thread compared to the wall clock since the last {@link #timeMillis()} call. - * To be meaning full, this method has to be called after the thread has called {@link #timeMillis()} at least once - * @return the amount of milliseconds the thread is behind the wall clock, 0 if none. - */ - static long behind() { - Long offset = OFFSET.get(); - return offset == null ? 0 : offset; - } - - private static long sleepTime(final long current, final long previous) { - long target = SLEEP_BASE + (current - previous) * 2; - return Math.min(target > 0 ? target : SLEEP_BASE, SLEEP_MAXIMAL); - } - - private static long getCurrentTime() { - return PROVIDER.currentTimeMillis(); - } - - /** - * Defines how the {@link SlewClock} utility class will get to the wall clock - */ - interface TimeProvider { - - /** - * @return the difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC. - */ - long currentTimeMillis(); - - } -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/constructs/web/ShutdownListener.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/constructs/web/ShutdownListener.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/constructs/web/ShutdownListener.java (revision 0) @@ -1,78 +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.web; - -import net.sf.ehcache.CacheManager; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.servlet.ServletContextEvent; -import javax.servlet.ServletContextListener; - - - - -import java.util.List; - -/** - * A ServletContextListener that shutsdown CacheManager. Use this when you want to shutdown - * ehcache automatically when the web application is shutdown. - *

- * To receive notification events, this class must be configured in the deployment - * descriptor for the web application. - * - * To do so, add the following to web.xml in your web application: - *

- * <listener>
- *      <listener-class>net.sf.ehcache.constructs.web.ShutdownListener</listener-class>
- * </listener>
- * 
- * - * @author Daniel Wiell - * @author Greg Luck - * @version $Id: ShutdownListener.java 744 2008-08-16 20:10:49Z gregluck $ - */ -public class ShutdownListener implements ServletContextListener { - - private static final Logger LOG = LoggerFactory.getLogger(ShutdownListener.class); - - /** - * Notification that the web application is ready to process requests. - * - * @param servletContextEvent - */ - public void contextInitialized(ServletContextEvent servletContextEvent) { - //nothing required - } - - /** - * Notification that the servlet context is about to be shut down. - *

- * Shuts down all cache managers known to {@link CacheManager#ALL_CACHE_MANAGERS} - * - * @param servletContextEvent - */ - public void contextDestroyed(ServletContextEvent servletContextEvent) { - List knownCacheManagers = CacheManager.ALL_CACHE_MANAGERS; - if (LOG.isDebugEnabled()) { - LOG.debug("Shutting down " + knownCacheManagers.size() + " CacheManagers."); - } - while (!knownCacheManagers.isEmpty()) { - ((CacheManager) CacheManager.ALL_CACHE_MANAGERS.get(0)).shutdown(); - } - } -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/event/OrderedEventListenerForDiskStoreBackendTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/event/OrderedEventListenerForDiskStoreBackendTest.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/event/OrderedEventListenerForDiskStoreBackendTest.java (revision 0) @@ -1,165 +0,0 @@ -package net.sf.ehcache.event; - -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.inOrder; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.reset; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; -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.store.CacheStore; -import net.sf.ehcache.store.DefaultElementValueComparator; -import net.sf.ehcache.store.disk.DiskStorageFactory; -import net.sf.ehcache.store.disk.DiskStore; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.mockito.InOrder; -import org.terracotta.test.categories.CheckShorts; - -import java.lang.reflect.Field; - -/** - * OrderedEventListenerForDiskStoreBackendTest - */ -@Category(CheckShorts.class) -public class OrderedEventListenerForDiskStoreBackendTest { - - private static CacheManager cacheManager; - private static DiskStore diskStore; - private static Cache diskCache; - private InternalCacheEventListener listener; - - @Before - public void setUp() throws Exception { - cacheManager = CacheManager.create(new Configuration().name("diskStoreTest")); - diskCache = new Cache(new CacheConfiguration().name("disk-event-cache").maxEntriesLocalHeap(10).overflowToDisk(true) - .eternal(false).timeToLiveSeconds(10).timeToIdleSeconds(10).diskPersistent(false).diskExpiryThreadIntervalSeconds(1) - .diskSpoolBufferSizeMB(10)); - cacheManager.addCache(diskCache); - Field compoundStoreField = Cache.class.getDeclaredField("compoundStore"); - compoundStoreField.setAccessible(true); - CacheStore cacheStore = (CacheStore)compoundStoreField.get(diskCache); - Field field = CacheStore.class.getDeclaredField("authoritativeTier"); - field.setAccessible(true); - diskStore = (DiskStore)field.get(cacheStore); - - listener = mock(InternalCacheEventListener.class); - diskCache.getCacheEventNotificationService().registerOrderedListener(listener); - } - - @Test - public void putTest() { - Element element = new Element("putKey", "value", 0); - diskStore.put(element); - verify(listener).notifyElementPut(any(Ehcache.class), eq(element)); - } - - @Test - public void putAndReplaceTest() { - String key = "putReplaceKey"; - Element element = new Element(key, "value", 0); - diskStore.put(element); - Element otherElement = new Element(key, "otherVal", 0); - diskStore.put(otherElement); - - InOrder inOrder = inOrder(listener); - inOrder.verify(listener).notifyElementRemoved(any(Ehcache.class), eq(element)); - inOrder.verify(listener).notifyElementPut(any(Ehcache.class), eq(otherElement)); - } - - @Test - public void putFaultedTest() { - Element element = new Element("faultedKey", "value", 0); - diskStore.putFaulted(element); - verify(listener).notifyElementPut(any(Ehcache.class), eq(element)); - } - - @Test - public void putIfAbsentTest() { - String key = "putIfAbsentKey"; - Element element = new Element(key, "value", 0); - diskStore.putIfAbsent(element); - verify(listener).notifyElementPut(any(Ehcache.class), eq(element)); - reset(listener); - - diskStore.putIfAbsent(new Element(key, "otherVal", 0)); - verifyZeroInteractions(listener); - - } - - @Test - public void replaceTest() { - String key = "replaceKey"; - Element oldElement = new Element(key, "oldValue", 0); - diskStore.put(oldElement); - Element element = new Element(key, "value", 0); - diskStore.replace(element); - - InOrder inOrder = inOrder(listener); - inOrder.verify(listener).notifyElementRemoved(any(Ehcache.class), eq(oldElement)); - inOrder.verify(listener).notifyElementPut(any(Ehcache.class), eq(element)); - } - - @Test - public void compareAndReplaceTest() { - String key = "casKey"; - Element oldElement = new Element(key, "oldValue", 0); - diskStore.put(oldElement); - Element element = new Element(key, "value", 0); - diskStore.replace(oldElement, element, new DefaultElementValueComparator(diskCache.getCacheConfiguration())); - - InOrder inOrder = inOrder(listener); - inOrder.verify(listener).notifyElementRemoved(any(Ehcache.class), eq(oldElement)); - inOrder.verify(listener).notifyElementPut(any(Ehcache.class), eq(element)); - } - - @Test - public void removeTest() { - String key = "removeKey"; - Element element = new Element(key, "value", 0); - diskStore.put(element); - - diskStore.remove(key); - verify(listener).notifyElementRemoved(any(Ehcache.class), eq(element)); - reset(listener); - - diskStore.put(element); - diskStore.removeElement(element, new DefaultElementValueComparator(diskCache.getCacheConfiguration())); - verify(listener).notifyElementRemoved(any(Ehcache.class), eq(element)); - } - - @Test - public void evictTest() { - String key = "evictKey"; - Element element = new Element(key, "value", 0); - diskStore.put(element); - - int maxTries = 100; - int tryCount = 0; - while (tryCount < maxTries) { - if (diskStore.evict(key, (DiskStorageFactory.DiskSubstitute)diskStore.unretrievedGet(key))) { - verify(listener).notifyElementRemoved(any(Ehcache.class), eq(element)); - return; - } else { - tryCount++; - } - } - assertThat(diskStore.containsKey(element.getObjectKey()), is(false)); - } - - @After - public void tearDown() { - cacheManager.shutdown(); - } -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/statistics/CacheUsageListener.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/statistics/CacheUsageListener.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/statistics/CacheUsageListener.java (revision 0) @@ -1,150 +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; - -/** - * Interface for listeners to any change in usage statistics of an - * Ehcache. - * - *

- * Implementations of this interface should implement the {@link Object#equals(Object)} and the {@link Object#hashCode()} as registering and - * removing listeners depends on these - *

- * - * @author Abhishek Sanoujam - * @since 1.7 - */ -public interface CacheUsageListener { - - /** - * Called on a cache hit in the MemoryStore - */ - void notifyCacheHitInMemory(); - - /** - * Called on a cache hit in the off-heap store - */ - void notifyCacheHitOffHeap(); - - /** - * Called on a cache hit in the DiskStore - */ - void notifyCacheHitOnDisk(); - - /** - * Called when an element is inserted in the cache - */ - void notifyCacheElementPut(); - - /** - * Called when an element is updated in the cache, i.e. a put for an already - * existing key - */ - void notifyCacheElementUpdated(); - - /** - * Called when an element is not found in the cache - */ - void notifyCacheMissedWithNotFound(); - - /** - * Called on a cache miss in the MemoryStore - */ - void notifyCacheMissInMemory(); - - /** - * Called on a cache miss in the off-heap store - */ - void notifyCacheMissOffHeap(); - - /** - * Called on a cache miss in the DiskStore - */ - void notifyCacheMissOnDisk(); - - /** - * Called when an element is found in the cache but already expired - */ - void notifyCacheMissedWithExpired(); - - /** - * Notified with time taken for a get operation in the cache - * - * DEPRECATED: use notifyGetTimeNanos(long) - * - * @param millis - * @deprecated - */ - @Deprecated - void notifyTimeTakenForGet(final long millis); - - /** - * Notified with time taken for a get operation in the cache - * - * @param nanos - */ - void notifyGetTimeNanos(final long nanos); - - /** - * Called when an element is expired in the cache - */ - void notifyCacheElementEvicted(); - - /** - * Called when an element in the cache expires - */ - void notifyCacheElementExpired(); - - /** - * Called when an element is removed from the cache - */ - void notifyCacheElementRemoved(); - - /** - * Called when Cache.removeAll() is called - */ - void notifyRemoveAll(); - - /** - * Notified when the statistics accuracy is changed. - * - * @param statisticsAccuracy the statistics accuracy - */ - void notifyStatisticsAccuracyChanged(int statisticsAccuracy); - - /** - * Called to dispose off the listener - */ - void dispose(); - - /** - * Called when a search finishes execution - * - * @param executeTime elapsed time in millis - */ - void notifyCacheSearch(long executeTime); - - /** - * Called when the Cache's XAResource has been asked to commit - */ - void notifyXaCommit(); - - /** - * Called when the Cache's XAResource has been asked to rollback - */ - void notifyXaRollback(); - -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/store/AbstractStore.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/store/AbstractStore.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/store/AbstractStore.java (revision 0) @@ -1,251 +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.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; - -import net.sf.ehcache.CacheException; -import net.sf.ehcache.Element; -import net.sf.ehcache.config.InvalidConfigurationException; -import net.sf.ehcache.search.Attribute; -import net.sf.ehcache.search.Results; -import net.sf.ehcache.search.attribute.AttributeExtractor; -import net.sf.ehcache.search.attribute.DynamicAttributesExtractor; -import net.sf.ehcache.search.impl.SearchManager; -import net.sf.ehcache.terracotta.TerracottaNotRunningException; - -/** - * @author gkeim - */ -public abstract class AbstractStore implements Store { - - /** - * search attribute extractors - */ - protected final Map attributeExtractors = new ConcurrentHashMap(); - - /** - * search manager - */ - protected final SearchManager searchManager; - - /** - * listener list - */ - private transient List listenerList; - - private final String cacheName; - - /** - * Constructor for stores that do not support search - */ - protected AbstractStore() { - this(null, null); - } - - /** - * Constructor for stores that do support search - * - * @param searchManager the search manager to use - */ - protected AbstractStore(SearchManager searchManager, String cacheName) { - this.searchManager = searchManager; - this.cacheName = cacheName; - } - - - /** - * onLoad initializer - */ - protected synchronized List getEventListenerList() { - if (listenerList == null) { - listenerList = new ArrayList(); - } - return listenerList; - } - - /** - * {@inheritDoc} - * - * @see net.sf.ehcache.store.Store#isCacheCoherent() - */ - public boolean isCacheCoherent() { - return false; - } - - /** - * {@inheritDoc} - * - * @see net.sf.ehcache.store.Store#isClusterCoherent() - */ - public boolean isClusterCoherent() { - return false; - } - - /** - * {@inheritDoc} - * - * @see net.sf.ehcache.store.Store#isNodeCoherent() - */ - public boolean isNodeCoherent() { - throw new UnsupportedOperationException(); - } - - /** - * {@inheritDoc} - * - * @see net.sf.ehcache.store.Store#setNodeCoherent(boolean) - */ - public void setNodeCoherent(boolean coherent) throws UnsupportedOperationException { - throw new UnsupportedOperationException(); - } - - /** - * {@inheritDoc} - * - * @throws InterruptedException - * @throws TerracottaNotRunningException - * - * @see net.sf.ehcache.store.Store#waitUntilClusterCoherent() - */ - public void waitUntilClusterCoherent() throws UnsupportedOperationException, TerracottaNotRunningException, InterruptedException { - throw new UnsupportedOperationException(); - } - - /** - * {@inheritDoc} - * - * @see net.sf.ehcache.store.Store#addStoreListener(net.sf.ehcache.store.StoreListener) - */ - public synchronized void addStoreListener(StoreListener listener) { - removeStoreListener(listener); - getEventListenerList().add(listener); - } - - /** - * {@inheritDoc} - * - * @see net.sf.ehcache.store.Store#removeStoreListener(net.sf.ehcache.store.StoreListener) - */ - public synchronized void removeStoreListener(StoreListener listener) { - getEventListenerList().remove(listener); - } - - /** - * {@inheritDoc} - */ - public void setAttributeExtractors(Map extractors) { - if (searchManager == null && !extractors.isEmpty()) { - throw new InvalidConfigurationException("Search attributes not supported by this store type: " + getClass().getName()); - } - - this.attributeExtractors.putAll(extractors); - - } - - /** - * {@inheritDoc} - */ - public Results executeQuery(StoreQuery query) { - if (searchManager == null) { - throw new UnsupportedOperationException("Query execution not supported by this store type: " + getClass().getName()); - } - DynamicAttributesExtractor dynExtractor = query.getCache().getCacheConfiguration().getDynamicExtractor(); - - return searchManager.executeQuery(query, attributeExtractors, dynExtractor); - } - - /** - * {@inheritDoc} - */ - public Attribute getSearchAttribute(String attributeName) throws CacheException { - Attribute attr = new Attribute(attributeName); - return getSearchAttributes().contains(attr) ? attr : null; - } - - /** - * {@inheritDoc} - */ - @Override - public Set getSearchAttributes() { - if (searchManager == null) { - throw new InvalidConfigurationException("Search attributes not supported by this store type: " + getClass().getName()); - } - return new HashSet(searchManager.getSearchAttributes(cacheName)); - } - - /** - * {@inheritDoc} - */ - public void putAll(Collection elements) throws CacheException { - for (Element element : elements) { - put(element); - } - } - - /** - * {@inheritDoc} - */ - public void removeAll(Collection keys) { - for (Object key : keys) { - remove(key); - } - } - - /** - * {@inheritDoc} - */ - public Map getAllQuiet(Collection keys) { - Map elements = new HashMap(); - for (Object key : keys) { - elements.put(key, getQuiet(key)); - } - return elements; - } - - /** - * {@inheritDoc} - */ - public Map getAll(Collection keys) { - Map elements = new HashMap(); - for (Object key : keys) { - elements.put(key, get(key)); - } - return elements; - } - - /** - * {@inheritDoc} - */ - public boolean hasAbortedSizeOf() { - return false; - } - - /** - * {@inheritDoc} - */ - public void recalculateSize(Object key) { - // overriden on necessity - } -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/event/CacheManagerEventListenerRegistry.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/event/CacheManagerEventListenerRegistry.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/event/CacheManagerEventListenerRegistry.java (revision 0) @@ -1,201 +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 java.util.Iterator; -import java.util.Set; -import java.util.concurrent.CopyOnWriteArraySet; - -import net.sf.ehcache.Status; - -/** - * Registered listeners for registering and unregistering CacheManagerEventListeners and sending notifications to registrants. - *

- * There is one of these per CacheManager. It is a composite listener. - * - * @author Greg Luck - * @version $Id: CacheManagerEventListenerRegistry.java 10789 2018-04-26 02:08:13Z adahanne $ - * @since 1.3 - */ -public class CacheManagerEventListenerRegistry implements CacheManagerEventListener { - - private volatile Status status; - - /** - * A Set of CacheEventListeners keyed by listener instance. - * CacheEventListener implementations that will be notified of this cache's events. - * - * @see CacheManagerEventListener - */ - private Set listeners; - - /** - * Construct a new registry - */ - public CacheManagerEventListenerRegistry() { - status = Status.STATUS_UNINITIALISED; - listeners = new CopyOnWriteArraySet(); - } - - /** - * Adds a listener to the notification service. No guarantee is made that listeners will be - * notified in the order they were added. - * - * @param cacheManagerEventListener the listener to add. Can be null, in which case nothing happens - * @return true if the listener is being added and was not already added - */ - public final boolean registerListener(CacheManagerEventListener cacheManagerEventListener) { - if (cacheManagerEventListener == null) { - return false; - } - return listeners.add(cacheManagerEventListener); - } - - /** - * Removes a listener from the notification service. - * - * @param cacheManagerEventListener the listener to remove - * @return true if the listener was present - */ - public final boolean unregisterListener(CacheManagerEventListener cacheManagerEventListener) { - return listeners.remove(cacheManagerEventListener); - } - - /** - * Returns whether or not at least one cache manager event listeners has been registered. - * - * @return true if a one or more listeners have registered, otherwise false - */ - public boolean hasRegisteredListeners() { - return listeners.size() > 0; - } - - /** - * Gets a Set of the listeners registered to this class - * - * @return a set of type CacheManagerEventListener - */ - public Set getRegisteredListeners() { - return listeners; - } - - /** - * Initialises the listeners, ready to receive events. - */ - public void init() { - //init once - Iterator iterator = listeners.iterator(); - while (iterator.hasNext()) { - CacheManagerEventListener cacheManagerEventListener = (CacheManagerEventListener) iterator.next(); - cacheManagerEventListener.init(); - } - status = Status.STATUS_ALIVE; - } - - /** - * Returns the listener status. - * - * @return the status at the point in time the method is called - */ - public Status getStatus() { - return status; - } - - /** - * Tell listeners to dispose themselves. - * Because this method is only ever called from a synchronized cache method, it does not itself need to be - * synchronized. - */ - public void dispose() { - Iterator iterator = listeners.iterator(); - while (iterator.hasNext()) { - CacheManagerEventListener cacheManagerEventListener = (CacheManagerEventListener) iterator.next(); - cacheManagerEventListener.dispose(); - } - listeners.clear(); - status = Status.STATUS_SHUTDOWN; - } - - /** - * 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 which cause this notification are synchronized on the - * CacheManager. An attempt to call {@link net.sf.ehcache.CacheManager#getEhcache(String)} - * will cause a deadlock. - *
- * The calling method will block until this method returns. - *

- * - * @param cacheName the name of the Cache the operation relates to - * @see CacheEventListener - */ - public void notifyCacheAdded(String cacheName) { - Iterator iterator = listeners.iterator(); - while (iterator.hasNext()) { - CacheManagerEventListener cacheManagerEventListener = (CacheManagerEventListener) iterator.next(); - cacheManagerEventListener.notifyCacheAdded(cacheName); - } - } - - /** - * 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 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) { - Iterator iterator = listeners.iterator(); - while (iterator.hasNext()) { - CacheManagerEventListener cacheManagerEventListener = (CacheManagerEventListener) iterator.next(); - cacheManagerEventListener.notifyCacheRemoved(cacheName); - } - } - - /** - * Returns a string representation of the object. In general, the - * toString method returns a string that - * "textually represents" this object. The result should - * be a concise but informative representation that is easy for a - * person to read. - * - * @return a string representation of the object. - */ - @Override - public String toString() { - StringBuilder sb = new StringBuilder(" cacheManagerEventListeners: "); - for (Iterator iterator = listeners.iterator(); iterator.hasNext();) { - CacheManagerEventListener cacheManagerEventListener = (CacheManagerEventListener) iterator.next(); - sb.append(cacheManagerEventListener.getClass().getName()).append(" "); - } - return sb.toString(); - } -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/util/CircularLossyQueue.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/util/CircularLossyQueue.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/util/CircularLossyQueue.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.util; - -import java.util.concurrent.atomic.AtomicLong; -import java.util.concurrent.atomic.AtomicReference; - -/** - * An implementation of a CircularQueue data-structure. - * When the number of items added exceeds the maximum capacity, items that were - * added first are lost. - * - * @param - * Type of the item's to add in this queue - * - * @author Abhishek Sanoujam - * @since 1.7 - */ -public class - -CircularLossyQueue { - private final AtomicReference[] circularArray; - private final int maxSize; - - private final AtomicLong currentIndex = new AtomicLong(-1); - - /** - * Constructs the circular queue with the specified capacity - * - * @param size - */ - public CircularLossyQueue(int size) { - this.circularArray = new AtomicReference[size]; - for (int i = 0; i < size; i++) { - this.circularArray[i] = new AtomicReference(); - } - this.maxSize = size; - } - - /** - * Adds a new item - * - * @param newVal - */ - public void push(T newVal) { - int index = (int) (currentIndex.incrementAndGet() % maxSize); - circularArray[index].set(newVal); - } - - /** - * Returns an array of the current elements in the queue. The order of - * elements is in reverse order of the order items were added. - * - * @param type - * @return An array containing the current elements in the queue. The first - * element of the array is the tail of the queue and the last - * element is the head of the queue - */ - public T[] toArray(T[] type) { - System.getProperties(); - - if (type.length > maxSize) { - throw new IllegalArgumentException("Size of array passed in cannot be greater than " + maxSize); - } - - int curIndex = getCurrentIndex(); - for (int k = 0; k < type.length; k++) { - int index = getIndex(curIndex - k); - type[k] = circularArray[index].get(); - } - return type; - } - - private int getIndex(int index) { - return (index < 0 ? index + maxSize : index); - } - - /** - * Returns value at the tail of the queue - * - * @return Value at the tail of the queue - */ - public T peek() { - if (depth() == 0) { - return null; - } - return circularArray[getIndex(getCurrentIndex())].get(); - } - - /** - * Returns true if the queue is empty, otherwise false - * - * @return true if the queue is empty, false otherwise - */ - public boolean isEmtpy() { - return depth() == 0; - } - - private int getCurrentIndex() { - return (int) (currentIndex.get() % maxSize); - } - - /** - * Returns the number of items currently in the queue - * - * @return the number of items in the queue - */ - public int depth() { - long currInd = currentIndex.get() + 1; - return currInd >= maxSize ? maxSize : (int) currInd; - } -} Index: rctags/ehcache-2.10.9.1.33/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/transaction/SoftLockManagerProvider.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/transaction/SoftLockManagerProvider.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/transaction/SoftLockManagerProvider.java (revision 0) @@ -1,96 +0,0 @@ -/* - * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved. - */ -package org.terracotta.modules.ehcache.transaction; - -import net.sf.ehcache.CacheException; -import net.sf.ehcache.Ehcache; -import net.sf.ehcache.Element; -import net.sf.ehcache.event.CacheEventListener; -import net.sf.ehcache.transaction.SoftLockManager; - -import org.terracotta.modules.ehcache.ToolkitInstanceFactory; - -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; - -public class SoftLockManagerProvider { - private final ConcurrentMap softLockFactories = new ConcurrentHashMap(); - private final ToolkitInstanceFactory toolkitInstanceFactory; - - public SoftLockManagerProvider( - ToolkitInstanceFactory toolkitInstanceFactory) { - this.toolkitInstanceFactory = toolkitInstanceFactory; - } - - public SoftLockManager getOrCreateClusteredSoftLockFactory(Ehcache cache) { - String name = toolkitInstanceFactory.getFullyQualifiedCacheName(cache); - SoftLockManager softLockFactory = softLockFactories.get(name); - if (softLockFactory == null) { - softLockFactory = new ReadCommittedClusteredSoftLockFactory(toolkitInstanceFactory, cache.getCacheManager() - .getName(), cache.getName()); - SoftLockManager old = softLockFactories.putIfAbsent(name, softLockFactory); - if (old == null) { - // Put successful add a Cache Event Listener. - cache.getCacheEventNotificationService().registerListener(new EventListener(name)); - } else { - softLockFactory = old; - } - } - return softLockFactory; - } - - private void disposeSoftLockFactory(String fullyQualifiedCacheName) { - softLockFactories.remove(fullyQualifiedCacheName); - } - - private class EventListener implements CacheEventListener { - private final String fullyQualifiedCacheName; - - private EventListener(String fullyQualifiedCacheName) { - this.fullyQualifiedCacheName = fullyQualifiedCacheName; - } - - @Override - public void dispose() { - disposeSoftLockFactory(fullyQualifiedCacheName); - } - - @Override - public void notifyElementRemoved(Ehcache cache, Element element) throws CacheException { - // DO Nothing - } - - @Override - public void notifyElementPut(Ehcache cache, Element element) throws CacheException { - // DO Nothing - } - - @Override - public void notifyElementUpdated(Ehcache cache, Element element) throws CacheException { - // DO Nothing - } - - @Override - public void notifyElementExpired(Ehcache cache, Element element) { - // DO Nothing - } - - @Override - public void notifyElementEvicted(Ehcache cache, Element element) { - // DO Nothing - } - - @Override - public void notifyRemoveAll(Ehcache cache) { - // DO Nothing - } - - @Override - public EventListener clone() throws CloneNotSupportedException { - return (EventListener) super.clone(); - } - - } - -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/writer/writebehind/operations/package.html =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/writer/writebehind/operations/package.html (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/writer/writebehind/operations/package.html (revision 0) @@ -1,7 +0,0 @@ - - - - -This package contains the operations for the write behind functionalities. - - \ No newline at end of file Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/config/CacheConfigurationTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/config/CacheConfigurationTest.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/config/CacheConfigurationTest.java (revision 0) @@ -1,323 +0,0 @@ -package net.sf.ehcache.config; - -import net.sf.ehcache.Cache; -import net.sf.ehcache.CacheException; -import net.sf.ehcache.CacheManager; -import net.sf.ehcache.config.PersistenceConfiguration.Strategy; - -import org.hamcrest.CoreMatchers; -import org.hamcrest.core.StringContains; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.terracotta.test.categories.CheckShorts; - -import java.util.List; -import java.util.concurrent.atomic.AtomicReference; -import java.util.logging.Handler; -import java.util.logging.LogManager; -import java.util.logging.LogRecord; -import java.util.logging.Logger; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.nullValue; -import static org.hamcrest.Matchers.empty; -import static org.hamcrest.Matchers.not; -import static org.hamcrest.core.StringContains.containsString; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.fail; -import static org.junit.Assume.assumeNotNull; - -/** - * @author Alex Snaps - */ -@Category(CheckShorts.class) -public class CacheConfigurationTest { - - private static CacheManager cacheManager; - - @BeforeClass - public static void setupClass() { - Configuration configTestCM = new Configuration().name("configTestCM") - .diskStore(new DiskStoreConfiguration().path("java.io.tmpdir")); - cacheManager = CacheManager.newInstance(configTestCM); - } - - @AfterClass - public static void tearDownClass() { - cacheManager.shutdown(); - } - - @Test - public void testTransactionalMode() { - CacheConfiguration configuration = new CacheConfiguration(); - assertEquals(CacheConfiguration.TransactionalMode.OFF, configuration.getTransactionalMode()); - try { - configuration.setTransactionalMode(null); - fail("expected IllegalArgumentException"); - } catch (IllegalArgumentException e) { - // expected - } - - configuration.setTransactionalMode("local"); - assertEquals(CacheConfiguration.TransactionalMode.LOCAL, configuration.getTransactionalMode()); - try { - configuration.transactionalMode(CacheConfiguration.TransactionalMode.OFF); - fail("expected InvalidConfigurationException"); - } catch (InvalidConfigurationException e) { - // expected - } - try { - configuration.setTransactionalMode(null); - fail("expected IllegalArgumentException"); - } catch (IllegalArgumentException e) { - // expected - } - - CacheConfiguration clone = configuration.clone(); - assertEquals(CacheConfiguration.TransactionalMode.LOCAL, clone.getTransactionalMode()); - try { - clone.transactionalMode(CacheConfiguration.TransactionalMode.XA); - fail("expected InvalidConfigurationException"); - } catch (InvalidConfigurationException e) { - // expected - } - } - - @Test - public void testReadPercentageProperly() { - CacheConfiguration configuration = new CacheConfiguration(); - assertThat(configuration.getMaxBytesLocalOffHeapPercentage(), nullValue()); - configuration.setMaxBytesLocalOffHeap("12%"); - assertThat(configuration.getMaxBytesLocalOffHeapPercentage(), equalTo(12)); - configuration.setMaxBytesLocalOffHeap("99%"); - assertThat(configuration.getMaxBytesLocalOffHeapPercentage(), equalTo(99)); - configuration.setMaxBytesLocalOffHeap("100%"); - assertThat(configuration.getMaxBytesLocalOffHeapPercentage(), equalTo(100)); - configuration.setMaxBytesLocalOffHeap("0%"); - assertThat(configuration.getMaxBytesLocalOffHeapPercentage(), equalTo(0)); - try { - configuration.setMaxBytesLocalOffHeap("101%"); - fail("This should throw an IllegalArgumentException, 101% is above 100%"); - } catch (IllegalArgumentException e) { - // Expected - } - try { - configuration.setMaxBytesLocalOffHeap("-10%"); - fail("This should throw an IllegalArgumentException, -10% is below 0%"); - } catch (IllegalArgumentException e) { - // Expected - } - } - - @Test - public void testCanSetBothMaxWhenCacheNotRunning() { - CacheConfiguration configuration = new CacheConfiguration(); - configuration.setMaxEntriesLocalHeap(10); - configuration.maxBytesLocalHeap(10, MemoryUnit.MEGABYTES); - configuration.setMaxEntriesLocalDisk(10); - configuration.maxBytesLocalDisk(10, MemoryUnit.MEGABYTES); - } - - @Test - public void testMaxMemoryOffHeap() { - CacheConfiguration configuration = new CacheConfiguration(); - - configuration.setMaxMemoryOffHeap("100m"); - assertEquals("100m", configuration.getMaxMemoryOffHeap()); - - configuration.setMaxBytesLocalOffHeap("1G"); - assertEquals("1G", configuration.getMaxMemoryOffHeap()); - } - - @Test - public void testMaxEntriesLocalDiskAndMaxElementsOnDiskAlias() { - CacheConfiguration configuration = new CacheConfiguration().maxElementsOnDisk(10); - assertThat(configuration.getMaxEntriesLocalDisk(), is(10L)); - assertThat(configuration.getMaxElementsOnDisk(), is(10)); - configuration.maxEntriesLocalDisk(20); - assertThat(configuration.getMaxEntriesLocalDisk(), is(20L)); - assertThat(configuration.getMaxElementsOnDisk(), is(20)); - } - - @Test - public void testCantSetMaxEntriesLocalDiskWhenClustered() { - CacheConfiguration configuration = new CacheConfiguration("Test", 10) - .maxEntriesLocalDisk(10).terracotta(new TerracottaConfiguration()); - try { - configuration.setupFor(cacheManager); - fail("This should throw InvalidConfigurationException"); - } catch (CacheException e) { - assertThat(e.getMessage(), containsString("use maxEntriesInCache instead")); - } - } - - @Test - public void testSynchronousWritesPersistenceConfiguration() { - CacheConfiguration configuration = new CacheConfiguration("Test", 10).persistence(new PersistenceConfiguration() - .strategy(Strategy.LOCALTEMPSWAP).synchronousWrites(true)); - try { - cacheManager.addCache(new Cache(configuration)); - fail("Expected InvalidConfigurationException"); - } catch (InvalidConfigurationException e) { - assertThat(e.getMessage(), containsString("synchronousWrites")); - } finally { - cacheManager.removeCache("Test"); - } - - configuration = new CacheConfiguration("Test", 10).persistence(new PersistenceConfiguration() - .strategy(Strategy.NONE).synchronousWrites(true)); - try { - cacheManager.addCache(new Cache(configuration)); - fail("Expected InvalidConfigurationException"); - } catch (InvalidConfigurationException e) { - assertThat(e.getMessage(), containsString("synchronousWrites")); - } finally { - cacheManager.removeCache("Test"); - } - - configuration = new CacheConfiguration("Test", 10).persistence(new PersistenceConfiguration() - .strategy(Strategy.LOCALRESTARTABLE).synchronousWrites(true)); - try { - cacheManager.addCache(new Cache(configuration)); - fail("Expected CacheException"); - } catch (CacheException e) { - assertThat(e.getMessage(), containsString("enterprise")); - } finally { - cacheManager.removeCache("Test"); - } - } - - @Test - public void testPersistenceConfigMixing() { - CacheConfiguration persistence = new CacheConfiguration().persistence(new PersistenceConfiguration().strategy(Strategy.LOCALTEMPSWAP)); - try { - persistence.diskPersistent(true); - Assert.fail(); - } catch (InvalidConfigurationException e) { - Assert.assertThat(e.getMessage(), StringContains.containsString(" and diskPersistent")); - } - try { - persistence.overflowToDisk(true); - Assert.fail(); - } catch (InvalidConfigurationException e) { - Assert.assertThat(e.getMessage(), StringContains.containsString(" and overflowToDisk")); - } - - CacheConfiguration diskPersistent = new CacheConfiguration().diskPersistent(true); - try { - diskPersistent.persistence(new PersistenceConfiguration().strategy(Strategy.LOCALTEMPSWAP)); - Assert.fail(); - } catch (InvalidConfigurationException e) { - Assert.assertThat(e.getMessage(), StringContains.containsString(" and diskPersistent")); - } - - CacheConfiguration overflowToDisk = new CacheConfiguration().overflowToDisk(true); - try { - overflowToDisk.persistence(new PersistenceConfiguration().strategy(Strategy.LOCALTEMPSWAP)); - Assert.fail(); - } catch (InvalidConfigurationException e) { - Assert.assertThat(e.getMessage(), StringContains.containsString(" and overflowToDisk")); - } - } - - @Test - public void testNoPersistenceStrategySet() { - CacheConfiguration config = new CacheConfiguration().name("foo").persistence(new PersistenceConfiguration()).maxBytesLocalHeap(1, MemoryUnit.MEGABYTES); - try { - cacheManager.addCache(new Cache(config)); - Assert.fail(); - } catch (InvalidConfigurationException e) { - Assert.assertThat(e.getMessage(), StringContains.containsString("Persistence configuration found with no strategy set.")); - } - } - - @Test - public void testMaxEntriesInCacheNotClustered() { - CacheConfiguration config = new CacheConfiguration().name("foo").maxEntriesInCache(100).maxBytesLocalHeap(1, MemoryUnit.MEGABYTES); - try { - cacheManager.addCache(new Cache(config)); - Assert.fail(); - } catch (InvalidConfigurationException e) { - Assert.assertThat(e.getMessage(), StringContains.containsString("maxEntriesInCache is not applicable to unclustered caches.")); - } - } - - @Test - public void testMaxEntriesInCacheBounds() { - try { - new CacheConfiguration().maxEntriesInCache(-1); - } catch (IllegalArgumentException e) { - assertThat(e.getMessage(), CoreMatchers.containsString("maxEntriesInCache")); - } - } - - @Test - public void testWarnTieredSizing() { - final AtomicReference ref = new AtomicReference(); - - try { - Class.forName("org.slf4j.impl.JDK14LoggerFactory"); - } catch (ClassNotFoundException e) { - fail("Could not load org.slf4j.impl.JDK14LoggerFactory, required for test to work. Is slf4j-jdk14 in test dependencies?"); - } - - LogManager logManager = LogManager.getLogManager(); - Logger logger = logManager.getLogger(CacheConfiguration.class.getName()); - assumeNotNull(logger); - - logger.addHandler(new Handler() { - @Override - public void publish(LogRecord record) { - ref.set(record.getMessage()); - } - - @Override - public void flush() { - // ignore - } - - @Override - public void close() throws SecurityException { - // ignore - } - }); - - - CacheConfiguration cacheConfiguration = new CacheConfiguration(); - cacheConfiguration.setName("HeapBiggerThanDisk"); - cacheConfiguration.setOverflowToDisk(true); - cacheConfiguration.setMaxEntriesLocalHeap(10L); - cacheConfiguration.setMaxEntriesLocalDisk(5L); - - cacheManager.addCache(new Cache(cacheConfiguration)); - - assertThat(ref.get(), CoreMatchers.containsString("Configuration problem for cache HeapBiggerThanDisk:")); - } - - @Test - public void testCloneCollectionsProperly() { - CacheConfiguration cacheConfiguration = new CacheConfiguration(); - CacheConfiguration otherCacheConfiguration = cacheConfiguration.clone(); - - otherCacheConfiguration.addCacheEventListenerFactory(new CacheConfiguration.CacheEventListenerFactoryConfiguration()); - assertThat((List) otherCacheConfiguration.getCacheEventListenerConfigurations(), not(empty())); - assertThat((List) cacheConfiguration.getCacheEventListenerConfigurations(), is(empty())); - - otherCacheConfiguration.addCacheExtensionFactory(new CacheConfiguration.CacheExtensionFactoryConfiguration()); - assertThat((List) otherCacheConfiguration.getCacheExtensionConfigurations(), not(empty())); - assertThat((List) cacheConfiguration.getCacheExtensionConfigurations(), is(empty())); - - otherCacheConfiguration.addCacheLoaderFactory(new CacheConfiguration.CacheLoaderFactoryConfiguration()); - assertThat((List) otherCacheConfiguration.getCacheLoaderConfigurations(), not(empty())); - assertThat((List) cacheConfiguration.getCacheLoaderConfigurations(), is(empty())); - - otherCacheConfiguration.addCacheDecoratorFactory(new CacheConfiguration.CacheDecoratorFactoryConfiguration()); - assertThat(otherCacheConfiguration.getCacheDecoratorConfigurations(), not(empty())); - assertThat(cacheConfiguration.getCacheDecoratorConfigurations(), is(empty())); - } -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/hibernate/HibernateAPIUsageTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/hibernate/HibernateAPIUsageTest.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/hibernate/HibernateAPIUsageTest.java (revision 0) @@ -1,654 +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.AbstractCacheTest; -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.store.disk.DiskStoreHelper; - -import org.hamcrest.CoreMatchers; -import org.hibernate.cfg.Environment; -import org.junit.After; - -import static org.hamcrest.number.OrderingComparison.greaterThan; -import static org.hamcrest.number.OrderingComparison.lessThanOrEqualTo; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -import java.io.IOException; -import java.io.Serializable; -import java.lang.reflect.Field; -import java.util.Map; -import java.util.Properties; -import java.util.concurrent.ExecutionException; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.terracotta.test.categories.CheckShorts; - - -/** - * Tests for a Cache - * - * @author Greg Luck, Claus Ibsen - * @version $Id: HibernateAPIUsageTest.java 10789 2018-04-26 02:08:13Z adahanne $ - */ -@Category(CheckShorts.class) -public class HibernateAPIUsageTest extends AbstractCacheTest { - private static final Logger LOG = LoggerFactory.getLogger(HibernateAPIUsageTest.class.getName()); - - /** - * teardown - */ - @Override - @After - public void tearDown() throws Exception { - super.tearDown(); - for (CacheManager cacheManager : CacheManager.ALL_CACHE_MANAGERS) { - cacheManager.shutdown(); - } - } - - @Override - @Before - public void setUp() { - // Do not setup a cachemanager here! - } - - - /** - * Make sure ehcache works with one of the main projects using it: Hibernate-2.1.8 - */ - @Test - public void testAPIAsUsedByHibernate2() throws Exception { - super.setUp(); - net.sf.hibernate.cache.EhCacheProvider provider = new net.sf.hibernate.cache.EhCacheProvider(); - provider.start(null); - net.sf.hibernate.cache.Cache cache = provider.buildCache("sampleCache1", null); - assertNotNull(manager.getCache("sampleCache1")); - - Serializable key = "key"; - Serializable value = "value"; - cache.put(key, value); - assertEquals(value, cache.get(key)); - - cache.remove(key); - assertEquals(null, cache.get(key)); - } - - - /** - * Make sure ehcache works with one of the main projects using it: Hibernate-3.1.3 and Hibernate 3.2 - * Note this test was updated to Hibernate3.2cr2 9 May 2006 - *

- * Note that getElementCountInMemory() is broken. It reports the total cache size rather than the memory size. Fixed in Hibernate 3.2 - * getTimeout appears to be broken. It returns 4096 minutes! - */ - @Test - public void testAPIAsUsedByHibernate3() throws InterruptedException, ExecutionException { - - org.hibernate.cache.EhCacheProvider provider = new org.hibernate.cache.EhCacheProvider(); - provider.start(null); - final org.hibernate.cache.Cache cache = provider.buildCache("sampleCache1", null); - final Serializable key = "key"; - final Serializable value = "value"; - assertThat(cache.getSizeInMemory(), CoreMatchers.is(0L)); - cache.put(key, value); - final long EMPTY_ELEMENT_SIZE = cache.getSizeInMemory(); - cache.clear(); - - //Check created and name - assertNotNull(cache.getRegionName()); - assertEquals("sampleCache1", cache.getRegionName()); - - cache.put(key, value); - assertEquals(value, cache.get(key)); - assertEquals(value, cache.read(key)); - - cache.remove(key); - assertEquals(null, cache.get(key)); - - //Behaves like a put - cache.update(key, value); - assertEquals(value, cache.get(key)); - cache.remove(key); - - //Check counts and stats - for (int i = 0; i < 10010; i++) { - cache.put("" + i, value); - } - DiskStoreHelper.flushAllEntriesToDisk(getBackingCache((org.hibernate.cache.EhCache)cache)).get(); - //this is now fixed - assertThat(cache.getElementCountInMemory(), lessThanOrEqualTo(10000L)); - // TODO Lower tier will _never_ be smaller than higher ones now -// RetryAssert.assertBy(1, SECONDS, new Callable() { -// public Long call() throws Exception { -// return cache.getElementCountOnDisk(); -// } -// }, lessThan(1002L)); - assertThat(cache.getElementCountOnDisk(), greaterThan(999L)); - - //clear - cache.clear(); - assertEquals(0, cache.getElementCountInMemory()); - cache.put(key, value); - assertEquals(EMPTY_ELEMENT_SIZE, cache.getSizeInMemory()); - - //locks - //timeout. This seems strange - assertEquals(245760000, cache.getTimeout()); - cache.lock(key); - cache.unlock(key); - - //toMap - Map map = cache.toMap(); - assertEquals(1, map.size()); - assertEquals(value, map.get(key)); - - long time1 = cache.nextTimestamp(); - long time2 = cache.nextTimestamp(); - assertTrue(time2 > time1); - - cache.clear(); - - cache.destroy(); - try { - cache.get(key); - fail(); - } catch (IllegalStateException e) { - //expected - } - - provider.stop(); - - } - - private Cache getBackingCache(final org.hibernate.cache.EhCache cache) { - try { - final Field cacheField = cache.getClass().getDeclaredField("cache"); - cacheField.setAccessible(true); - return (Cache)cacheField.get(cache); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - - /** - * Test new features: - *

    - *
  1. Support for Object signatures - *
  2. support for multiple SessionFactory objects in Hibernate, which presumably mean multiple providers. - * We can have two caches of the same name in different providers and interact with both - *
- */ - @Test - public void testNewHibernate32CacheAndProviderNewFeatures() { - - org.hibernate.cache.EhCacheProvider provider = new org.hibernate.cache.EhCacheProvider(); - provider.start(null); - org.hibernate.cache.Cache cache = provider.buildCache("sampleCache1", null); - - //start up second provider pointing to ehcache-failsage.xml because it is there - org.hibernate.cache.EhCacheProvider provider2 = new org.hibernate.cache.EhCacheProvider(); - - //Fire up a second provider, CacheManager and cache concurrently - Properties properties = new Properties(); - - properties.setProperty(Environment.CACHE_PROVIDER_CONFIG, "ehcache-2.xml"); - provider2.start(properties); - org.hibernate.cache.Cache cache2 = provider.buildCache("sampleCache1", null); - - //Check created and name - assertNotNull(cache.getRegionName()); - assertEquals("sampleCache1", cache.getRegionName()); - - //Test with Object rather than Serializable - Object key = new Object(); - Object value = new Object(); - - cache.put(key, value); - assertEquals(value, cache.get(key)); - assertEquals(value, cache.read(key)); - cache2.put(key, value); - assertEquals(value, cache2.get(key)); - assertEquals(value, cache2.read(key)); - - cache.remove(key); - assertEquals(null, cache.get(key)); - cache2.remove(key); - assertEquals(null, cache2.get(key)); - - //Behaves like a put - cache.update(key, value); - assertEquals(value, cache.get(key)); - cache.remove(key); - cache2.update(key, value); - assertEquals(value, cache2.get(key)); - cache2.remove(key); - - //Check counts and stats - for (int i = 0; i < 10010; i++) { - cache.put("" + i, value); - } - assertEquals(10000, cache.getElementCountInMemory()); - //objects don't overflow, only Serializable - assertEquals(0, cache.getElementCountOnDisk()); - - //clear - cache.clear(); - assertEquals(0, cache.getElementCountInMemory()); - cache.put(key, value); - - //locks - //timeout. This seems strange - assertEquals(245760000, cache.getTimeout()); - cache.lock(key); - cache.unlock(key); - - //toMap - broken in Hibernate 3.2 -// Map map = cache.toMap(); -// assertEquals(1, map.size()); -// assertEquals(value, map.get(key)); - - long time1 = cache.nextTimestamp(); - long time2 = cache.nextTimestamp(); - assertTrue(time2 > time1); - - cache.destroy(); - try { - cache.get(key); - fail(); - } catch (IllegalStateException e) { - //expected - } - - cache2.destroy(); - try { - cache2.get(key); - fail(); - } catch (IllegalStateException e) { - //expected - } - - provider.stop(); - provider2.stop(); - } - - - /** - * Test ehcache packaged provider and EhCache with Hibernate-3.1.3 - * Leave broken timeout until get clarification from Emmanuel - */ - @Test - public void testNewHibernateEhcacheAndProviderBackwardCompatible() { - - net.sf.ehcache.hibernate.EhCacheProvider provider = new net.sf.ehcache.hibernate.EhCacheProvider(); - - //Fire up a second provider, CacheManager and cache concurrently - Properties properties = new Properties(); - - properties.setProperty("net.sf.ehcache.configurationResourceName", "ehcache-2.xml"); - provider.start(properties); - final org.hibernate.cache.Cache cache = provider.buildCache("sampleCache1", null); - final Serializable key = "key"; - final Serializable value = "value"; - assertThat(cache.getSizeInMemory(), CoreMatchers.is(0L)); - cache.put(key, value); - final long EMPTY_ELEMENT_SIZE = cache.getSizeInMemory(); - cache.clear(); - - //Check created and name - assertNotNull(cache.getRegionName()); - assertEquals("sampleCache1", cache.getRegionName()); - - cache.put(key, value); - assertEquals(value, cache.get(key)); - assertEquals(value, cache.read(key)); - - cache.remove(key); - assertEquals(null, cache.get(key)); - - //Behaves like a put - cache.update(key, value); - assertEquals(value, cache.get(key)); - cache.remove(key); - - //Check counts and stats - for (int i = 0; i < 10010; i++) { - cache.put("" + i, value); - } - assertEquals(10010, cache.getElementCountInMemory()); - - //clear - cache.clear(); - assertEquals(0, cache.getElementCountInMemory()); - cache.put(key, value); - assertEquals(EMPTY_ELEMENT_SIZE, cache.getSizeInMemory()); - - //locks - //timeout. This seems strange - assertEquals(245760000, cache.getTimeout()); - cache.lock(key); - cache.unlock(key); - - //toMap - Map map = cache.toMap(); - assertEquals(1, map.size()); - assertEquals(value, map.get(key)); - - long time1 = cache.nextTimestamp(); - long time2 = cache.nextTimestamp(); - assertTrue(time2 > time1); - - cache.destroy(); - try { - cache.get(key); - fail(); - } catch (IllegalStateException e) { - //expected - } - - provider.stop(); - } - - - /** - * An integration test, at the CacheManager level, to make sure persistence works - */ - @Test - public void testPersistentStoreFromCacheManager() throws IOException, InterruptedException, CacheException, ExecutionException { - - //initialise - CacheManager manager = CacheManager.create(AbstractCacheTest.TEST_CONFIG_DIR + "ehcache.xml"); - Ehcache cache = manager.getCache("persistentLongExpiryIntervalCache"); - - cache.removeAll(); - DiskStoreHelper.flushAllEntriesToDisk((Cache)cache).get(); - for (int i = 0; i < 100; i++) { - byte[] data = new byte[1024]; - cache.put(new Element("key" + (i + 100), data)); - } - assertEquals(100, cache.getSize()); - - manager.shutdown(); - - net.sf.ehcache.hibernate.EhCacheProvider provider = new net.sf.ehcache.hibernate.EhCacheProvider(); - provider.start(null); - org.hibernate.cache.Cache hibernateCache = provider.buildCache("persistentLongExpiryIntervalCache", null); - - for (int i = 0; i < 100; i++) { - assertNotNull(hibernateCache.get("key" + (i + 100))); - } - - assertEquals(100, hibernateCache.getElementCountInMemory()); - - provider.stop(); - - - } - - - /** - * An integration test, at the CacheManager level, to make sure persistence works - */ - @Test - public void testPersistentStoreFromCacheManagerUsingHibernate321Provider() throws Exception { - - //initialise - CacheManager manager = CacheManager.create(AbstractCacheTest.TEST_CONFIG_DIR + "ehcache.xml"); - Ehcache cache = manager.getCache("persistentLongExpiryIntervalCache"); - cache.removeAll(); - - for (int i = 0; i < 100; i++) { - byte[] data = new byte[1024]; - cache.put(new Element("key" + (i + 100), data)); - } - assertEquals(100, cache.getSize()); - - manager.shutdown(); - - //Create hibernate using ehcache - org.hibernate.cache.EhCacheProvider provider = new org.hibernate.cache.EhCacheProvider(); - provider.start(null); - org.hibernate.cache.Cache hibernateCache = provider.buildCache("persistentLongExpiryIntervalCache", null); - - assertEquals(100, hibernateCache.getElementCountInMemory() + hibernateCache.getElementCountOnDisk()); - - provider.stop(); - - } - - /** - * Test ehcache packaged provider and EhCache with Hibernate-3.1.3 - * Leave broken timeout until get clarification from Emmanuel - *

- * Test new features: - *

    - *
  1. Support for Object signatures - *
  2. support for multiple SessionFactory objects in Hibernate, which presumably mean multiple providers. - * We can have two caches of the same name in different providers and interact with both - *
- */ - @Test - public void testNewHibernateEhcacheAndProviderNewFeatures() { - - net.sf.ehcache.hibernate.EhCacheProvider provider = new net.sf.ehcache.hibernate.EhCacheProvider(); - provider.start(null); - org.hibernate.cache.Cache cache = provider.buildCache("sampleCache1", null); - - //start up second provider pointing to ehcache-failsafe.xml because it is there - net.sf.ehcache.hibernate.EhCacheProvider provider2 = new net.sf.ehcache.hibernate.EhCacheProvider(); - - //Fire up a second provider, CacheManager and cache concurrently - Properties properties = new Properties(); - properties.setProperty(EhCacheProvider.NET_SF_EHCACHE_CONFIGURATION_RESOURCE_NAME, "ehcache-2.xml"); - provider2.start(properties); - org.hibernate.cache.Cache cache2 = provider.buildCache("sampleCache1", null); - - //Check created and name - assertNotNull(cache.getRegionName()); - assertEquals("sampleCache1", cache.getRegionName()); - - //Test with Object rather than Serializable - Object key = new Object(); - Object value = new Object(); - - cache.put(key, value); - assertEquals(value, cache.get(key)); - assertEquals(value, cache.read(key)); - cache2.put(key, value); - assertEquals(value, cache2.get(key)); - assertEquals(value, cache2.read(key)); - - cache.remove(key); - assertEquals(null, cache.get(key)); - cache2.remove(key); - assertEquals(null, cache2.get(key)); - - //Behaves like a put - cache.update(key, value); - assertEquals(value, cache.get(key)); - cache.remove(key); - cache2.update(key, value); - assertEquals(value, cache2.get(key)); - cache2.remove(key); - - //Check counts and stats - for (int i = 0; i < 10010; i++) { - cache.put("" + i, value); - } - assertEquals(10010, cache.getElementCountInMemory()); - - //clear - cache.clear(); - assertEquals(0, cache.getElementCountInMemory()); - cache.put(key, value); - // elements don't need to be serializable anymore to be measured - assertTrue(cache.getSizeInMemory() > 0); - - //locks - //timeout. This seems strange - assertEquals(245760000, cache.getTimeout()); - cache.lock(key); - cache.unlock(key); - - //toMap - Map map = cache.toMap(); - assertEquals(1, map.size()); - assertEquals(value, map.get(key)); - - long time1 = cache.nextTimestamp(); - long time2 = cache.nextTimestamp(); - assertTrue(time2 > time1); - - cache.destroy(); - try { - cache.get(key); - fail(); - } catch (IllegalStateException e) { - //expected - } - - cache2.destroy(); - try { - cache2.get(key); - fail(); - } catch (IllegalStateException e) { - //expected - } - - provider.stop(); - provider2.stop(); - } - - /** - * Test ehcache packaged provider and EhCache with Hibernate-3.1.3 - * Leave broken timeout until get clarification from Emmanuel - *

- * Test new features: - *

    - *
  1. Support for Object signatures - *
- */ - @Test - public void testNewHibernateSingletonEhcacheAndProviderNewFeatures() { - - net.sf.ehcache.hibernate.SingletonEhCacheProvider provider = new net.sf.ehcache.hibernate.SingletonEhCacheProvider(); - provider.start(null); - org.hibernate.cache.Cache cache = provider.buildCache("sampleCache1", null); - - net.sf.ehcache.hibernate.SingletonEhCacheProvider provider2 = new net.sf.ehcache.hibernate.SingletonEhCacheProvider(); - provider2.start(null); - org.hibernate.cache.Cache cache2 = provider.buildCache("sampleCache1", null); - - //Check created and name - assertNotNull(cache.getRegionName()); - assertEquals("sampleCache1", cache.getRegionName()); - - //Test with Object rather than Serializable - Object key = new Object(); - Object value = new Object(); - - cache.put(key, value); - assertEquals(value, cache2.get(key)); - assertEquals(value, cache.read(key)); - cache2.put(key, value); - assertEquals(value, cache.get(key)); - assertEquals(value, cache2.read(key)); - - cache.remove(key); - assertEquals(null, cache.get(key)); - cache2.remove(key); - assertEquals(null, cache2.get(key)); - - //Behaves like a put - cache.update(key, value); - assertEquals(value, cache.get(key)); - cache.remove(key); - cache2.update(key, value); - assertEquals(value, cache2.get(key)); - cache2.remove(key); - - //Check counts and stats - for (int i = 0; i < 10010; i++) { - cache.put("" + i, value); - } - assertEquals(10010, cache.getElementCountInMemory()); - - //clear - cache.clear(); - assertEquals(0, cache.getElementCountInMemory()); - cache.put(key, value); - // elements don't need to be serializable anymore to be measured - assertTrue(cache.getSizeInMemory() > 0); - - //locks - //timeout. This seems strange - assertEquals(245760000, cache.getTimeout()); - cache.lock(key); - cache.unlock(key); - - //toMap - Map map = cache.toMap(); - assertEquals(1, map.size()); - assertEquals(value, map.get(key)); - - long time1 = cache.nextTimestamp(); - long time2 = cache.nextTimestamp(); - assertTrue(time2 > time1); - - cache.destroy(); - try { - cache.get(key); - fail(); - } catch (IllegalStateException e) { - //expected - } - - cache2.destroy(); - //second destroy ok - cache2.destroy(); - - try { - cache2.get(key); - fail(); - } catch (IllegalStateException e) { - //expected - } - - - ((net.sf.ehcache.hibernate.EhCache) cache).getBackingCache().getCacheManager().shutdown(); - ((net.sf.ehcache.hibernate.EhCache) cache).getBackingCache().getCacheManager().shutdown(); - ((net.sf.ehcache.hibernate.EhCache) cache2).getBackingCache().getCacheManager().shutdown(); - - //Spring and Hibernate together can call destroy after the CacheManager has been shutdown - //See bug 1901094. We need to deal with this as "normal". - cache2.destroy(); - } -} Index: rctags/ehcache-2.10.9.1.33/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/ToolkitLookup.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/ToolkitLookup.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/ToolkitLookup.java (revision 0) @@ -1,13 +0,0 @@ -/* - * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved. - */ -package org.terracotta.modules.ehcache; - -import org.terracotta.toolkit.Toolkit; - -/** - * Package protected interface used in tests to lookup internal toolkit. - */ -interface ToolkitLookup { - Toolkit getToolkit(); -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/store/BruteForceSource.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/store/BruteForceSource.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/store/BruteForceSource.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 net.sf.ehcache.store; - -import net.sf.ehcache.Element; -import net.sf.ehcache.config.Searchable; - -/** - * This interface exposes what is required by the {@link BruteForceSearchManager} - * - * @author ljacomet - */ -interface BruteForceSource { - - /** - * An {@link Iterable} over the elements from the source. - * The elements returned are in the form expected by the {@link BruteForceSearchManager}. - * - * @return an Iterable of Element - */ - Iterable elements(); - - /** - * Returns the {@link Searchable} configuration of the source. - * - * @return the Searchable configuration - */ - Searchable getSearchable(); - - /** - * Transform the element so that it can be used for indexing by the {@link BruteForceSearchManager}. - * - * @param element the element to transform - * @return the transformed element - */ - Element transformForIndexing(Element element); -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/hibernate/management/impl/package.html =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/hibernate/management/impl/package.html (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/hibernate/management/impl/package.html (revision 0) @@ -1,5 +0,0 @@ - - - This package contains JMX related classes for Hibernate and ehcache statistics - - Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/config/generator/xsom/XSDAttribute.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/config/generator/xsom/XSDAttribute.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/config/generator/xsom/XSDAttribute.java (revision 0) @@ -1,37 +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.generator.xsom; - -import net.sf.ehcache.config.generator.model.SimpleNodeAttribute; - -public class XSDAttribute extends SimpleNodeAttribute { - - private XSDAttributeValueType attributeValueType; - - public XSDAttribute(String name) { - super(name); - } - - public XSDAttributeValueType getAttributeValueType() { - return attributeValueType; - } - - public void setAttributeValueType(XSDAttributeValueType attributeValueType) { - this.attributeValueType = attributeValueType; - } - -} Index: rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/net/sf/ehcache/osgi/EvenCacheLoader.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/net/sf/ehcache/osgi/EvenCacheLoader.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/net/sf/ehcache/osgi/EvenCacheLoader.java (revision 0) @@ -1,12 +0,0 @@ -/* - * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved. - */ -package net.sf.ehcache.osgi; - -public class EvenCacheLoader extends IncrementingCacheLoader { - - public EvenCacheLoader() { - super(true, 20000); - } - -} \ No newline at end of file Index: rctags/ehcache-2.10.9.1.33/distribution/src/main/resources/terracotta-ehcache-version.properties =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/distribution/src/main/resources/terracotta-ehcache-version.properties (revision 11516) +++ rctags/ehcache-2.10.9.1.33/distribution/src/main/resources/terracotta-ehcache-version.properties (revision 0) @@ -1,8 +0,0 @@ -product-name = ${project.name} -version = ${project.version} -built-by = ${user.name} -build-jdk = ${java.version} -build-time = ${build.time} -build-revision = ${build.revision} -required-core-version = ${project.version} -enterprise = false Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/util/counter/sampled/SampledCounterConfig.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/util/counter/sampled/SampledCounterConfig.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/util/counter/sampled/SampledCounterConfig.java (revision 0) @@ -1,95 +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.counter.sampled; - -import net.sf.ehcache.util.counter.Counter; -import net.sf.ehcache.util.counter.CounterConfig; - -/** - * Config for a {@link SampledCounter} - * - * @author Abhishek Sanoujam - * @since 1.7 - * - */ -public class SampledCounterConfig extends CounterConfig { - private final int intervalSecs; - private final int historySize; - private final boolean isReset; - - /** - * Make a new timed counter config (duh) - * - * @param intervalSecs - * the interval (in seconds) between sampling - * @param historySize - * number of counter samples that will be retained in memory - * @param isResetOnSample - * true if the counter should be reset to 0 upon each sample - * @param initialValue - * the initial value given to this counter - */ - public SampledCounterConfig(int intervalSecs, int historySize, boolean isResetOnSample, long initialValue) { - super(initialValue); - if (intervalSecs < 1) { - throw new IllegalArgumentException("Interval (" + intervalSecs + ") must be greater than or equal to 1"); - } - if (historySize < 1) { - throw new IllegalArgumentException("History size (" + historySize + ") must be greater than or equal to 1"); - } - - this.intervalSecs = intervalSecs; - this.historySize = historySize; - this.isReset = isResetOnSample; - } - - /** - * Returns the history size - * - * @return The history size - */ - public int getHistorySize() { - return historySize; - } - - /** - * Returns the interval time (seconds) - * - * @return Interval of the sampling thread in seconds - */ - public int getIntervalSecs() { - return intervalSecs; - } - - /** - * Returns true if counters created from this config will reset on each - * sample - * - * @return true if values are reset to the initial value after each sample - */ - public boolean isResetOnSample() { - return this.isReset; - } - - /** - * {@inheritDoc} - */ - @Override - public Counter createCounter() { - return new SampledCounterImpl(this); - } -} Index: rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/org/terracotta/ehcache/tests/servermap/LockGCNotFlushingEntriesTestClient.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/org/terracotta/ehcache/tests/servermap/LockGCNotFlushingEntriesTestClient.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/org/terracotta/ehcache/tests/servermap/LockGCNotFlushingEntriesTestClient.java (revision 0) @@ -1,40 +0,0 @@ -/* - * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved. - */ -package org.terracotta.ehcache.tests.servermap; - -import net.sf.ehcache.Cache; -import net.sf.ehcache.Element; - -import org.terracotta.toolkit.Toolkit; - -public class LockGCNotFlushingEntriesTestClient extends ServerMapClientBase { - - public LockGCNotFlushingEntriesTestClient(String[] args) { - super("testLockGC", args); - } - - public static void main(String[] args) { - new LockGCNotFlushingEntriesTestClient(args).run(); - } - - @Override - protected void runTest(Cache cache, Toolkit clusteringToolkit) throws Throwable { - int size = cache.getSize(); - assertEquals(0, size); - System.out.println("Client populating cache."); - for (int i = 0; i < 1000; i++) { - cache.put(new Element("key-" + i, "value-" + i)); - } - - System.out.println("Cache populated. Sleeping for 120 secs. size: " + cache.getSize() + " inMemorySize: " - + cache.getStatistics().getLocalHeapSize()); - Thread.sleep(120 * 1000); - - System.out.println("After sleeping 120 secs. size: " + cache.getSize() + " inMemorySize: " - + cache.getStatistics().getLocalHeapSize()); - // assert range as some may have got evicted while populating cache - assertTrue(1000 == cache.getSize()); - assertTrue(1000 == cache.getStatistics().getLocalHeapSize()); - } -} Index: rctags/ehcache-2.10.9.1.33/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/writebehind/OperationsFilterWrapper.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/writebehind/OperationsFilterWrapper.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/writebehind/OperationsFilterWrapper.java (revision 0) @@ -1,40 +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.ItemsFilter; -import org.terracotta.modules.ehcache.writebehind.operations.SingleAsyncOperation; - -import net.sf.ehcache.CacheException; -import net.sf.ehcache.writer.writebehind.OperationConverter; -import net.sf.ehcache.writer.writebehind.OperationsFilter; -import net.sf.ehcache.writer.writebehind.operations.KeyBasedOperation; - -import java.util.List; - -public class OperationsFilterWrapper implements ItemsFilter { - private final OperationsFilter delegate; - - public OperationsFilterWrapper(OperationsFilter delegate) { - this.delegate = delegate; - } - - @Override - public void filter(final List items) { - delegate.filter(items, new OperationConverter() { - public KeyBasedOperation convert(Object source) { - SingleAsyncOperation operation = (SingleAsyncOperation) source; - try { - return new KeyBasedOperationWrapper(operation.getKey(), operation.getCreationTime()); - } catch (Exception e) { - throw new CacheException(e); - } - } - }); - } - - OperationsFilter getDelegate() { - return delegate; - } -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/constructs/blocking/CacheEntryFactory.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/constructs/blocking/CacheEntryFactory.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/constructs/blocking/CacheEntryFactory.java (revision 0) @@ -1,37 +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; - - -/** - * Creates objects to populate the cache. - * @version $Id: CacheEntryFactory.java 5594 2012-05-07 16:04:31Z cdennis $ - * @author Greg Luck - */ -public interface CacheEntryFactory { - /** - * Creates the cacheEntry for the given cache key. - * - * ehcache requires cache entries to be serializable. - * - * Note that this method must be thread safe. - * - * @return The entry, or null if it does not exist. - * @throws Exception On failure creating the object. - */ - Object createEntry(Object key) throws Exception; -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/event/OrderedEventListenerForMemoryStoreBackendTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/event/OrderedEventListenerForMemoryStoreBackendTest.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/event/OrderedEventListenerForMemoryStoreBackendTest.java (revision 0) @@ -1,88 +0,0 @@ -package net.sf.ehcache.event; - -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.inOrder; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.reset; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; -import net.sf.ehcache.Cache; -import net.sf.ehcache.Ehcache; -import net.sf.ehcache.Element; -import net.sf.ehcache.pool.PoolAccessor; -import net.sf.ehcache.store.chm.SelectableConcurrentHashMap; - -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.mockito.InOrder; -import org.terracotta.test.categories.CheckShorts; - -/** - * OrderedEventListenerForMemoryStoreBackendTest - */ -@Category(CheckShorts.class) -public class OrderedEventListenerForMemoryStoreBackendTest { - - private SelectableConcurrentHashMap map; - private InternalCacheEventListener listener; - - @Before - public void setUp() { - RegisteredEventListeners registeredEventListeners = new RegisteredEventListeners(mock(Cache.class)); - listener = mock(InternalCacheEventListener.class); - registeredEventListeners.registerOrderedListener(listener); - map = new SelectableConcurrentHashMap(mock(PoolAccessor.class), 10, 100, registeredEventListeners); - } - - @Test - public void putTest() { - String key = "putKey"; - Element element = new Element(key, "value", 0); - map.put(key, element, 0); - verify(listener).notifyElementPut(any(Ehcache.class), eq(element)); - } - - @Test - public void putAndReplaceTest() { - String key = "putAndReplaceKey"; - - Element element = new Element(key, "value", 0); - map.put(key, element, 0); - - Element newElement = new Element(key, "value2", 0); - map.put(key, newElement, 0); - - InOrder inOrder = inOrder(listener); - inOrder.verify(listener).notifyElementRemoved(any(Ehcache.class), eq(element)); - inOrder.verify(listener).notifyElementPut(any(Ehcache.class), eq(newElement)); - } - - @Test - public void putIfAbsentTest() { - String key = "putIfAbsentKey"; - Element element = new Element(key, "someValue", 0); - map.putIfAbsent(key, element, 0); - verify(listener).notifyElementPut(any(Ehcache.class), eq(element)); - reset(listener); - - map.putIfAbsent(key, new Element(key, "otherValue", 0), 0); - verifyZeroInteractions(listener); - } - - @Test - public void removeTest() { - String key = "removeKey"; - Element element = new Element(key, "value", 0); - map.put(key, element, 0); - map.remove(key); - verify(listener).notifyElementRemoved(any(Ehcache.class), eq(element)); - reset(listener); - - map.put(key, element, 0); - map.remove(key, element); - verify(listener).notifyElementRemoved(any(Ehcache.class), eq(element)); - - } -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/util/counter/sampled/SampledRateCounter.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/util/counter/sampled/SampledRateCounter.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/util/counter/sampled/SampledRateCounter.java (revision 0) @@ -1,67 +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.counter.sampled; - -/** - * Interface of a sampled rate counter -- a counter that keeps sampled values of - * rates - * - * @author Abhishek Sanoujam - * @since 1.7 - * - */ -public interface SampledRateCounter extends SampledCounter { - - /** - * Increments the numerator and denominator by the passed values - * - * @param numerator - * @param denominator - */ - void increment(long numerator, long denominator); - - /** - * Decrements the numerator and denominator by the passed values - * - * @param numerator - * @param denominator - */ - void decrement(long numerator, long denominator); - - /** - * Sets the values of the numerator and denominator to the passed values - * - * @param numerator - * @param denominator - */ - void setValue(long numerator, long denominator); - - /** - * Sets the value of the numerator to the passed value - * - * @param newValue - */ - void setNumeratorValue(long newValue); - - /** - * Sets the value of the denominator to the passed value - * - * @param newValue - */ - void setDenominatorValue(long newValue); - -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/hibernate/EhCacheRegionFactoryTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/hibernate/EhCacheRegionFactoryTest.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/hibernate/EhCacheRegionFactoryTest.java (revision 0) @@ -1,70 +0,0 @@ -package net.sf.ehcache.hibernate; - -import static org.hamcrest.CoreMatchers.notNullValue; -import static org.hamcrest.CoreMatchers.nullValue; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.fail; - -import java.lang.reflect.Field; -import java.net.URL; -import java.util.Map; - -import net.sf.ehcache.CacheManager; -import org.hibernate.HibernateException; -import org.hibernate.SessionFactory; -import org.hibernate.cfg.Configuration; -import org.junit.AfterClass; -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 EhCacheRegionFactoryTest { - - private static Configuration config; - - - @BeforeClass - public static void setUp() throws Exception { - System.setProperty("derby.system.home", "target/derby"); - config = new Configuration().configure("/hibernate-config/hibernate.cfg.xml"); - config.setProperty("hibernate.hbm2ddl.auto", "create"); - } - - @Test - public void testLoadingFromOutsideTheClasspath() { - URL resource = Thread.currentThread().getContextClassLoader().getResource("hibernate-config/ehcache.xml"); - config.setProperty("net.sf.ehcache.configurationResourceName", "file://" + resource.getFile()); - SessionFactory sessionFactory = null; - try { - sessionFactory = config.buildSessionFactory(); - } catch (HibernateException e) { - e.printStackTrace(); - fail("This should have succeeded"); - } - assertNotNull("Session factory should have been successfully created!", sessionFactory); - sessionFactory.close(); - } - - @Test - public void testOverwritesCacheManager() throws NoSuchFieldException, IllegalAccessException { - URL resource = Thread.currentThread().getContextClassLoader().getResource("hibernate-config/ehcache.xml"); - config.setProperty("net.sf.ehcache.configurationResourceName", "file://" + resource.getFile()); - config.setProperty("net.sf.ehcache.cacheManagerName", "overwrittenCacheManagerName"); - SessionFactory sessionFactory = config.buildSessionFactory(); - final Field cache_managers_map = CacheManager.class.getDeclaredField("CACHE_MANAGERS_MAP"); - cache_managers_map.setAccessible(true); - assertThat(((Map)cache_managers_map.get(null)).get("tc"), nullValue()); - assertThat(((Map)cache_managers_map.get(null)).get("overwrittenCacheManagerName"), notNullValue()); - sessionFactory.close(); - } - - @AfterClass - public static void tearDown() throws Exception { - } -} Index: rctags/ehcache-2.10.9.1.33/distribution/src/main/assembly/root/licenses/EHCACHE-CORE-LICENSE.txt =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/distribution/src/main/assembly/root/licenses/EHCACHE-CORE-LICENSE.txt (revision 11516) +++ rctags/ehcache-2.10.9.1.33/distribution/src/main/assembly/root/licenses/EHCACHE-CORE-LICENSE.txt (revision 0) @@ -1,15 +0,0 @@ -/** - * Copyright 2003-2010 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. - */ \ No newline at end of file Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/hibernate/strategy/ReadWriteEhcacheEntityRegionAccessStrategy.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/hibernate/strategy/ReadWriteEhcacheEntityRegionAccessStrategy.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/hibernate/strategy/ReadWriteEhcacheEntityRegionAccessStrategy.java (revision 0) @@ -1,113 +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.EhcacheEntityRegion; - -import org.hibernate.cache.CacheException; -import org.hibernate.cache.EntityRegion; -import org.hibernate.cache.access.EntityRegionAccessStrategy; -import org.hibernate.cache.access.SoftLock; -import org.hibernate.cfg.Settings; - -/** - * Ehcache specific read/write entity region access strategy - * - * @author Chris Dennis - */ -public class ReadWriteEhcacheEntityRegionAccessStrategy extends AbstractReadWriteEhcacheAccessStrategy - implements EntityRegionAccessStrategy { - - /** - * Create a read/write access strategy accessing the given entity region. - */ - public ReadWriteEhcacheEntityRegionAccessStrategy(EhcacheEntityRegion region, Settings settings) { - super(region, settings); - } - - /** - * {@inheritDoc} - */ - public EntityRegion getRegion() { - return region; - } - - /** - * A no-op since this is an asynchronous cache access strategy. - */ - public boolean insert(Object key, Object value, Object version) throws CacheException { - return false; - } - - /** - * {@inheritDoc} - *

- * Inserts will only succeed if there is no existing value mapped to this key. - */ - public boolean afterInsert(Object key, Object value, Object version) throws CacheException { - region.writeLock(key); - try { - Lockable item = (Lockable) region.get(key); - if (item == null) { - region.put(key, new Item(value, version, region.nextTimestamp())); - return true; - } else { - return false; - } - } finally { - region.writeUnlock(key); - } - } - - /** - * A no-op since this is an asynchronous cache access strategy. - */ - public boolean update(Object key, Object value, Object currentVersion, Object previousVersion) throws CacheException { - return false; - } - - /** - * {@inheritDoc} - *

- * Updates will only succeed if this entry was locked by this transaction and exclusively this transaction for the - * duration of this transaction. It is important to also note that updates will fail if the soft-lock expired during - * the course of this transaction. - */ - public boolean afterUpdate(Object key, Object value, Object currentVersion, Object previousVersion, SoftLock lock) - throws CacheException { - //what should we do with previousVersion here? - region.writeLock(key); - try { - Lockable item = (Lockable) region.get(key); - - if (item != null && item.isUnlockable(lock)) { - Lock lockItem = (Lock) item; - if (lockItem.wasLockedConcurrently()) { - decrementLock(key, lockItem); - return false; - } else { - region.put(key, new Item(value, currentVersion, region.nextTimestamp())); - return true; - } - } else { - handleMissingLock(key, item); - return false; - } - } finally { - region.writeUnlock(key); - } - } -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/constructs/blocking/BlockingCacheEntryFactory.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/constructs/blocking/BlockingCacheEntryFactory.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/constructs/blocking/BlockingCacheEntryFactory.java (revision 0) @@ -1,69 +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 cache entry factory that blocks until signaled. - *

- * This is useful for writing tests. - * - * @author Greg Luck - * @version $Id: BlockingCacheEntryFactory.java 10789 2018-04-26 02:08:13Z adahanne $ - */ -public class BlockingCacheEntryFactory implements CacheEntryFactory { - - private final Object value; - private int count; - - /** - * Constructs a new object - * - * @param value the factory always creates values equal to this value - */ - public BlockingCacheEntryFactory(final Object value) { - this.value = value; - } - - - /** - * @return number of entries the factory has created. - */ - public int getCount() { - return count; - } - - - /** - * Signals the factory. - */ - public synchronized void signal(final int count) { - this.count += count; - notify(); - } - - /** - * Fetches an entry. - */ - public synchronized Object createEntry(final Object key) throws Exception { - // Wait until signalled - while (count == 0) { - wait(); - } - count--; - return value; - } -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/store/XATransactionalStoreTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/store/XATransactionalStoreTest.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/store/XATransactionalStoreTest.java (revision 0) @@ -1,415 +0,0 @@ -package net.sf.ehcache.store; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import javax.transaction.RollbackException; -import javax.transaction.Transaction; -import javax.transaction.TransactionManager; - -import net.sf.ehcache.Cache; -import net.sf.ehcache.CacheManager; -import net.sf.ehcache.Element; -import net.sf.ehcache.concurrent.CacheLockProvider; -import net.sf.ehcache.concurrent.LockType; -import net.sf.ehcache.config.CacheConfiguration; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.terracotta.test.categories.CheckShorts; - -import bitronix.tm.TransactionManagerServices; -import net.sf.ehcache.config.Configuration; - -/** - * @author Alex Snaps - */ -@Category(CheckShorts.class) -public class XATransactionalStoreTest { - - private TransactionManager transactionManager; - private Cache cach1; - private Cache cache; - private CacheManager cacheManager; - - @Before - public void setup() throws Exception { - TransactionManagerServices.getConfiguration().setServerId("XATransactionalStoreTest").setJournal("null"); - transactionManager = TransactionManagerServices.getTransactionManager(); - - Configuration configuration = new Configuration(); - configuration.cache(new CacheConfiguration("xaCache", 1000).transactionalMode(CacheConfiguration.TransactionalMode.XA_STRICT)); - configuration.cache(new CacheConfiguration("otherXaCache", 1000).transactionalMode(CacheConfiguration.TransactionalMode.XA_STRICT)); - cacheManager = new CacheManager(configuration); - - cache = cacheManager.getCache("xaCache"); - cach1 = cacheManager.getCache("otherXaCache"); - - transactionManager.begin(); - cache.removeAll(); - cach1.removeAll(); - transactionManager.commit(); - } - - @After - public void tearDown() throws Exception { - cacheManager.shutdown(); - TransactionManagerServices.getTransactionManager().shutdown(); - } - - @Test - public void testPutIfAbsent() throws Exception { - transactionManager.begin(); - assertEquals("Cache should be empty to start", 0, cache.getSize()); - assertEquals("Cach1 should be empty to start", 0, cach1.getSize()); - assertNull(cach1.putIfAbsent(new Element("key", "value1"))); - assertNull(cache.putIfAbsent(new Element("key", "value1"))); - Transaction tx1 = transactionManager.suspend(); - transactionManager.begin(); - assertNull(cache.putIfAbsent(new Element("key", "value2"))); - transactionManager.commit(); - transactionManager.resume(tx1); - try { - transactionManager.commit(); - fail("This should have thrown an Exception, as the putIfAbsent should have failed!"); - } catch (RollbackException e) { - // Expected - } - - CacheLockProvider clp = (CacheLockProvider) cache.getInternalContext(); - assertFalse(clp.getSyncForKey("key").isHeldByCurrentThread(LockType.WRITE)); - - transactionManager.begin(); - Element element = cache.get("key"); - assertEquals("value2", element.getValue()); - assertNull(cach1.get("key")); - assertEquals(element, cache.putIfAbsent(new Element("key", "value3"))); - transactionManager.commit(); - - transactionManager.begin(); - element = cache.get("key"); - assertEquals("value2", element.getValue()); - transactionManager.commit(); - - transactionManager.begin(); - cache.put(new Element("key2", "randomValue")); - cache.putIfAbsent(new Element("key2", "notThere!")); - assertEquals("randomValue", cache.get("key2").getValue()); - transactionManager.commit(); - - transactionManager.begin(); - assertEquals("randomValue", cache.get("key2").getValue()); - transactionManager.commit(); - - transactionManager.begin(); - cach1.remove("key2"); - cache.remove("key2"); - cache.putIfAbsent(new Element("key2", "nowThere!")); - assertEquals("nowThere!", cache.get("key2").getValue()); - transactionManager.commit(); - - transactionManager.begin(); - assertEquals("nowThere!", cache.get("key2").getValue()); - transactionManager.commit(); - - transactionManager.begin(); - cache.remove("key2"); - cache.putIfAbsent(new Element("key2", "nowThere!")); - assertEquals("nowThere!", cache.get("key2").getValue()); - Transaction tx2 = transactionManager.suspend(); - - transactionManager.begin(); - assertEquals("nowThere!", cache.get("key2").getValue()); - cache.put(new Element("key2", "newValue")); - transactionManager.commit(); - - transactionManager.resume(tx2); - cach1.put(new Element("fake", "entry")); - try { - transactionManager.commit(); - fail("This should have thrown an Exception!"); - } catch (RollbackException e) { - // Expected - } - - transactionManager.begin(); - assertEquals("newValue", cache.get("key2").getValue()); - transactionManager.commit(); - } - - @Test - public void testRemoveElement() throws Exception { - transactionManager.begin(); - assertEquals("Cache should be empty to start", 0, cache.getSize()); - assertEquals("Cach1 should be empty to start", 0, cach1.getSize()); - assertFalse(cache.removeElement(new Element("blah", "someValue"))); - cache.put(new Element("blah", "value")); - assertFalse(cache.removeElement(new Element("blah", "someValue"))); - transactionManager.commit(); - transactionManager.begin(); - assertNotNull(cache.get("blah")); - assertTrue(cache.removeElement(new Element("blah", "value"))); - transactionManager.commit(); - transactionManager.begin(); - assertNull(cache.get("blah")); - transactionManager.commit(); - - transactionManager.begin(); - cache.put(new Element("key", "value")); - transactionManager.commit(); - transactionManager.begin(); - cach1.put(new Element("random", "things")); - cache.removeElement(new Element("key", "value")); - Transaction tx1 = transactionManager.suspend(); - transactionManager.begin(); - assertTrue(cache.removeElement(new Element("key", "value"))); - transactionManager.commit(); - transactionManager.resume(tx1); - try { - transactionManager.commit(); - fail("Transaction should have failed, element is deleted already"); - } catch (RollbackException e) { - // Expected - } - transactionManager.begin(); - assertNull(cache.get("key")); - transactionManager.commit(); - - transactionManager.begin(); - cache.put(new Element("key", "value")); - transactionManager.commit(); - transactionManager.begin(); - cach1.put(new Element("random", "things")); - cache.removeElement(new Element("key", "value")); - tx1 = transactionManager.suspend(); - transactionManager.begin(); - cache.put(new Element("key", "newValue")); - transactionManager.commit(); - transactionManager.resume(tx1); - try { - transactionManager.commit(); - fail("Transaction should have failed, element has changed in the meantime!"); - } catch (RollbackException e) { - // Expected - } - transactionManager.begin(); - assertNotNull(cache.get("key")); - assertEquals("newValue", cache.get("key").getValue()); - transactionManager.commit(); - } - - @Test - public void testReplace() throws Exception { - transactionManager.begin(); - assertEquals("Cache should be empty to start", 0, cache.getSize()); - assertEquals("Cach1 should be empty to start", 0, cach1.getSize()); - assertNull(cache.replace(new Element("blah", "someValue"))); - cache.put(new Element("blah", "value")); - assertNotNull(cache.replace(new Element("blah", "someValue"))); - transactionManager.commit(); - transactionManager.begin(); - assertNotNull(cache.get("blah")); - assertEquals("someValue", cache.get("blah").getValue()); - transactionManager.commit(); - - transactionManager.begin(); - cache.put(new Element("key", "value")); - transactionManager.commit(); - transactionManager.begin(); - cach1.put(new Element("random", "things")); - cache.replace(new Element("key", "newValue")); - Transaction tx1 = transactionManager.suspend(); - transactionManager.begin(); - cache.remove("key"); - transactionManager.commit(); - transactionManager.resume(tx1); - try { - transactionManager.commit(); - fail("Transaction should have failed, element is deleted already"); - } catch (RollbackException e) { - // Expected - } - transactionManager.begin(); - assertNull(cache.get("key")); - transactionManager.commit(); - - transactionManager.begin(); - cache.put(new Element("key", "value")); - transactionManager.commit(); - transactionManager.begin(); - cach1.put(new Element("random", "things")); - cache.replace(new Element("key", "newValue")); - tx1 = transactionManager.suspend(); - transactionManager.begin(); - cache.put(new Element("key", "allNewValue")); - transactionManager.commit(); - transactionManager.resume(tx1); - try { - transactionManager.commit(); - fail("Transaction should have failed, element is deleted already"); - } catch (RollbackException e) { - // Expected - } - transactionManager.begin(); - assertNotNull(cache.get("key")); - assertNotNull("allNewValue", cache.get("key").getValue()); - transactionManager.commit(); - - transactionManager.begin(); - cache.put(new Element("key", "value")); - transactionManager.commit(); - transactionManager.begin(); - cach1.put(new Element("random", "things")); - cache.replace(new Element("key", "newValue")); - tx1 = transactionManager.suspend(); - transactionManager.begin(); - cache.put(new Element("key", "allNewValue")); - transactionManager.commit(); - transactionManager.resume(tx1); - try { - transactionManager.commit(); - fail("Transaction should have failed, element value has changed"); - } catch (RollbackException e) { - // Expected - } - transactionManager.begin(); - assertNotNull(cache.get("key")); - assertNotNull("allNewValue", cache.get("key").getValue()); - transactionManager.commit(); - - transactionManager.begin(); - cache.put(new Element("key", "value")); - transactionManager.commit(); - transactionManager.begin(); - cach1.put(new Element("random", "things")); - cache.replace(new Element("key", "value")); - tx1 = transactionManager.suspend(); - transactionManager.begin(); - cache.put(new Element("key", "newValue")); - transactionManager.commit(); - transactionManager.resume(tx1); - try { - transactionManager.commit(); - fail("Transaction should have failed, element has changed in the meantime!"); - } catch (RollbackException e) { - // Expected - } - transactionManager.begin(); - assertNotNull(cache.get("key")); - assertEquals("newValue", cache.get("key").getValue()); - transactionManager.commit(); - } - - @Test - public void testReplaceElement() throws Exception { - transactionManager.begin(); - assertEquals("Cache should be empty to start", 0, cache.getSize()); - assertEquals("Cach1 should be empty to start", 0, cach1.getSize()); - assertFalse(cache.replace(new Element("blah", "someValue"), new Element("blah", "someOtherValue"))); - cache.put(new Element("blah", "value")); - assertTrue(cache.replace(new Element("blah", "value"), new Element("blah", "someValue"))); - transactionManager.commit(); - transactionManager.begin(); - assertNotNull(cache.get("blah")); - assertEquals("someValue", cache.get("blah").getValue()); - transactionManager.commit(); - - transactionManager.begin(); - assertEquals("someValue", cache.get("blah").getValue()); - transactionManager.commit(); - - transactionManager.begin(); - cache.put(new Element("key", "value")); - transactionManager.commit(); - transactionManager.begin(); - cach1.put(new Element("random", "things")); - cache.replace(new Element("key", "value"), new Element("key", "newValue")); - Transaction tx1 = transactionManager.suspend(); - transactionManager.begin(); - cache.remove("key"); - transactionManager.commit(); - transactionManager.resume(tx1); - try { - transactionManager.commit(); - fail("Transaction should have failed, element is deleted already"); - } catch (RollbackException e) { - // Expected - } - transactionManager.begin(); - assertNull(cache.get("key")); - transactionManager.commit(); - - transactionManager.begin(); - cache.put(new Element("key", "value")); - transactionManager.commit(); - transactionManager.begin(); - cach1.put(new Element("random", "things")); - assertFalse(cache.replace(new Element("key", "wrongValue"), new Element("key", "newValue"))); - assertTrue(cache.replace(new Element("key", "value"), new Element("key", "newValue"))); - tx1 = transactionManager.suspend(); - transactionManager.begin(); - cache.put(new Element("key", "allNewValue")); - transactionManager.commit(); - transactionManager.resume(tx1); - try { - transactionManager.commit(); - fail("Transaction should have failed, element's value has changed"); - } catch (RollbackException e) { - // Expected - } - transactionManager.begin(); - assertNotNull(cache.get("key")); - assertNotNull("allNewValue", cache.get("key").getValue()); - transactionManager.commit(); - - transactionManager.begin(); - cache.put(new Element("key", "value")); - transactionManager.commit(); - transactionManager.begin(); - cach1.put(new Element("random", "things")); - cache.replace(new Element("key", "value"), new Element("key", "newValue")); - tx1 = transactionManager.suspend(); - transactionManager.begin(); - cache.put(new Element("key", "allNewValue")); - transactionManager.commit(); - transactionManager.resume(tx1); - try { - transactionManager.commit(); - fail("Transaction should have failed, element is deleted already"); - } catch (RollbackException e) { - // Expected - } - transactionManager.begin(); - assertNotNull(cache.get("key")); - assertNotNull("allNewValue", cache.get("key").getValue()); - transactionManager.commit(); - - transactionManager.begin(); - cache.put(new Element("key", "value")); - transactionManager.commit(); - transactionManager.begin(); - cach1.put(new Element("random", "things")); - cache.replace(new Element("key", "value"), new Element("key", "wrongValue")); - tx1 = transactionManager.suspend(); - transactionManager.begin(); - cache.put(new Element("key", "newValue")); - transactionManager.commit(); - transactionManager.resume(tx1); - try { - transactionManager.commit(); - fail("Transaction should have failed, element has changed in the meantime!"); - } catch (RollbackException e) { - // Expected - } - transactionManager.begin(); - assertNotNull(cache.get("key")); - assertEquals("newValue", cache.get("key").getValue()); - transactionManager.commit(); - } -} Index: rctags/ehcache-2.10.9.1.33/distribution/events/.settings/org.eclipse.jdt.core.prefs =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/distribution/events/.settings/org.eclipse.jdt.core.prefs (revision 11516) +++ rctags/ehcache-2.10.9.1.33/distribution/events/.settings/org.eclipse.jdt.core.prefs (revision 0) @@ -1,6 +0,0 @@ -#Mon Apr 02 19:16:29 PDT 2012 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.compliance=1.6 -org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.compiler.source=1.6 Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/pool/sizeof/filter/SizeOfFilter.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/pool/sizeof/filter/SizeOfFilter.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/pool/sizeof/filter/SizeOfFilter.java (revision 0) @@ -1,44 +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 java.lang.reflect.Field; -import java.util.Collection; - -/** - * Filter to filter types or fields of object graphs passed to a SizeOf engine - * - * @author Chris Dennis - * @see net.sf.ehcache.pool.sizeof.SizeOf - */ -public interface SizeOfFilter { - - /** - * Returns the fields to walk and measure for a type - * @param klazz the type - * @param fields the fields already "qualified" - * @return the filtered Set - */ - Collection filterFields(Class klazz, Collection fields); - - /** - * Checks whether the type needs to be filtered - * @param klazz the type - * @return true, if to be filtered out - */ - boolean filterClass(Class klazz); -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/config/ConfigurationHelper.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/config/ConfigurationHelper.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/config/ConfigurationHelper.java (revision 0) @@ -1,424 +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 java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.util.Set; - -import net.sf.ehcache.Cache; -import net.sf.ehcache.CacheException; -import net.sf.ehcache.CacheManager; -import net.sf.ehcache.Ehcache; -import net.sf.ehcache.config.CacheConfiguration.CacheDecoratorFactoryConfiguration; -import net.sf.ehcache.constructs.CacheDecoratorFactory; -import net.sf.ehcache.distribution.CacheManagerPeerListener; -import net.sf.ehcache.distribution.CacheManagerPeerListenerFactory; -import net.sf.ehcache.distribution.CacheManagerPeerProvider; -import net.sf.ehcache.distribution.CacheManagerPeerProviderFactory; -import net.sf.ehcache.event.CacheManagerEventListener; -import net.sf.ehcache.event.CacheManagerEventListenerFactory; -import net.sf.ehcache.exceptionhandler.CacheExceptionHandler; -import net.sf.ehcache.exceptionhandler.CacheExceptionHandlerFactory; -import net.sf.ehcache.exceptionhandler.ExceptionHandlingDynamicCacheProxy; -import net.sf.ehcache.util.ClassLoaderUtil; -import net.sf.ehcache.util.PropertyUtil; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * The configuration for ehcache. - *

- * This class can be populated through: - *

    - *
  • introspection by {@link ConfigurationFactory} or - *
  • programmatically - *
- * - * @author Greg Luck - * @version $Id: ConfigurationHelper.java 10789 2018-04-26 02:08:13Z adahanne $ - */ -public final class ConfigurationHelper { - - private static final Logger LOG = LoggerFactory.getLogger(ConfigurationHelper.class.getName()); - - private final Configuration configuration; - private final CacheManager cacheManager; - - private final ClassLoader loader; - - /** - * Only Constructor - * - * @param cacheManager - * @param configuration - */ - public ConfigurationHelper(CacheManager cacheManager, Configuration configuration) { - if (cacheManager == null || configuration == null) { - throw new IllegalArgumentException("Cannot have null parameters"); - } - this.cacheManager = cacheManager; - this.configuration = configuration; - this.loader = configuration.getClassLoader(); - } - - /** - * Tries to create a CacheLoader from the configuration using the factory - * specified. - * - * @return The CacheExceptionHandler, or null if it could not be found. - */ - public static CacheExceptionHandler createCacheExceptionHandler( - CacheConfiguration.CacheExceptionHandlerFactoryConfiguration factoryConfiguration, ClassLoader loader) throws CacheException { - String className = null; - CacheExceptionHandler cacheExceptionHandler = null; - if (factoryConfiguration != null) { - className = factoryConfiguration.getFullyQualifiedClassPath(); - } - if (className == null || className.length() == 0) { - LOG.debug("No CacheExceptionHandlerFactory class specified. Skipping..."); - } else { - CacheExceptionHandlerFactory factory = (CacheExceptionHandlerFactory) - ClassLoaderUtil.createNewInstance(loader, className); - Properties properties = PropertyUtil.parseProperties(factoryConfiguration.getProperties(), - factoryConfiguration.getPropertySeparator()); - return factory.createExceptionHandler(properties); - } - return cacheExceptionHandler; - } - - - /** - * Tries to load the class specified otherwise defaults to null - * - * @return a map of CacheManagerPeerProviders - */ - public Map createCachePeerProviders() { - String className = null; - Map cacheManagerPeerProviders = new HashMap(); - List cachePeerProviderFactoryConfiguration = - configuration.getCacheManagerPeerProviderFactoryConfiguration(); - for (FactoryConfiguration factoryConfiguration : cachePeerProviderFactoryConfiguration) { - - if (factoryConfiguration != null) { - className = factoryConfiguration.getFullyQualifiedClassPath(); - } - if (className == null) { - LOG.debug("No CachePeerProviderFactoryConfiguration specified. Not configuring a CacheManagerPeerProvider."); - return null; - } else { - CacheManagerPeerProviderFactory cacheManagerPeerProviderFactory = - (CacheManagerPeerProviderFactory) - ClassLoaderUtil.createNewInstance(loader, className); - Properties properties = PropertyUtil.parseProperties(factoryConfiguration.getProperties(), - factoryConfiguration.getPropertySeparator()); - CacheManagerPeerProvider cacheManagerPeerProvider = - cacheManagerPeerProviderFactory.createCachePeerProvider(cacheManager, properties); - cacheManagerPeerProviders.put(cacheManagerPeerProvider.getScheme(), cacheManagerPeerProvider); - - } - } - return cacheManagerPeerProviders; - } - - /** - * Tries to load the class specified otherwise defaults to null - */ - public Map createCachePeerListeners() { - String className = null; - Map cacheManagerPeerListeners = new HashMap(); - List cacheManagerPeerListenerFactoryConfigurations = - configuration.getCacheManagerPeerListenerFactoryConfigurations(); - boolean first = true; - for (FactoryConfiguration factoryConfiguration : cacheManagerPeerListenerFactoryConfigurations) { - - if (factoryConfiguration != null) { - className = factoryConfiguration.getFullyQualifiedClassPath(); - } - if (className == null) { - LOG.debug("No CachePeerListenerFactoryConfiguration specified. Not configuring a CacheManagerPeerListener."); - return null; - } else { - CacheManagerPeerListenerFactory cacheManagerPeerListenerFactory = (CacheManagerPeerListenerFactory) - ClassLoaderUtil.createNewInstance(loader, className); - Properties properties = PropertyUtil.parseProperties(factoryConfiguration.getProperties(), - factoryConfiguration.getPropertySeparator()); - CacheManagerPeerListener cacheManagerPeerListener = - cacheManagerPeerListenerFactory.createCachePeerListener(cacheManager, properties); - cacheManagerPeerListeners.put(cacheManagerPeerListener.getScheme(), cacheManagerPeerListener); - } - } - return cacheManagerPeerListeners; - } - - /** - * Tries to load the class specified. - * - * @return If there is none returns null. - * @param cacheManager - */ - public final CacheManagerEventListener createCacheManagerEventListener(CacheManager cacheManager) throws CacheException { - String className = null; - FactoryConfiguration cacheManagerEventListenerFactoryConfiguration = - configuration.getCacheManagerEventListenerFactoryConfiguration(); - if (cacheManagerEventListenerFactoryConfiguration != null) { - className = cacheManagerEventListenerFactoryConfiguration.getFullyQualifiedClassPath(); - } - if (className == null || className.length() == 0) { - LOG.debug("No CacheManagerEventListenerFactory class specified. Skipping..."); - return null; - } else { - CacheManagerEventListenerFactory factory = (CacheManagerEventListenerFactory) - ClassLoaderUtil.createNewInstance(loader, className); - Properties properties = PropertyUtil.parseProperties(cacheManagerEventListenerFactoryConfiguration.properties, - cacheManagerEventListenerFactoryConfiguration.getPropertySeparator()); - return factory.createCacheManagerEventListener(cacheManager, properties); - } - } - - - /** - * @return the disk store path, or null if not set. - */ - public final String getDiskStorePath() { - DiskStoreConfiguration diskStoreConfiguration = configuration.getDiskStoreConfiguration(); - if (diskStoreConfiguration == null) { - return null; - } else { - return diskStoreConfiguration.getPath(); - } - } - - /** - * @return the Default Cache - * @throws net.sf.ehcache.CacheException if there is no default cache - */ - public final Ehcache createDefaultCache() throws CacheException { - CacheConfiguration cacheConfiguration = configuration.getDefaultCacheConfiguration(); - if (cacheConfiguration == null) { - return null; - } else { - cacheConfiguration.name = Cache.DEFAULT_CACHE_NAME; - return createCache(cacheConfiguration); - } - } - - /** - * Creates unitialised caches for each cache configuration found - * - * @return an empty set if there are none, - */ - public final Set createCaches() { - Set caches = new HashSet(); - Set cacheConfigurations = configuration.getCacheConfigurations().entrySet(); - for (Iterator iterator = cacheConfigurations.iterator(); iterator.hasNext();) { - Map.Entry entry = (Map.Entry) iterator.next(); - CacheConfiguration cacheConfiguration = (CacheConfiguration) entry.getValue(); - Ehcache cache = createCache(cacheConfiguration); - caches.add(cache); - } - return caches; - } - - /** - * Calculates the number of caches in the configuration that are diskPersistent - */ - public final int numberOfCachesThatUseDiskStorage() { - int count = 0; - Set cacheConfigurations = configuration.getCacheConfigurations().entrySet(); - for (CacheConfiguration cacheConfig : configuration.getCacheConfigurations().values()) { - if (cacheConfig.isOverflowToDisk() || cacheConfig.isDiskPersistent() || - (cacheConfig.isOverflowToOffHeap() && cacheConfig.isSearchable())) { - count++; - } else { - PersistenceConfiguration persistence = cacheConfig.getPersistenceConfiguration(); - if (persistence != null) { - switch (persistence.getStrategy()) { - case LOCALTEMPSWAP: - case LOCALRESTARTABLE: - count++; - break; - default: - break; - } - } - } - } - return count; - } - - /** - * Creates a cache from configuration where the configuration cache name matches the given name - * - * @return the cache, or null if there is no match - */ - final Ehcache createCacheFromName(String name) { - CacheConfiguration cacheConfiguration = null; - Set cacheConfigurations = configuration.getCacheConfigurations().entrySet(); - for (Iterator iterator = cacheConfigurations.iterator(); iterator.hasNext();) { - Map.Entry entry = (Map.Entry) iterator.next(); - CacheConfiguration cacheConfigurationCandidate = (CacheConfiguration) entry.getValue(); - if (cacheConfigurationCandidate.name.equals(name)) { - cacheConfiguration = cacheConfigurationCandidate; - break; - } - } - if (cacheConfiguration == null) { - return null; - } else { - return createCache(cacheConfiguration); - } - } - - /** - * Create a cache given a cache configuration - * - * @param cacheConfiguration - */ - final Ehcache createCache(CacheConfiguration cacheConfiguration) { - CacheConfiguration configClone = cacheConfiguration.clone(); - - // make sure all caches use the same classloader that the CacheManager is configured to use - configClone.setClassLoader(configuration.getClassLoader()); - - Ehcache cache = new Cache(configClone, null, null); - cache = applyCacheExceptionHandler(configClone, cache); - return cache; - } - - private Ehcache applyCacheExceptionHandler(CacheConfiguration cacheConfiguration, Ehcache cache) { - CacheExceptionHandler cacheExceptionHandler = - createCacheExceptionHandler(cacheConfiguration.getCacheExceptionHandlerFactoryConfiguration(), loader); - cache.setCacheExceptionHandler(cacheExceptionHandler); - - if (cache.getCacheExceptionHandler() != null) { - return ExceptionHandlingDynamicCacheProxy.createProxy(cache); - } - return cache; - } - - /** - * Creates decorated ehcaches for the cache, if any configured in ehcache.xml - * - * @param cache the cache - * @return List of the decorated ehcaches, if any configured in ehcache.xml otherwise returns empty list - */ - public List createCacheDecorators(Ehcache cache) { - CacheConfiguration cacheConfiguration = cache.getCacheConfiguration(); - if (cacheConfiguration == null) { - return createDefaultCacheDecorators(cache, configuration.getDefaultCacheConfiguration(), loader); - } - List cacheDecoratorConfigurations = cacheConfiguration.getCacheDecoratorConfigurations(); - if (cacheDecoratorConfigurations == null || cacheDecoratorConfigurations.size() == 0) { - LOG.debug("CacheDecoratorFactory not configured. Skipping for '" + cache.getName() + "'."); - return createDefaultCacheDecorators(cache, configuration.getDefaultCacheConfiguration(), loader); - } - List result = new ArrayList(); - for (CacheDecoratorFactoryConfiguration factoryConfiguration : cacheDecoratorConfigurations) { - Ehcache decoratedCache = createDecoratedCache(cache, factoryConfiguration, false, loader); - if (decoratedCache != null) { - result.add(decoratedCache); - } - } - for (Ehcache defaultDecoratedCache : createDefaultCacheDecorators(cache, configuration.getDefaultCacheConfiguration(), loader)) { - result.add(defaultDecoratedCache); - } - return result; - } - - /** - * Creates default cache decorators specified in the default cache configuration if any - * @param cache the underlying cache that will be decorated - * @param defaultCacheConfiguration default cache configuration - * @param loader - * @return list of decorated caches - */ - public static List createDefaultCacheDecorators(Ehcache cache, CacheConfiguration defaultCacheConfiguration, ClassLoader loader) { - if (cache == null) { - throw new CacheException("Underlying cache cannot be null when creating decorated caches."); - } - List defaultCacheDecoratorConfigurations = defaultCacheConfiguration == null ? - null : defaultCacheConfiguration.getCacheDecoratorConfigurations(); - if (defaultCacheDecoratorConfigurations == null || defaultCacheDecoratorConfigurations.size() == 0) { - LOG.debug("CacheDecoratorFactory not configured for defaultCache. Skipping for '" + cache.getName() + "'."); - return Collections.emptyList(); - } - List result = new ArrayList(); - Set newCacheNames = new HashSet(); - for (CacheDecoratorFactoryConfiguration factoryConfiguration : defaultCacheDecoratorConfigurations) { - Ehcache decoratedCache = createDecoratedCache(cache, factoryConfiguration, true, loader); - if (decoratedCache != null) { - if (newCacheNames.contains(decoratedCache.getName())) { - throw new InvalidConfigurationException( - "Looks like the defaultCache is configured with multiple CacheDecoratorFactory's " - + "that does not set unique names for newly created caches. Please fix the " - + "CacheDecoratorFactory and/or the config to set unique names for newly created caches."); - } - newCacheNames.add(decoratedCache.getName()); - result.add(decoratedCache); - } - } - return result; - } - - /** - * Creates the decorated cache from the decorator config specified. Returns null if the name of the factory class is not specified - */ - private static Ehcache createDecoratedCache(Ehcache cache, - CacheConfiguration.CacheDecoratorFactoryConfiguration factoryConfiguration, boolean forDefaultCache, ClassLoader loader) { - if (factoryConfiguration == null) { - return null; - } - String className = factoryConfiguration.getFullyQualifiedClassPath(); - if (className == null) { - LOG.debug("CacheDecoratorFactory was specified without the name of the factory. Skipping..."); - return null; - } else { - CacheDecoratorFactory factory = (CacheDecoratorFactory) ClassLoaderUtil.createNewInstance(loader, className); - Properties properties = PropertyUtil.parseProperties(factoryConfiguration.getProperties(), - factoryConfiguration.getPropertySeparator()); - if (forDefaultCache) { - return factory.createDefaultDecoratedEhcache(cache, properties); - } else { - return factory.createDecoratedEhcache(cache, properties); - } - } - } - - /** - * @deprecated internal use only - * @param sa search attribute - * @return attribute type as class - */ - public static Class getSearchAttributeType(SearchAttribute sa, ClassLoader loader) { - return sa.getType(loader); - } - - /** - * @return the Configuration used - */ - public final Configuration getConfigurationBean() { - return configuration; - } -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/config/CacheWriterConfiguration.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/config/CacheWriterConfiguration.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/config/CacheWriterConfiguration.java (revision 0) @@ -1,702 +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 java.util.Collection; - -import net.sf.ehcache.Cache; -import net.sf.ehcache.store.Store; -import net.sf.ehcache.writer.CacheWriterManager; -import net.sf.ehcache.writer.writebehind.WriteBehindManager; -import net.sf.ehcache.writer.writethrough.WriteThroughManager; - -/** - * Class to hold the CacheWriterManager configuration - * - * @author Geert Bevin - * @version $Id: CacheWriterConfiguration.java 10789 2018-04-26 02:08:13Z adahanne $ - */ -public class CacheWriterConfiguration implements Cloneable { - /** - * Default writeMode - */ - public static final WriteMode DEFAULT_WRITE_MODE = WriteMode.WRITE_THROUGH; - /** - * Default notifyListenersOnException behavior - */ - public static final boolean DEFAULT_NOTIFY_LISTENERS_ON_EXCEPTION = false; - /** - * Default minimum write delay - */ - public static final int DEFAULT_MIN_WRITE_DELAY = 1; - /** - * Default maximum write delay - */ - public static final int DEFAULT_MAX_WRITE_DELAY = 1; - /** - * Default rate limit per second - */ - public static final int DEFAULT_RATE_LIMIT_PER_SECOND = 0; - /** - * Default write coalescing behavior - */ - public static final boolean DEFAULT_WRITE_COALESCING = false; - /** - * Default writeBatching behavior - */ - public static final boolean DEFAULT_WRITE_BATCHING = false; - /** - * Default write batch size - */ - public static final int DEFAULT_WRITE_BATCH_SIZE = 1; - /** - * Default retry attempts - */ - public static final int DEFAULT_RETRY_ATTEMPTS = 0; - /** - * Default retry attempt delay - */ - public static final int DEFAULT_RETRY_ATTEMPT_DELAY_SECONDS = 1; - - /** - * Default concurrency level for write behind - */ - public static final int DEFAULT_WRITE_BEHIND_CONCURRENCY = 1; - - /** - * Default max queue size for write behind - */ - public static final int DEFAULT_WRITE_BEHIND_MAX_QUEUE_SIZE = 0; - - /** - * Represents how elements are written to the {@link net.sf.ehcache.writer.CacheWriter} - */ - public static enum WriteMode { - /** - * Write mode enum constant that can be used to configure a cache writer to use write through - */ - WRITE_THROUGH { - /** - * {@inheritDoc} - */ - @Override - public CacheWriterManager createWriterManager(Cache cache, Store store) { - return new WriteThroughManager(); - } - }, - - /** - * Write mode enum constant that can be used to configure a cache writer to use write behind - */ - WRITE_BEHIND { - /** - * {@inheritDoc} - */ - @Override - public CacheWriterManager createWriterManager(Cache cache, Store store) { - return new WriteBehindManager(cache, store); - } - }; - - /** - * Create a new {@code WriterManager} for a particular cache instance - * - * @param cache the cache instance for which the {@code WriterManager} should be created - * @return the newly created {@code WriterManager} - */ - public abstract CacheWriterManager createWriterManager(Cache cache, Store store); - } - - private WriteMode writeMode = DEFAULT_WRITE_MODE; - private boolean notifyListenersOnException = DEFAULT_NOTIFY_LISTENERS_ON_EXCEPTION; - private int minWriteDelay = DEFAULT_MIN_WRITE_DELAY; - private int maxWriteDelay = DEFAULT_MAX_WRITE_DELAY; - private int rateLimitPerSecond = DEFAULT_RATE_LIMIT_PER_SECOND; - private boolean writeCoalescing = DEFAULT_WRITE_COALESCING; - private boolean writeBatching = DEFAULT_WRITE_BATCHING; - private int writeBatchSize = DEFAULT_WRITE_BATCH_SIZE; - private int retryAttempts = DEFAULT_RETRY_ATTEMPTS; - private int retryAttemptDelaySeconds = DEFAULT_RETRY_ATTEMPT_DELAY_SECONDS; - private int writeBehindConcurrency = DEFAULT_WRITE_BEHIND_CONCURRENCY; - private int writeBehindMaxQueueSize = DEFAULT_WRITE_BEHIND_MAX_QUEUE_SIZE; - private CacheWriterFactoryConfiguration cacheWriterFactoryConfiguration; - - /** - * Clones this object, following the usual contract. - * - * @return a copy, which independent other than configurations than cannot change. - */ - @Override - public CacheWriterConfiguration clone() { - CacheWriterConfiguration config; - try { - config = (CacheWriterConfiguration) super.clone(); - } catch (CloneNotSupportedException e) { - throw new RuntimeException(e); - } - - if (cacheWriterFactoryConfiguration != null) { - config.cacheWriterFactoryConfiguration = cacheWriterFactoryConfiguration.clone(); - } - - return config; - } - - /** - * Converts the {@code writeMode} string argument to uppercase and looks up enum constant in WriteMode. - */ - public void setWriteMode(String writeMode) { - if (writeMode == null) { - throw new IllegalArgumentException("WriteMode can't be null"); - } - this.writeMode = WriteMode.valueOf(WriteMode.class, writeMode.replace('-', '_').toUpperCase()); - } - - /** - * @return this configuration instance - * @see #setWriteMode(String) - */ - public CacheWriterConfiguration writeMode(String writeMode) { - setWriteMode(writeMode); - return this; - } - - /** - * @return this configuration instance - * @see #setWriteMode(String) - */ - public CacheWriterConfiguration writeMode(WriteMode writeMode) { - if (null == writeMode) { - throw new IllegalArgumentException("WriteMode can't be null"); - } - this.writeMode = writeMode; - return this; - } - - /** - * Get the write mode in terms of the mode enum - */ - public WriteMode getWriteMode() { - return this.writeMode; - } - - /** - * Sets whether to notify listeners when an exception occurs on a writer operation. - *

- * This is only applicable to write through mode. - *

- * Defaults to {@value #DEFAULT_NOTIFY_LISTENERS_ON_EXCEPTION}. - * - * @param notifyListenersOnException {@code true} if listeners should be notified when an exception occurs on a writer operation; {@code false} otherwise - */ - public void setNotifyListenersOnException(boolean notifyListenersOnException) { - this.notifyListenersOnException = notifyListenersOnException; - } - - /** - * @return this configuration instance - * @see #setNotifyListenersOnException(boolean) - */ - public CacheWriterConfiguration notifyListenersOnException(boolean notifyListenersOnException) { - setNotifyListenersOnException(notifyListenersOnException); - return this; - } - - /** - * Check whether listeners should be notified when an exception occurs on a writer operation - */ - public boolean getNotifyListenersOnException() { - return this.notifyListenersOnException; - } - - /** - * Set the minimum number of seconds to wait before writing behind. If set to a value greater than 0, it permits - * operations to build up in the queue. This is different from the maximum write delay in that by waiting a minimum - * amount of time, work is always being built up. If the minimum write delay is set to zero and the {@code CacheWriter} - * performs its work very quickly, the overhead of processing the write behind queue items becomes very noticeable - * in a cluster since all the operations might be done for individual items instead of for a collection of them. - *

- * This is only applicable to write behind mode. - *

- * Defaults to {@value #DEFAULT_MIN_WRITE_DELAY}). - * - * @param minWriteDelay the minimum number of seconds to wait before writing behind - */ - public void setMinWriteDelay(int minWriteDelay) { - if (minWriteDelay < 0) { - this.minWriteDelay = 0; - } else { - this.minWriteDelay = minWriteDelay; - } - } - - /** - * @return this configuration instance - * @see #setMinWriteDelay(int) - */ - public CacheWriterConfiguration minWriteDelay(int minWriteDelay) { - setMinWriteDelay(minWriteDelay); - return this; - } - - /** - * Get the minimum number of seconds to wait before writing behind - */ - public int getMinWriteDelay() { - return this.minWriteDelay; - } - - /** - * Set the maximum number of seconds to wait before writing behind. If set to a value greater than 0, it permits - * operations to build up in the queue to enable effective coalescing and batching optimisations. - *

- * This is only applicable to write behind mode. - *

- * Defaults to {@value #DEFAULT_MAX_WRITE_DELAY}). - * - * @param maxWriteDelay the maximum number of seconds to wait before writing behind - */ - public void setMaxWriteDelay(int maxWriteDelay) { - if (maxWriteDelay < 0) { - this.maxWriteDelay = 0; - } else { - this.maxWriteDelay = maxWriteDelay; - } - } - - /** - * @return this configuration instance - * @see #setMaxWriteDelay(int) - */ - public CacheWriterConfiguration maxWriteDelay(int maxWriteDelay) { - setMaxWriteDelay(maxWriteDelay); - return this; - } - - /** - * Get the maximum number of seconds to wait before writing behind - */ - public int getMaxWriteDelay() { - return this.maxWriteDelay; - } - - /** - * Sets the maximum number of write operations to allow per second when {@link #writeBatching} is enabled. - *

- * This is only applicable to write behind mode. - *

- * Defaults to {@value #DEFAULT_RATE_LIMIT_PER_SECOND}. - * - * @param rateLimitPerSecond the number of write operations to allow; use a number {@code <=0} to disable rate limiting. - */ - public void setRateLimitPerSecond(int rateLimitPerSecond) { - if (rateLimitPerSecond < 0) { - this.rateLimitPerSecond = 0; - } else { - this.rateLimitPerSecond = rateLimitPerSecond; - } - } - - /** - * @return this configuration instance - * @see #setRateLimitPerSecond(int rateLimitPerSecond) - */ - public CacheWriterConfiguration rateLimitPerSecond(int rateLimitPerSecond) { - setRateLimitPerSecond(rateLimitPerSecond); - return this; - } - - /** - * Get the maximum number of write operations to allow per second. - */ - public int getRateLimitPerSecond() { - return rateLimitPerSecond; - } - - /** - * Sets whether to use write coalescing. If set to {@code true} and multiple operations on the same key are present - * in the write-behind queue, only the latest write is done, as the others are redundant. This can dramatically - * reduce load on the underlying resource. - *

- * This is only applicable to write behind mode. - *

- * Defaults to {@value #DEFAULT_WRITE_COALESCING}. - * - * @param writeCoalescing {@code true} to enable write coalescing; or {@code false} to disable it - */ - public void setWriteCoalescing(boolean writeCoalescing) { - this.writeCoalescing = writeCoalescing; - } - - /** - * @return this configuration instance - * @see #setWriteCoalescing(boolean) - */ - public CacheWriterConfiguration writeCoalescing(boolean writeCoalescing) { - setWriteCoalescing(writeCoalescing); - return this; - } - - /** - * @return this configuration instance - * @see #setWriteCoalescing(boolean) - */ - public boolean getWriteCoalescing() { - return writeCoalescing; - } - - /** - * Sets whether to batch write operations. If set to {@code true}, {@link net.sf.ehcache.writer.CacheWriter#writeAll} and {@code CacheWriter#deleteAll} - * will be called rather than {@link net.sf.ehcache.writer.CacheWriter#write} and {@link net.sf.ehcache.writer.CacheWriter#delete} being called for each key. Resources such - * as databases can perform more efficiently if updates are batched, thus reducing load. - *

- * This is only applicable to write behind mode. - *

- * Defaults to {@value #DEFAULT_WRITE_BATCHING}. - * - * @param writeBatching {@code true} if write operations should be batched; {@code false} otherwise - */ - public void setWriteBatching(boolean writeBatching) { - this.writeBatching = writeBatching; - } - - /** - * @return this configuration instance - * @see #setWriteBatching(boolean) - */ - public CacheWriterConfiguration writeBatching(boolean writeBatching) { - setWriteBatching(writeBatching); - return this; - } - - /** - * Check whether write operations should be batched - */ - public boolean getWriteBatching() { - return this.writeBatching; - } - - /** - * Sets the number of operations to include in each batch when {@link #writeBatching} is enabled. If there are less - * entries in the write-behind queue than the batch size, the queue length size is used. - *

- * This is only applicable to write behind mode. - *

- * Defaults to {@value #DEFAULT_WRITE_BATCH_SIZE}. - * - * @param writeBatchSize the number of operations to include in each batch; numbers smaller than {@code 1} will cause - * the default batch size to be used - */ - public void setWriteBatchSize(int writeBatchSize) { - if (writeBatchSize < 1) { - this.writeBatchSize = DEFAULT_WRITE_BATCH_SIZE; - } else { - this.writeBatchSize = writeBatchSize; - } - } - - /** - * @return this configuration instance - * @see #setWriteBatchSize(int) - */ - public CacheWriterConfiguration writeBatchSize(int writeBatchSize) { - setWriteBatchSize(writeBatchSize); - return this; - } - - /** - * Retrieves the size of the batch operation. - */ - public int getWriteBatchSize() { - return writeBatchSize; - } - - /** - * Sets the number of times the operation is retried in the {@code CacheWriter}, this happens after the - * original operation. - *

- * This is only applicable to write behind mode. - *

- * Defaults to {@value #DEFAULT_RETRY_ATTEMPTS}. - * - * @param retryAttempts the number of retries for a particular element - */ - public void setRetryAttempts(int retryAttempts) { - if (retryAttempts < 0) { - this.retryAttempts = 0; - } else { - this.retryAttempts = retryAttempts; - } - } - - /** - * @return this configuration instance - * @see #setRetryAttempts(int) - */ - public CacheWriterConfiguration retryAttempts(int retryAttempts) { - setRetryAttempts(retryAttempts); - return this; - } - - /** - * Retrieves the number of times the write of element is retried. - */ - public int getRetryAttempts() { - return retryAttempts; - } - - /** - * Sets the number of seconds to wait before retrying an failed operation. - *

- * This is only applicable to write behind mode. - *

- * Defaults to {@value #DEFAULT_RETRY_ATTEMPT_DELAY_SECONDS}. - * - * @param retryAttemptDelaySeconds the number of seconds to wait before retrying an operation - */ - public void setRetryAttemptDelaySeconds(int retryAttemptDelaySeconds) { - if (retryAttemptDelaySeconds < 0) { - this.retryAttemptDelaySeconds = 0; - } else { - this.retryAttemptDelaySeconds = retryAttemptDelaySeconds; - } - } - - /** - * @return this configuration instance - * @see #setRetryAttemptDelaySeconds(int) - */ - public CacheWriterConfiguration retryAttemptDelaySeconds(int retryAttemptDelaySeconds) { - setRetryAttemptDelaySeconds(retryAttemptDelaySeconds); - return this; - } - - /** - * Retrieves the number of seconds to wait before retrying an failed operation. - */ - public int getRetryAttemptDelaySeconds() { - return retryAttemptDelaySeconds; - } - - /** - * Configuration for the CacheWriterFactoryConfiguration. - */ - public static final class CacheWriterFactoryConfiguration extends FactoryConfiguration { - - /** - * Overrided hashCode() - */ - @Override - public int hashCode() { - return super.hashCode(); - } - - /** - * Overrided equals - */ - @Override - public boolean equals(Object obj) { - return super.equals(obj); - } - } - - /** - * Allows BeanHandler to add the CacheWriterFactory to the configuration. - */ - public final void addCacheWriterFactory(CacheWriterFactoryConfiguration cacheWriterFactoryConfiguration) { - this.cacheWriterFactoryConfiguration = cacheWriterFactoryConfiguration; - } - - /** - * @return this configuration instance - * @see #addCacheWriterFactory(CacheWriterFactoryConfiguration) - */ - public CacheWriterConfiguration cacheWriterFactory(CacheWriterFactoryConfiguration cacheWriterFactory) { - addCacheWriterFactory(cacheWriterFactory); - return this; - } - - /** - * Accessor - * - * @return the configuration - */ - public CacheWriterFactoryConfiguration getCacheWriterFactoryConfiguration() { - return cacheWriterFactoryConfiguration; - } - - /** - * Configures the amount of thread/bucket pairs WriteBehind should use - * @param concurrency Amount of thread/bucket pairs, has to be at least 1 - */ - public void setWriteBehindConcurrency(int concurrency) { - if (concurrency < 1) { - this.writeBehindConcurrency = 1; - } else { - this.writeBehindConcurrency = concurrency; - } - } - - /** - * - * @param concurrency Amount of thread/bucket pairs, has to be at least 1 - * @return this configuration instance - * @see #setWriteBehindConcurrency(int) - */ - public CacheWriterConfiguration writeBehindConcurrency(int concurrency) { - this.setWriteBehindConcurrency(concurrency); - return this; - } - - /** - * Accessor - * @return the amount of bucket/thread pairs configured for this cache's write behind - */ - public int getWriteBehindConcurrency() { - return writeBehindConcurrency; - } - - /** - * Configures the maximum amount of operations to be on the waiting queue, before it blocks - * @param writeBehindMaxQueueSize maximum amount of operations allowed on the waiting queue - */ - public void setWriteBehindMaxQueueSize(final int writeBehindMaxQueueSize) { - if (writeBehindMaxQueueSize < 0) { - this.writeBehindMaxQueueSize = DEFAULT_WRITE_BEHIND_MAX_QUEUE_SIZE; - } else { - this.writeBehindMaxQueueSize = writeBehindMaxQueueSize; - } - } - - /** - * Accessor - * @return the maximum amount of operations allowed on the write behind queue - */ - public int getWriteBehindMaxQueueSize() { - return writeBehindMaxQueueSize; - } - - /** - * @param writeBehindMaxQueueSize maximum amount of operations allowed on the waiting queue - * @return this configuration instance - * @see #setWriteBehindMaxQueueSize(int) - */ - public CacheWriterConfiguration writeBehindMaxQueueSize(int writeBehindMaxQueueSize) { - this.setWriteBehindMaxQueueSize(writeBehindMaxQueueSize); - return this; - } - - /** - * Overrided hashCode() - */ - @Override - public int hashCode() { - final int prime = 31; - final int primeTwo = 1231; - final int primeThree = 1237; - int result = 1; - result = prime * result + ((cacheWriterFactoryConfiguration == null) ? 0 : cacheWriterFactoryConfiguration.hashCode()); - result = prime * result + maxWriteDelay; - result = prime * result + minWriteDelay; - result = prime * result + (notifyListenersOnException ? primeTwo : primeThree); - result = prime * result + rateLimitPerSecond; - result = prime * result + retryAttemptDelaySeconds; - result = prime * result + retryAttempts; - result = prime * result + writeBatchSize; - result = prime * result + (writeBatching ? primeTwo : primeThree); - result = prime * result + (writeCoalescing ? primeTwo : primeThree); - result = prime * result + ((writeMode == null) ? 0 : writeMode.hashCode()); - result = prime * result + writeBehindConcurrency; - return result; - } - - /** - * Overrided equals() - */ - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - CacheWriterConfiguration other = (CacheWriterConfiguration) obj; - if (cacheWriterFactoryConfiguration == null) { - if (other.cacheWriterFactoryConfiguration != null) { - return false; - } - } else if (!cacheWriterFactoryConfiguration.equals(other.cacheWriterFactoryConfiguration)) { - return false; - } - if (maxWriteDelay != other.maxWriteDelay) { - return false; - } - if (minWriteDelay != other.minWriteDelay) { - return false; - } - if (notifyListenersOnException != other.notifyListenersOnException) { - return false; - } - if (rateLimitPerSecond != other.rateLimitPerSecond) { - return false; - } - if (retryAttemptDelaySeconds != other.retryAttemptDelaySeconds) { - return false; - } - if (retryAttempts != other.retryAttempts) { - return false; - } - if (writeBatchSize != other.writeBatchSize) { - return false; - } - if (writeBatching != other.writeBatching) { - return false; - } - if (writeCoalescing != other.writeCoalescing) { - return false; - } - if (writeBehindConcurrency != other.writeBehindConcurrency) { - return false; - } - if (writeMode == null) { - if (other.writeMode != null) { - return false; - } - } else if (!writeMode.equals(other.writeMode)) { - return false; - } - return true; - } - - - /** - * Check for errors/inconsistencies in this configuration. Add any erros found as - * {@link ConfigError} in the errors collection. - * @param errors collection to add errors to. - */ - public void validate(Collection errors) { - if (writeMode.equals(WriteMode.WRITE_BEHIND)) { - if (!getWriteBatching() && getWriteBatchSize() != 1) { - errors.add(new ConfigError("Configured Write Batch Size is not equal to 1 with Write Batching turned off.")); - } - } - } -} Index: rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/net/sf/ehcache/terracotta/BootstrapCacheTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/net/sf/ehcache/terracotta/BootstrapCacheTest.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/net/sf/ehcache/terracotta/BootstrapCacheTest.java (revision 0) @@ -1,179 +0,0 @@ -/* - * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved. - */ -package net.sf.ehcache.terracotta; - -import net.sf.ehcache.Cache; -import net.sf.ehcache.CacheManager; -import net.sf.ehcache.CacheStoreHelper; -import net.sf.ehcache.Element; -import net.sf.ehcache.config.CacheConfiguration; -import net.sf.ehcache.config.Configuration; -import net.sf.ehcache.config.TerracottaClientConfiguration; -import net.sf.ehcache.config.TerracottaConfiguration; -import net.sf.ehcache.store.Store; -import net.sf.ehcache.store.TerracottaStore; - -import org.terracotta.ehcache.tests.AbstractCacheTestBase; -import org.terracotta.ehcache.tests.ClientBase; -import org.terracotta.test.util.WaitUtil; -import org.terracotta.toolkit.Toolkit; - -import com.tc.test.config.model.TestConfig; - -import java.util.Collection; -import java.util.Date; -import java.util.Set; -import java.util.concurrent.Callable; -import java.util.concurrent.CyclicBarrier; - -import junit.framework.Assert; - -/** - * @author Alex Snaps - */ -public class BootstrapCacheTest extends AbstractCacheTestBase { - - private static final int NODE_COUNT = 3; - - private static final int ELEMENTS_PER_NODE = 10; - - public BootstrapCacheTest(TestConfig testConfig) { - super(testConfig, App.class, App.class, App.class); - } - - public static class App extends ClientBase { - - public App(String[] args) { - super(args); - } - - public static void main(String[] args) { - new App(args).run(); - } - - @Override - public void doTest() throws Exception { - final int index = getBarrierForAllClients().await(); - - Assert.assertEquals(0, KeySnapshotter.getKnownCacheManagers().size()); - cacheManager = createCacheManager(index); - getBarrierForAllClients().await(); - Cache cache = cacheManager.getCache("test"); - final KeySnapshotter snapshotter = ((TerracottaBootstrapCacheLoader) cache.getBootstrapCacheLoader()) - .getKeySnapshotter(); - final CyclicBarrier waitSnapshot = new CyclicBarrier(2); - snapshotter.setOnSnapshot(new Runnable() { - @Override - public void run() { - try { - waitSnapshot.await(); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - }); - - getBarrierForAllClients().await(); - waitSnapshot.await(); // WRITING NOTHING TO DISK - for (int i = 0; i < ELEMENTS_PER_NODE; i++) { - cache.put(new Element("key" + i + "_node" + index, "value for key")); - } - System.out.println(new Date() + " ==> node" + index + " put 10 elements in the cache"); - getBarrierForAllClients().await(); - - if (index == 0) { - Assert.assertEquals(ELEMENTS_PER_NODE * NODE_COUNT, cache.getSize()); - } - Assert.assertEquals(1, KeySnapshotter.getKnownCacheManagers().size()); - Assert.assertEquals(true, KeySnapshotter.getKnownCacheManagers().contains(cacheManager)); - waitSnapshot.await(); // WRITING THE LOCAL KEY SET TO DISK - System.out.println(new Date() + " ==> node" + index + " CacheManager shutdown1..."); - cacheManager.shutdown(); // IMMEDIATE SHUTDOWN - getBarrierForAllClients().await(); - cacheManager = createCacheManager(index); - cache = cacheManager.getCache("test"); - - final KeySnapshotter keySnapshotter = ((TerracottaBootstrapCacheLoader) cache.getBootstrapCacheLoader()) - .getKeySnapshotter(); - keySnapshotter.doSnapshot(); - - final Store store = new CacheStoreHelper(cache).getStore(); - final Set localKeys = ((TerracottaStore) store).getLocalKeys(); - for (Object localKey : localKeys) { - final String key = (String) localKey; - Assert.assertEquals("_node" + index, key.substring(key.indexOf("_"), key.length())); - } - Assert.assertEquals("For node" + index, ELEMENTS_PER_NODE, localKeys.size()); - getBarrierForAllClients().await(); - gc(); - getBarrierForAllClients().await(); - - WaitUtil.waitUntilCallableReturnsTrue(new Callable() { - @Override - public Boolean call() throws Exception { - gc(); - Collection knownCacheManagers = KeySnapshotter.getKnownCacheManagers(); - System.out.println("Known cacheMnaagers: " + knownCacheManagers.size()); - for (CacheManager cm : knownCacheManagers) { - System.out.println(" name: " + cm.getName()); - } - return knownCacheManagers.size() == 1; - } - }); - Assert.assertEquals("For node " + index, true, KeySnapshotter.getKnownCacheManagers().contains(cacheManager)); - getBarrierForAllClients().await(); - cacheManager.shutdown(); - System.out.println(new Date() + " ==> node" + index + " CacheManager shutdown2..."); - pass(); - } - - private void gc() throws InterruptedException { - for (int i = 0; i < 20; i++) { - System.gc(); - } - Thread.sleep(2000); - for (int i = 0; i < 20; i++) { - System.gc(); - } - } - - @Override - protected CacheManager getCacheManager() { - - return null; - } - - protected CacheManager createCacheManager(final int index) { - - final Configuration configuration = new Configuration().name("bootstrap-cache-test"); - TerracottaClientConfiguration tcConfiguration = new TerracottaClientConfiguration(); - tcConfiguration.setUrl(getTerracottaUrl()); - tcConfiguration.setRejoin(true); - configuration.addTerracottaConfig(tcConfiguration); - - configuration - .addCache(new CacheConfiguration("test", 20) - .eternal(true) - .terracotta(new TerracottaConfiguration().clustered(true) - .consistency(TerracottaConfiguration.Consistency.STRONG)) - .bootstrapCacheLoaderFactory(new CacheConfiguration.BootstrapCacheLoaderFactoryConfiguration() - .className(net.sf.ehcache.terracotta.TerracottaBootstrapCacheLoaderFactory.class - .getName()) - .properties("bootstrapAsynchronously=false" + ",directory=dumps_node" - + index + ",interval=15" + ",immediateShutdown=true" - + ",doKeySnapshot=true" - + ",doKeySnapshotOnDedicatedThread=false") - .propertySeparator(","))); - return new CacheManager(configuration); - } - - @Override - protected void runTest(Cache cache, Toolkit clusteringToolkit) { - // Added to fix compilation error. This will never get called for this test as it overrides the run method of - // ClientBase. - } - - } - -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/CachePinningTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/CachePinningTest.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/CachePinningTest.java (revision 0) @@ -1,147 +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 static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.notNullValue; -import static org.hamcrest.Matchers.nullValue; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertThat; - -import java.util.List; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.Future; - -import junit.framework.Assert; -import net.sf.ehcache.config.CacheConfiguration; -import net.sf.ehcache.config.Configuration; -import net.sf.ehcache.config.DiskStoreConfiguration; -import net.sf.ehcache.config.PinningConfiguration; -import net.sf.ehcache.store.disk.DiskStoreHelper; - -import org.hamcrest.Matchers; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -/** - * Tests for Cache pinning - * - * @author Ludovic Orban - */ -public class CachePinningTest { - - private static final int ELEMENT_COUNT = 4000; - - private CacheManager cacheManager; - - @Before - public void setUp() throws Exception { - cacheManager = new CacheManager( - new Configuration() - .diskStore(new DiskStoreConfiguration().path("java.io.tmpdir/CachePinningTest")) - ); - } - - @After - public void tearDown() { - cacheManager.shutdown(); - cacheManager = null; - } - - @Test - public void testClassicLru() throws Exception { - System.setProperty(Cache.NET_SF_EHCACHE_USE_CLASSIC_LRU, "true"); - try { - testMemoryOnly(); - } finally { - System.setProperty(Cache.NET_SF_EHCACHE_USE_CLASSIC_LRU, "false"); - } - } - - @Test - public void testMemoryOnly() throws Exception { - cacheManager.addCache(new Cache( - new CacheConfiguration() - .maxEntriesLocalHeap(10) - .name("memoryOnlyCache_inCache") - .pinning(new PinningConfiguration().store(PinningConfiguration.Store.INCACHE)) - )); - doAssertions(cacheManager.getCache("memoryOnlyCache_inCache"), ELEMENT_COUNT, 0); - } - - @Test - public void testOverflowToDisk() throws Exception { - cacheManager.addCache(new Cache( - new CacheConfiguration() - .maxEntriesLocalHeap(10) - .maxElementsOnDisk(20) - .overflowToDisk(true) - .name("overflowToDiskCache_inCache") - .pinning(new PinningConfiguration().store(PinningConfiguration.Store.INCACHE)) - )); - doAssertions(cacheManager.getCache("overflowToDiskCache_inCache"), 10, ELEMENT_COUNT - 10); - } - - @Test - public void testDiskPersistent() throws Exception { - cacheManager.addCache(new Cache( - new CacheConfiguration() - .maxEntriesLocalHeap(10) - .maxElementsOnDisk(20) - .overflowToDisk(true) - .diskPersistent(true) - .name("diskPersistentCache_inCache") - .pinning(new PinningConfiguration().store(PinningConfiguration.Store.INCACHE)) - )); - doAssertions(cacheManager.getCache("diskPersistentCache_inCache"), 10, ELEMENT_COUNT - 10); - } - - private void doAssertions(Cache cache, long expectedMemoryHits, long expectedDiskHits) throws ExecutionException, InterruptedException { - - cache.removeAll(); - flushDisk(cache); - - for (int i = 0; i < ELEMENT_COUNT; i++) { - cache.put(new Element(i, i)); - if(i % 100 == 0) { - flushDisk(cache); - } - } - - flushDisk(cache); - Assert.assertEquals(ELEMENT_COUNT, cache.getSize()); - - for (int i = 0; i < ELEMENT_COUNT; i++) { - assertNotNull(cache.get(i)); - } - -// Assert.assertEquals(expectedMemoryHits, ); - Assert.assertEquals(ELEMENT_COUNT - cache.getStatistics().localHeapHitCount(), cache.getStatistics().localHeapMissCount()); - Assert.assertEquals(cache.getStatistics().localHeapMissCount(), cache.getStatistics().localDiskHitCount()); - Assert.assertEquals(0, cache.getStatistics().localDiskMissCount()); - Assert.assertEquals(0, cache.getStatistics().cacheEvictedCount()); - } - - private void flushDisk(final Cache cache) throws InterruptedException, ExecutionException { - final Future future = DiskStoreHelper.flushAllEntriesToDisk(cache); - if(future != null) { - future.get(); - } - } -} - Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/hibernate/strategy/NonStrictReadWriteEhcacheEntityRegionAccessStrategy.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/hibernate/strategy/NonStrictReadWriteEhcacheEntityRegionAccessStrategy.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/hibernate/strategy/NonStrictReadWriteEhcacheEntityRegionAccessStrategy.java (revision 0) @@ -1,120 +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.EhcacheEntityRegion; - -import org.hibernate.cache.CacheException; -import org.hibernate.cache.EntityRegion; -import org.hibernate.cache.access.EntityRegionAccessStrategy; -import org.hibernate.cache.access.SoftLock; -import org.hibernate.cfg.Settings; - -/** - * Ehcache specific non-strict read/write entity region access strategy - * - * @author Chris Dennis - */ -public class NonStrictReadWriteEhcacheEntityRegionAccessStrategy extends AbstractEhcacheAccessStrategy - implements EntityRegionAccessStrategy { - - /** - * Create a non-strict read/write access strategy accessing the given collection region. - */ - public NonStrictReadWriteEhcacheEntityRegionAccessStrategy(EhcacheEntityRegion region, Settings settings) { - super(region, settings); - } - - /** - * {@inheritDoc} - */ - public EntityRegion getRegion() { - return region; - } - - /** - * {@inheritDoc} - */ - public Object get(Object key, long txTimestamp) throws CacheException { - return region.get(key); - } - - /** - * {@inheritDoc} - */ - public boolean putFromLoad(Object key, Object value, long txTimestamp, Object version, boolean minimalPutOverride) - throws CacheException { - if (minimalPutOverride && region.contains(key)) { - return false; - } else { - region.put(key, value); - return true; - } - } - - /** - * Since this is a non-strict read/write strategy item locking is not used. - */ - public SoftLock lockItem(Object key, Object version) throws CacheException { - return null; - } - - /** - * Since this is a non-strict read/write strategy item locking is not used. - */ - public void unlockItem(Object key, SoftLock lock) throws CacheException { - region.remove(key); - } - - /** - * Returns false since this is an asynchronous cache access strategy. - */ - public boolean insert(Object key, Object value, Object version) throws CacheException { - return false; - } - - /** - * Returns false since this is a non-strict read/write cache access strategy - */ - public boolean afterInsert(Object key, Object value, Object version) throws CacheException { - return false; - } - - /** - * Removes the entry since this is a non-strict read/write cache strategy. - */ - public boolean update(Object key, Object value, Object currentVersion, Object previousVersion) throws CacheException { - remove(key); - return false; - } - - /** - * {@inheritDoc} - */ - public boolean afterUpdate(Object key, Object value, Object currentVersion, Object previousVersion, SoftLock lock) - throws CacheException { - unlockItem(key, lock); - return false; - } - - /** - * {@inheritDoc} - */ - @Override - public void remove(Object key) throws CacheException { - region.remove(key); - } -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/search/expression/LessThanOrEqual.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/search/expression/LessThanOrEqual.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/search/expression/LessThanOrEqual.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.expression; - -/** - * Less than or equal criteria - * - * @author teck - */ -public class LessThanOrEqual extends ComparableValue { - - private final Comparable comparableValue; - - /** - * Constructor - * - * @param attributeName attribute name - * @param value - */ - public LessThanOrEqual(String attributeName, Object value) { - super(attributeName, value); - this.comparableValue = (Comparable) value; - } - - /** - * {@inheritDoc} - */ - @Override - protected boolean executeComparable(Comparable attributeValue) { - return attributeValue.compareTo(comparableValue) <= 0; - } - - /** - * {@inheritDoc} - */ - @Override - protected boolean executeComparableString(Comparable attributeValue) { - return luceneStringCompare(attributeValue.toString(), comparableValue.toString()) <= 0; - } - - /** - * Comparable value. - * - * @return value - */ - public Comparable getComparableValue() { - return comparableValue; - } - -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/config/SearchAttribute.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/config/SearchAttribute.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/config/SearchAttribute.java (revision 0) @@ -1,333 +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 java.util.Properties; -import java.util.Set; - -import net.sf.ehcache.config.generator.model.NodeElement; -import net.sf.ehcache.config.generator.model.SimpleNodeAttribute; -import net.sf.ehcache.config.generator.model.SimpleNodeElement; -import net.sf.ehcache.search.attribute.AttributeExtractor; -import net.sf.ehcache.search.attribute.AttributeType; -import net.sf.ehcache.search.attribute.JavaBeanAttributeExtractor; -import net.sf.ehcache.search.attribute.ReflectionAttributeExtractor; -import net.sf.ehcache.util.ClassLoaderUtil; -import net.sf.ehcache.util.PropertyUtil; - -/** - * A cache search attribute. Search attributes must have a name and optionally an expression or class set (if neither is set then this - * implies java bean style) - * - * @author teck - */ -public class SearchAttribute { - - private static final Class UNRESOLVED = UnresolvedType.class; - - private String name; - private String className; - private String expression; - private String properties; - private String propertySeparator; - private String typeName; - private Class type; - - /** - * Set the attribute name - * - * @param name - */ - public void setName(String name) { - this.name = name; - } - - /** - * Set the extractor class for this attribute. This class must be available at runtime and must implement {@link AttributeExtractor} - * - * @param className - */ - public void setClass(String className) { - if (expression != null) { - throw new InvalidConfigurationException("Cannot set both class and expression for a search attribute"); - } - this.className = className; - } - - /** - * Set the attribute expression. See {@link ReflectionAttributeExtractor} for more information - * - * @param expression - */ - public void setExpression(String expression) { - if (className != null) { - throw new InvalidConfigurationException("Cannot set both class and expression for a search attribute"); - } - this.expression = expression; - } - - /** - * Set optional attribute type - * @param type - */ - public void setType(String type) { - this.type = UNRESOLVED; - this.typeName = type; - } - - /** - * Set optional attribute type - * @param type - */ - public void setType(Class type) { - this.typeName = validateType(type); - this.type = type; - } - - /** - * Get the extractor class name - */ - public String getClassName() { - return className; - } - - /** - * Get the attribute expression - */ - public String getExpression() { - return expression; - } - - /** - * Get the attribute name - */ - public String getName() { - return name; - } - - /** - * @return String representation of attribute type - */ - public String getTypeName() { - return typeName; - } - - - /** - * Get actual attribute type - * @return - */ - Class getType(ClassLoader loader) { - if (type == UNRESOLVED) { - type = validateType(this.typeName, loader); - } - - - return type; - } - - /** - * Construct the extractor for this attribute configuration - */ - public AttributeExtractor constructExtractor(ClassLoader loader) { - if (name == null) { - throw new InvalidConfigurationException("search attribute has no name"); - } - - if (expression != null) { - return new ReflectionAttributeExtractor(expression); - } else if (className != null) { - if (properties != null) { - return (AttributeExtractor) ClassLoaderUtil.createNewInstance(loader, className, new Class[] {Properties.class}, - new Object[] {PropertyUtil.parseProperties(properties, propertySeparator)}); - } else { - return (AttributeExtractor) ClassLoaderUtil.createNewInstance(loader, className); - } - } else { - return new JavaBeanAttributeExtractor(name); - } - } - - /** - * Set the attribute name - * - * @param name - * @return this - */ - public SearchAttribute name(String name) { - setName(name); - return this; - } - - /** - * Set the attribute extractor class name - * - * @param className - * attribute extractor class - * @return this - */ - public SearchAttribute className(String className) { - setClass(className); - return this; - } - - /** - * Set the attribute expression - * - * @param expression - * attribute expression - * @return this - */ - public SearchAttribute expression(String expression) { - setExpression(expression); - return this; - } - - /** - * Set optional attribute type - * @param type - * @return this - */ - public SearchAttribute type(String type) { - setType(type); - return this; - } - - /** - * Set optional attribute type - * @param type - * @return this - */ - public SearchAttribute type(Class type) { - setType(type); - return this; - } - - /** - * Set the extractor properties - * - * @param props - */ - public void setProperties(String props) { - this.properties = props; - } - - /** - * Set the extractor properties separator - * - * @param sep - */ - public void setPropertySeparator(String sep) { - this.propertySeparator = sep; - } - - /** - * Set the extractor properties separator - * - * @param sep - * @return this - */ - public SearchAttribute propertySeparator(String sep) { - setPropertySeparator(sep); - return this; - } - - /** - * Set the extractor properties - * - * @param props - * @return this - */ - public SearchAttribute properties(String props) { - setProperties(props); - return this; - } - - /** - * Create a generated config element node for this search attribute definition - * - * @param parent the enclosing parent config element - * @return generated config element for this search attribute - */ - public NodeElement asConfigElement(NodeElement parent) { - SimpleNodeElement rv = new SimpleNodeElement(parent, "searchAttribute"); - - rv.addAttribute(new SimpleNodeAttribute("name", name)); - - if (expression != null) { - rv.addAttribute(new SimpleNodeAttribute("expression", expression)); - } else if (className != null) { - rv.addAttribute(new SimpleNodeAttribute("class", className)); - if (properties != null) { - rv.addAttribute(new SimpleNodeAttribute("properties", properties)); - } - if (propertySeparator != null) { - rv.addAttribute(new SimpleNodeAttribute("propertySeparator", propertySeparator)); - } - } - if (typeName != null) { - rv.addAttribute(new SimpleNodeAttribute("type", typeName)); - } - - return rv; - } - - private Class validateType(String attrType, ClassLoader loader) { - Class realType = null; - for (Class c : AttributeType.getSupportedJavaTypes()) { - if (attrType.equals(c.getName())) { - realType = c; - break; - } - String[] groups = c.getName().split("\\."); - if (attrType.equals(groups[groups.length - 1])) { - if (realType != null) { throw new InvalidConfigurationException("Ambiguous attribute type " + attrType); } - realType = c; - } - } - - if (realType == null) { - // Attempt to load then validate that it's enum - try { - realType = loader.loadClass(attrType); - } catch (ClassNotFoundException e) { - throw new InvalidConfigurationException(String.format("Unable to load class specified as type of attribute %s: %s", - name, e.getMessage())); - } - if (!realType.isEnum()) { - throw new InvalidConfigurationException(String.format("Unsupported attribute type specified %s for search attribute %s", - attrType, name)); - } - } - - return realType; - } - - private String validateType(Class attrType) { - Set> knownTypes = AttributeType.getSupportedJavaTypes(); - String t = attrType.getName(); - if (!knownTypes.contains(attrType) && !attrType.isEnum()) { - throw new InvalidConfigurationException(String.format("Unsupported attribute type specified %s for search attribute %s", t, name)); - } - return t; - } - - private static class UnresolvedType { - // - } - -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/store/TerracottaTransactionalCopyingCacheStore.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/store/TerracottaTransactionalCopyingCacheStore.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/store/TerracottaTransactionalCopyingCacheStore.java (revision 0) @@ -1,78 +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.CacheConfiguration; -import net.sf.ehcache.store.compound.ReadWriteCopyStrategy; -import net.sf.ehcache.writer.writebehind.WriteBehind; - -import java.util.Set; - -/** - * A copying cache store designed for transactional terracotta clustered stores - * - * @author ljacomet - */ -public final class TerracottaTransactionalCopyingCacheStore extends AbstractCopyingCacheStore implements TerracottaStore { - - /** - * Creates a terracotta copying instance of store, that wraps the actual storage - * - * @param store the real store - * @param copyStrategyInstance the copy strategy to use on every copy operation - * @param loader classloader of the containing cache - */ - public TerracottaTransactionalCopyingCacheStore(TerracottaStore store, ReadWriteCopyStrategy copyStrategyInstance, ClassLoader loader) { - super(store, true, false, copyStrategyInstance, loader); - } - - @Override - public Element unsafeGet(Object key) { - return getCopyStrategyHandler().copyElementForReadIfNeeded(getUnderlyingStore().unsafeGet(key)); - } - - @Override - public void quickClear() { - getUnderlyingStore().quickClear(); - } - - @Override - public int quickSize() { - return getUnderlyingStore().quickSize(); - } - - @Override - public Set getLocalKeys() { - return getUnderlyingStore().getLocalKeys(); - } - - @Override - public CacheConfiguration.TransactionalMode getTransactionalMode() { - return getUnderlyingStore().getTransactionalMode(); - } - - @Override - public WriteBehind createWriteBehind() { - return getUnderlyingStore().createWriteBehind(); - } - - @Override - public void notifyCacheEventListenersChanged() { - getUnderlyingStore().notifyCacheEventListenersChanged(); - } -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/search/expression/NotNull.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/search/expression/NotNull.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/search/expression/NotNull.java (revision 0) @@ -1,62 +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.expression; - -import java.util.Collections; -import java.util.Map; -import java.util.Set; - -import net.sf.ehcache.Element; -import net.sf.ehcache.search.Attribute; -import net.sf.ehcache.search.attribute.AttributeExtractor; - -/** - * @author vfunshte - * - */ -public class NotNull extends BaseCriteria { - - private final String attributeName; - - /** - * @param attributeName - */ - public NotNull(String attributeName) { - this.attributeName = attributeName; - } - - /** - * Get attribute name. - * - * @return attribute name. - */ - public String getAttributeName() { - return attributeName; - } - - - @Override - public boolean execute(Element e, Map attributeExtractors) { - return getExtractor(getAttributeName(), attributeExtractors).attributeFor(e, getAttributeName()) != null; - } - - @Override - public Set> getAttributes() { - return Collections.>singleton(new Attribute(attributeName)); - } - -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/distribution/RMIAsynchronousCacheReplicator.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/distribution/RMIAsynchronousCacheReplicator.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/distribution/RMIAsynchronousCacheReplicator.java (revision 0) @@ -1,419 +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.lang.ref.SoftReference; -import java.rmi.UnmarshalException; -import java.util.ArrayList; -import java.util.List; -import java.util.Queue; -import java.util.concurrent.ConcurrentLinkedQueue; -import net.sf.ehcache.distribution.RmiEventMessage.RmiEventType; - -import org.slf4j.LoggerFactory; -import org.slf4j.Logger; - -/** - * Listens to {@link net.sf.ehcache.CacheManager} and {@link net.sf.ehcache.Cache} events and propagates those to - * {@link CachePeer} peers of the Cache asynchronously. - *

- * Updates are guaranteed to be replicated in the order in which they are received. - *

- * While much faster in operation than {@link RMISynchronousCacheReplicator}, it does suffer from a number - * of problems. Elements, which may be being spooled to DiskStore may stay around in memory because references - * are being held to them from {@link EventMessage}s which are queued up. The replication thread runs once - * per second, limiting the build up. However a lot of elements can be put into a cache in that time. We do not want - * to get an {@link OutOfMemoryError} using distribution in circumstances when it would not happen if we were - * just using the DiskStore. - *

- * Accordingly, the Element values in {@link EventMessage}s are held by {@link java.lang.ref.SoftReference} in the queue, - * so that they can be discarded if required by the GC to avoid an {@link OutOfMemoryError}. A log message - * will be issued on each flush of the queue if there were any forced discards. One problem with GC collection - * of SoftReferences is that the VM (JDK1.5 anyway) will do that rather than grow the heap size to the maximum. - * The workaround is to either set minimum heap size to the maximum heap size to force heap allocation at start - * up, or put up with a few lost messages while the heap grows. - * - * @author Greg Luck - * @version $Id: RMIAsynchronousCacheReplicator.java 10789 2018-04-26 02:08:13Z adahanne $ - */ -public class RMIAsynchronousCacheReplicator extends RMISynchronousCacheReplicator { - - - private static final Logger LOG = LoggerFactory.getLogger(RMIAsynchronousCacheReplicator.class.getName()); - - - /** - * A thread which handles replication, so that replication can take place asynchronously and not hold up the cache - */ - private final Thread replicationThread = new ReplicationThread(); - - /** - * The amount of time the replication thread sleeps after it detects the replicationQueue is empty - * before checking again. - */ - private final int replicationInterval; - - /** - * The maximum number of Element replication in single RMI message. - */ - private final int maximumBatchSize; - - /** - * A queue of updates. - */ - private final Queue replicationQueue = new ConcurrentLinkedQueue(); - - /** - * Constructor for internal and subclass use - */ - public RMIAsynchronousCacheReplicator( - boolean replicatePuts, - boolean replicatePutsViaCopy, - boolean replicateUpdates, - boolean replicateUpdatesViaCopy, - boolean replicateRemovals, - int replicationInterval, - int maximumBatchSize) { - super(replicatePuts, - replicatePutsViaCopy, - replicateUpdates, - replicateUpdatesViaCopy, - replicateRemovals); - this.replicationInterval = replicationInterval; - this.maximumBatchSize = maximumBatchSize; - status = Status.STATUS_ALIVE; - replicationThread.start(); - } - - /** - * RemoteDebugger method for the replicationQueue thread. - *

- * Note that the replicationQueue thread locks the cache for the entire time it is writing elements to the disk. - */ - private void replicationThreadMain() { - while (true) { - // Wait for elements in the replicationQueue - while (alive() && replicationQueue != null && replicationQueue.isEmpty()) { - try { - Thread.sleep(replicationInterval); - } catch (InterruptedException e) { - LOG.debug("Spool Thread interrupted."); - return; - } - } - if (notAlive()) { - return; - } - try { - writeReplicationQueue(); - } catch (Throwable e) { - LOG.error("Exception on flushing of replication queue: " + e.getMessage() + ". Continuing...", e); - } - } - } - - - /** - * {@inheritDoc} - *

- * This implementation queues the put notification for in-order replication to peers. - * - * @param cache the cache emitting the notification - * @param element the element which was just put into the cache. - */ - public final void notifyElementPut(final Ehcache cache, final Element element) throws CacheException { - if (notAlive()) { - return; - } - - if (!replicatePuts) { - return; - } - - if (replicatePutsViaCopy) { - if (!element.isSerializable()) { - if (LOG.isWarnEnabled()) { - LOG.warn("Object with key " + element.getObjectKey() + " is not Serializable and cannot be replicated."); - } - return; - } - addToReplicationQueue(new RmiEventMessage(cache, RmiEventType.PUT, null, element)); - } else { - if (!element.isKeySerializable()) { - if (LOG.isWarnEnabled()) { - LOG.warn("Object with key " + element.getObjectKey() - + " does not have a Serializable key and cannot be replicated via invalidate."); - } - return; - } - addToReplicationQueue(new RmiEventMessage(cache, RmiEventType.REMOVE, element.getKey(), null)); - } - - } - - /** - * 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 final 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; - } - addToReplicationQueue(new RmiEventMessage(cache, RmiEventType.PUT, null, element)); - } else { - if (!element.isKeySerializable()) { - if (LOG.isWarnEnabled()) { - LOG.warn("Object with key " + element.getObjectKey() - + " does not have a Serializable key and cannot be replicated via invalidate."); - } - return; - } - addToReplicationQueue(new RmiEventMessage(cache, RmiEventType.REMOVE, element.getKey(), null)); - } - } - - /** - * 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. - */ - public final 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; - } - addToReplicationQueue(new RmiEventMessage(cache, RmiEventType.REMOVE, element.getKey(), null)); - } - - - /** - * 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; - } - - addToReplicationQueue(new RmiEventMessage(cache, RmiEventType.REMOVE_ALL, null, null)); - } - - - /** - * Adds a message to the queue. - *

- * This method checks the state of the replication thread and warns - * if it has stopped and then discards the message. - * - * @param eventMessage - */ - protected void addToReplicationQueue(RmiEventMessage eventMessage) { - if (!replicationThread.isAlive()) { - LOG.error("CacheEventMessages cannot be added to the replication queue because the replication thread has died."); - } else { - switch (eventMessage.getType()) { - case PUT: - replicationQueue.add(new SoftReference(eventMessage)); - break; - default: - replicationQueue.add(eventMessage); - break; - } - } - } - - - /** - * Gets called once per {@link #replicationInterval}. - *

- * Sends accumulated messages in bulk to each peer. i.e. if ther are 100 messages and 1 peer, - * 1 RMI invocation results, not 100. Also, if a peer is unavailable this is discovered in only 1 try. - *

- * Makes a copy of the queue so as not to hold up the enqueue operations. - *

- * Any exceptions are caught so that the replication thread does not die, and because errors are expected, - * due to peers becoming unavailable. - *

- * This method issues warnings for problems that can be fixed with configuration changes. - */ - private void writeReplicationQueue() { - List eventMessages = extractEventMessages(maximumBatchSize); - - if (!eventMessages.isEmpty()) { - for (CachePeer cachePeer : listRemoteCachePeers(eventMessages.get(0).getEhcache())) { - try { - cachePeer.send(eventMessages); - } catch (UnmarshalException e) { - String message = e.getMessage(); - if (message.contains("Read time out") || message.contains("Read timed out")) { - LOG.warn("Unable to send message to remote peer due to socket read timeout. Consider increasing" + - " the socketTimeoutMillis setting in the cacheManagerPeerListenerFactory. " + - "Message was: " + message); - } else { - LOG.debug("Unable to send message to remote peer. Message was: " + message); - } - } catch (Throwable t) { - LOG.warn("Unable to send message to remote peer. Message was: " + t.getMessage(), t); - } - } - } - } - - private void flushReplicationQueue() { - while (!replicationQueue.isEmpty()) { - writeReplicationQueue(); - } - } - - /** - * Extracts CacheEventMessages and attempts to get a hard reference to the underlying EventMessage - *

- * If an EventMessage has been invalidated due to SoftReference collection of the Element, it is not - * propagated. This only affects puts and updates via copy. - * - * @param replicationQueueCopy - * @return a list of EventMessages which were able to be resolved - */ - private List extractEventMessages(int limit) { - List list = new ArrayList(Math.min(replicationQueue.size(), limit)); - - int droppedMessages = 0; - - while (list.size() < limit) { - Object polled = replicationQueue.poll(); - if (polled == null) { - break; - } else if (polled instanceof EventMessage) { - list.add((EventMessage) polled); - } else { - EventMessage message = ((SoftReference) polled).get(); - if (message == null) { - droppedMessages++; - } else { - list.add(message); - } - } - } - - if (droppedMessages > 0) { - LOG.warn(droppedMessages + " messages were discarded on replicate due to reclamation of " + - "SoftReferences by the VM. Consider increasing the maximum heap size and/or setting the " + - "starting heap size to a higher value."); - } - return list; - } - - /** - * A background daemon thread that writes objects to the file. - */ - private final class ReplicationThread extends Thread { - public ReplicationThread() { - super("Replication Thread"); - setDaemon(true); - setPriority(Thread.NORM_PRIORITY); - } - - /** - * RemoteDebugger thread method. - */ - public final void run() { - replicationThreadMain(); - } - } - - /** - * Give the replicator a chance to flush the replication queue, then cleanup and free resources when no longer needed - */ - public final void dispose() { - status = Status.STATUS_SHUTDOWN; - flushReplicationQueue(); - } - - - /** - * 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 RMIAsynchronousCacheReplicator(replicatePuts, replicatePutsViaCopy, - replicateUpdates, replicateUpdatesViaCopy, replicateRemovals, replicationInterval, maximumBatchSize); - } - - -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/distribution/PayloadUtilTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/distribution/PayloadUtilTest.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/distribution/PayloadUtilTest.java (revision 0) @@ -1,299 +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 static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.io.IOException; -import java.io.Serializable; -import java.rmi.RemoteException; -import java.util.ArrayList; -import java.util.List; -import java.util.Random; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import net.sf.ehcache.AbstractCacheTest; -import net.sf.ehcache.CacheManager; -import net.sf.ehcache.Element; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -/** - * Note these tests need a live network interface running in multicast mode to work - * - * @author Greg Luck - * @version $Id: PayloadUtilTest.java 10789 2018-04-26 02:08:13Z adahanne $ - */ -public class PayloadUtilTest extends AbstractRMITest { - - private static final Logger LOG = LoggerFactory.getLogger(PayloadUtilTest.class.getName()); - private static final Random RANDOM = new Random(System.currentTimeMillis()); - private static final String RANDOM_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ."; - private CacheManager manager; - - /** - * setup test - * - * @throws Exception - */ - @Before - public void setUp() throws Exception { - String fileName = AbstractCacheTest.TEST_CONFIG_DIR + "ehcache-big.xml"; - manager = new CacheManager(fileName); - } - - /** - * Shuts down the cachemanager - * - * @throws Exception - */ - @After - public void tearDown() throws Exception { - manager.shutdown(); - } - - /** - * The maximum Ethernet MTU is 1500 bytes. - *

- * We want to be able to work with 100 caches - */ - @Test - public void testMaximumDatagram() throws IOException { - String payload = createReferenceString(); - - final byte[] compressed = PayloadUtil.gzip(payload.getBytes()); - - int length = compressed.length; - LOG.info("gzipped size: " + length); - assertTrue("Heartbeat too big for one Datagram " + length, length <= 1500); - - } - - private String createReferenceString() { - - String[] names = manager.getCacheNames(); - String urlBase = "//localhost.localdomain:12000/"; - StringBuilder buffer = new StringBuilder(); - for (String name : names) { - buffer.append(urlBase); - buffer.append(name); - buffer.append("|"); - } - String payload = buffer.toString(); - return payload; - } - - @Test - public void testBigPayload() throws RemoteException { - List bigPayloadList = new ArrayList(); - // create 5000 peers, each peer having cache name between 50 - 500 char length - int peers = 5000; - int minCacheNameSize = 50; - int maxCacheNameSize = 500; - for (int i = 0; i < peers; i++) { - bigPayloadList.add(new PayloadUtilTestCachePeer(getRandomName(minCacheNameSize, maxCacheNameSize))); - } - - doTestBigPayLoad(bigPayloadList, 5); - doTestBigPayLoad(bigPayloadList, 10); - doTestBigPayLoad(bigPayloadList, 50); - doTestBigPayLoad(bigPayloadList, 100); - doTestBigPayLoad(bigPayloadList, 150); - doTestBigPayLoad(bigPayloadList, 300); - doTestBigPayLoad(bigPayloadList, 500); - - // do a big test where maximumPeersPerSend is a large value, try to accomodate all peers in one payload - // this should result in payload breaking up by MTU size - doTestBigPayLoad(bigPayloadList, 1000000); - - // test heartbeat won't work when single cache has very very long cacheName - bigPayloadList.clear(); - bigPayloadList.add(new PayloadUtilTestCachePeer(getRandomName(3000, 3001))); - List compressedList = PayloadUtil.createCompressedPayloadList(bigPayloadList, 150); - assertEquals(0, compressedList.size()); - - } - - private void doTestBigPayLoad(List bigPayloadList, int maximumPeersPerSend) throws RemoteException { - List compressedList = PayloadUtil.createCompressedPayloadList(bigPayloadList, maximumPeersPerSend); - // the big list cannot be compressed in 1 entry - assertTrue(compressedList.size() > 1); - StringBuilder actual = new StringBuilder(); - for (byte[] bytes : compressedList) { - assertTrue("One payload should not be greater than MTU, actual size: " + bytes.length + ", MTU: " + PayloadUtil.MTU, - bytes.length <= PayloadUtil.MTU); - String urlList = new String(PayloadUtil.ungzip(bytes)); - String[] urls = urlList.split(PayloadUtil.URL_DELIMITER_REGEXP); - assertTrue("Number of URL's in one payload should not exceed maximumPeersPerSend (=" + maximumPeersPerSend + "), actual: " - + urls.length, urls.length <= maximumPeersPerSend); - - if (bytes == compressedList.get(compressedList.size() - 1)) { - actual.append(urlList); - } else { - actual.append(urlList + PayloadUtil.URL_DELIMITER); - } - } - StringBuilder expected = new StringBuilder(); - for (CachePeer peer : bigPayloadList) { - if (peer != bigPayloadList.get(bigPayloadList.size() - 1)) { - expected.append(peer.getUrl() + PayloadUtil.URL_DELIMITER); - } else { - expected.append(peer.getUrl()); - } - } - assertEquals(expected.toString(), actual.toString()); - } - - private String getRandomName(final int minLength, final int maxLength) { - int length = minLength + RANDOM.nextInt(maxLength - minLength); - StringBuilder rv = new StringBuilder(); - for (int i = 0; i < length; i++) { - rv.append(RANDOM_CHARS.charAt(RANDOM.nextInt(RANDOM_CHARS.length()))); - } - return rv.toString(); - } - - /** - * A test class which implements only {@link #getUrl()} to test PayloadUtil.createCompressedPayloadList() - * - * @author Abhishek Sanoujam - */ - private static class PayloadUtilTestCachePeer implements CachePeer { - - public static final String URL_BASE = "//localhost.localdomain:12000/"; - private final String cacheName; - - public PayloadUtilTestCachePeer(String cacheName) { - this.cacheName = cacheName; - } - - /** - * {@inheritDoc} - * - * @see net.sf.ehcache.distribution.CachePeer#getUrl() - */ - public String getUrl() throws RemoteException { - return URL_BASE + cacheName; - } - - /** - * {@inheritDoc} - * - * @see net.sf.ehcache.distribution.CachePeer#getElements(java.util.List) - */ - public List getElements(List keys) throws RemoteException { - // no-op - return null; - } - - /** - * {@inheritDoc} - * - * @see net.sf.ehcache.distribution.CachePeer#getGuid() - */ - public String getGuid() throws RemoteException { - // no-op - return null; - } - - /** - * {@inheritDoc} - * - * @see net.sf.ehcache.distribution.CachePeer#getKeys() - */ - public List getKeys() throws RemoteException { - // no-op - return null; - } - - /** - * {@inheritDoc} - * - * @see net.sf.ehcache.distribution.CachePeer#getName() - */ - public String getName() throws RemoteException { - // no-op - return null; - } - - /** - * {@inheritDoc} - * - * @see net.sf.ehcache.distribution.CachePeer#getQuiet(java.io.Serializable) - */ - public Element getQuiet(Serializable key) throws RemoteException { - // no-op - return null; - } - - /** - * {@inheritDoc} - * - * @see net.sf.ehcache.distribution.CachePeer#getUrlBase() - */ - public String getUrlBase() throws RemoteException { - // no-op - return null; - } - - /** - * {@inheritDoc} - * - * @see net.sf.ehcache.distribution.CachePeer#put(net.sf.ehcache.Element) - */ - public void put(Element element) throws IllegalArgumentException, IllegalStateException, RemoteException { - // no-op - - } - - /** - * {@inheritDoc} - * - * @see net.sf.ehcache.distribution.CachePeer#remove(java.io.Serializable) - */ - public boolean remove(Serializable key) throws IllegalStateException, RemoteException { - // no-op - return false; - } - - /** - * {@inheritDoc} - * - * @see net.sf.ehcache.distribution.CachePeer#removeAll() - */ - public void removeAll() throws RemoteException, IllegalStateException { - // no-op - } - - /** - * {@inheritDoc} - * - * @see net.sf.ehcache.distribution.CachePeer#send(java.util.List) - */ - public void send(List eventMessages) throws RemoteException { - // no-op - - } - - } - -} Index: rctags/ehcache-2.10.9.1.33/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/writebehind/AsyncWriteBehind.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/writebehind/AsyncWriteBehind.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/writebehind/AsyncWriteBehind.java (revision 0) @@ -1,94 +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.Ehcache; -import net.sf.ehcache.Element; -import net.sf.ehcache.writer.CacheWriter; -import net.sf.ehcache.writer.writebehind.OperationsFilter; -import net.sf.ehcache.writer.writebehind.WriteBehind; - -import org.terracotta.modules.ehcache.async.AsyncCoordinator; -import org.terracotta.modules.ehcache.async.scatterpolicies.ItemScatterPolicy; -import org.terracotta.modules.ehcache.writebehind.operations.DeleteAsyncOperation; -import org.terracotta.modules.ehcache.writebehind.operations.SingleAsyncOperation; -import org.terracotta.modules.ehcache.writebehind.operations.WriteAsyncOperation; - -public class AsyncWriteBehind implements WriteBehind { - public static final ItemScatterPolicy POLICY = new SingleAsyncOperationItemScatterPolicy(); - - private final AsyncCoordinator async; - private final int concurrency; - - /** - * Instantiate a new instance of {@code AsyncWriteBehind} by providing the async coordinator instance that will be - * used for the underlying behavior. - * - * @param async the async coordinator instance that will be used by the write behind queue - * @param writeBehindConcurrency the amount of buckets and threads to use - */ - public AsyncWriteBehind(final AsyncCoordinator async, final int writeBehindConcurrency) { - if(async == null) { - throw new IllegalArgumentException("AsyncCoordinator can't be null"); - } - if(writeBehindConcurrency < 1) { - throw new IllegalArgumentException("writeBehindConcurrency has to be at least one"); - } - this.async = async; - this.concurrency = writeBehindConcurrency; - } - - @Override - public void start(CacheWriter writer) throws CacheException { - async.start(new CacheWriterProcessor(writer), concurrency, POLICY); - } - - // This method is to be called from within a clustered Lock as it does not take any clustered lock inside. - @Override - public void write(Element element) { - async.add(new WriteAsyncOperation(element)); - } - - // This method is to be called from within a clustered Lock as it does not take any clustered lock inside. - @Override - public void delete(CacheEntry entry) { - async.add(new DeleteAsyncOperation(entry.getKey(), entry.getElement())); - } - - @Override - public void setOperationsFilter(OperationsFilter filter) { - OperationsFilterWrapper filterWrapper = new OperationsFilterWrapper(filter); - async.setOperationsFilter(filterWrapper); - } - - @Override - public void stop() throws CacheException { - async.stop(); - } - - @Override - public long getQueueSize() { - return async.getQueueSize(); - } - - private static class SingleAsyncOperationItemScatterPolicy implements ItemScatterPolicy { - private SingleAsyncOperationItemScatterPolicy() { - // - } - - @Override - public int selectBucket(final int count, final SingleAsyncOperation item) { - Object key; - try { - key = item.getKey(); - } catch (Exception e) { - throw new CacheException(e); - } - return Math.abs(key.hashCode() % count); - } - } - -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/config/generator/model/elements/PinningConfigurationElement.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/config/generator/model/elements/PinningConfigurationElement.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/config/generator/model/elements/PinningConfigurationElement.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.config.generator.model.elements; - -import net.sf.ehcache.config.PinningConfiguration; -import net.sf.ehcache.config.generator.model.NodeElement; -import net.sf.ehcache.config.generator.model.SimpleNodeAttribute; -import net.sf.ehcache.config.generator.model.SimpleNodeElement; - -/** - * {@link net.sf.ehcache.config.generator.model.NodeElement} representing the {@link net.sf.ehcache.config.PinningConfiguration} - * - * @author Ludovic Orban - * - */ -public class PinningConfigurationElement extends SimpleNodeElement { - - private final PinningConfiguration pinningConfiguration; - - /** - * Constructor accepting the parent and the {@link net.sf.ehcache.config.TerracottaConfiguration} - * - * @param parent - * @param pinningConfiguration - */ - public PinningConfigurationElement(NodeElement parent, PinningConfiguration pinningConfiguration) { - super(parent, "pinning"); - this.pinningConfiguration = pinningConfiguration; - init(); - } - - private void init() { - if (pinningConfiguration == null) { - return; - } - - addAttribute(new SimpleNodeAttribute("store", pinningConfiguration.getStore()).optional(false)); - } - -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/resources/ehcache-failsafe.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/resources/ehcache-failsafe.xml (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/resources/ehcache-failsafe.xml (revision 0) @@ -1,286 +0,0 @@ - - - - - - - - - - - - - - - - - - - - Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/constructs/refreshahead/StringifyCacheLoaderFactory.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/constructs/refreshahead/StringifyCacheLoaderFactory.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/constructs/refreshahead/StringifyCacheLoaderFactory.java (revision 0) @@ -1,95 +0,0 @@ -package net.sf.ehcache.constructs.refreshahead; - -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; -import java.util.Properties; - -import net.sf.ehcache.CacheException; -import net.sf.ehcache.Ehcache; -import net.sf.ehcache.Status; -import net.sf.ehcache.loader.CacheLoader; -import net.sf.ehcache.loader.CacheLoaderFactory; - -public class StringifyCacheLoaderFactory extends CacheLoaderFactory { - - @Override - public CacheLoader createCacheLoader(Ehcache cache, Properties properties) { - return new StringifyCacheLoader(properties); - } - - public static class StringifyCacheLoader implements CacheLoader { - - private long delayMS = 0; - - public StringifyCacheLoader(Properties properties) { - if (properties != null) { - delayMS = Long.parseLong(properties.getProperty("delayMS", "0")); - } - } - - @Override - public Map loadAll(Collection keys, Object argument) { - return loadAll(keys); - } - - @Override - public Map loadAll(Collection keys) { - try { - Thread.sleep(delayMS); - } catch (InterruptedException e) { - - } - HashMap ret=new HashMap(); - for(Object k:keys) { - ret.put(k, k.toString()); - } - return ret; - } - - @Override - public Object load(Object key, Object argument) { - return load(key); - } - - @Override - public Object load(Object key) throws CacheException { - try { - Thread.sleep(delayMS); - } catch (InterruptedException e) { - - } - 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; - } - } -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/resources/services/net.sf.ehcache.pool.SizeOfEngineFactory.txt =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/resources/services/net.sf.ehcache.pool.SizeOfEngineFactory.txt (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/resources/services/net.sf.ehcache.pool.SizeOfEngineFactory.txt (revision 0) @@ -1 +0,0 @@ -net.sf.ehcache.pool.SizeOfEngineLoaderTest$MyRealFactory \ No newline at end of file Index: rctags/ehcache-2.10.9.1.33/management-ehcache-impl/management-ehcache-common/impl/CacheManagerConfigurationEntityBuilderV2.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/management-ehcache-impl/management-ehcache-common/impl/CacheManagerConfigurationEntityBuilderV2.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/management-ehcache-impl/management-ehcache-common/impl/CacheManagerConfigurationEntityBuilderV2.java (revision 0) @@ -1,57 +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.management.resource.CacheManagerConfigEntityV2; -import net.sf.ehcache.management.sampled.CacheManagerSampler; - -import org.terracotta.management.resource.AgentEntityV2; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -/** - * @author brandony - */ -final class CacheManagerConfigurationEntityBuilderV2 { - private final List cmSamplers = new ArrayList(); - - static CacheManagerConfigurationEntityBuilderV2 createWith(CacheManagerSampler sampler) { - return new CacheManagerConfigurationEntityBuilderV2(sampler); - } - - private CacheManagerConfigurationEntityBuilderV2(CacheManagerSampler sampler) { - addSampler(sampler); - } - - CacheManagerConfigurationEntityBuilderV2 add(CacheManagerSampler sampler) { - addSampler(sampler); - return this; - } - - Collection build() { - Collection cmces = new ArrayList(cmSamplers.size()); - - for (CacheManagerSampler sampler : cmSamplers) { - CacheManagerConfigEntityV2 cmce = new CacheManagerConfigEntityV2(); - cmce.setCacheManagerName(sampler.getName()); - cmce.setAgentId(AgentEntityV2.EMBEDDED_AGENT_ID); - // cmce.setVersion(this.getClass().getPackage().getImplementationVersion()); - cmce.setXml(sampler.generateActiveConfigDeclaration()); - - cmces.add(cmce); - } - - return cmces; - } - - private void addSampler(CacheManagerSampler sampler) { - if (sampler == null) { - throw new IllegalArgumentException("sampler == null"); - } - cmSamplers.add(sampler); - } -} Index: rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/org/terracotta/modules/ehcache/l1bm/L1BMCacheManagerRecreateTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/org/terracotta/modules/ehcache/l1bm/L1BMCacheManagerRecreateTest.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/org/terracotta/modules/ehcache/l1bm/L1BMCacheManagerRecreateTest.java (revision 0) @@ -1,55 +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.Element; - -import org.junit.Assert; -import org.terracotta.toolkit.Toolkit; -import org.terracotta.ehcache.tests.AbstractCacheTestBase; -import org.terracotta.ehcache.tests.ClientBase; - -import com.tc.test.config.model.TestConfig; - -public class L1BMCacheManagerRecreateTest extends AbstractCacheTestBase { - - public L1BMCacheManagerRecreateTest(TestConfig testConfig) { - super(testConfig, App.class); - } - - public static class App extends ClientBase { - private Cache cache; - - public App(String[] args) { - super(args); - } - - @Override - protected void runTest(Cache testcache, Toolkit clusteringToolkit) throws Throwable { - cache = testcache; - for (int i = 0; i < 100; i++) { - cache.put(new Element("key" + i, "value" + i)); - } - cleanup(); - - setup(); - for (int i = 0; i < 100; i++) { - Element e = cache.get("key" + i); - Assert.assertNotNull(e); - Assert.assertEquals("value" + i, e.getObjectValue()); - } - cleanup(); - } - - private void setup() { - setupCacheManager(); - cache = getCache(); - } - - private void cleanup() { - getCacheManager().shutdown(); - } - } -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/hibernate/nonstop/package.html =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/hibernate/nonstop/package.html (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/hibernate/nonstop/package.html (revision 0) @@ -1,5 +0,0 @@ - - - This package contains interfaces and classes for Hibernate related to Ehcache's nonstop feature. - - Index: rctags/ehcache-2.10.9.1.33/management-ehcache-v1/src/main/java/net/sf/ehcache/management/resource/ElementEntity.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/management-ehcache-v1/src/main/java/net/sf/ehcache/management/resource/ElementEntity.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/management-ehcache-v1/src/main/java/net/sf/ehcache/management/resource/ElementEntity.java (revision 0) @@ -1,35 +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 org.terracotta.management.resource.VersionedEntity; - -/** - * @author brandony - */ -public class ElementEntity extends VersionedEntity { - private String agentId; - - private String cacheName; - - @Override - public String getAgentId() { - return agentId; - } - - @Override - public void setAgentId(String agentId) { - this.agentId = agentId; - } - - public String getCacheName() { - return cacheName; - } - - public void setCacheName(String cacheName) { - this.cacheName = cacheName; - } -} Index: rctags/ehcache-2.10.9.1.33/management-ehcache-v2/src/main/java/net/sf/ehcache/management/resource/AbstractCacheEntityV2.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/management-ehcache-v2/src/main/java/net/sf/ehcache/management/resource/AbstractCacheEntityV2.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/management-ehcache-v2/src/main/java/net/sf/ehcache/management/resource/AbstractCacheEntityV2.java (revision 0) @@ -1,38 +0,0 @@ -package net.sf.ehcache.management.resource; - -import org.terracotta.management.resource.AbstractEntityV2; - -/** - * An abstract class for all cache entity objects providing all common properties, namely: - * - *

    - *
  • agentId
  • - *
  • name
  • - *
  • cacheManagerName
  • - *
- * - * @author brandony - */ -public abstract class AbstractCacheEntityV2 extends AbstractEntityV2 { - - private String name; - - private String cacheManagerName; - - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getCacheManagerName() { - return cacheManagerName; - } - - public void setCacheManagerName(String cacheManagerName) { - this.cacheManagerName = cacheManagerName; - } -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/exceptionhandler/CacheExceptionHandlerTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/exceptionhandler/CacheExceptionHandlerTest.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/exceptionhandler/CacheExceptionHandlerTest.java (revision 0) @@ -1,224 +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.exceptionhandler; - - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; - -import java.util.ArrayList; -import java.util.List; - -import net.sf.ehcache.AbstractCacheTest; -import net.sf.ehcache.CacheException; -import net.sf.ehcache.CacheManager; -import net.sf.ehcache.Ehcache; -import net.sf.ehcache.loader.CacheLoader; -import net.sf.ehcache.loader.ExceptionThrowingLoader; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -/** - * @author Greg Luck - * @version $Id: CacheExceptionHandlerTest.java 5594 2012-05-07 16:04:31Z cdennis $ - */ -public class CacheExceptionHandlerTest { - - /** - * manager - */ - protected CacheManager manager; - /** - * the cache name we wish to test - */ - protected String cacheName = "exceptionHandlingCache"; - /** - * the cache we wish to test - */ - protected Ehcache cache; - - /** - * {@inheritDoc} - * - * @throws Exception - */ - @Before - public void setUp() throws Exception { - manager = CacheManager.create(AbstractCacheTest.TEST_CONFIG_DIR + "ehcache.xml"); - cache = manager.getEhcache(cacheName); - cache.removeAll(); - } - - - /** - * {@inheritDoc} - * - * @throws Exception - */ - @After - public void tearDown() throws Exception { - CountingExceptionHandler.resetCounters(); - manager.shutdown(); - } - - /** - * Test a cache which has been configured to have a CountingExceptionHandler configured - */ - @Test - public void testConfiguredCache() { - manager.removeCache("exceptionHandlingCache"); - //Would normally throw an IllegalStateException - cache.get("key1"); - - assertEquals(1, CountingExceptionHandler.HANDLED_EXCEPTIONS.size()); - assertEquals(null, ((CountingExceptionHandler.HandledException) CountingExceptionHandler.HANDLED_EXCEPTIONS.get(0)).getKey()); - assertEquals(IllegalStateException.class, ((CountingExceptionHandler.HandledException) CountingExceptionHandler.HANDLED_EXCEPTIONS - .get(0)).getException().getClass()); - } - - /** - * Test a cache which has been configured to have an ExceptionThrowingLoader screw up loading. - * This one should have a key set. - */ - @Test - public void testKeyWithConfiguredCache() { - - List loaders = new ArrayList(cache.getRegisteredCacheLoaders()); - for (CacheLoader loader : loaders) { - cache.unregisterCacheLoader(loader); - } - - cache.registerCacheLoader(new ExceptionThrowingLoader()); - cache.getWithLoader("key1", null, null); - - assertEquals(1, CountingExceptionHandler.HANDLED_EXCEPTIONS.size()); - assertEquals("key1", ((CountingExceptionHandler.HandledException) CountingExceptionHandler.HANDLED_EXCEPTIONS.get(0)).getKey()); - assertEquals(CacheException.class, ((CountingExceptionHandler.HandledException) CountingExceptionHandler.HANDLED_EXCEPTIONS - .get(0)).getException().getClass()); - } - - /** - * Double proxy test - */ - @Test - public void testCacheExceptionHandler() { - Ehcache proxiedCache = ExceptionHandlingDynamicCacheProxy.createProxy(cache); - - List loaders = new ArrayList(cache.getRegisteredCacheLoaders()); - for (CacheLoader loader : loaders) { - cache.unregisterCacheLoader(loader); - } - cache.registerCacheLoader(new CustomExceptionThrowingLoader()); - proxiedCache.getWithLoader("key1", null, null); - - - //Would normally throw an IllegalArgumentException -// proxiedCache.put(null); - - assertEquals(1, CountingExceptionHandler.HANDLED_EXCEPTIONS.size()); - assertEquals("key1", ((CountingExceptionHandler.HandledException) CountingExceptionHandler.HANDLED_EXCEPTIONS.get(0)).getKey()); - assertEquals(CacheException.class, ((CountingExceptionHandler.HandledException) CountingExceptionHandler.HANDLED_EXCEPTIONS - .get(0)).getException().getClass()); - } - - - /** - * Test some gnarly parsing code - */ - @Test - public void testKeyExtraction() { - - String testMessage = "For key 1234"; - String key = ExceptionHandlingDynamicCacheProxy.extractKey(testMessage); - assertEquals("1234", key); - - testMessage = "key 1234"; - key = ExceptionHandlingDynamicCacheProxy.extractKey(testMessage); - assertEquals("1234", key); - - testMessage = null; - key = ExceptionHandlingDynamicCacheProxy.extractKey(testMessage); - assertEquals(null, key); - - testMessage = ""; - key = ExceptionHandlingDynamicCacheProxy.extractKey(testMessage); - assertEquals(null, key); - - testMessage = "key 1234 "; - key = ExceptionHandlingDynamicCacheProxy.extractKey(testMessage); - assertEquals("1234", key); - - testMessage = "key 1234 ."; - key = ExceptionHandlingDynamicCacheProxy.extractKey(testMessage); - assertEquals("1234", key); - - testMessage = "key ."; - key = ExceptionHandlingDynamicCacheProxy.extractKey(testMessage); - assertEquals(".", key); - - testMessage = "key"; - key = ExceptionHandlingDynamicCacheProxy.extractKey(testMessage); - assertEquals(null, key); - - } - - /** - * Tests that the exception thrown by a configured loader, is - * actually passed on to exception handler - */ - @Test - public void testExceptionThrown() { - - List loaders = new ArrayList(cache.getRegisteredCacheLoaders()); - for (CacheLoader loader : loaders) { - cache.unregisterCacheLoader(loader); - } - cache.registerCacheLoader(new CustomExceptionThrowingLoader()); - - cache.getWithLoader("key1", null, null); - - assertEquals(1, CountingExceptionHandler.HANDLED_EXCEPTIONS.size()); - assertEquals("key1", ((CountingExceptionHandler.HandledException) CountingExceptionHandler.HANDLED_EXCEPTIONS.get(0)).getKey()); - - - Class expectedExceptionClass = UnsupportedOperationException.class; - - Exception e = ((CountingExceptionHandler.HandledException) CountingExceptionHandler.HANDLED_EXCEPTIONS - .get(0)).getException(); - - Throwable cause = e; - boolean foundExceptionInChain = false; - - - //Recurse through the chain - while ((cause = cause.getCause()) != null) { - - if (cause.getClass().equals(expectedExceptionClass)) { - foundExceptionInChain = true; - break; - } - } - - if (!foundExceptionInChain) { - fail(); - } - - - } -} Index: rctags/ehcache-2.10.9.1.33/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/store/ClusteredStoreExceptionHandler.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/store/ClusteredStoreExceptionHandler.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/store/ClusteredStoreExceptionHandler.java (revision 0) @@ -1,10 +0,0 @@ -/* - * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved. - */ -package org.terracotta.modules.ehcache.store; - -public interface ClusteredStoreExceptionHandler { - - public void handleException(Throwable t); - -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/pool/impl/RoundRobinOnHeapPoolEvictor.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/pool/impl/RoundRobinOnHeapPoolEvictor.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/pool/impl/RoundRobinOnHeapPoolEvictor.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.pool.impl; - -import net.sf.ehcache.pool.PoolAccessor; -import net.sf.ehcache.pool.PoolEvictor; -import net.sf.ehcache.pool.PoolParticipant; - -import java.util.Collection; - -/** - * @author Ludovic Orban - */ -public class RoundRobinOnHeapPoolEvictor implements PoolEvictor { - public boolean freeSpace(Collection> from, long bytes) { - long remaining = bytes; - - while (true) { - for (PoolAccessor accessor : from) { - long beforeEvictionSize = accessor.getSize(); - if (!accessor.getParticipant().evict(1, bytes)) { - return false; - } - long afterEvictionSize = accessor.getSize(); - - remaining -= (beforeEvictionSize - afterEvictionSize); - if (remaining <= 0L) { - return true; - } - } - } - } -} Index: rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/org/terracotta/ehcache/tests/container/hibernate/domain/HolidayCalendar.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/org/terracotta/ehcache/tests/container/hibernate/domain/HolidayCalendar.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/org/terracotta/ehcache/tests/container/hibernate/domain/HolidayCalendar.java (revision 0) @@ -1,59 +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.ehcache.tests.container.hibernate.domain; - -import java.text.DateFormat; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; - -public class HolidayCalendar { - private Long id; - private Map holidays = new HashMap(); // Date -> String - - public HolidayCalendar init() { - DateFormat df = new SimpleDateFormat("yyyy.MM.dd"); - try { - holidays.clear(); - holidays.put(df.parse("2009.01.01"), "New Year's Day"); - holidays.put(df.parse("2009.02.14"), "Valentine's Day"); - holidays.put(df.parse("2009.11.11"), "Armistice Day"); - } catch (ParseException e) { - System.out.println("Error parsing date string"); - throw new RuntimeException(e); - } - return this; - } - - public Map getHolidays() { - return holidays; - } - - protected void setHolidays(Map holidays) { - this.holidays = holidays; - } - - public void addHoliday(Date d, String name) { - holidays.put(d, name); - } - - public String getHoliday(Date d) { - return (String)holidays.get(d); - } - - public boolean isHoliday(Date d) { - return holidays.containsKey(d); - } - - protected Long getId() { - return id; - } - - protected void setId(Long id) { - this.id = id; - } -} - Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/writer/CoalesceKeysFilterTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/writer/CoalesceKeysFilterTest.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/writer/CoalesceKeysFilterTest.java (revision 0) @@ -1,87 +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.Element; -import net.sf.ehcache.writer.writebehind.CastingOperationConverter; -import net.sf.ehcache.writer.writebehind.CoalesceKeysFilter; -import net.sf.ehcache.writer.writebehind.operations.DeleteOperation; -import net.sf.ehcache.writer.writebehind.operations.KeyBasedOperation; -import net.sf.ehcache.writer.writebehind.operations.WriteOperation; - -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.terracotta.test.categories.CheckShorts; - -import java.util.ArrayList; -import java.util.List; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -/** - * Tests for a key-based operations coalescing - * - * @author Geert Bevin - * @version $Id: CoalesceKeysFilterTest.java 8024 2013-08-22 10:33:13Z ljacomet $ - */ -@Category(CheckShorts.class) -public class CoalesceKeysFilterTest { - - @Test - public void testFilter() { - List operations = new ArrayList(); - operations.add(new WriteOperation(new Element("key1", "value1"), 10)); - operations.add(new WriteOperation(new Element("key2", "value2"), 10)); - operations.add(new WriteOperation(new Element("key1", "value3"), 30)); - operations.add(new WriteOperation(new Element("key1", "value4"), 20)); - operations.add(new DeleteOperation(new CacheEntry("key3", new Element("key3", "value5")), 30)); - operations.add(new WriteOperation(new Element("key4", "value6"), 40)); - operations.add(new DeleteOperation(new CacheEntry("key2", new Element("key2", "value7")), 20)); - operations.add(new DeleteOperation(new CacheEntry("key4", new Element("key4", "value8")), 30)); - operations.add(new WriteOperation(new Element("key4", "value9"), 20)); - operations.add(new WriteOperation(new Element("key5", "value10"), 50)); - - // key1 - W 10, W 30, W 20 = 3 - // key2 - W 10, D 20 = 2 - // key3 - D 30 = 1 - // key4 - W 40, D 30, W 20 = 3 - // key5 - W 50 = 1 - // operations = k1, k2, k1, k2, k4, k1, k3, k4, k4, k5 = 10 (create time order) - // operations = k1 10, k2 10, k1 30, k1 20, k3 30, k4 40, k2 20, k4 30, k4 20, k5 50 = 10 (add order) - // operations = k1 30, k3 30, k4 40, k2 20, k5 50 = 5 - - new CoalesceKeysFilter().filter(operations, CastingOperationConverter.getInstance()); - - assertEquals(5, operations.size()); - assertEquals("key1", operations.get(0).getKey()); - assertEquals("value3", ((WriteOperation) operations.get(0)).getElement().getValue()); - - assertTrue(operations.get(1) instanceof DeleteOperation); - assertEquals("key3", operations.get(1).getKey()); - - assertEquals("key4", operations.get(2).getKey()); - assertEquals("value6", ((WriteOperation) operations.get(2)).getElement().getValue()); - - assertTrue(operations.get(3) instanceof DeleteOperation); - assertEquals("key2", operations.get(3).getKey()); - - assertEquals("key5", operations.get(4).getKey()); - assertEquals("value10", ((WriteOperation) operations.get(4)).getElement().getValue()); - } -} \ No newline at end of file Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/resources/ehcache.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/resources/ehcache.xml (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/resources/ehcache.xml (revision 0) @@ -1,184 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Index: rctags/ehcache-2.10.9.1.33/system-tests/src/test/resources/cache-consistency-test.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/system-tests/src/test/resources/cache-consistency-test.xml (revision 11516) +++ rctags/ehcache-2.10.9.1.33/system-tests/src/test/resources/cache-consistency-test.xml (revision 0) @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - Index: rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/org/terracotta/ehcache/tests/DoubleConfigStandaloneCacheTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/org/terracotta/ehcache/tests/DoubleConfigStandaloneCacheTest.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/system-tests/src/test/java/org/terracotta/ehcache/tests/DoubleConfigStandaloneCacheTest.java (revision 0) @@ -1,45 +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.ehcache.tests; - -import com.tc.test.config.model.TestConfig; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileReader; - -/** - * @author cdennis - */ -public class DoubleConfigStandaloneCacheTest extends AbstractCacheTestBase { - - public DoubleConfigStandaloneCacheTest(TestConfig testConfig) { - super("double-config-cache-test.xml", testConfig); - } - - @Override - protected void evaluateClientOutput(String clientName, int exitCode, File output) throws Throwable { - if ((exitCode == 0)) { throw new AssertionError("Client " + clientName + " exited with exit code: " + exitCode); } - - FileReader fr = null; - try { - fr = new FileReader(output); - BufferedReader reader = new BufferedReader(fr); - String st = ""; - while ((st = reader.readLine()) != null) { - if (st.contains("InvalidConfigurationException")) return; - } - throw new AssertionError("Client " + clientName + " did not pass"); - } catch (Exception e) { - throw new AssertionError(e); - } finally { - try { - fr.close(); - } catch (Exception e) { - // - } - } - } -} Index: rctags/ehcache-2.10.9.1.33/distribution/colorcache/src/assemble/jetty6.1/9081/conf.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/distribution/colorcache/src/assemble/jetty6.1/9081/conf.xml (revision 11516) +++ rctags/ehcache-2.10.9.1.33/distribution/colorcache/src/assemble/jetty6.1/9081/conf.xml (revision 0) @@ -1,63 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /webapps - false - true - false - - - - - - - - ./logs/console.yyyy_mm_dd.log - false - 90 - GMT - - - - - - Redirecting stderr/stdout to - - - - Index: rctags/ehcache-2.10.9.1.33/distribution/colorcache/src/assemble/jetty6.1/9082/conf.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/distribution/colorcache/src/assemble/jetty6.1/9082/conf.xml (revision 11516) +++ rctags/ehcache-2.10.9.1.33/distribution/colorcache/src/assemble/jetty6.1/9082/conf.xml (revision 0) @@ -1,63 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /webapps - false - true - false - - - - - - - - ./logs/console.yyyy_mm_dd.log - false - 90 - GMT - - - - - - Redirecting stderr/stdout to - - - - Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/config/DynamicSearchListener.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/config/DynamicSearchListener.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/config/DynamicSearchListener.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.config; - -import net.sf.ehcache.search.attribute.DynamicAttributesExtractor; - -/** - * Listener for changes to dynamic attributes extractor config - * @author vfunshte - */ -public interface DynamicSearchListener { - /** - * Called to indicate that a new dynamic attributes extractor was added - * @param oldValue - * @param newValue - */ - public void extractorChanged(DynamicAttributesExtractor oldValue, DynamicAttributesExtractor newValue); -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/constructs/nonstop/MockCacheWriterFactory.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/constructs/nonstop/MockCacheWriterFactory.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/constructs/nonstop/MockCacheWriterFactory.java (revision 0) @@ -1,76 +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.nonstop; - -import java.util.Collection; -import java.util.Properties; - -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.CacheWriter; -import net.sf.ehcache.writer.CacheWriterFactory; -import net.sf.ehcache.writer.writebehind.operations.SingleOperationType; - -public class MockCacheWriterFactory extends CacheWriterFactory { - - @Override - public CacheWriter createCacheWriter(Ehcache cache, Properties properties) { - return new CacheWriter() { - - public void writeAll(Collection elements) throws CacheException { - // no-op - } - - public void write(Element element) throws CacheException { - // no-op - - } - - public void init() { - // no-op - - } - - public void dispose() throws CacheException { - // no-op - - } - - public void deleteAll(Collection entries) throws CacheException { - // no-op - - } - - public void throwAway(final Element element, final SingleOperationType operationType, final RuntimeException e) { - // no-op - } - - public void delete(CacheEntry entry) throws CacheException { - // no-op - - } - - public CacheWriter clone(Ehcache cache) throws CloneNotSupportedException { - // no-op - return null; - } - }; - } - -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/store/TxCopyStrategyHandler.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/store/TxCopyStrategyHandler.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/store/TxCopyStrategyHandler.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.store; - -import net.sf.ehcache.Element; -import net.sf.ehcache.store.compound.ReadWriteCopyStrategy; -import net.sf.ehcache.transaction.SoftLockID; - -/** - * @author Alex Snaps - */ -public class TxCopyStrategyHandler extends CopyStrategyHandler { - - /** - * Creates a TxCopyStrategyHandler based on the copy configuration - * - * @param copyOnRead copy on read flag - * @param copyOnWrite copy on write flag - * @param copyStrategy the copy strategy to use - * @param loader - */ - public TxCopyStrategyHandler(final boolean copyOnRead, final boolean copyOnWrite, - final ReadWriteCopyStrategy copyStrategy, final ClassLoader loader) { - super(copyOnRead, copyOnWrite, copyStrategy, loader); - } - - @Override - public Element copyElementForReadIfNeeded(final Element element) { - final Object objectValue = element.getObjectValue(); - if (objectValue instanceof SoftLockID) { - return super.copyElementForReadIfNeeded(((SoftLockID)objectValue).getOldElement()); - } - return super.copyElementForReadIfNeeded(element); - } -} Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/config/generator/model/NodeElement.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/config/generator/model/NodeElement.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/config/generator/model/NodeElement.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.config.generator.model; - -import java.util.List; - -/** - * Interface that abstracts the idea of an element. An element has a name, list of {@link NodeAttribute}'s, a parent element and child elements - * - * @author Abhishek Sanoujam - * - */ -public interface NodeElement { - - /** - * The name of the element - * - * @return Name of the element - */ - String getName(); - - /** - * Same as calling {@link #getFQName(String)} with the string "." - * - * @return the fully qualified name of this element - */ - String getFQName(); - - /** - * The fully qualified name of the element. The fully qualified name of the name is the name from the root element till this element - * separated by the delimiter string - * - * @param delimiter - * @return the fully qualified name of this element separated by delimiter - */ - String getFQName(String delimiter); - - /** - * List of attributes of this element - * - * @return list of attributes of this element - */ - List getAttributes(); - - /** - * Returns the parent of this element. May be null. - * - * @return parent of this element. May be null. - */ - NodeElement getParent(); - - /** - * Returns the list of child elements. - * - * @return the list of child elements - */ - List getChildElements(); - - /** - * Returns true if there is at least one child - * - * @return true if there is at least one child, otherwise false - */ - boolean hasChildren(); - - /** - * The inner content of this element as string. Does not include the child elements - * - * @return inner content of this element as string. This does not include the child elements - */ - String getInnerContent(); - - /** - * Add an attribute - * - * @param attribute - * add an attribute - */ - void addAttribute(NodeAttribute attribute); - - /** - * Adds a child element. - * - * @param childElement - * adds a child element - */ - void addChildElement(NodeElement childElement); - - /** - * Accepts an {@link NodeElementVisitor} - * - * @param visitor - * the visitor whose visit methods will be called - */ - void accept(NodeElementVisitor visitor); - - /** - * Returns true if this element is optional - * - * @return true if this element is optional - */ - boolean isOptional(); - - /** - * Sets optional or not - * - * @param optional - */ - void setOptional(boolean optional); - - /** - * Sets the inner content of this element - * - * @param content - */ - void setInnerContent(String content); -} Index: rctags/ehcache-2.10.9.1.33/system-tests/src/test/resources/strong-cache-invalidation-test.xml =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/system-tests/src/test/resources/strong-cache-invalidation-test.xml (revision 11516) +++ rctags/ehcache-2.10.9.1.33/system-tests/src/test/resources/strong-cache-invalidation-test.xml (revision 0) @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - - - Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/transaction/xa/TwoPCTest.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/transaction/xa/TwoPCTest.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/test/java/net/sf/ehcache/transaction/xa/TwoPCTest.java (revision 0) @@ -1,151 +0,0 @@ -package net.sf.ehcache.transaction.xa; - -import bitronix.tm.BitronixTransactionManager; -import bitronix.tm.TransactionManagerServices; -import bitronix.tm.internal.TransactionStatusChangeListener; -import net.sf.ehcache.Cache; -import net.sf.ehcache.CacheManager; -import net.sf.ehcache.CacheStoreHelper; -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.store.TxCopyingCacheStore; -import net.sf.ehcache.transaction.TransactionTimeoutException; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import java.lang.reflect.Field; -import java.util.Map; - -import javax.transaction.RollbackException; -import javax.transaction.Status; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; - -/** - * @author lorban - */ -public class TwoPCTest { - - private CacheManager cacheManager; - private Ehcache xaCache1; - private Ehcache xaCache2; - private BitronixTransactionManager transactionManager; - - @Before - public void setUp() throws Exception { - TransactionManagerServices.getConfiguration().setJournal("null").setServerId("SoftLockPinningTest"); - transactionManager = TransactionManagerServices.getTransactionManager(); - - cacheManager = new CacheManager(new Configuration()); - - cacheManager.addCache(new Cache(new CacheConfiguration().name("xaCache1") - .maxEntriesLocalHeap(10) - .transactionalMode(CacheConfiguration.TransactionalMode.XA_STRICT))); - cacheManager.addCache(new Cache(new CacheConfiguration().name("xaCache2") - .maxEntriesLocalHeap(10) - .transactionalMode(CacheConfiguration.TransactionalMode.XA_STRICT))); - - xaCache1 = cacheManager.getEhcache("xaCache1"); - xaCache2 = cacheManager.getEhcache("xaCache2"); - } - - private void clearAll() throws Exception { - transactionManager.begin(); - xaCache1.removeAll(); - xaCache2.removeAll(); - transactionManager.commit(); - } - - @After - public void tearDown() throws Exception { - if (transactionManager.getStatus() != Status.STATUS_NO_TRANSACTION) { - transactionManager.rollback(); - } - transactionManager.shutdown(); - cacheManager.shutdown(); - } - - @Test - public void testRemoveCachesAfterPhase1() throws Exception { - clearAll(); - transactionManager.begin(); - - for (int i = 0; i < 100; i++) { - Element element1 = new Element(i, i); - element1.setTimeToIdle(1); - element1.setTimeToLive(1); - xaCache1.put(element1); - - Element element2 = new Element(i, i); - element2.setTimeToIdle(1); - element2.setTimeToLive(1); - xaCache2.put(element2); - } - - // Remove the caches between the 1st and 2nd phase of 2PC to make sure the soft locks are in the cache but won't be deserializable. - // We must also make sure to use at least 2 XA resources to prevent the 1PC optimization to kick in. - transactionManager.getCurrentTransaction().addTransactionStatusChangeListener(new TransactionStatusChangeListener() { - public void statusChanged(final int oldStatus, final int newStatus) { - if (oldStatus == Status.STATUS_PREPARED) { - cacheManager.removeCache("xaCache1"); - cacheManager.removeCache("xaCache2"); - } - } - }); - - // the TM should be able to commit without problem, the test should just pass. - transactionManager.commit(); - } - - @Test - public void testTimeout() throws Exception { - xaCache1.getCacheManager().getTransactionController().setDefaultTransactionTimeout(5); - - transactionManager.setTransactionTimeout(2); - transactionManager.begin(); - - // get doesn't enlist -> XATransactionStore will set this cache's XA timeout for this TX to be the default local TX timeout - xaCache1.get(1); - - Thread.sleep(3000); - // XA tx timed out but the resource doesn't know about it -> call succeeds - xaCache1.get(1); - - Thread.sleep(3000); - // cache's XA timeout for this TX reached -> fail - try { - xaCache1.get(1); - fail("expected TransactionTimeoutException"); - } catch (TransactionTimeoutException e) { - // expected - } - - try { - // this XA tx timed out - transactionManager.commit(); - fail("expected RollbackException"); - } catch (RollbackException e) { - // expected - } - - // check that there is no internal leak (EHC-937) - assertEquals(0, ((Map)getStoreField(xaCache1, "transactionToTimeoutMap")).size()); - } - - private static Object getStoreField(Ehcache cache, String storeFieldName) throws IllegalAccessException, NoSuchFieldException { - CacheStoreHelper cacheStoreHelper = new CacheStoreHelper((Cache)cache); - - TxCopyingCacheStore copyingCacheStore = (TxCopyingCacheStore)cacheStoreHelper.getStore(); - XATransactionStore store = (XATransactionStore)copyingCacheStore.getUnderlyingStore(); - - Field field = store.getClass().getDeclaredField(storeFieldName); - field.setAccessible(true); - return field.get(store); - } - -} \ No newline at end of file Index: rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/hibernate/management/impl/BaseEmitterBean.java =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/hibernate/management/impl/BaseEmitterBean.java (revision 11516) +++ rctags/ehcache-2.10.9.1.33/ehcache-core/src/main/java/net/sf/ehcache/hibernate/management/impl/BaseEmitterBean.java (revision 0) @@ -1,168 +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.util.List; -import java.util.concurrent.CopyOnWriteArrayList; -import java.util.concurrent.atomic.AtomicLong; - -import javax.management.ListenerNotFoundException; -import javax.management.MBeanNotificationInfo; -import javax.management.NotCompliantMBeanException; -import javax.management.Notification; -import javax.management.NotificationBroadcasterSupport; -import javax.management.NotificationEmitter; -import javax.management.NotificationFilter; -import javax.management.NotificationListener; -import javax.management.StandardMBean; - -/** - * @author gkeim - * - */ -public abstract class BaseEmitterBean extends StandardMBean implements NotificationEmitter { - /** - * emitter - */ - protected final Emitter emitter = new Emitter(); - - /** - * sequenceNumber - */ - protected final AtomicLong sequenceNumber = new AtomicLong(); - - - private final List notificationListeners = new CopyOnWriteArrayList(); - - /** - * BaseEmitterBean - * - * @param - * @param mbeanInterface - * @throws NotCompliantMBeanException - */ - protected BaseEmitterBean(Class mbeanInterface) throws NotCompliantMBeanException { - super(mbeanInterface); - } - - /** - * sendNotification - * - * @param eventType - */ - public void sendNotification(String eventType) { - sendNotification(eventType, null, null); - } - - /** - * sendNotification - * - * @param eventType - * @param data - */ - public void sendNotification(String eventType, Object data) { - sendNotification(eventType, data, null); - } - - /** - * sendNotification - * - * @param eventType - * @param data - * @param msg - */ - public void sendNotification(String eventType, Object data, String msg) { - Notification notif = new Notification(eventType, this, sequenceNumber.incrementAndGet(), System.currentTimeMillis(), msg); - if (data != null) { - notif.setUserData(data); - } - emitter.sendNotification(notif); - } - - /** - * Dispose of this SampledCacheManager and clean up held resources - */ - public final void dispose() { - doDispose(); - removeAllNotificationListeners(); - } - - /** - * Dispose callback of subclasses - */ - protected abstract void doDispose(); - - /** - * @author gkeim - */ - private class Emitter extends NotificationBroadcasterSupport { - /** - * @see javax.management.NotificationBroadcasterSupport#getNotificationInfo() - */ - @Override - public MBeanNotificationInfo[] getNotificationInfo() { - return BaseEmitterBean.this.getNotificationInfo(); - } - } - - /** - * @see javax.management.NotificationBroadcaster#addNotificationListener(javax.management.NotificationListener, - * javax.management.NotificationFilter, java.lang.Object) - */ - public void addNotificationListener(NotificationListener notif, NotificationFilter filter, Object callBack) { - emitter.addNotificationListener(notif, filter, callBack); - notificationListeners.add(notif); - } - - /** - * remove all added notification listeners - */ - private void removeAllNotificationListeners() { - for (NotificationListener listener : notificationListeners) { - try { - emitter.removeNotificationListener(listener); - } catch (ListenerNotFoundException e) { - // ignore - } - } - notificationListeners.clear(); - } - - /** - * @see javax.management.NotificationBroadcaster#getNotificationInfo() - */ - public abstract MBeanNotificationInfo[] getNotificationInfo(); - - - /** - * @see javax.management.NotificationBroadcaster#removeNotificationListener(javax.management.NotificationListener) - */ - public void removeNotificationListener(NotificationListener listener) throws ListenerNotFoundException { - emitter.removeNotificationListener(listener); - notificationListeners.remove(listener); - } - - /** - * @see javax.management.NotificationEmitter#removeNotificationListener(javax.management.NotificationListener, - * javax.management.NotificationFilter, java.lang.Object) - */ - public void removeNotificationListener(NotificationListener notif, NotificationFilter filter, Object callBack) - throws ListenerNotFoundException { - emitter.removeNotificationListener(notif, filter, callBack); - notificationListeners.remove(notif); - } -} Index: rctags/ehcache-2.10.9.1.33/distribution/src/main/assembly/root/licenses/EHCACHE-TERRACOTTA-LICENSE.txt =================================================================== diff -u -N --- rctags/ehcache-2.10.9.1.33/distribution/src/main/assembly/root/licenses/EHCACHE-TERRACOTTA-LICENSE.txt (revision 11516) +++ rctags/ehcache-2.10.9.1.33/distribution/src/main/assembly/root/licenses/EHCACHE-TERRACOTTA-LICENSE.txt (revision 0) @@ -1,534 +0,0 @@ -Terracotta Public License Version 1.0 -===================================== - -1. Definitions - -1.1. "Contributor" means each individual or entity that creates or -contributes to the creation of Modifications. - -1.2. "Contributor Version" means the combination of the Original Code, -prior Modifications used by a Contributor, and the Modifications made -by that particular Contributor. - -1.3. "Covered Code" means the Original Code or Modifications or the -combination of the Original Code and Modifications, in each case -including portions thereof. - -1.4. "Electronic Distribution Mechanism" means a mechanism generally -accepted in the software development community for the electronic -transfer of data. - -1.5. "Executable" means Covered Code in any form other than Source -Code. - -1.6. "Initial Developer" means the individual or entity identified as -the Initial Developer in the Source Code notice required by Exhibit A. - -1.7. "Larger Work" means a work which combines Covered Code or portions -thereof with code not governed by the terms of this License. - -1.8. "License" means this document. - -1.8.1. "Licensable" means having the right to grant, to the maximum -extent possible, whether at the time of the initial grant or -subsequently acquired, any and all of the rights conveyed herein. - -1.9. "Modifications" means any addition to or deletion from the -substance or structure of either the Original Code or any previous -Modifications. When Covered Code is released as a series of files, a -Modification is: - - a. Any addition to or deletion from the contents of a file - containing Original Code or previous Modifications. - - b. Any new file that contains any part of the Original Code or - previous Modifications. - - c. Any new file that is contributed or otherwise made available - under the terms of this License. - -1.10. "Original Code" means Source Code and Executable form of computer -software code which is described in the Source Code notice required by -Exhibit A as Original Code, and which, at the time of its release under -this License is not already Covered Code governed by this License. - -1.10.1. "Patent Claims" means any patent claim(s), now owned or -hereafter acquired, including without limitation, method, process, and -apparatus claims, in any patent Licensable by grantor. - -1.11. "Source Code" means the preferred form of the Covered Code for -making modifications to it, including all modules it contains, plus any -associated interface definition files, scripts used to control -compilation and installation of an Executable, or source code -differential comparisons against either the Original Code or another -well known, available Covered Code of the Contributor's choice. The -Source Code can be in a compressed or archival form, provided the -appropriate decompression or de-archiving software is widely available -for no charge. - -1.12. "You" (or "Your") means an individual or a legal entity -exercising rights under, and complying with all of the terms of, this -License or a future version of this License issued under Section 6.1. -For legal entities, "You" includes any entity which controls, is -controlled by, or is under common control with You. For purposes of -this definition, "control" means (a) the power, direct or indirect, to -cause the direction or management of such entity, whether by contract -or otherwise, or (b) ownership of more than fifty percent (50%) of the -outstanding shares or beneficial ownership of such entity. - - -2. Source Code License - -2.1. The Initial Developer Grant. - -THE INITIAL DEVELOPER HEREBY GRANTS YOU A WORLD-WIDE, ROYALTY-FREE, -NON-EXCLUSIVE LICENSE, SUBJECT TO THIRD PARTY INTELLECTUAL PROPERTY -CLAIMS: - - a. under intellectual property rights (other than patent or - trademark) Licensable by Initial Developer to use, reproduce, - modify, display, perform, sublicense and distribute the - Original Code (or portions thereof) with or without - Modifications, and/or as part of a Larger Work; and - - b. under Patents Claims infringed by the making, using or selling - of Original Code, to make, have made, use, practice, sell, and - offer for sale, and/or otherwise dispose of the Original Code - (or portions thereof). - - c. the licenses granted in this Section 2.1 (a) and (b) are - effective on the date Initial Developer first distributes or - otherwise makes available O