exo-jcr SVN: r4721 - in jcr/trunk: applications/exo.jcr.applications.config and 17 other directories.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2011-08-09 10:08:31 -0400 (Tue, 09 Aug 2011)
New Revision: 4721
Added:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/infinispan/JBossStandaloneJTAManagerLookup.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/TestISPNCacheWorkspaceStorageCache.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/TestJBossCacheWorkspaceStorageCache.java
Removed:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestISPNCacheWorkspaceStorageCache.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestJBossCacheWorkspaceStorageCache.java
Modified:
jcr/trunk/applications/exo.jcr.applications.config/pom.xml
jcr/trunk/applications/exo.jcr.ear/pom.xml
jcr/trunk/applications/product-patches/as/jboss/exo-configuration.xml
jcr/trunk/applications/product-patches/as/jetty/exo-configuration.xml
jcr/trunk/applications/product-patches/as/jonas/exo-configuration.xml
jcr/trunk/applications/product-patches/as/tomcat/exo-configuration.xml
jcr/trunk/exo.jcr.component.core/pom.xml
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/BufferedISPNCache.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CacheId.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CacheNodesByPageId.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CacheNodesId.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CachePatternNodesId.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CachePatternPropsId.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CachePropsId.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CacheQPath.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CacheRefsId.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/ISPNCacheWorkspaceStorageCache.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/infinispan/ISPNCacheFactory.java
jcr/trunk/exo.jcr.component.core/src/main/resources/conf/portal/cluster/infinispan-data.xml
jcr/trunk/exo.jcr.component.core/src/main/resources/conf/portal/cluster/infinispan-indexer.xml
jcr/trunk/exo.jcr.component.core/src/main/resources/conf/portal/cluster/infinispan-lock.xml
jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/cluster/test-configuration.xml
jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/cluster/test-infinispan-config.xml
jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/cluster/test-infinispan-indexer.xml
jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/cluster/test-infinispan-lock.xml
jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-configuration-sjdbc.xml
jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-configuration.xml
jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-infinispan-config.xml
jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-infinispan-lock.xml
jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/kernel/transaction-service.xml
jcr/trunk/pom.xml
Log:
EXOJCR-1475: Upgrade ISPN to 5.0.0 FINAL (JCR part)
* BufferedISPNCache has been updated to better fit with the new API
* All cache key types has been modified to add a public constructor with no argument to prevent serialization exceptions
* putIfAbsent has been re-set to the method ISPNCacheWorkspaceStorageCache.addChildNodes to prevent TestISPNCacheWorkspaceStorageCacheInClusterMode to fail
* JGroups and ISPN have been upgraded in the pom files
* jboss-logging-spi has been excluded in case of ISPN to prevent conflicts with the latest version
* JBossStandaloneJTAManagerLookup has been rewritten to prevent issues due to the loading order (more info in the class org.exoplatform.services.transaction.infinispan.JBossStandaloneJTAManagerLookup)
* Fluent config has been used to prevent compilation warnings
* Adapted the config files to ISPN 5 : Correct version has been set to the config files header, replication timeout has been set explicitly to prevent warnings, wakeUpInterval has been moved from eviction to expiration and the new transactionManagerLookupClass has been set
* TestISPNCacheWorkspaceStorageCache and TestJBossCacheWorkspaceStorageCache have been moved to org.exoplatform.services.jcr.impl.dataflow.persistent.infinispan and to org.exoplatform.services.jcr.impl.dataflow.persistent.jbosscache to be easily excluded since they fail due to their conflict dependencies
Modified: jcr/trunk/applications/exo.jcr.applications.config/pom.xml
===================================================================
--- jcr/trunk/applications/exo.jcr.applications.config/pom.xml 2011-08-09 14:05:16 UTC (rev 4720)
+++ jcr/trunk/applications/exo.jcr.applications.config/pom.xml 2011-08-09 14:08:31 UTC (rev 4721)
@@ -92,7 +92,7 @@
<dependency>
<groupId>org.jgroups</groupId>
<artifactId>jgroups</artifactId>
- <version>2.11.1.Final</version>
+ <version>2.12.1.3.Final</version>
</dependency>
<dependency>
<groupId>org.infinispan</groupId>
@@ -101,6 +101,18 @@
<dependency>
<groupId>org.infinispan</groupId>
<artifactId>infinispan-cachestore-jdbc</artifactId>
- </dependency>
+ </dependency>
+ <!-- Excludes jboss-logging-spi since it is in conflict with the
+ latest version that is required by infinispan -->
+ <dependency>
+ <groupId>org.jboss.cache</groupId>
+ <artifactId>jbosscache-core</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-spi</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
</dependencies>
</project>
Modified: jcr/trunk/applications/exo.jcr.ear/pom.xml
===================================================================
--- jcr/trunk/applications/exo.jcr.ear/pom.xml 2011-08-09 14:05:16 UTC (rev 4720)
+++ jcr/trunk/applications/exo.jcr.ear/pom.xml 2011-08-09 14:08:31 UTC (rev 4721)
@@ -115,7 +115,7 @@
<dependency>
<groupId>org.jgroups</groupId>
<artifactId>jgroups</artifactId>
- <version>2.11.1.Final</version>
+ <version>2.12.1.3.Final</version>
</dependency>
<dependency>
<groupId>org.infinispan</groupId>
@@ -124,7 +124,19 @@
<dependency>
<groupId>org.infinispan</groupId>
<artifactId>infinispan-cachestore-jdbc</artifactId>
- </dependency>
+ </dependency>
+ <!-- Excludes jboss-logging-spi since it is in conflict with the
+ latest version that is required by infinispan -->
+ <dependency>
+ <groupId>org.jboss.cache</groupId>
+ <artifactId>jbosscache-core</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-spi</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
</dependencies>
<build>
<finalName>exo-jcr-ear</finalName>
Modified: jcr/trunk/applications/product-patches/as/jboss/exo-configuration.xml
===================================================================
--- jcr/trunk/applications/product-patches/as/jboss/exo-configuration.xml 2011-08-09 14:05:16 UTC (rev 4720)
+++ jcr/trunk/applications/product-patches/as/jboss/exo-configuration.xml 2011-08-09 14:08:31 UTC (rev 4721)
@@ -195,7 +195,7 @@
</component>
<component profiles="ispn">
<key>org.infinispan.transaction.lookup.TransactionManagerLookup</key>
- <type>org.infinispan.transaction.lookup.JBossStandaloneJTAManagerLookup</type>
+ <type>org.exoplatform.services.transaction.infinispan.JBossStandaloneJTAManagerLookup</type>
</component>
<component profiles="ispn">
Modified: jcr/trunk/applications/product-patches/as/jetty/exo-configuration.xml
===================================================================
--- jcr/trunk/applications/product-patches/as/jetty/exo-configuration.xml 2011-08-09 14:05:16 UTC (rev 4720)
+++ jcr/trunk/applications/product-patches/as/jetty/exo-configuration.xml 2011-08-09 14:08:31 UTC (rev 4721)
@@ -195,7 +195,7 @@
</component>
<component profiles="ispn">
<key>org.infinispan.transaction.lookup.TransactionManagerLookup</key>
- <type>org.infinispan.transaction.lookup.JBossStandaloneJTAManagerLookup</type>
+ <type>org.exoplatform.services.transaction.infinispan.JBossStandaloneJTAManagerLookup</type>
</component>
<component profiles="ispn">
Modified: jcr/trunk/applications/product-patches/as/jonas/exo-configuration.xml
===================================================================
--- jcr/trunk/applications/product-patches/as/jonas/exo-configuration.xml 2011-08-09 14:05:16 UTC (rev 4720)
+++ jcr/trunk/applications/product-patches/as/jonas/exo-configuration.xml 2011-08-09 14:08:31 UTC (rev 4721)
@@ -195,7 +195,7 @@
</component>
<component profiles="ispn">
<key>org.infinispan.transaction.lookup.TransactionManagerLookup</key>
- <type>org.infinispan.transaction.lookup.JBossStandaloneJTAManagerLookup</type>
+ <type>org.exoplatform.services.transaction.infinispan.JBossStandaloneJTAManagerLookup</type>
</component>
<component profiles="ispn">
Modified: jcr/trunk/applications/product-patches/as/tomcat/exo-configuration.xml
===================================================================
--- jcr/trunk/applications/product-patches/as/tomcat/exo-configuration.xml 2011-08-09 14:05:16 UTC (rev 4720)
+++ jcr/trunk/applications/product-patches/as/tomcat/exo-configuration.xml 2011-08-09 14:08:31 UTC (rev 4721)
@@ -211,7 +211,7 @@
</component>
<component profiles="ispn">
<key>org.infinispan.transaction.lookup.TransactionManagerLookup</key>
- <type>org.infinispan.transaction.lookup.JBossStandaloneJTAManagerLookup</type>
+ <type>org.exoplatform.services.transaction.infinispan.JBossStandaloneJTAManagerLookup</type>
</component>
<component profiles="ispn">
Modified: jcr/trunk/exo.jcr.component.core/pom.xml
===================================================================
--- jcr/trunk/exo.jcr.component.core/pom.xml 2011-08-09 14:05:16 UTC (rev 4720)
+++ jcr/trunk/exo.jcr.component.core/pom.xml 2011-08-09 14:08:31 UTC (rev 4721)
@@ -853,8 +853,20 @@
<dependency>
<groupId>org.jgroups</groupId>
<artifactId>jgroups</artifactId>
- <version>2.11.1.Final</version>
+ <version>2.12.1.3.Final</version>
</dependency>
+ <!-- Excludes jboss-logging-spi since it is in conflict with the
+ latest version that is required by infinispan -->
+ <dependency>
+ <groupId>org.jboss.cache</groupId>
+ <artifactId>jbosscache-core</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-spi</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
</dependencies>
</profile>
<profile>
@@ -868,8 +880,20 @@
<dependency>
<groupId>org.jgroups</groupId>
<artifactId>jgroups</artifactId>
- <version>2.11.1.Final</version>
+ <version>2.12.1.3.Final</version>
</dependency>
+ <!-- Excludes jboss-logging-spi since it is in conflict with the
+ latest version that is required by infinispan -->
+ <dependency>
+ <groupId>org.jboss.cache</groupId>
+ <artifactId>jbosscache-core</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-spi</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
</dependencies>
</profile>
<profile>
@@ -883,8 +907,20 @@
<dependency>
<groupId>org.jgroups</groupId>
<artifactId>jgroups</artifactId>
- <version>2.11.1.Final</version>
+ <version>2.12.1.3.Final</version>
</dependency>
+ <!-- Excludes jboss-logging-spi since it is in conflict with the
+ latest version that is required by infinispan -->
+ <dependency>
+ <groupId>org.jboss.cache</groupId>
+ <artifactId>jbosscache-core</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-spi</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
</dependencies>
</profile>
</profiles>
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java 2011-08-09 14:05:16 UTC (rev 4720)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java 2011-08-09 14:08:31 UTC (rev 4721)
@@ -463,7 +463,7 @@
* @param systemDataContainerHolder
* System Workspace data container (persistent level)
*/
- protected CacheableWorkspaceDataManager(WorkspaceDataContainer dataContainer, WorkspaceStorageCache cache,
+ public CacheableWorkspaceDataManager(WorkspaceDataContainer dataContainer, WorkspaceStorageCache cache,
SystemDataContainerHolder systemDataContainerHolder)
{
this(dataContainer, cache, systemDataContainerHolder, null, (RPCService)null);
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/BufferedISPNCache.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/BufferedISPNCache.java 2011-08-09 14:05:16 UTC (rev 4720)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/BufferedISPNCache.java 2011-08-09 14:08:31 UTC (rev 4721)
@@ -29,7 +29,7 @@
import org.infinispan.config.Configuration.CacheMode;
import org.infinispan.context.Flag;
import org.infinispan.lifecycle.ComponentStatus;
-import org.infinispan.manager.CacheContainer;
+import org.infinispan.manager.EmbeddedCacheManager;
import org.infinispan.util.concurrent.NotifyingFuture;
import java.security.PrivilegedAction;
@@ -514,7 +514,7 @@
/**
* {@inheritDoc}
*/
- public CacheContainer getCacheManager()
+ public EmbeddedCacheManager getCacheManager()
{
return parentCache.getCacheManager();
}
@@ -1007,6 +1007,14 @@
}
/**
+ * {@inheritDoc}
+ */
+ public NotifyingFuture<Object> getAsync(CacheKey key)
+ {
+ return parentCache.getAsync(key);
+ }
+
+ /**
* Start buffering process.
*/
public void beginTransaction()
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CacheId.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CacheId.java 2011-08-09 14:05:16 UTC (rev 4720)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CacheId.java 2011-08-09 14:08:31 UTC (rev 4721)
@@ -27,7 +27,7 @@
public class CacheId extends CacheKey
{
- CacheId()
+ public CacheId()
{
super();
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CacheNodesByPageId.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CacheNodesByPageId.java 2011-08-09 14:05:16 UTC (rev 4720)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CacheNodesByPageId.java 2011-08-09 14:08:31 UTC (rev 4721)
@@ -25,7 +25,7 @@
public class CacheNodesByPageId extends CacheKey
{
- CacheNodesByPageId()
+ public CacheNodesByPageId()
{
super();
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CacheNodesId.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CacheNodesId.java 2011-08-09 14:05:16 UTC (rev 4720)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CacheNodesId.java 2011-08-09 14:08:31 UTC (rev 4721)
@@ -31,7 +31,7 @@
public class CacheNodesId extends CacheKey
{
- CacheNodesId()
+ public CacheNodesId()
{
super();
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CachePatternNodesId.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CachePatternNodesId.java 2011-08-09 14:05:16 UTC (rev 4720)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CachePatternNodesId.java 2011-08-09 14:08:31 UTC (rev 4721)
@@ -27,7 +27,7 @@
public class CachePatternNodesId extends CacheKey
{
- CachePatternNodesId()
+ public CachePatternNodesId()
{
super();
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CachePatternPropsId.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CachePatternPropsId.java 2011-08-09 14:05:16 UTC (rev 4720)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CachePatternPropsId.java 2011-08-09 14:08:31 UTC (rev 4721)
@@ -27,7 +27,7 @@
public class CachePatternPropsId extends CacheKey
{
- CachePatternPropsId()
+ public CachePatternPropsId()
{
super();
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CachePropsId.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CachePropsId.java 2011-08-09 14:05:16 UTC (rev 4720)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CachePropsId.java 2011-08-09 14:08:31 UTC (rev 4721)
@@ -31,7 +31,7 @@
public class CachePropsId extends CacheKey
{
- CachePropsId()
+ public CachePropsId()
{
super();
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CacheQPath.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CacheQPath.java 2011-08-09 14:05:16 UTC (rev 4720)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CacheQPath.java 2011-08-09 14:08:31 UTC (rev 4721)
@@ -35,7 +35,7 @@
*/
class CacheQPath extends CacheKey
{
- CacheQPath()
+ public CacheQPath()
{
super();
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CacheRefsId.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CacheRefsId.java 2011-08-09 14:05:16 UTC (rev 4720)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CacheRefsId.java 2011-08-09 14:08:31 UTC (rev 4721)
@@ -30,7 +30,7 @@
*/
public class CacheRefsId extends CacheKey
{
- CacheRefsId()
+ public CacheRefsId()
{
super();
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/ISPNCacheWorkspaceStorageCache.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/ISPNCacheWorkspaceStorageCache.java 2011-08-09 14:05:16 UTC (rev 4720)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/ISPNCacheWorkspaceStorageCache.java 2011-08-09 14:08:31 UTC (rev 4721)
@@ -662,12 +662,12 @@
putNode(child, ModifyChildOption.NOT_MODIFY);
set.add(child.getIdentifier());
}
- cache.put(new CacheNodesId(parent.getIdentifier()), set);
+ cache.putIfAbsent(new CacheNodesId(parent.getIdentifier()), set);
}
else
{
// cache fact of empty childs list
- cache.put(new CacheNodesId(parent.getIdentifier()), new HashSet<Object>());
+ cache.putIfAbsent(new CacheNodesId(parent.getIdentifier()), new HashSet<Object>());
}
}
finally
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/infinispan/ISPNCacheFactory.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/infinispan/ISPNCacheFactory.java 2011-08-09 14:05:16 UTC (rev 4720)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/infinispan/ISPNCacheFactory.java 2011-08-09 14:08:31 UTC (rev 4721)
@@ -215,10 +215,10 @@
GlobalConfiguration gc = manager.getGlobalConfiguration();
ExoContainer container = ExoContainerContext.getCurrentContainer();
// Ensure that the cluster name won't be used between 2 ExoContainers
- gc.setClusterName(gc.getClusterName() + "_" + container.getContext().getName());
- gc.setCacheManagerName(gc.getCacheManagerName() + "_" + container.getContext().getName());
+ gc.fluent().transport().clusterName(gc.getClusterName() + "_" + container.getContext().getName())
+ .globalJmxStatistics().cacheManagerName(gc.getCacheManagerName() + "_" + container.getContext().getName()).
// Configure the MBeanServerLookup
- gc.setMBeanServerLookupInstance(MBEAN_SERVER_LOOKUP);
+ mBeanServerLookup(MBEAN_SERVER_LOOKUP);
Configuration conf = manager.getDefaultConfiguration();
if (CACHE_MANAGERS.containsKey(gc))
{
Added: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/infinispan/JBossStandaloneJTAManagerLookup.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/infinispan/JBossStandaloneJTAManagerLookup.java (rev 0)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/infinispan/JBossStandaloneJTAManagerLookup.java 2011-08-09 14:08:31 UTC (rev 4721)
@@ -0,0 +1,104 @@
+/*
+ * Copyright (C) 2011 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.transaction.infinispan;
+
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+import org.exoplatform.services.transaction.TransactionService;
+import org.infinispan.transaction.lookup.TransactionManagerLookup;
+
+import java.lang.reflect.Method;
+
+import javax.transaction.TransactionManager;
+import javax.transaction.UserTransaction;
+
+/**
+ * This class is used to replace the one provided by default in ISPN 5.0 since
+ * it implicitly requires that ISPN is initialized before the rest which is actually
+ * the exact opposite. Indeed Arjuna accessors are initialized in the init method which is
+ * called at ISPN initialization but we expect to get the {@link TransactionManager}
+ * from it through the {@link TransactionService} before initializing the JCR so before
+ * initializing ISPN.
+ *
+ * The code below is a simple copy/paste of the code of
+ * {@link org.infinispan.transaction.lookup.JBossStandaloneJTAManagerLookup} of ISPN 4.
+ *
+ * @author <a href="mailto:nfilotto@exoplatform.com">Nicolas Filotto</a>
+ * @version $Id$
+ *
+ */
+public class JBossStandaloneJTAManagerLookup implements TransactionManagerLookup
+{
+ /**
+ * The logger
+ */
+ private static final Log LOG = ExoLogger.getLogger("exo.jcr.component.core.JBossStandaloneJTAManagerLookup");
+
+ private Method manager, user;
+
+ public JBossStandaloneJTAManagerLookup()
+ {
+ try
+ {
+ manager = loadClassStrict("com.arjuna.ats.jta.TransactionManager").getMethod("transactionManager");
+ user = loadClassStrict("com.arjuna.ats.jta.UserTransaction").getMethod("userTransaction");
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public TransactionManager getTransactionManager() throws Exception
+ {
+ TransactionManager tm = (TransactionManager)manager.invoke(null);
+ if (tm == null && LOG.isWarnEnabled())
+ {
+ LOG.warn("The transaction manager could not be found");
+ }
+ return tm;
+ }
+
+ public UserTransaction getUserTransaction() throws Exception
+ {
+ UserTransaction ut = (UserTransaction)user.invoke(null);
+ if (ut == null && LOG.isWarnEnabled())
+ {
+ LOG.warn("The user transaction could not be found");
+ }
+ return ut;
+ }
+
+ /**
+ * Loads the specified class using this class's classloader, or, if it is <code>null</code> (i.e. this class was
+ * loaded by the bootstrap classloader), the system classloader. <p/> If loadtime instrumentation via
+ * GenerateInstrumentedClassLoader is used, this class may be loaded by the bootstrap classloader. <p/>
+ *
+ * @param classname name of the class to load
+ * @return the class
+ * @throws ClassNotFoundException
+ */
+ private static Class<?> loadClassStrict(String classname) throws ClassNotFoundException
+ {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ if (cl == null)
+ cl = ClassLoader.getSystemClassLoader();
+ return cl.loadClass(classname);
+ }
+}
Modified: jcr/trunk/exo.jcr.component.core/src/main/resources/conf/portal/cluster/infinispan-data.xml
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/resources/conf/portal/cluster/infinispan-data.xml 2011-08-09 14:05:16 UTC (rev 4720)
+++ jcr/trunk/exo.jcr.component.core/src/main/resources/conf/portal/cluster/infinispan-data.xml 2011-08-09 14:08:31 UTC (rev 4721)
@@ -21,8 +21,8 @@
-->
<infinispan
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="urn:infinispan:config:4.1 http://www.infinispan.org/schemas/infinispan-config-4.1.xsd"
- xmlns="urn:infinispan:config:4.1">
+ xsi:schemaLocation="urn:infinispan:config:5.0 http://www.infinispan.org/schemas/infinispan-config-5.0.xsd"
+ xmlns="urn:infinispan:config:5.0">
<global>
<evictionScheduledExecutor factory="org.infinispan.executors.DefaultScheduledExecutorFactory">
@@ -43,12 +43,13 @@
<default>
<clustering mode="replication">
<stateRetrieval timeout="20000" fetchInMemoryState="false" />
- <sync />
+ <sync replTimeout="20000"/>
</clustering>
<locking isolationLevel="READ_COMMITTED" lockAcquisitionTimeout="20000" writeSkewCheck="false" concurrencyLevel="500" useLockStriping="false"/>
- <transaction transactionManagerLookupClass="org.infinispan.transaction.lookup.JBossStandaloneJTAManagerLookup" syncRollbackPhase="true" syncCommitPhase="true"/>
+ <transaction transactionManagerLookupClass="org.exoplatform.services.transaction.infinispan.JBossStandaloneJTAManagerLookup" syncRollbackPhase="true" syncCommitPhase="true"/>
<jmxStatistics enabled="true"/>
- <eviction strategy="LRU" wakeUpInterval="5000" threadPolicy="DEFAULT" maxEntries="1000000"/>
+ <eviction strategy="LRU" threadPolicy="DEFAULT" maxEntries="1000000"/>
+ <expiration wakeUpInterval="5000"/>
</default>
</infinispan>
Modified: jcr/trunk/exo.jcr.component.core/src/main/resources/conf/portal/cluster/infinispan-indexer.xml
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/resources/conf/portal/cluster/infinispan-indexer.xml 2011-08-09 14:05:16 UTC (rev 4720)
+++ jcr/trunk/exo.jcr.component.core/src/main/resources/conf/portal/cluster/infinispan-indexer.xml 2011-08-09 14:08:31 UTC (rev 4721)
@@ -21,8 +21,8 @@
-->
<infinispan
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="urn:infinispan:config:4.1 http://www.infinispan.org/schemas/infinispan-config-4.1.xsd"
- xmlns="urn:infinispan:config:4.1">
+ xsi:schemaLocation="urn:infinispan:config:5.0 http://www.infinispan.org/schemas/infinispan-config-5.0.xsd"
+ xmlns="urn:infinispan:config:5.0">
<global>
<evictionScheduledExecutor factory="org.infinispan.executors.DefaultScheduledExecutorFactory">
@@ -43,11 +43,11 @@
<default>
<clustering mode="replication">
<stateRetrieval timeout="20000" fetchInMemoryState="false" />
- <sync />
+ <sync replTimeout="20000"/>
</clustering>
<locking isolationLevel="READ_COMMITTED" lockAcquisitionTimeout="20000" writeSkewCheck="false" concurrencyLevel="500" useLockStriping="false"/>
- <transaction transactionManagerLookupClass="org.infinispan.transaction.lookup.JBossStandaloneJTAManagerLookup" syncRollbackPhase="true" syncCommitPhase="true"/>
+ <transaction transactionManagerLookupClass="org.exoplatform.services.transaction.infinispan.JBossStandaloneJTAManagerLookup" syncRollbackPhase="true" syncCommitPhase="true"/>
<jmxStatistics enabled="true"/>
<eviction strategy="NONE"/>
Modified: jcr/trunk/exo.jcr.component.core/src/main/resources/conf/portal/cluster/infinispan-lock.xml
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/resources/conf/portal/cluster/infinispan-lock.xml 2011-08-09 14:05:16 UTC (rev 4720)
+++ jcr/trunk/exo.jcr.component.core/src/main/resources/conf/portal/cluster/infinispan-lock.xml 2011-08-09 14:08:31 UTC (rev 4721)
@@ -21,8 +21,8 @@
-->
<infinispan
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="urn:infinispan:config:4.1 http://www.infinispan.org/schemas/infinispan-config-4.1.xsd"
- xmlns="urn:infinispan:config:4.1">
+ xsi:schemaLocation="urn:infinispan:config:5.0 http://www.infinispan.org/schemas/infinispan-config-5.0.xsd"
+ xmlns="urn:infinispan:config:5.0">
<global>
<evictionScheduledExecutor factory="org.infinispan.executors.DefaultScheduledExecutorFactory">
@@ -43,11 +43,11 @@
<default>
<clustering mode="replication">
<stateRetrieval timeout="20000" fetchInMemoryState="false" />
- <sync />
+ <sync replTimeout="20000"/>
</clustering>
<locking isolationLevel="READ_COMMITTED" lockAcquisitionTimeout="20000" writeSkewCheck="false" concurrencyLevel="500" useLockStriping="false"/>
- <transaction transactionManagerLookupClass="org.infinispan.transaction.lookup.JBossStandaloneJTAManagerLookup" syncRollbackPhase="true" syncCommitPhase="true"/>
+ <transaction transactionManagerLookupClass="org.exoplatform.services.transaction.infinispan.JBossStandaloneJTAManagerLookup" syncRollbackPhase="true" syncCommitPhase="true"/>
<jmxStatistics enabled="true"/>
<eviction strategy="NONE"/>
Deleted: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestISPNCacheWorkspaceStorageCache.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestISPNCacheWorkspaceStorageCache.java 2011-08-09 14:05:16 UTC (rev 4720)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestISPNCacheWorkspaceStorageCache.java 2011-08-09 14:08:31 UTC (rev 4721)
@@ -1,51 +0,0 @@
-/*
- * Copyright (C) 2003-2011 eXo Platform SAS.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Affero General Public License
- * as published by the Free Software Foundation; either version 3
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see<http://www.gnu.org/licenses/>.
- */
-package org.exoplatform.services.jcr.impl.dataflow.persistent;
-
-import org.exoplatform.container.configuration.ConfigurationManagerImpl;
-import org.exoplatform.services.jcr.config.CacheEntry;
-import org.exoplatform.services.jcr.config.SimpleParameterEntry;
-import org.exoplatform.services.jcr.config.WorkspaceEntry;
-import org.exoplatform.services.jcr.dataflow.persistent.WorkspaceStorageCache;
-import org.exoplatform.services.jcr.impl.dataflow.persistent.infinispan.ISPNCacheWorkspaceStorageCache;
-
-import java.util.ArrayList;
-
-/**
- * Created by The eXo Platform SAS.
- *
- * <br/>Date:
- *
- * @author <a href="karpenko.sergiy(a)gmail.com">Karpenko Sergiy</a>
- * @version $Id: TestISPNCacheWorkspaceStorageCache.java 111 2008-11-11 11:11:11Z serg $
- */
-public class TestISPNCacheWorkspaceStorageCache extends TestJBossCacheWorkspaceStorageCache
-{
- @Override
- public WorkspaceStorageCache getCacheImpl() throws Exception
- {
- ArrayList<SimpleParameterEntry> list = new ArrayList<SimpleParameterEntry>();
- list.add(new SimpleParameterEntry("infinispan-configuration", "jar:/conf/standalone/test-infinispan-config.xml"));
-
- CacheEntry entry = new CacheEntry(list);
- entry.setEnabled(true);
- WorkspaceEntry workspaceEntry = new WorkspaceEntry();
- workspaceEntry.setUniqueName("WS_UUID");
- workspaceEntry.setCache(entry);
- return new ISPNCacheWorkspaceStorageCache(workspaceEntry, new ConfigurationManagerImpl());
- }
-}
\ No newline at end of file
Deleted: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestJBossCacheWorkspaceStorageCache.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestJBossCacheWorkspaceStorageCache.java 2011-08-09 14:05:16 UTC (rev 4720)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestJBossCacheWorkspaceStorageCache.java 2011-08-09 14:08:31 UTC (rev 4721)
@@ -1,374 +0,0 @@
-/*
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.exoplatform.services.jcr.impl.dataflow.persistent;
-
-import org.exoplatform.container.configuration.ConfigurationManagerImpl;
-import org.exoplatform.services.jcr.config.CacheEntry;
-import org.exoplatform.services.jcr.config.SimpleParameterEntry;
-import org.exoplatform.services.jcr.config.WorkspaceEntry;
-import org.exoplatform.services.jcr.dataflow.ItemState;
-import org.exoplatform.services.jcr.dataflow.PlainChangesLog;
-import org.exoplatform.services.jcr.dataflow.PlainChangesLogImpl;
-import org.exoplatform.services.jcr.dataflow.persistent.PersistedNodeData;
-import org.exoplatform.services.jcr.dataflow.persistent.WorkspaceStorageCache;
-import org.exoplatform.services.jcr.datamodel.ItemData;
-import org.exoplatform.services.jcr.datamodel.ItemType;
-import org.exoplatform.services.jcr.datamodel.NodeData;
-import org.exoplatform.services.jcr.datamodel.PropertyData;
-import org.exoplatform.services.jcr.datamodel.QPathEntry;
-import org.exoplatform.services.jcr.impl.Constants;
-import org.exoplatform.services.jcr.impl.core.itemfilters.QPathEntryFilter;
-import org.exoplatform.services.jcr.impl.dataflow.persistent.jbosscache.JBossCacheWorkspaceStorageCache;
-import org.exoplatform.services.jcr.impl.storage.SystemDataContainerHolder;
-import org.exoplatform.services.jcr.impl.storage.WorkspaceDataContainerBase;
-import org.exoplatform.services.jcr.storage.WorkspaceDataContainer;
-import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
-import org.exoplatform.services.transaction.TransactionService;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.atomic.AtomicReference;
-
-import javax.jcr.InvalidItemStateException;
-import javax.jcr.RepositoryException;
-
-/**
- * Created by The eXo Platform SAS.
- *
- * @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter Nedonosko</a>
- * @version $Id$
- */
-public class TestJBossCacheWorkspaceStorageCache extends WorkspaceStorageCacheBaseCase
-{
-
- @Override
- public WorkspaceStorageCache getCacheImpl() throws Exception
- {
- TransactionService transactionService =
- (TransactionService)container.getComponentInstanceOfType(TransactionService.class);
-
- ArrayList<SimpleParameterEntry> list = new ArrayList<SimpleParameterEntry>();
- list.add(new SimpleParameterEntry(JBossCacheWorkspaceStorageCache.JBOSSCACHE_CONFIG,
- "jar:/conf/standalone/test-jbosscache-config.xml"));
-
- CacheEntry entry = new CacheEntry(list);
- entry.setEnabled(true);
- WorkspaceEntry workspaceEntry = new WorkspaceEntry();
- workspaceEntry.setUniqueName("WS_UUID");
- workspaceEntry.setCache(entry);
- return new JBossCacheWorkspaceStorageCache(workspaceEntry,
- transactionService == null ? null : transactionService, new ConfigurationManagerImpl());
- }
-
- public void testRaceConditions() throws Exception
- {
- MyWorkspaceStorageConnection con = new MyWorkspaceStorageConnection();
- WorkspaceDataContainer wdc = new MyWorkspaceDataContainer(con);
- final CacheableWorkspaceDataManager cwdm =
- new CacheableWorkspaceDataManager(wdc, getCacheImpl(), new SystemDataContainerHolder(wdc));
- String idNode = "foo1";
- executeConcurrentReadNWrite(con, cwdm, Mode.READ_FIRST, idNode);
- assertNotNull(cwdm.getItemData(idNode));
- idNode = "foo2";
- executeConcurrentReadNWrite(con, cwdm, Mode.WRITE_FIRST, idNode);
- assertNotNull(cwdm.getItemData(idNode));
- }
-
- /**
- * @param con
- * @param cwdm
- * @param mode
- * @param idNode
- * @throws InterruptedException
- */
- private void executeConcurrentReadNWrite(MyWorkspaceStorageConnection con, final CacheableWorkspaceDataManager cwdm,
- final Mode mode, final String idNode) throws InterruptedException
- {
- final CountDownLatch goSignal = con.setMode(mode);
- final AtomicReference<Exception> ex = new AtomicReference<Exception>();
- final CountDownLatch startSignal = new CountDownLatch(1);
- final CountDownLatch doneSignal = new CountDownLatch(2);
- Thread writer = new Thread()
- {
- public void run()
- {
- try
- {
- startSignal.await();
- PlainChangesLog chlog = new PlainChangesLogImpl();
- chlog.add(ItemState.createAddedState(new PersistedNodeData(idNode, Constants.ROOT_PATH, "parent-id", 1, 0,
- Constants.NT_UNSTRUCTURED, null, null)));
- cwdm.save(chlog);
- if (mode == Mode.WRITE_FIRST) goSignal.countDown();
- }
- catch (Exception e)
- {
- ex.set(e);
- }
- finally
- {
- doneSignal.countDown();
- }
- }
- };
- writer.start();
- Thread reader = new Thread()
- {
- public void run()
- {
- try
- {
- startSignal.await();
- cwdm.getItemData(idNode);
- if (mode == Mode.READ_FIRST) goSignal.countDown();
- }
- catch (Exception e)
- {
- ex.set(e);
- }
- finally
- {
- doneSignal.countDown();
- }
- }
- };
- reader.start();
- startSignal.countDown();
- doneSignal.await();
- assertNull(ex.get());
- }
-
- private static enum Mode
- {
- READ_FIRST, WRITE_FIRST;
- }
- private static class MyWorkspaceStorageConnection implements WorkspaceStorageConnection
- {
-
-
- private Mode mode;
- private CountDownLatch goSignal;
-
- public CountDownLatch setMode(Mode mode)
- {
- this.mode = mode;
- this.goSignal = new CountDownLatch(1);
- return goSignal;
- }
-
-
- public void add(NodeData data) throws RepositoryException, UnsupportedOperationException,
- InvalidItemStateException, IllegalStateException
- {
- }
-
- public void add(PropertyData data) throws RepositoryException, UnsupportedOperationException,
- InvalidItemStateException, IllegalStateException
- {
- }
-
- public void close() throws IllegalStateException, RepositoryException
- {
- }
-
- public void commit() throws IllegalStateException, RepositoryException
- {
- if (mode == Mode.READ_FIRST)
- {
- try
- {
- goSignal.await();
- }
- catch (InterruptedException e)
- {
- Thread.currentThread().interrupt();
- }
- }
- }
-
- public void delete(NodeData data) throws RepositoryException, UnsupportedOperationException,
- InvalidItemStateException, IllegalStateException
- {
- }
-
- public void delete(PropertyData data) throws RepositoryException, UnsupportedOperationException,
- InvalidItemStateException, IllegalStateException
- {
- }
-
- public int getChildNodesCount(NodeData parent) throws RepositoryException
- {
- return -1;
- }
-
- public List<NodeData> getChildNodesData(NodeData parent) throws RepositoryException, IllegalStateException
- {
- return null;
- }
-
- public List<PropertyData> getChildPropertiesData(NodeData parent) throws RepositoryException,
- IllegalStateException
- {
- return null;
- }
-
- public List<PropertyData> getChildPropertiesData(NodeData parent, List<QPathEntryFilter> pattern)
- throws RepositoryException, IllegalStateException
- {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public ItemData getItemData(NodeData parentData, QPathEntry name) throws RepositoryException,
- IllegalStateException
- {
- return getItemData(parentData, name, ItemType.UNKNOWN);
- }
-
- public ItemData getItemData(NodeData parentData, QPathEntry name, ItemType itemType) throws RepositoryException,
- IllegalStateException
- {
- return null;
- }
-
- public ItemData getItemData(String identifier) throws RepositoryException, IllegalStateException
- {
- if (mode == Mode.WRITE_FIRST)
- {
- try
- {
- goSignal.await();
- }
- catch (InterruptedException e)
- {
- Thread.currentThread().interrupt();
- }
- }
- return null;
- }
-
- public List<PropertyData> getReferencesData(String nodeIdentifier) throws RepositoryException,
- IllegalStateException, UnsupportedOperationException
- {
- return null;
- }
-
- public boolean isOpened()
- {
- return true;
- }
-
- public List<PropertyData> listChildPropertiesData(NodeData parent) throws RepositoryException,
- IllegalStateException
- {
- return null;
- }
-
- public void rename(NodeData data) throws RepositoryException, UnsupportedOperationException,
- InvalidItemStateException, IllegalStateException
- {
- }
-
- public void rollback() throws IllegalStateException, RepositoryException
- {
- }
-
- public void update(NodeData data) throws RepositoryException, UnsupportedOperationException,
- InvalidItemStateException, IllegalStateException
- {
- }
-
- public void update(PropertyData data) throws RepositoryException, UnsupportedOperationException,
- InvalidItemStateException, IllegalStateException
- {
- }
-
- public int getLastOrderNumber(NodeData parent) throws RepositoryException
- {
- return -1;
- }
-
- public List<NodeData> getChildNodesData(NodeData parent, List<QPathEntryFilter> pattern) throws RepositoryException,
- IllegalStateException
- {
- return getChildNodesData(parent);
- }
-
- };
-
- private static class MyWorkspaceDataContainer extends WorkspaceDataContainerBase
- {
-
- private WorkspaceStorageConnection con;
-
- public MyWorkspaceDataContainer(WorkspaceStorageConnection con)
- {
- this.con = con;
- }
-
- public boolean isCheckSNSNewConnection()
- {
- return false;
- }
-
- public boolean isSame(WorkspaceDataContainer another)
- {
- return false;
- }
-
- public WorkspaceStorageConnection openConnection() throws RepositoryException
- {
- return con;
- }
-
- public WorkspaceStorageConnection openConnection(boolean readOnly) throws RepositoryException
- {
- return con;
- }
-
- public WorkspaceStorageConnection reuseConnection(WorkspaceStorageConnection original) throws RepositoryException
- {
- return con;
- }
-
- public String getInfo()
- {
- return "MyWorkspaceDataContainer";
- }
-
- public String getName()
- {
- return "MyWorkspaceDataContainer";
- }
-
- public String getStorageVersion()
- {
- return "0";
- }
-
- public String getUniqueName()
- {
- return "MyWorkspaceDataContainer";
- }
- };
-
-}
Copied: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/TestISPNCacheWorkspaceStorageCache.java (from rev 4697, jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestISPNCacheWorkspaceStorageCache.java)
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/TestISPNCacheWorkspaceStorageCache.java (rev 0)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/TestISPNCacheWorkspaceStorageCache.java 2011-08-09 14:08:31 UTC (rev 4721)
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2003-2011 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.services.jcr.impl.dataflow.persistent.infinispan;
+
+import org.exoplatform.container.configuration.ConfigurationManagerImpl;
+import org.exoplatform.services.jcr.config.CacheEntry;
+import org.exoplatform.services.jcr.config.SimpleParameterEntry;
+import org.exoplatform.services.jcr.config.WorkspaceEntry;
+import org.exoplatform.services.jcr.dataflow.persistent.WorkspaceStorageCache;
+import org.exoplatform.services.jcr.impl.dataflow.persistent.infinispan.ISPNCacheWorkspaceStorageCache;
+import org.exoplatform.services.jcr.impl.dataflow.persistent.jbosscache.TestJBossCacheWorkspaceStorageCache;
+
+import java.util.ArrayList;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>Date:
+ *
+ * @author <a href="karpenko.sergiy(a)gmail.com">Karpenko Sergiy</a>
+ * @version $Id: TestISPNCacheWorkspaceStorageCache.java 111 2008-11-11 11:11:11Z serg $
+ */
+public class TestISPNCacheWorkspaceStorageCache extends TestJBossCacheWorkspaceStorageCache
+{
+ @Override
+ public WorkspaceStorageCache getCacheImpl() throws Exception
+ {
+ ArrayList<SimpleParameterEntry> list = new ArrayList<SimpleParameterEntry>();
+ list.add(new SimpleParameterEntry("infinispan-configuration", "jar:/conf/standalone/test-infinispan-config.xml"));
+
+ CacheEntry entry = new CacheEntry(list);
+ entry.setEnabled(true);
+ WorkspaceEntry workspaceEntry = new WorkspaceEntry();
+ workspaceEntry.setUniqueName("WS_UUID");
+ workspaceEntry.setCache(entry);
+ return new ISPNCacheWorkspaceStorageCache(workspaceEntry, new ConfigurationManagerImpl());
+ }
+}
\ No newline at end of file
Copied: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/TestJBossCacheWorkspaceStorageCache.java (from rev 4697, jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestJBossCacheWorkspaceStorageCache.java)
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/TestJBossCacheWorkspaceStorageCache.java (rev 0)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/TestJBossCacheWorkspaceStorageCache.java 2011-08-09 14:08:31 UTC (rev 4721)
@@ -0,0 +1,376 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.jcr.impl.dataflow.persistent.jbosscache;
+
+import org.exoplatform.container.configuration.ConfigurationManagerImpl;
+import org.exoplatform.services.jcr.config.CacheEntry;
+import org.exoplatform.services.jcr.config.SimpleParameterEntry;
+import org.exoplatform.services.jcr.config.WorkspaceEntry;
+import org.exoplatform.services.jcr.dataflow.ItemState;
+import org.exoplatform.services.jcr.dataflow.PlainChangesLog;
+import org.exoplatform.services.jcr.dataflow.PlainChangesLogImpl;
+import org.exoplatform.services.jcr.dataflow.persistent.PersistedNodeData;
+import org.exoplatform.services.jcr.dataflow.persistent.WorkspaceStorageCache;
+import org.exoplatform.services.jcr.datamodel.ItemData;
+import org.exoplatform.services.jcr.datamodel.ItemType;
+import org.exoplatform.services.jcr.datamodel.NodeData;
+import org.exoplatform.services.jcr.datamodel.PropertyData;
+import org.exoplatform.services.jcr.datamodel.QPathEntry;
+import org.exoplatform.services.jcr.impl.Constants;
+import org.exoplatform.services.jcr.impl.core.itemfilters.QPathEntryFilter;
+import org.exoplatform.services.jcr.impl.dataflow.persistent.CacheableWorkspaceDataManager;
+import org.exoplatform.services.jcr.impl.dataflow.persistent.WorkspaceStorageCacheBaseCase;
+import org.exoplatform.services.jcr.impl.dataflow.persistent.jbosscache.JBossCacheWorkspaceStorageCache;
+import org.exoplatform.services.jcr.impl.storage.SystemDataContainerHolder;
+import org.exoplatform.services.jcr.impl.storage.WorkspaceDataContainerBase;
+import org.exoplatform.services.jcr.storage.WorkspaceDataContainer;
+import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
+import org.exoplatform.services.transaction.TransactionService;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.atomic.AtomicReference;
+
+import javax.jcr.InvalidItemStateException;
+import javax.jcr.RepositoryException;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter Nedonosko</a>
+ * @version $Id$
+ */
+public class TestJBossCacheWorkspaceStorageCache extends WorkspaceStorageCacheBaseCase
+{
+
+ @Override
+ public WorkspaceStorageCache getCacheImpl() throws Exception
+ {
+ TransactionService transactionService =
+ (TransactionService)container.getComponentInstanceOfType(TransactionService.class);
+
+ ArrayList<SimpleParameterEntry> list = new ArrayList<SimpleParameterEntry>();
+ list.add(new SimpleParameterEntry(JBossCacheWorkspaceStorageCache.JBOSSCACHE_CONFIG,
+ "jar:/conf/standalone/test-jbosscache-config.xml"));
+
+ CacheEntry entry = new CacheEntry(list);
+ entry.setEnabled(true);
+ WorkspaceEntry workspaceEntry = new WorkspaceEntry();
+ workspaceEntry.setUniqueName("WS_UUID");
+ workspaceEntry.setCache(entry);
+ return new JBossCacheWorkspaceStorageCache(workspaceEntry,
+ transactionService == null ? null : transactionService, new ConfigurationManagerImpl());
+ }
+
+ public void testRaceConditions() throws Exception
+ {
+ MyWorkspaceStorageConnection con = new MyWorkspaceStorageConnection();
+ WorkspaceDataContainer wdc = new MyWorkspaceDataContainer(con);
+ final CacheableWorkspaceDataManager cwdm =
+ new CacheableWorkspaceDataManager(wdc, getCacheImpl(), new SystemDataContainerHolder(wdc));
+ String idNode = "foo1";
+ executeConcurrentReadNWrite(con, cwdm, Mode.READ_FIRST, idNode);
+ assertNotNull(cwdm.getItemData(idNode));
+ idNode = "foo2";
+ executeConcurrentReadNWrite(con, cwdm, Mode.WRITE_FIRST, idNode);
+ assertNotNull(cwdm.getItemData(idNode));
+ }
+
+ /**
+ * @param con
+ * @param cwdm
+ * @param mode
+ * @param idNode
+ * @throws InterruptedException
+ */
+ private void executeConcurrentReadNWrite(MyWorkspaceStorageConnection con, final CacheableWorkspaceDataManager cwdm,
+ final Mode mode, final String idNode) throws InterruptedException
+ {
+ final CountDownLatch goSignal = con.setMode(mode);
+ final AtomicReference<Exception> ex = new AtomicReference<Exception>();
+ final CountDownLatch startSignal = new CountDownLatch(1);
+ final CountDownLatch doneSignal = new CountDownLatch(2);
+ Thread writer = new Thread()
+ {
+ public void run()
+ {
+ try
+ {
+ startSignal.await();
+ PlainChangesLog chlog = new PlainChangesLogImpl();
+ chlog.add(ItemState.createAddedState(new PersistedNodeData(idNode, Constants.ROOT_PATH, "parent-id", 1, 0,
+ Constants.NT_UNSTRUCTURED, null, null)));
+ cwdm.save(chlog);
+ if (mode == Mode.WRITE_FIRST) goSignal.countDown();
+ }
+ catch (Exception e)
+ {
+ ex.set(e);
+ }
+ finally
+ {
+ doneSignal.countDown();
+ }
+ }
+ };
+ writer.start();
+ Thread reader = new Thread()
+ {
+ public void run()
+ {
+ try
+ {
+ startSignal.await();
+ cwdm.getItemData(idNode);
+ if (mode == Mode.READ_FIRST) goSignal.countDown();
+ }
+ catch (Exception e)
+ {
+ ex.set(e);
+ }
+ finally
+ {
+ doneSignal.countDown();
+ }
+ }
+ };
+ reader.start();
+ startSignal.countDown();
+ doneSignal.await();
+ assertNull(ex.get());
+ }
+
+ private static enum Mode
+ {
+ READ_FIRST, WRITE_FIRST;
+ }
+ private static class MyWorkspaceStorageConnection implements WorkspaceStorageConnection
+ {
+
+
+ private Mode mode;
+ private CountDownLatch goSignal;
+
+ public CountDownLatch setMode(Mode mode)
+ {
+ this.mode = mode;
+ this.goSignal = new CountDownLatch(1);
+ return goSignal;
+ }
+
+
+ public void add(NodeData data) throws RepositoryException, UnsupportedOperationException,
+ InvalidItemStateException, IllegalStateException
+ {
+ }
+
+ public void add(PropertyData data) throws RepositoryException, UnsupportedOperationException,
+ InvalidItemStateException, IllegalStateException
+ {
+ }
+
+ public void close() throws IllegalStateException, RepositoryException
+ {
+ }
+
+ public void commit() throws IllegalStateException, RepositoryException
+ {
+ if (mode == Mode.READ_FIRST)
+ {
+ try
+ {
+ goSignal.await();
+ }
+ catch (InterruptedException e)
+ {
+ Thread.currentThread().interrupt();
+ }
+ }
+ }
+
+ public void delete(NodeData data) throws RepositoryException, UnsupportedOperationException,
+ InvalidItemStateException, IllegalStateException
+ {
+ }
+
+ public void delete(PropertyData data) throws RepositoryException, UnsupportedOperationException,
+ InvalidItemStateException, IllegalStateException
+ {
+ }
+
+ public int getChildNodesCount(NodeData parent) throws RepositoryException
+ {
+ return -1;
+ }
+
+ public List<NodeData> getChildNodesData(NodeData parent) throws RepositoryException, IllegalStateException
+ {
+ return null;
+ }
+
+ public List<PropertyData> getChildPropertiesData(NodeData parent) throws RepositoryException,
+ IllegalStateException
+ {
+ return null;
+ }
+
+ public List<PropertyData> getChildPropertiesData(NodeData parent, List<QPathEntryFilter> pattern)
+ throws RepositoryException, IllegalStateException
+ {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public ItemData getItemData(NodeData parentData, QPathEntry name) throws RepositoryException,
+ IllegalStateException
+ {
+ return getItemData(parentData, name, ItemType.UNKNOWN);
+ }
+
+ public ItemData getItemData(NodeData parentData, QPathEntry name, ItemType itemType) throws RepositoryException,
+ IllegalStateException
+ {
+ return null;
+ }
+
+ public ItemData getItemData(String identifier) throws RepositoryException, IllegalStateException
+ {
+ if (mode == Mode.WRITE_FIRST)
+ {
+ try
+ {
+ goSignal.await();
+ }
+ catch (InterruptedException e)
+ {
+ Thread.currentThread().interrupt();
+ }
+ }
+ return null;
+ }
+
+ public List<PropertyData> getReferencesData(String nodeIdentifier) throws RepositoryException,
+ IllegalStateException, UnsupportedOperationException
+ {
+ return null;
+ }
+
+ public boolean isOpened()
+ {
+ return true;
+ }
+
+ public List<PropertyData> listChildPropertiesData(NodeData parent) throws RepositoryException,
+ IllegalStateException
+ {
+ return null;
+ }
+
+ public void rename(NodeData data) throws RepositoryException, UnsupportedOperationException,
+ InvalidItemStateException, IllegalStateException
+ {
+ }
+
+ public void rollback() throws IllegalStateException, RepositoryException
+ {
+ }
+
+ public void update(NodeData data) throws RepositoryException, UnsupportedOperationException,
+ InvalidItemStateException, IllegalStateException
+ {
+ }
+
+ public void update(PropertyData data) throws RepositoryException, UnsupportedOperationException,
+ InvalidItemStateException, IllegalStateException
+ {
+ }
+
+ public int getLastOrderNumber(NodeData parent) throws RepositoryException
+ {
+ return -1;
+ }
+
+ public List<NodeData> getChildNodesData(NodeData parent, List<QPathEntryFilter> pattern) throws RepositoryException,
+ IllegalStateException
+ {
+ return getChildNodesData(parent);
+ }
+
+ };
+
+ private static class MyWorkspaceDataContainer extends WorkspaceDataContainerBase
+ {
+
+ private WorkspaceStorageConnection con;
+
+ public MyWorkspaceDataContainer(WorkspaceStorageConnection con)
+ {
+ this.con = con;
+ }
+
+ public boolean isCheckSNSNewConnection()
+ {
+ return false;
+ }
+
+ public boolean isSame(WorkspaceDataContainer another)
+ {
+ return false;
+ }
+
+ public WorkspaceStorageConnection openConnection() throws RepositoryException
+ {
+ return con;
+ }
+
+ public WorkspaceStorageConnection openConnection(boolean readOnly) throws RepositoryException
+ {
+ return con;
+ }
+
+ public WorkspaceStorageConnection reuseConnection(WorkspaceStorageConnection original) throws RepositoryException
+ {
+ return con;
+ }
+
+ public String getInfo()
+ {
+ return "MyWorkspaceDataContainer";
+ }
+
+ public String getName()
+ {
+ return "MyWorkspaceDataContainer";
+ }
+
+ public String getStorageVersion()
+ {
+ return "0";
+ }
+
+ public String getUniqueName()
+ {
+ return "MyWorkspaceDataContainer";
+ }
+ };
+
+}
Modified: jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/cluster/test-configuration.xml
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/cluster/test-configuration.xml 2011-08-09 14:05:16 UTC (rev 4720)
+++ jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/cluster/test-configuration.xml 2011-08-09 14:08:31 UTC (rev 4721)
@@ -200,13 +200,13 @@
</component>
<component>
- <key>org.jboss.cache.transaction.TransactionManagerLookup</key>
- <type>org.jboss.cache.transaction.JBossStandaloneJTAManagerLookup</type>
+ <key>org.infinispan.transaction.lookup.TransactionManagerLookup</key>
+ <type>org.exoplatform.services.transaction.infinispan.JBossStandaloneJTAManagerLookup</type>
</component>
<component>
<key>org.exoplatform.services.transaction.TransactionService</key>
- <type>org.exoplatform.services.transaction.jbosscache.JBossTransactionsService</type>
+ <type>org.exoplatform.services.transaction.infinispan.JBossTransactionsService</type>
<init-params>
<value-param>
<name>timeout</name>
Modified: jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/cluster/test-infinispan-config.xml
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/cluster/test-infinispan-config.xml 2011-08-09 14:05:16 UTC (rev 4720)
+++ jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/cluster/test-infinispan-config.xml 2011-08-09 14:08:31 UTC (rev 4721)
@@ -21,8 +21,8 @@
-->
<infinispan
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="urn:infinispan:config:4.1 http://www.infinispan.org/schemas/infinispan-config-4.1.xsd"
- xmlns="urn:infinispan:config:4.1">
+ xsi:schemaLocation="urn:infinispan:config:5.0 http://www.infinispan.org/schemas/infinispan-config-5.0.xsd"
+ xmlns="urn:infinispan:config:5.0">
<global>
<evictionScheduledExecutor factory="org.infinispan.executors.DefaultScheduledExecutorFactory">
@@ -43,12 +43,13 @@
<default>
<clustering mode="replication">
<stateRetrieval timeout="20000" fetchInMemoryState="false" />
- <sync />
+ <sync replTimeout="20000"/>
</clustering>
<locking isolationLevel="READ_COMMITTED" lockAcquisitionTimeout="20000" writeSkewCheck="false" concurrencyLevel="500" useLockStriping="false"/>
- <transaction transactionManagerLookupClass="org.infinispan.transaction.lookup.JBossStandaloneJTAManagerLookup" syncRollbackPhase="true" syncCommitPhase="true"/>
+ <transaction transactionManagerLookupClass="org.exoplatform.services.transaction.infinispan.JBossStandaloneJTAManagerLookup" syncRollbackPhase="true" syncCommitPhase="true"/>
<jmxStatistics enabled="true"/>
- <eviction strategy="LRU" wakeUpInterval="5000" threadPolicy="DEFAULT" maxEntries="1000000"/>
+ <eviction strategy="LRU" threadPolicy="DEFAULT" maxEntries="1000000"/>
+ <expiration wakeUpInterval="5000"/>
</default>
</infinispan>
Modified: jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/cluster/test-infinispan-indexer.xml
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/cluster/test-infinispan-indexer.xml 2011-08-09 14:05:16 UTC (rev 4720)
+++ jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/cluster/test-infinispan-indexer.xml 2011-08-09 14:08:31 UTC (rev 4721)
@@ -21,8 +21,8 @@
-->
<infinispan
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="urn:infinispan:config:4.1 http://www.infinispan.org/schemas/infinispan-config-4.1.xsd"
- xmlns="urn:infinispan:config:4.1">
+ xsi:schemaLocation="urn:infinispan:config:5.0 http://www.infinispan.org/schemas/infinispan-config-5.0.xsd"
+ xmlns="urn:infinispan:config:5.0">
<global>
<evictionScheduledExecutor factory="org.infinispan.executors.DefaultScheduledExecutorFactory">
@@ -43,11 +43,11 @@
<default>
<clustering mode="replication">
<stateRetrieval timeout="20000" fetchInMemoryState="false" />
- <sync />
+ <sync replTimeout="20000"/>
</clustering>
<locking isolationLevel="READ_COMMITTED" lockAcquisitionTimeout="20000" writeSkewCheck="false" concurrencyLevel="500" useLockStriping="false"/>
- <transaction transactionManagerLookupClass="org.infinispan.transaction.lookup.JBossStandaloneJTAManagerLookup" syncRollbackPhase="true" syncCommitPhase="true"/>
+ <transaction transactionManagerLookupClass="org.exoplatform.services.transaction.infinispan.JBossStandaloneJTAManagerLookup" syncRollbackPhase="true" syncCommitPhase="true"/>
<jmxStatistics enabled="true"/>
<eviction strategy="NONE"/>
Modified: jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/cluster/test-infinispan-lock.xml
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/cluster/test-infinispan-lock.xml 2011-08-09 14:05:16 UTC (rev 4720)
+++ jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/cluster/test-infinispan-lock.xml 2011-08-09 14:08:31 UTC (rev 4721)
@@ -21,8 +21,8 @@
-->
<infinispan
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="urn:infinispan:config:4.1 http://www.infinispan.org/schemas/infinispan-config-4.1.xsd"
- xmlns="urn:infinispan:config:4.1">
+ xsi:schemaLocation="urn:infinispan:config:5.0 http://www.infinispan.org/schemas/infinispan-config-5.0.xsd"
+ xmlns="urn:infinispan:config:5.0">
<global>
<evictionScheduledExecutor factory="org.infinispan.executors.DefaultScheduledExecutorFactory">
@@ -43,11 +43,11 @@
<default>
<clustering mode="replication">
<stateRetrieval timeout="20000" fetchInMemoryState="false" />
- <sync />
+ <sync replTimeout="20000"/>
</clustering>
<locking isolationLevel="READ_COMMITTED" lockAcquisitionTimeout="20000" writeSkewCheck="false" concurrencyLevel="500" useLockStriping="false"/>
- <transaction transactionManagerLookupClass="org.infinispan.transaction.lookup.JBossStandaloneJTAManagerLookup" syncRollbackPhase="true" syncCommitPhase="true"/>
+ <transaction transactionManagerLookupClass="org.exoplatform.services.transaction.infinispan.JBossStandaloneJTAManagerLookup" syncRollbackPhase="true" syncCommitPhase="true"/>
<jmxStatistics enabled="true"/>
<eviction strategy="NONE"/>
Modified: jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-configuration-sjdbc.xml
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-configuration-sjdbc.xml 2011-08-09 14:05:16 UTC (rev 4720)
+++ jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-configuration-sjdbc.xml 2011-08-09 14:08:31 UTC (rev 4721)
@@ -200,13 +200,13 @@
</component>
<component>
- <key>org.jboss.cache.transaction.TransactionManagerLookup</key>
- <type>org.jboss.cache.transaction.JBossStandaloneJTAManagerLookup</type>
+ <key>org.infinispan.transaction.lookup.TransactionManagerLookup</key>
+ <type>org.exoplatform.services.transaction.infinispan.JBossStandaloneJTAManagerLookup</type>
</component>
<component>
<key>org.exoplatform.services.transaction.TransactionService</key>
- <type>org.exoplatform.services.transaction.jbosscache.JBossTransactionsService</type>
+ <type>org.exoplatform.services.transaction.infinispan.JBossTransactionsService</type>
<init-params>
<value-param>
<name>timeout</name>
Modified: jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-configuration.xml
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-configuration.xml 2011-08-09 14:05:16 UTC (rev 4720)
+++ jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-configuration.xml 2011-08-09 14:08:31 UTC (rev 4721)
@@ -200,13 +200,13 @@
</component>
<component>
- <key>org.jboss.cache.transaction.TransactionManagerLookup</key>
- <type>org.jboss.cache.transaction.JBossStandaloneJTAManagerLookup</type>
+ <key>org.infinispan.transaction.lookup.TransactionManagerLookup</key>
+ <type>org.exoplatform.services.transaction.infinispan.JBossStandaloneJTAManagerLookup</type>
</component>
<component>
<key>org.exoplatform.services.transaction.TransactionService</key>
- <type>org.exoplatform.services.transaction.jbosscache.JBossTransactionsService</type>
+ <type>org.exoplatform.services.transaction.infinispan.JBossTransactionsService</type>
<init-params>
<value-param>
<name>timeout</name>
Modified: jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-infinispan-config.xml
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-infinispan-config.xml 2011-08-09 14:05:16 UTC (rev 4720)
+++ jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-infinispan-config.xml 2011-08-09 14:08:31 UTC (rev 4721)
@@ -21,8 +21,8 @@
-->
<infinispan
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="urn:infinispan:config:4.1 http://www.infinispan.org/schemas/infinispan-config-4.1.xsd"
- xmlns="urn:infinispan:config:4.1">
+ xsi:schemaLocation="urn:infinispan:config:5.0 http://www.infinispan.org/schemas/infinispan-config-5.0.xsd"
+ xmlns="urn:infinispan:config:5.0">
<global>
<evictionScheduledExecutor factory="org.infinispan.executors.DefaultScheduledExecutorFactory">
@@ -36,8 +36,9 @@
<default>
<locking isolationLevel="READ_COMMITTED" lockAcquisitionTimeout="20000" writeSkewCheck="false" concurrencyLevel="500" useLockStriping="false"/>
- <transaction transactionManagerLookupClass="org.infinispan.transaction.lookup.JBossStandaloneJTAManagerLookup" syncRollbackPhase="true" syncCommitPhase="true"/>
+ <transaction transactionManagerLookupClass="org.exoplatform.services.transaction.infinispan.JBossStandaloneJTAManagerLookup" syncRollbackPhase="true" syncCommitPhase="true"/>
<jmxStatistics enabled="true"/>
- <eviction strategy="LRU" wakeUpInterval="5000" threadPolicy="DEFAULT" maxEntries="1000000"/>
+ <eviction strategy="LRU" threadPolicy="DEFAULT" maxEntries="1000000"/>
+ <expiration wakeUpInterval="5000"/>
</default>
</infinispan>
Modified: jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-infinispan-lock.xml
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-infinispan-lock.xml 2011-08-09 14:05:16 UTC (rev 4720)
+++ jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-infinispan-lock.xml 2011-08-09 14:08:31 UTC (rev 4721)
@@ -21,8 +21,8 @@
-->
<infinispan
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="urn:infinispan:config:4.1 http://www.infinispan.org/schemas/infinispan-config-4.1.xsd"
- xmlns="urn:infinispan:config:4.1">
+ xsi:schemaLocation="urn:infinispan:config:5.0 http://www.infinispan.org/schemas/infinispan-config-5.0.xsd"
+ xmlns="urn:infinispan:config:5.0">
<global>
<evictionScheduledExecutor factory="org.infinispan.executors.DefaultScheduledExecutorFactory">
@@ -36,7 +36,7 @@
<default>
<locking isolationLevel="READ_COMMITTED" lockAcquisitionTimeout="20000" writeSkewCheck="false" concurrencyLevel="500" useLockStriping="false"/>
- <transaction transactionManagerLookupClass="org.infinispan.transaction.lookup.JBossStandaloneJTAManagerLookup" syncRollbackPhase="true" syncCommitPhase="true"/>
+ <transaction transactionManagerLookupClass="org.exoplatform.services.transaction.infinispan.JBossStandaloneJTAManagerLookup" syncRollbackPhase="true" syncCommitPhase="true"/>
<jmxStatistics enabled="true"/>
<eviction strategy="NONE"/>
Modified: jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/kernel/transaction-service.xml
===================================================================
--- jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/kernel/transaction-service.xml 2011-08-09 14:05:16 UTC (rev 4720)
+++ jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/kernel/transaction-service.xml 2011-08-09 14:08:31 UTC (rev 4721)
@@ -190,7 +190,7 @@
<programlisting> <!-- Configuration of the TransactionManagerLookup -->
<component>
<key>org.infinispan.transaction.lookup.TransactionManagerLookup</key>
- <type>org.infinispan.transaction.lookup.JBossStandaloneJTAManagerLookup</type>
+ <type>org.exoplatform.services.transaction.infinispan.JBossStandaloneJTAManagerLookup</type>
</component>
<!-- Configuration of the TransactionService -->
<component>
Modified: jcr/trunk/pom.xml
===================================================================
--- jcr/trunk/pom.xml 2011-08-09 14:05:16 UTC (rev 4720)
+++ jcr/trunk/pom.xml 2011-08-09 14:08:31 UTC (rev 4721)
@@ -392,12 +392,12 @@
<dependency>
<groupId>org.infinispan</groupId>
<artifactId>infinispan-core</artifactId>
- <version>4.2.1.FINAL</version>
+ <version>5.0.0.FINAL</version>
</dependency>
<dependency>
<groupId>org.infinispan</groupId>
<artifactId>infinispan-cachestore-jdbc</artifactId>
- <version>4.2.1.FINAL</version>
+ <version>5.0.0.FINAL</version>
</dependency>
</dependencies>
</dependencyManagement>
12 years, 9 months
exo-jcr SVN: r4720 - in kernel/trunk: exo.kernel.component.common/src/main/java/org/exoplatform/services/rpc/impl and 25 other directories.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2011-08-09 10:05:16 -0400 (Tue, 09 Aug 2011)
New Revision: 4720
Added:
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/pom.xml
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/java/
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/java/org/
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/java/org/exoplatform/
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/java/org/exoplatform/services/
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/java/org/exoplatform/services/cache/
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/java/org/exoplatform/services/cache/impl/
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/java/org/exoplatform/services/cache/impl/infinispan/
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/java/org/exoplatform/services/cache/impl/infinispan/AbstractExoCache.java
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/java/org/exoplatform/services/cache/impl/infinispan/ExoCacheCreator.java
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/java/org/exoplatform/services/cache/impl/infinispan/ExoCacheCreatorPlugin.java
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/java/org/exoplatform/services/cache/impl/infinispan/ExoCacheFactoryConfigPlugin.java
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/java/org/exoplatform/services/cache/impl/infinispan/ExoCacheFactoryImpl.java
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/java/org/exoplatform/services/cache/impl/infinispan/generic/
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/java/org/exoplatform/services/cache/impl/infinispan/generic/GenericExoCacheConfig.java
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/java/org/exoplatform/services/cache/impl/infinispan/generic/GenericExoCacheCreator.java
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/resources/
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/resources/conf/
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/resources/conf/portal/
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/resources/conf/portal/cache-configuration-template.xml
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/resources/conf/portal/configuration.xml
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/java/
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/java/org/
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/java/org/exoplatform/
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/java/org/exoplatform/services/
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/java/org/exoplatform/services/cache/
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/java/org/exoplatform/services/cache/impl/
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/java/org/exoplatform/services/cache/impl/infinispan/
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/java/org/exoplatform/services/cache/impl/infinispan/TestAbstractExoCache.java
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/java/org/exoplatform/services/cache/impl/infinispan/TestExoCacheConfig.java
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/java/org/exoplatform/services/cache/impl/infinispan/TestExoCacheCreator.java
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/java/org/exoplatform/services/cache/impl/infinispan/TestExoCacheFactoryImpl.java
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/resources/
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/resources/conf/
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/resources/conf/portal/
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/resources/conf/portal/cache-configuration-template.xml
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/resources/conf/portal/distributed-cache-configuration-template.xml
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/resources/conf/portal/test-configuration.xml
Removed:
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/
Modified:
kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/rpc/impl/RPCServiceImpl.java
kernel/trunk/pom.xml
Log:
EXOJCR-1475: Upgrade ISPN to 5.0.0 FINAL (kernel part)
* Removed exo.kernel.component.ext.cache.impl.infinispan.v4 since ISPN 4 and 5 are not compatible and only the version 5 will be supported by RH
* Used reflection to call the method org.jgroups.Message.setObject since the signature of the method has changed since JGroups 2.12
* Adapted the code to IPSN 5 : Fluent config has been used, eviction events have been modified and wakeUpInterval has been moved from eviction to expiration
* Adapted the config files to ISPN 5 : Correct version has been set to the config files header and replication timeout has been set explicitly to prevent warnings
* JGroups and ISPN have been upgraded in the pom files
Modified: kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/rpc/impl/RPCServiceImpl.java
===================================================================
--- kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/rpc/impl/RPCServiceImpl.java 2011-08-09 12:59:58 UTC (rev 4719)
+++ kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/rpc/impl/RPCServiceImpl.java 2011-08-09 14:05:16 UTC (rev 4720)
@@ -53,6 +53,7 @@
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.io.Serializable;
+import java.lang.reflect.Method;
import java.net.URL;
import java.security.PrivilegedAction;
import java.security.PrivilegedActionException;
@@ -83,6 +84,41 @@
private static final Log LOG = ExoLogger.getLogger("exo.kernel.component.common.RPCServiceImpl");
/**
+ * We use reflection for the Message.setObject method in order to remain backward compatible
+ * because since JGroups 2.12 the signature has changed the expected parameter is no more a Serializable,
+ * it is an Object
+ */
+ private static Method MESSAGE_SET_OBJECT_METHOD;
+
+ static
+ {
+ try
+ {
+ MESSAGE_SET_OBJECT_METHOD = Message.class.getMethod("setObject", Serializable.class);
+ }
+ catch (SecurityException e)
+ {
+ throw e;
+ }
+ catch (NoSuchMethodException e)
+ {
+ // We assume that we use JGroups 2.12 or higher
+ try
+ {
+ MESSAGE_SET_OBJECT_METHOD = Message.class.getMethod("setObject", Object.class);
+ }
+ catch (SecurityException e1)
+ {
+ throw e1;
+ }
+ catch (Exception e1)
+ {
+ throw new RuntimeException("Could not find the right Message.setObject method", e);
+ }
+ }
+ }
+
+ /**
* The name of the parameter for the location of the JGroups configuration.
*/
protected static final String PARAM_JGROUPS_CONFIG = "jgroups-configuration";
@@ -426,7 +462,14 @@
throw new RPCException("Command " + commandId + " unknown, please register your command first");
}
final Message msg = new Message();
- msg.setObject(new MessageBody(dests.size() == 1 && dests != members ? dests.get(0) : null, commandId, args));
+ try
+ {
+ MESSAGE_SET_OBJECT_METHOD.invoke(msg, new MessageBody(dests.size() == 1 && dests != members ? dests.get(0) : null, commandId, args));
+ }
+ catch (Exception e)
+ {
+ throw new RPCException("Could not call the method Message.setObject");
+ }
RspList rsps = SecurityHelper.doPrivilegedAction(new PrivilegedAction<RspList>()
{
public RspList run()
Added: kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/pom.xml
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/pom.xml (rev 0)
+++ kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/pom.xml 2011-08-09 14:05:16 UTC (rev 4720)
@@ -0,0 +1,84 @@
+
+ <!--
+
+ Copyright (C) 2009 eXo Platform SAS. This is free software; you can
+ redistribute it and/or modify it under the terms of the GNU Lesser
+ General Public License as published by the Free Software Foundation;
+ either version 2.1 of the License, or (at your option) any later
+ version. This software is distributed in the hope that it will be
+ useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details. You should have
+ received a copy of the GNU Lesser General Public License along with
+ this software; if not, write to the Free Software Foundation, Inc., 51
+ Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
+ site: http://www.fsf.org.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.exoplatform.kernel</groupId>
+ <artifactId>kernel-parent</artifactId>
+ <version>2.3.0-GA-SNAPSHOT</version>
+ </parent>
+ <artifactId>exo.kernel.component.ext.cache.impl.infinispan.v5</artifactId>
+ <name>eXo Kernel :: Cache Extension :: Infinispan Implementation</name>
+ <description>Infinispan Implementation for the Cache Service</description>
+ <dependencies>
+ <dependency>
+ <groupId>org.exoplatform.kernel</groupId>
+ <artifactId>exo.kernel.component.cache</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.infinispan</groupId>
+ <artifactId>infinispan-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jgroups</groupId>
+ <artifactId>jgroups</artifactId>
+ <version>2.12.1.3.Final</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <systemProperties>
+ <!--
+ We add this system property due to some incompatibility between
+ IPv6 and some JVM of Linux distributions such as Ubuntu and
+ Fedora
+ -->
+ <property>
+ <name>java.net.preferIPv4Stack</name>
+ <value>true</value>
+ </property>
+ <!-- Avoid the firewall -->
+ <property>
+ <name>bind.address</name>
+ <value>127.0.0.1</value>
+ </property>
+ <property>
+ <name>jgroups.stack</name>
+ <value>udp</value>
+ </property>
+ </systemProperties>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Added: kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/java/org/exoplatform/services/cache/impl/infinispan/AbstractExoCache.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/java/org/exoplatform/services/cache/impl/infinispan/AbstractExoCache.java (rev 0)
+++ kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/java/org/exoplatform/services/cache/impl/infinispan/AbstractExoCache.java 2011-08-09 14:05:16 UTC (rev 4720)
@@ -0,0 +1,581 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.cache.impl.infinispan;
+
+import org.exoplatform.services.cache.CacheInfo;
+import org.exoplatform.services.cache.CacheListener;
+import org.exoplatform.services.cache.CacheListenerContext;
+import org.exoplatform.services.cache.CachedObjectSelector;
+import org.exoplatform.services.cache.ExoCache;
+import org.exoplatform.services.cache.ExoCacheConfig;
+import org.exoplatform.services.cache.ObjectCacheInfo;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+import org.infinispan.AdvancedCache;
+import org.infinispan.Cache;
+import org.infinispan.context.Flag;
+import org.infinispan.notifications.Listener;
+import org.infinispan.notifications.cachelistener.annotation.CacheEntriesEvicted;
+import org.infinispan.notifications.cachelistener.annotation.CacheEntryModified;
+import org.infinispan.notifications.cachelistener.annotation.CacheEntryRemoved;
+import org.infinispan.notifications.cachelistener.event.CacheEntriesEvictedEvent;
+import org.infinispan.notifications.cachelistener.event.CacheEntryModifiedEvent;
+import org.infinispan.notifications.cachelistener.event.CacheEntryRemovedEvent;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * An {@link org.exoplatform.services.cache.ExoCache} implementation based on {@link Cache}.
+ *
+ * @author <a href="mailto:nicolas.filotto@exoplatform.com">Nicolas Filotto</a>
+ * @version $Id$
+ *
+ */
+public abstract class AbstractExoCache<K extends Serializable, V> implements ExoCache<K, V>
+{
+
+ /**
+ * Logger.
+ */
+ private static final Log LOG = ExoLogger.getLogger("exo.kernel.component.ext.cache.impl.infinispan.v4.AbstractExoCache");
+
+ private final AtomicInteger hits = new AtomicInteger(0);
+
+ private final AtomicInteger misses = new AtomicInteger(0);
+
+ private String label;
+
+ private String name;
+
+ private boolean distributed;
+
+ private boolean replicated;
+
+ private boolean logEnabled;
+
+ private final CopyOnWriteArrayList<ListenerContext<K, V>> listeners;
+
+ protected final AdvancedCache<K, V> cache;
+
+ public AbstractExoCache(ExoCacheConfig config, Cache<K, V> cache)
+ {
+ this.cache = cache.getAdvancedCache();
+ this.listeners = new CopyOnWriteArrayList<ListenerContext<K, V>>();
+ setDistributed(config.isDistributed());
+ setLabel(config.getLabel());
+ setName(config.getName());
+ setLogEnabled(config.isLogEnabled());
+ setReplicated(config.isRepicated());
+ cache.addListener(new CacheEventListener());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addCacheListener(CacheListener<? super K, ? super V> listener)
+ {
+ if (listener == null)
+ {
+ throw new NullPointerException();
+ }
+ listeners.add(new ListenerContext<K, V>(listener, this));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void clearCache()
+ {
+ cache.withFlags(Flag.CACHE_MODE_LOCAL).clear();
+ onClearCache();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @SuppressWarnings("unchecked")
+ public V get(Serializable name)
+ {
+ if (name == null)
+ {
+ return null;
+ }
+ final V result = cache.get(name);
+ if (result == null)
+ {
+ misses.incrementAndGet();
+ }
+ else
+ {
+ hits.incrementAndGet();
+ }
+ onGet((K)name, result);
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getCacheHit()
+ {
+ return hits.get();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getCacheMiss()
+ {
+ return misses.get();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getCacheSize()
+ {
+ return cache.size();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public List<V> getCachedObjects()
+ {
+ Collection<V> values = cache.values();
+ if (values == null || values.isEmpty())
+ {
+ return Collections.emptyList();
+ }
+ else
+ {
+ return new ArrayList<V>(values);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getLabel()
+ {
+ return label;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getName()
+ {
+ return name;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isDistributed()
+ {
+ return distributed;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isLogEnabled()
+ {
+ return logEnabled;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isReplicated()
+ {
+ return replicated;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void put(K key, V value) throws NullPointerException
+ {
+ if (key == null)
+ {
+ throw new NullPointerException("No null cache key accepted");
+ }
+ putOnly(key, value);
+ onPut(key, value);
+ }
+
+ /**
+ * Only puts the data into the cache nothing more
+ */
+ protected void putOnly(K key, V value)
+ {
+ cache.withFlags(Flag.SKIP_REMOTE_LOOKUP).put(key, value);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void putMap(Map<? extends K, ? extends V> objs) throws NullPointerException, IllegalArgumentException
+ {
+ if (objs == null)
+ {
+ throw new NullPointerException("No null map accepted");
+ }
+ for (Serializable name : objs.keySet())
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException("No null cache key accepted");
+ }
+ }
+ cache.startBatch();
+ try
+ {
+ // Start transaction
+ for (Map.Entry<? extends K, ? extends V> entry : objs.entrySet())
+ {
+ putOnly(entry.getKey(), entry.getValue());
+ }
+ cache.endBatch(true);
+ // End transaction
+ for (Map.Entry<? extends K, ? extends V> entry : objs.entrySet())
+ {
+ onPut(entry.getKey(), entry.getValue());
+ }
+ }
+ catch (Exception e)
+ {
+ cache.endBatch(false);
+ LOG.warn("An error occurs while executing the putMap method", e);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @SuppressWarnings("unchecked")
+ public V remove(Serializable name) throws NullPointerException
+ {
+ if (name == null)
+ {
+ throw new NullPointerException("No null cache key accepted");
+ }
+ V result = cache.remove(name);
+ onRemove((K)name, result);
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public List<V> removeCachedObjects()
+ {
+ final List<V> list = getCachedObjects();
+ clearCache();
+ return list;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void select(CachedObjectSelector<? super K, ? super V> selector) throws Exception
+ {
+ if (selector == null)
+ {
+ throw new IllegalArgumentException("No null selector");
+ }
+ for (K key : cache.keySet())
+ {
+ if (key == null)
+ {
+ continue;
+ }
+ final V value = cache.withFlags(Flag.SKIP_LOCKING).get(key);
+ ObjectCacheInfo<V> info = new ObjectCacheInfo<V>()
+ {
+ public V get()
+ {
+ return value;
+ }
+
+ public long getExpireTime()
+ {
+ // Cannot know: The expire time is managed by Infinispan itself
+ return -1;
+ }
+ };
+ if (selector.select(key, info))
+ {
+ selector.onSelect(this, key, info);
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setDistributed(boolean distributed)
+ {
+ this.distributed = distributed;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setLabel(String label)
+ {
+ this.label = label;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setLogEnabled(boolean logEnabled)
+ {
+ this.logEnabled = logEnabled;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setReplicated(boolean replicated)
+ {
+ this.replicated = replicated;
+ }
+
+ void onExpire(K key, V obj)
+ {
+ if (listeners.isEmpty())
+ {
+ return;
+ }
+ for (ListenerContext<K, V> context : listeners)
+ {
+ try
+ {
+ context.onExpire(key, obj);
+ }
+ catch (Exception e)
+ {
+ if (LOG.isWarnEnabled())
+ LOG.warn("Cannot execute the CacheListener properly", e);
+ }
+ }
+ }
+
+ void onRemove(K key, V obj)
+ {
+ if (listeners.isEmpty())
+ {
+ return;
+ }
+ for (ListenerContext<K, V> context : listeners)
+ {
+ try
+ {
+ context.onRemove(key, obj);
+ }
+ catch (Exception e)
+ {
+ if (LOG.isWarnEnabled())
+ LOG.warn("Cannot execute the CacheListener properly", e);
+ }
+ }
+ }
+
+ void onPut(K key, V obj)
+ {
+ if (listeners.isEmpty())
+ {
+ return;
+ }
+ for (ListenerContext<K, V> context : listeners)
+ try
+ {
+ context.onPut(key, obj);
+ }
+ catch (Exception e)
+ {
+ if (LOG.isWarnEnabled())
+ LOG.warn("Cannot execute the CacheListener properly", e);
+ }
+ }
+
+ void onGet(K key, V obj)
+ {
+ if (listeners.isEmpty())
+ {
+ return;
+ }
+ for (ListenerContext<K, V> context : listeners)
+ try
+ {
+ context.onGet(key, obj);
+ }
+ catch (Exception e)
+ {
+ if (LOG.isWarnEnabled())
+ LOG.warn("Cannot execute the CacheListener properly", e);
+ }
+ }
+
+ void onClearCache()
+ {
+ if (listeners.isEmpty())
+ {
+ return;
+ }
+ for (ListenerContext<K, V> context : listeners)
+ try
+ {
+ context.onClearCache();
+ }
+ catch (Exception e)
+ {
+ if (LOG.isWarnEnabled())
+ LOG.warn("Cannot execute the CacheListener properly", e);
+ }
+ }
+
+ @Listener
+ public class CacheEventListener
+ {
+ /**
+ * Warning Infinispan triggers a <code>CacheEntryEvictedEvent</code> only at explicit eviction
+ * that is done lazily which is not exactly what we expect, we still use it to be
+ * able to use it with <code>avoidValueReplication</code> set to <code>true</code>.
+ */
+ @CacheEntriesEvicted
+ public void cacheEntryEvicted(CacheEntriesEvictedEvent<K, V> evt)
+ {
+ if (evt.isPre())
+ {
+ for (Map.Entry<K, V> entry : evt.getEntries().entrySet())
+ {
+ onExpire(entry.getKey(), entry.getValue());
+ }
+ }
+ }
+
+ @CacheEntryRemoved
+ public void cacheEntryRemoved(CacheEntryRemovedEvent<K, V> evt)
+ {
+ if (evt.isPre() && !evt.isOriginLocal())
+ {
+ final K key = evt.getKey();
+ final V value = evt.getValue();
+ onRemove(key, value);
+ }
+ }
+
+ @CacheEntryModified
+ public void cacheEntryModified(CacheEntryModifiedEvent<K, V> evt)
+ {
+ if (!evt.isOriginLocal() && !evt.isPre())
+ {
+ final K key = evt.getKey();
+ final V value = evt.getValue();
+ onPut(key, value);
+ }
+ }
+ }
+
+ private static class ListenerContext<K extends Serializable, V> implements CacheListenerContext, CacheInfo
+ {
+
+ /** . */
+ private final ExoCache<K, V> cache;
+
+ /** . */
+ final CacheListener<? super K, ? super V> listener;
+
+ public ListenerContext(CacheListener<? super K, ? super V> listener, ExoCache<K, V> cache)
+ {
+ this.listener = listener;
+ this.cache = cache;
+ }
+
+ public CacheInfo getCacheInfo()
+ {
+ return this;
+ }
+
+ public String getName()
+ {
+ return cache.getName();
+ }
+
+ public int getMaxSize()
+ {
+ return cache.getMaxSize();
+ }
+
+ public long getLiveTime()
+ {
+ return cache.getLiveTime();
+ }
+
+ public int getSize()
+ {
+ return cache.getCacheSize();
+ }
+
+ void onExpire(K key, V obj) throws Exception
+ {
+ listener.onExpire(this, key, obj);
+ }
+
+ void onRemove(K key, V obj) throws Exception
+ {
+ listener.onRemove(this, key, obj);
+ }
+
+ void onPut(K key, V obj) throws Exception
+ {
+ listener.onPut(this, key, obj);
+ }
+
+ void onGet(K key, V obj) throws Exception
+ {
+ listener.onGet(this, key, obj);
+ }
+
+ void onClearCache() throws Exception
+ {
+ listener.onClearCache(this);
+ }
+ }
+}
\ No newline at end of file
Added: kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/java/org/exoplatform/services/cache/impl/infinispan/ExoCacheCreator.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/java/org/exoplatform/services/cache/impl/infinispan/ExoCacheCreator.java (rev 0)
+++ kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/java/org/exoplatform/services/cache/impl/infinispan/ExoCacheCreator.java 2011-08-09 14:05:16 UTC (rev 4720)
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.cache.impl.infinispan;
+
+import org.exoplatform.services.cache.ExoCache;
+import org.exoplatform.services.cache.ExoCacheConfig;
+import org.exoplatform.services.cache.ExoCacheInitException;
+import org.infinispan.Cache;
+import org.infinispan.config.Configuration;
+
+import java.io.Serializable;
+import java.util.Set;
+import java.util.concurrent.Callable;
+
+/**
+ * This class is used to create the cache according to the given
+ * configuration {@link org.exoplatform.services.cache.ExoCacheConfig}
+ *
+ * @author <a href="mailto:nicolas.filotto@exoplatform.com">Nicolas Filotto</a>
+ * @version $Id$
+ */
+public interface ExoCacheCreator
+{
+
+ /**
+ * Creates an eXo cache according to the given configuration {@link org.exoplatform.services.cache.ExoCacheConfig}
+ * @param config the configuration of the cache to apply
+ * @param cacheConfig the configuration of the infinispan cache
+ * @param cacheGetter a {@link Callable} instance from which we can get the cache
+ * @exception ExoCacheInitException if an exception happens while initializing the cache
+ */
+ public ExoCache<Serializable, Object> create(ExoCacheConfig config, Configuration cacheConfig,
+ Callable<Cache<Serializable, Object>> cacheGetter) throws ExoCacheInitException;
+
+ /**
+ * Returns the type of {@link org.exoplatform.services.cache.ExoCacheConfig} expected by the creator
+ * @return the expected type
+ */
+ public Class<? extends ExoCacheConfig> getExpectedConfigType();
+
+ /**
+ * Returns a set of all the implementations expected by the creator. This is mainly used to be backward compatible
+ * @return the expected by the creator
+ */
+ public Set<String> getExpectedImplementations();
+}
Added: kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/java/org/exoplatform/services/cache/impl/infinispan/ExoCacheCreatorPlugin.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/java/org/exoplatform/services/cache/impl/infinispan/ExoCacheCreatorPlugin.java (rev 0)
+++ kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/java/org/exoplatform/services/cache/impl/infinispan/ExoCacheCreatorPlugin.java 2011-08-09 14:05:16 UTC (rev 4720)
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.cache.impl.infinispan;
+
+import org.exoplatform.container.component.BaseComponentPlugin;
+import org.exoplatform.container.xml.InitParams;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * This class allows us to define new creators
+ * @author <a href="mailto:nicolas.filotto@exoplatform.com">Nicolas Filotto</a>
+ * @version $Id$
+ */
+public class ExoCacheCreatorPlugin extends BaseComponentPlugin
+{
+
+ /**
+ * The list of all the creators defined for this ComponentPlugin
+ */
+ private final List<ExoCacheCreator> creators;
+
+ public ExoCacheCreatorPlugin(InitParams params)
+ {
+ creators = new ArrayList<ExoCacheCreator>();
+ List<?> configs = params.getObjectParamValues(ExoCacheCreator.class);
+ for (int i = 0; i < configs.size(); i++)
+ {
+ ExoCacheCreator config = (ExoCacheCreator)configs.get(i);
+ creators.add(config);
+ }
+ }
+
+ /**
+ * Returns all the creators defined for this ComponentPlugin
+ */
+ public List<ExoCacheCreator> getCreators()
+ {
+ return creators;
+ }
+}
Added: kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/java/org/exoplatform/services/cache/impl/infinispan/ExoCacheFactoryConfigPlugin.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/java/org/exoplatform/services/cache/impl/infinispan/ExoCacheFactoryConfigPlugin.java (rev 0)
+++ kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/java/org/exoplatform/services/cache/impl/infinispan/ExoCacheFactoryConfigPlugin.java 2011-08-09 14:05:16 UTC (rev 4720)
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.cache.impl.infinispan;
+
+import org.exoplatform.container.component.BaseComponentPlugin;
+import org.exoplatform.container.xml.InitParams;
+import org.exoplatform.container.xml.ValueParam;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * This class is used to define custom configurations
+ *
+ * @author <a href="mailto:nicolas.filotto@exoplatform.com">Nicolas Filotto</a>
+ * @version $Id$
+ */
+public class ExoCacheFactoryConfigPlugin extends BaseComponentPlugin
+{
+
+ /**
+ * The map of all the creators defined for this ComponentPlugin
+ */
+ private final Map<String, String> configs;
+
+ public ExoCacheFactoryConfigPlugin(InitParams params)
+ {
+ configs = new HashMap<String, String>();
+ for (Iterator<ValueParam> iterator = params.getValueParamIterator(); iterator.hasNext();)
+ {
+ ValueParam vParam = iterator.next();
+ configs.put(vParam.getName(), vParam.getValue());
+ }
+ }
+
+ /**
+ * Returns all the configurations defined for this ComponentPlugin
+ */
+ public Map<String, String> getConfigs()
+ {
+ return configs;
+ }
+}
Added: kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/java/org/exoplatform/services/cache/impl/infinispan/ExoCacheFactoryImpl.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/java/org/exoplatform/services/cache/impl/infinispan/ExoCacheFactoryImpl.java (rev 0)
+++ kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/java/org/exoplatform/services/cache/impl/infinispan/ExoCacheFactoryImpl.java 2011-08-09 14:05:16 UTC (rev 4720)
@@ -0,0 +1,458 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.cache.impl.infinispan;
+
+import org.exoplatform.container.ExoContainerContext;
+import org.exoplatform.container.configuration.ConfigurationManager;
+import org.exoplatform.container.xml.InitParams;
+import org.exoplatform.container.xml.ValueParam;
+import org.exoplatform.services.cache.ExoCache;
+import org.exoplatform.services.cache.ExoCacheConfig;
+import org.exoplatform.services.cache.ExoCacheFactory;
+import org.exoplatform.services.cache.ExoCacheInitException;
+import org.exoplatform.services.cache.impl.infinispan.generic.GenericExoCacheCreator;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+import org.infinispan.Cache;
+import org.infinispan.config.Configuration;
+import org.infinispan.config.Configuration.CacheMode;
+import org.infinispan.config.GlobalConfiguration;
+import org.infinispan.eviction.EvictionStrategy;
+import org.infinispan.jmx.MBeanServerLookup;
+import org.infinispan.manager.DefaultCacheManager;
+import org.infinispan.remoting.transport.jgroups.JGroupsTransport;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.concurrent.Callable;
+
+import javax.management.MBeanServer;
+
+/**
+ * This class is the Infinispan implementation of the {@link org.exoplatform.services.cache.ExoCacheFactory}
+ *
+ * @author <a href="mailto:nicolas.filotto@exoplatform.com">Nicolas Filotto</a>
+ * @version $Id$
+ *
+ */
+public class ExoCacheFactoryImpl implements ExoCacheFactory
+{
+
+ /**
+ * The logger
+ */
+ private static final Log LOG =
+ ExoLogger.getLogger("exo.kernel.component.ext.cache.impl.infinispan.v4.ExoCacheFactoryImpl");
+
+ /**
+ * The initial parameter key that defines the full path of the configuration template
+ */
+ private static final String CACHE_CONFIG_TEMPLATE_KEY = "cache.config.template";
+
+ /**
+ * The current {@link ExoContainerContext}
+ */
+ private final ExoContainerContext ctx;
+
+ /**
+ * The configuration manager that allows us to retrieve a configuration file in several different
+ * manners
+ */
+ private final ConfigurationManager configManager;
+
+ /**
+ * The {@link DefaultCacheManager} used for all the cache regions
+ */
+ private final DefaultCacheManager cacheManager;
+
+ /**
+ * The mapping between the configuration types and the creators
+ */
+ private final Map<Class<? extends ExoCacheConfig>, ExoCacheCreator> mappingConfigTypeCreators =
+ new HashMap<Class<? extends ExoCacheConfig>, ExoCacheCreator>();
+
+ /**
+ * The mapping between the implementations and the creators. This is mainly used for backward compatibility
+ */
+ private final Map<String, ExoCacheCreator> mappingImplCreators = new HashMap<String, ExoCacheCreator>();
+
+ /**
+ * The mapping between the cache names and the configuration paths
+ */
+ private final Map<String, String> mappingCacheNameConfig = new HashMap<String, String>();
+
+ /**
+ * The mapping between the global configuration and the cache managers
+ */
+ private final Map<GlobalConfiguration, DefaultCacheManager> mappingGlobalConfigCacheManager =
+ new HashMap<GlobalConfiguration, DefaultCacheManager>();
+
+ /**
+ * The default creator
+ */
+ private final ExoCacheCreator defaultCreator = new GenericExoCacheCreator();
+
+ private static final MBeanServerLookup MBEAN_SERVER_LOOKUP = new MBeanServerLookup()
+ {
+ public MBeanServer getMBeanServer(Properties properties)
+ {
+ return ExoContainerContext.getTopContainer().getMBeanServer();
+ }
+ };
+
+ public ExoCacheFactoryImpl(ExoContainerContext ctx, InitParams params, ConfigurationManager configManager)
+ throws ExoCacheInitException
+ {
+ this(ctx, getValueParam(params, CACHE_CONFIG_TEMPLATE_KEY), configManager);
+ }
+
+ ExoCacheFactoryImpl(ExoContainerContext ctx, String cacheConfigTemplate, ConfigurationManager configManager)
+ throws ExoCacheInitException
+ {
+ this.ctx = ctx;
+ this.configManager = configManager;
+ if (cacheConfigTemplate == null)
+ {
+ throw new RuntimeException("The parameter '" + CACHE_CONFIG_TEMPLATE_KEY + "' must be set");
+ }
+ // Initialize the main cache manager
+ this.cacheManager = initCacheManager(cacheConfigTemplate);
+ // Register the main cache manager
+ mappingGlobalConfigCacheManager.put(cacheManager.getGlobalConfiguration(), cacheManager);
+ }
+
+ /**
+ * Initializes the {@link DefaultCacheManager}
+ * @throws ExoCacheInitException if the cache manager cannot be initialized
+ */
+ private DefaultCacheManager initCacheManager(String cacheConfigTemplate)
+ throws ExoCacheInitException
+ {
+ InputStream is = null;
+ try
+ {
+ // Read the configuration file of the cache
+ is = configManager.getInputStream(cacheConfigTemplate);
+ }
+ catch (Exception e)
+ {
+ throw new ExoCacheInitException("The configuration of the CacheManager cannot be loaded from '"
+ + cacheConfigTemplate + "'", e);
+ }
+ if (is == null)
+ {
+ throw new ExoCacheInitException("The configuration of the CacheManager cannot be found at '"
+ + cacheConfigTemplate + "'");
+ }
+ DefaultCacheManager cacheManager = null;
+ try
+ {
+ // Create the CacheManager from the input stream
+ cacheManager = new DefaultCacheManager(is, false);
+ }
+ catch (Exception e)
+ {
+ throw new ExoCacheInitException("Cannot initialize the CacheManager corresponding to the configuration '"
+ + cacheConfigTemplate + "'", e);
+ }
+
+ GlobalConfiguration config = cacheManager.getGlobalConfiguration();
+
+ configureCacheManager(config);
+ cacheManager.start();
+ return cacheManager;
+ }
+
+ /**
+ * Configure the cache manager
+ *
+ * @param config
+ * @throws ExoCacheInitException
+ */
+ private void configureCacheManager(GlobalConfiguration config) throws ExoCacheInitException
+ {
+ // Configure JGroups
+ configureJGroups(config);
+ // Configure the name of the cache manager
+ config.fluent().globalJmxStatistics().cacheManagerName(config.getCacheManagerName() + "_" + ctx.getName()).
+ // Configure the MBeanServerLookup
+ mBeanServerLookup(MBEAN_SERVER_LOOKUP);
+ }
+
+ /**
+ * If some JGoups properties has been set, it will load the configuration and set
+ * the cluster name by adding as suffix the name of the {@link ExoContainerContext}
+ *
+ * @param config the global configuration from which the JGroups config will be extracted
+ * @throws ExoCacheInitException if any exception occurs while configuring JGroups
+ */
+ private void configureJGroups(GlobalConfiguration config) throws ExoCacheInitException
+ {
+ if (loadJGroupsConfig(config))
+ {
+ // The JGroups Config could be loaded which means that the configuration is for a cluster
+ config.fluent().transport().clusterName(config.getClusterName() + "-" + ctx.getName());
+ }
+ }
+
+ /**
+ * Load the JGroups configuration file thanks to the {@link ConfigurationManager}
+ * @param config the global configuration from which the JGroups config will be extracted
+ * @return <code>true</code> if the JGoups config could be loaded successfully,
+ * <code>false</code> if there were no JGroups config to load
+ * @throws ExoCacheInitException if the JGroups config could not be loaded
+ */
+ private boolean loadJGroupsConfig(GlobalConfiguration config) throws ExoCacheInitException
+ {
+ Properties properties = config.getTransportProperties();
+ if (properties == null || !properties.containsKey(JGroupsTransport.CONFIGURATION_FILE))
+ {
+ return false;
+ }
+ InputStream is;
+ String jgroupsFileLocation = properties.getProperty(JGroupsTransport.CONFIGURATION_FILE);
+ try
+ {
+ // Read the jgroups configuration file
+ URL url = configManager.getURL(jgroupsFileLocation);
+ is = url == null ? null : url.openStream();
+ }
+ catch (Exception e)
+ {
+ throw new ExoCacheInitException("The jgroups configuration cannot be loaded from '" + jgroupsFileLocation
+ + "'", e);
+ }
+ if (is != null)
+ {
+ try
+ {
+ // Set the jgroups configuration as XML
+ properties.setProperty(JGroupsTransport.CONFIGURATION_XML, readStream(is));
+ }
+ catch (IOException e)
+ {
+ throw new ExoCacheInitException("The jgroups configuration cannot be read from '" + jgroupsFileLocation
+ + "'");
+ }
+ // Remove the property corresponding to the configuration file
+ properties.remove(JGroupsTransport.CONFIGURATION_FILE);
+ }
+ return true;
+ }
+
+ /**
+ * Reads bytes from input stream and builds a string from them
+ *
+ * @param inputStream
+ * @return
+ * @throws IOException
+ */
+ protected String readStream(InputStream inputStream) throws IOException
+ {
+ StringBuilder out = new StringBuilder(4096);
+ byte[] b = new byte[4096];
+ try
+ {
+ for (int length; (length = inputStream.read(b)) != -1;)
+ {
+ out.append(new String(b, 0, length));
+ }
+ }
+ finally
+ {
+ try
+ {
+ inputStream.close();
+ }
+ catch (Exception e)
+ {
+ LOG.debug("Cannot close stream", e);
+ }
+ }
+ return out.toString();
+ }
+
+ /**
+ * To create a new cache instance according to the given configuration, we follow the steps below:
+ *
+ * We first try to find if a specific location of the cache configuration has been defined thanks
+ * to an external component plugin of type ExoCacheFactoryConfigPlugin. If so we use the default cache
+ * configuration defined in this file otherwise we use the default cache configuration defined in
+ * "${CACHE_CONFIG_TEMPLATE_KEY}"
+ */
+ public ExoCache<Serializable, Object> createCache(ExoCacheConfig config) throws ExoCacheInitException
+ {
+ final String region = config.getName();
+ final String customConfig = mappingCacheNameConfig.get(region);
+ final ExoCache<Serializable, Object> eXoCache;
+ final DefaultCacheManager cacheManager;
+ try
+ {
+ final Configuration conf;
+ if (customConfig != null)
+ {
+ // A custom configuration has been set
+ if (LOG.isInfoEnabled())
+ LOG.info("A custom configuration has been set for the cache '" + region + "'.");
+ // Create the CacheManager by loading the configuration
+ DefaultCacheManager customCacheManager = new DefaultCacheManager(configManager.getInputStream(customConfig), false);
+ GlobalConfiguration gc = customCacheManager.getGlobalConfiguration();
+ // Configure JGroups and JMX since it could affect the state of the Global Config
+ configureCacheManager(gc);
+ // Check if a CacheManager with the same GlobalConfiguration exists
+ DefaultCacheManager currentCacheManager = mappingGlobalConfigCacheManager.get(gc);
+ if (currentCacheManager == null)
+ {
+ // No cache manager has been defined so far for this Cache Configuration
+ currentCacheManager = customCacheManager;
+ // Use a different cache manager name to prevent naming conflict
+ gc.fluent().globalJmxStatistics().cacheManagerName(gc.getCacheManagerName() + "_" + region + "_" + ctx.getName());
+ currentCacheManager.start();
+ // We register this new cache manager
+ mappingGlobalConfigCacheManager.put(gc, customCacheManager);
+ }
+ conf = currentCacheManager.getDefaultConfiguration().clone();
+ cacheManager = currentCacheManager;
+ }
+ else
+ {
+ cacheManager = this.cacheManager;
+ // No custom configuration has been found, a configuration template will be used
+ if (LOG.isInfoEnabled())
+ LOG.info("The configuration template will be used for the the cache '" + region + "'.");
+ conf = cacheManager.getDefaultConfiguration().clone();
+ if (!config.isDistributed() && !config.isRepicated())
+ {
+ // The cache is local
+ conf.fluent().clustering().mode(CacheMode.LOCAL);
+ }
+ }
+ // Reset the configuration to avoid conflicts
+ resetConfiguration(conf);
+ final ExoCacheCreator creator = getExoCacheCreator(config);
+ // Create the cache
+ eXoCache = creator.create(config, conf, new Callable<Cache<Serializable, Object>>()
+ {
+ @Override
+ public Cache<Serializable, Object> call() throws Exception
+ {
+ // Define the configuration
+ cacheManager.defineConfiguration(region, conf);
+ // create and start the cache
+ return cacheManager.getCache(region);
+ }
+ });
+ }
+ catch (Exception e)
+ {
+ throw new ExoCacheInitException("The cache '" + region + "' could not be initialized", e);
+ }
+ return eXoCache;
+ }
+
+ /**
+ * Add a list of creators to register
+ * @param plugin the plugin that contains the creators
+ */
+ public void addCreator(ExoCacheCreatorPlugin plugin)
+ {
+ final List<ExoCacheCreator> creators = plugin.getCreators();
+ for (ExoCacheCreator creator : creators)
+ {
+ mappingConfigTypeCreators.put(creator.getExpectedConfigType(), creator);
+ Set<String> implementations = creator.getExpectedImplementations();
+ if (implementations == null)
+ {
+ throw new NullPointerException("The set of implementations cannot be null");
+ }
+ for (String imp : implementations)
+ {
+ mappingImplCreators.put(imp, creator);
+ }
+ }
+ }
+
+ /**
+ * Add a list of custom configuration to register
+ * @param plugin the plugin that contains the configs
+ */
+ public void addConfig(ExoCacheFactoryConfigPlugin plugin)
+ {
+ final Map<String, String> configs = plugin.getConfigs();
+ mappingCacheNameConfig.putAll(configs);
+ }
+
+ /**
+ * Returns the value of the ValueParam if and only if the value is not empty
+ */
+ private static String getValueParam(InitParams params, String key)
+ {
+ if (params == null)
+ {
+ return null;
+ }
+ final ValueParam vp = params.getValueParam(key);
+ String result;
+ if (vp == null || (result = vp.getValue()) == null || (result = result.trim()).length() == 0)
+ {
+ return null;
+ }
+ return result;
+ }
+
+ /**
+ * Returns the most relevant ExoCacheCreator according to the give configuration
+ */
+ protected ExoCacheCreator getExoCacheCreator(ExoCacheConfig config)
+ {
+ ExoCacheCreator creator = mappingConfigTypeCreators.get(config.getClass());
+ if (creator == null)
+ {
+ // No creator for this type has been found, let's try the implementation field
+ creator = mappingImplCreators.get(config.getImplementation());
+ if (creator == null)
+ {
+ // No creator can be found, we will use the default creator
+ if (LOG.isInfoEnabled())
+ LOG.info("No cache creator has been found for the the cache '" + config.getName()
+ + "', the default one will be used.");
+ return defaultCreator;
+ }
+ }
+ if (LOG.isInfoEnabled())
+ LOG.info("The cache '" + config.getName() + "' will be created with '" + creator.getClass() + "'.");
+ return creator;
+ }
+
+ /**
+ * Clean the configuration template to prevent conflicts
+ */
+ protected void resetConfiguration(Configuration config)
+ {
+ config.fluent().invocationBatching().eviction().strategy(EvictionStrategy.NONE).maxEntries(-1).expiration()
+ .lifespan(-1L).maxIdle(-1L).wakeUpInterval(60000L);
+ }
+}
Added: kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/java/org/exoplatform/services/cache/impl/infinispan/generic/GenericExoCacheConfig.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/java/org/exoplatform/services/cache/impl/infinispan/generic/GenericExoCacheConfig.java (rev 0)
+++ kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/java/org/exoplatform/services/cache/impl/infinispan/generic/GenericExoCacheConfig.java 2011-08-09 14:05:16 UTC (rev 4720)
@@ -0,0 +1,123 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.cache.impl.infinispan.generic;
+
+import org.exoplatform.services.cache.ExoCacheConfig;
+
+/**
+ * The {@link org.exoplatform.services.cache.ExoCacheConfig} for all the eviction algorithms
+ * available in infinispan
+ *
+ * @author <a href="mailto:nicolas.filotto@exoplatform.com">Nicolas Filotto</a>
+ * @version $Id$
+ *
+ */
+public class GenericExoCacheConfig extends ExoCacheConfig
+{
+
+ private String strategy;
+
+ private int maxEntries;
+
+ private long lifespan;
+
+ private long maxIdle;
+
+ private long wakeUpInterval;
+
+ /**
+ * @return the strategy
+ */
+ public String getStrategy()
+ {
+ return strategy;
+ }
+
+ /**
+ * @param strategy the strategy to set
+ */
+ public void setStrategy(String strategy)
+ {
+ this.strategy = strategy;
+ }
+
+ /**
+ * @return the wakeUpInterval
+ */
+ public long getWakeUpInterval()
+ {
+ return wakeUpInterval;
+ }
+
+ /**
+ * @param wakeUpInterval the wakeUpInterval to set
+ */
+ public void setWakeUpInterval(long wakeUpInterval)
+ {
+ this.wakeUpInterval = wakeUpInterval;
+ }
+
+ /**
+ * @return the maxEntries
+ */
+ public int getMaxEntries()
+ {
+ return maxEntries;
+ }
+
+ /**
+ * @param maxEntries the maxEntries to set
+ */
+ public void setMaxEntries(int maxEntries)
+ {
+ this.maxEntries = maxEntries;
+ }
+
+ /**
+ * @return the lifespan
+ */
+ public long getLifespan()
+ {
+ return lifespan;
+ }
+
+ /**
+ * @param lifespan the lifespan to set
+ */
+ public void setLifespan(long lifespan)
+ {
+ this.lifespan = lifespan;
+ }
+
+ /**
+ * @return the maxIdle
+ */
+ public long getMaxIdle()
+ {
+ return maxIdle;
+ }
+
+ /**
+ * @param maxIdle the maxIdle to set
+ */
+ public void setMaxIdle(long maxIdle)
+ {
+ this.maxIdle = maxIdle;
+ }
+}
\ No newline at end of file
Added: kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/java/org/exoplatform/services/cache/impl/infinispan/generic/GenericExoCacheCreator.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/java/org/exoplatform/services/cache/impl/infinispan/generic/GenericExoCacheCreator.java (rev 0)
+++ kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/java/org/exoplatform/services/cache/impl/infinispan/generic/GenericExoCacheCreator.java 2011-08-09 14:05:16 UTC (rev 4720)
@@ -0,0 +1,198 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.cache.impl.infinispan.generic;
+
+import org.exoplatform.management.annotations.Managed;
+import org.exoplatform.management.annotations.ManagedDescription;
+import org.exoplatform.management.annotations.ManagedName;
+import org.exoplatform.services.cache.ExoCache;
+import org.exoplatform.services.cache.ExoCacheConfig;
+import org.exoplatform.services.cache.ExoCacheInitException;
+import org.exoplatform.services.cache.impl.infinispan.AbstractExoCache;
+import org.exoplatform.services.cache.impl.infinispan.ExoCacheCreator;
+import org.infinispan.Cache;
+import org.infinispan.config.Configuration;
+import org.infinispan.eviction.EvictionStrategy;
+
+import java.io.Serializable;
+import java.util.Locale;
+import java.util.Set;
+import java.util.concurrent.Callable;
+
+/**
+ * The generic {@link ExoCacheCreator} for all the expiration available in infinispan.
+ *
+ * @author <a href="mailto:nicolas.filotto@exoplatform.com">Nicolas Filotto</a>
+ * @version $Id$
+ *
+ */
+public class GenericExoCacheCreator implements ExoCacheCreator
+{
+
+ /**
+ * The default value for the eviction strategy
+ */
+ protected String defaultStrategy = "LRU";
+
+ /**
+ * The default value for maxIdle
+ */
+ protected long defaultMaxIdle = -1;
+
+ /**
+ * The default value for wakeUpInterval
+ */
+ protected long defaultWakeUpInterval = 5000;
+
+ /**
+ * A set of all the implementations supported by this creator
+ */
+ protected Set<String> implementations;
+
+ /**
+ * {@inheritDoc}
+ */
+ public Set<String> getExpectedImplementations()
+ {
+ return implementations;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Class<? extends ExoCacheConfig> getExpectedConfigType()
+ {
+ return GenericExoCacheConfig.class;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public ExoCache<Serializable, Object> create(ExoCacheConfig config, Configuration cacheConfig,
+ Callable<Cache<Serializable, Object>> cacheGetter) throws ExoCacheInitException
+ {
+ if (config instanceof GenericExoCacheConfig)
+ {
+ final GenericExoCacheConfig gConfig = (GenericExoCacheConfig)config;
+ return create(config, cacheConfig, cacheGetter, gConfig.getStrategy(), gConfig.getMaxEntries(), gConfig
+ .getLifespan(), gConfig.getMaxIdle() == 0 ? defaultMaxIdle : gConfig.getMaxIdle(), gConfig
+ .getWakeUpInterval() == 0 ? defaultWakeUpInterval : gConfig.getWakeUpInterval());
+ }
+ else
+ {
+ final long period = config.getLiveTime();
+ return create(config, cacheConfig, cacheGetter, config.getImplementation() == null ? defaultStrategy : config
+ .getImplementation(), config.getMaxSize(), period > 0 ? period * 1000 : -1, defaultMaxIdle,
+ defaultWakeUpInterval);
+ }
+ }
+
+ /**
+ * Creates a new ExoCache instance with the relevant parameters
+ * @throws ExoCacheInitException If any exception occurs while creating the cache
+ */
+ private ExoCache<Serializable, Object> create(ExoCacheConfig config, Configuration cacheConfig,
+ Callable<Cache<Serializable, Object>> cacheGetter, String strategy, int maxEntries, long lifespan, long maxIdle,
+ long wakeUpInterval) throws ExoCacheInitException
+ {
+ EvictionStrategy es = strategy == null || strategy.length() == 0 ? null : EvictionStrategy.valueOf(strategy.toUpperCase(Locale.ENGLISH));
+ if (es == null)
+ {
+ es = EvictionStrategy.LRU;
+ }
+ cacheConfig.fluent().eviction().strategy(EvictionStrategy.valueOf(strategy)).maxEntries(maxEntries).expiration()
+ .lifespan(lifespan).maxIdle(maxIdle).wakeUpInterval(wakeUpInterval);
+ try
+ {
+ return new GenericExoCache(cacheConfig, config, cacheGetter.call());
+ }
+ catch (Exception e)
+ {
+ throw new ExoCacheInitException("Cannot create the cache '" + config.getName() + "'", e);
+ }
+ }
+
+ /**
+ * The Generic implementation of an ExoCache
+ */
+ public static class GenericExoCache extends AbstractExoCache<Serializable, Object>
+ {
+
+ private final Configuration cacheConfig;
+
+ public GenericExoCache(Configuration cacheConfig, ExoCacheConfig config, Cache<Serializable, Object> cache)
+ {
+ super(config, cache);
+ this.cacheConfig = cacheConfig;
+ }
+
+ public void setMaxSize(int max)
+ {
+ cacheConfig.fluent().eviction().maxEntries(max);
+ }
+
+ public void setLiveTime(long period)
+ {
+ cacheConfig.fluent().expiration().lifespan(period);
+ }
+
+ public void setMaxIdle(long maxIdle)
+ {
+ cacheConfig.fluent().expiration().maxIdle(maxIdle);
+ }
+
+ public void setWakeUpInterval(long wakeUpInterval)
+ {
+ cacheConfig.fluent().expiration().wakeUpInterval(wakeUpInterval);
+ }
+
+ @ManagedName("MaxEntries")
+ @ManagedDescription("Maximum number of entries in a cache instance. -1 means no limit.")
+ public int getMaxSize()
+ {
+ return cacheConfig.getEvictionMaxEntries();
+ }
+
+ @ManagedName("Lifespan")
+ @ManagedDescription("Maximum lifespan of a cache entry, after which the entry is expired cluster-wide." +
+ " -1 means the entries never expire.")
+ public long getLiveTime()
+ {
+ return cacheConfig.getExpirationLifespan();
+ }
+
+ @Managed
+ @ManagedName("MaxIdle")
+ @ManagedDescription("Maximum idle time a cache entry will be maintained in the cache. " +
+ "If the idle time is exceeded, the entry will be expired cluster-wide. -1 means the entries never expire.")
+ public long getMaxIdle()
+ {
+ return cacheConfig.getExpirationMaxIdle();
+ }
+
+ @Managed
+ @ManagedName("WakeUpInterval")
+ @ManagedDescription("Interval between subsequent eviction runs. If you wish to disable the periodic eviction " +
+ "process altogether, set wakeupInterval to -1.")
+ public long getWakeUpInterval()
+ {
+ return cacheConfig.getExpirationWakeUpInterval();
+ }
+ }
+}
\ No newline at end of file
Added: kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/resources/conf/portal/cache-configuration-template.xml
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/resources/conf/portal/cache-configuration-template.xml (rev 0)
+++ kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/resources/conf/portal/cache-configuration-template.xml 2011-08-09 14:05:16 UTC (rev 4720)
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Copyright (C) 2010 eXo Platform SAS.
+
+ This is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+
+-->
+<infinispan xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:infinispan:config:5.0 http://www.infinispan.org/schemas/infinispan-config-5.0.xsd"
+ xmlns="urn:infinispan:config:5.0">
+ <global>
+ <asyncListenerExecutor factory="org.infinispan.executors.DefaultExecutorFactory">
+ <properties>
+ <property name="maxThreads" value="1"/>
+ <property name="queueSize" value="100000"/>
+ <property name="threadNamePrefix" value="AsyncListenerThread"/>
+ </properties>
+ </asyncListenerExecutor>
+ <asyncTransportExecutor factory="org.infinispan.executors.DefaultExecutorFactory">
+ <properties>
+ <property name="threadNamePrefix" value="AsyncSerializationThread"/>
+ </properties>
+ </asyncTransportExecutor>
+ <evictionScheduledExecutor factory="org.infinispan.executors.DefaultScheduledExecutorFactory">
+ <properties>
+ <property name="threadNamePrefix" value="EvictionThread"/>
+ </properties>
+ </evictionScheduledExecutor>
+ <replicationQueueScheduledExecutor factory="org.infinispan.executors.DefaultScheduledExecutorFactory">
+ <properties>
+ <property name="threadNamePrefix" value="ReplicationQueueThread"/>
+ </properties>
+ </replicationQueueScheduledExecutor>
+ <globalJmxStatistics jmxDomain="exo" enabled="true" allowDuplicateDomains="true"/>
+ <transport transportClass="org.infinispan.remoting.transport.jgroups.JGroupsTransport" clusterName="eXoCache-cluster" distributedSyncTimeout="20000">
+ <properties>
+ <property name="configurationFile" value="flush-udp.xml"/>
+ </properties>
+ </transport>
+ <shutdown hookBehavior="DEFAULT"/>
+ </global>
+ <default>
+ <locking isolationLevel="READ_COMMITTED" lockAcquisitionTimeout="10000" writeSkewCheck="false" concurrencyLevel="500"/>
+ <transaction transactionManagerLookupClass="org.infinispan.transaction.lookup.GenericTransactionManagerLookup" syncRollbackPhase="false" syncCommitPhase="false"/>
+ <jmxStatistics enabled="true"/>
+ <invocationBatching enabled="true"/>
+ <clustering mode="replication">
+ <stateRetrieval timeout="20000" fetchInMemoryState="false"/>
+ <sync replTimeout="20000"/>
+ </clustering>
+ </default>
+</infinispan>
\ No newline at end of file
Added: kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/resources/conf/portal/configuration.xml
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/resources/conf/portal/configuration.xml (rev 0)
+++ kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/resources/conf/portal/configuration.xml 2011-08-09 14:05:16 UTC (rev 4720)
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+ Copyright (C) 2009 eXo Platform SAS.
+
+ This is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+
+-->
+<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.exoplatform.org/xml/ns/kernel_1_0.xsd http://www.exoplatform.org/xml/ns/kernel_1_0.xsd"
+ xmlns="http://www.exoplatform.org/xml/ns/kernel_1_0.xsd">
+ <component>
+ <key>org.exoplatform.services.cache.ExoCacheFactory</key>
+ <type>org.exoplatform.services.cache.impl.infinispan.ExoCacheFactoryImpl</type>
+ <init-params>
+ <value-param>
+ <name>cache.config.template</name>
+ <value>jar:/conf/portal/cache-configuration-template.xml</value>
+ </value-param>
+ </init-params>
+ </component>
+</configuration>
Added: kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/java/org/exoplatform/services/cache/impl/infinispan/TestAbstractExoCache.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/java/org/exoplatform/services/cache/impl/infinispan/TestAbstractExoCache.java (rev 0)
+++ kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/java/org/exoplatform/services/cache/impl/infinispan/TestAbstractExoCache.java 2011-08-09 14:05:16 UTC (rev 4720)
@@ -0,0 +1,752 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.cache.impl.infinispan;
+
+import org.exoplatform.container.ExoContainerContext;
+import org.exoplatform.container.PortalContainer;
+import org.exoplatform.container.configuration.ConfigurationManager;
+import org.exoplatform.services.cache.CacheListener;
+import org.exoplatform.services.cache.CacheListenerContext;
+import org.exoplatform.services.cache.CacheService;
+import org.exoplatform.services.cache.CachedObjectSelector;
+import org.exoplatform.services.cache.ExoCache;
+import org.exoplatform.services.cache.ExoCacheConfig;
+import org.exoplatform.services.cache.ExoCacheFactory;
+import org.exoplatform.services.cache.ExoCacheInitException;
+import org.exoplatform.services.cache.ObjectCacheInfo;
+import org.exoplatform.test.BasicTestCase;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * @author <a href="mailto:nicolas.filotto@exoplatform.com">Nicolas Filotto</a>
+ * @version $Id$
+ *
+ */
+public class TestAbstractExoCache extends BasicTestCase
+{
+
+ CacheService service;
+
+ AbstractExoCache<Serializable, Object> cache;
+
+ public TestAbstractExoCache(String name)
+ {
+ super(name);
+ }
+
+ public void setUp() throws Exception
+ {
+ this.service = (CacheService)PortalContainer.getInstance().getComponentInstanceOfType(CacheService.class);
+ this.cache = (AbstractExoCache<Serializable, Object>)service.getCacheInstance("myCache");
+ }
+
+ public void testPut() throws Exception
+ {
+ cache.put(new MyKey("a"), "a");
+ cache.put(new MyKey("b"), "b");
+ cache.put(new MyKey("c"), "c");
+ assertEquals(3, cache.getCacheSize());
+ cache.put(new MyKey("a"), "c");
+ assertEquals(3, cache.getCacheSize());
+ cache.put(new MyKey("d"), "c");
+ assertEquals(4, cache.getCacheSize());
+
+ cache.clearCache();
+ }
+
+ public void testClearCache() throws Exception
+ {
+ cache.put(new MyKey("a"), "a");
+ cache.put(new MyKey("b"), "b");
+ cache.put(new MyKey("c"), "c");
+ assertTrue(cache.getCacheSize() > 0);
+ cache.clearCache();
+ assertTrue(cache.getCacheSize() == 0);
+
+ cache.clearCache();
+ }
+
+ public void testGet() throws Exception
+ {
+ cache.put(new MyKey("a"), "a");
+ assertEquals("a", cache.get(new MyKey("a")));
+ cache.put(new MyKey("a"), "c");
+ assertEquals("c", cache.get(new MyKey("a")));
+ cache.remove(new MyKey("a"));
+ assertEquals(null, cache.get(new MyKey("a")));
+ assertEquals(null, cache.get(new MyKey("x")));
+
+ cache.clearCache();
+ }
+
+ public void testRemove() throws Exception
+ {
+ cache.put(new MyKey("a"), 1);
+ cache.put(new MyKey("b"), 2);
+ cache.put(new MyKey("c"), 3);
+ assertEquals(3, cache.getCacheSize());
+ assertEquals(1, cache.remove(new MyKey("a")));
+ assertEquals(2, cache.getCacheSize());
+ assertEquals(2, cache.remove(new MyKey("b")));
+ assertEquals(1, cache.getCacheSize());
+ assertEquals(null, cache.remove(new MyKey("x")));
+ assertEquals(1, cache.getCacheSize());
+
+ cache.clearCache();
+ }
+
+ public void testPutMap() throws Exception
+ {
+ Map<Serializable, Object> values = new HashMap<Serializable, Object>();
+ values.put(new MyKey("a"), "a");
+ values.put(new MyKey("b"), "b");
+ assertEquals(0, cache.getCacheSize());
+ cache.putMap(values);
+ assertEquals(2, cache.getCacheSize());
+ values = new HashMap<Serializable, Object>()
+ {
+ private static final long serialVersionUID = 1L;
+
+ public Set<Entry<Serializable, Object>> entrySet()
+ {
+ Set<Entry<Serializable, Object>> set = new LinkedHashSet<Entry<Serializable, Object>>(super.entrySet());
+ set.add(new Entry<Serializable, Object>()
+ {
+
+ public Object setValue(Object paramV)
+ {
+ return null;
+ }
+
+ public Object getValue()
+ {
+ throw new RuntimeException("An exception");
+ }
+
+ public Serializable getKey()
+ {
+ return "c";
+ }
+ });
+ return set;
+ }
+ };
+ values.put(new MyKey("e"), "e");
+ values.put(new MyKey("d"), "d");
+ cache.putMap(values);
+ assertEquals(2, cache.getCacheSize());
+
+ cache.clearCache();
+ }
+
+ public void testGetCachedObjects() throws Exception
+ {
+ cache.put(new MyKey("a"), "a");
+ cache.put(new MyKey("b"), "b");
+ cache.put(new MyKey("c"), "c");
+ cache.put(new MyKey("d"), null);
+ assertEquals(3, cache.getCacheSize());
+ List<Object> values = cache.getCachedObjects();
+ assertEquals(3, values.size());
+ assertTrue(values.contains("a"));
+ assertTrue(values.contains("b"));
+ assertTrue(values.contains("c"));
+
+ cache.clearCache();
+ }
+
+ public void testRemoveCachedObjects() throws Exception
+ {
+ cache.put(new MyKey("a"), "a");
+ cache.put(new MyKey("b"), "b");
+ cache.put(new MyKey("c"), "c");
+ cache.put(new MyKey("d"), null);
+ assertEquals(3, cache.getCacheSize());
+ List<Object> values = cache.removeCachedObjects();
+ assertEquals(3, values.size());
+ assertTrue(values.contains("a"));
+ assertTrue(values.contains("b"));
+ assertTrue(values.contains("c"));
+ assertEquals(0, cache.getCacheSize());
+
+ cache.clearCache();
+ }
+
+ public void testSelect() throws Exception
+ {
+ cache.put(new MyKey("a"), 1);
+ cache.put(new MyKey("b"), 2);
+ cache.put(new MyKey("c"), 3);
+ final AtomicInteger count = new AtomicInteger();
+ CachedObjectSelector<Serializable, Object> selector = new CachedObjectSelector<Serializable, Object>()
+ {
+
+ public void onSelect(ExoCache<? extends Serializable, ? extends Object> cache, Serializable key,
+ ObjectCacheInfo<? extends Object> ocinfo) throws Exception
+ {
+ assertTrue(key.equals(new MyKey("a")) || key.equals(new MyKey("b")) || key.equals(new MyKey("c")));
+ assertTrue(ocinfo.get().equals(1) || ocinfo.get().equals(2) || ocinfo.get().equals(3));
+ count.incrementAndGet();
+ }
+
+ public boolean select(Serializable key, ObjectCacheInfo<? extends Object> ocinfo)
+ {
+ return true;
+ }
+ };
+ cache.select(selector);
+ assertEquals(3, count.intValue());
+
+ cache.clearCache();
+ }
+
+ public void testGetHitsNMisses() throws Exception
+ {
+ int hits = cache.getCacheHit();
+ int misses = cache.getCacheMiss();
+ cache.put(new MyKey("a"), "a");
+ cache.get(new MyKey("a"));
+ cache.remove(new MyKey("a"));
+ cache.get(new MyKey("a"));
+ cache.get(new MyKey("z"));
+ assertEquals(1, cache.getCacheHit() - hits);
+ assertEquals(2, cache.getCacheMiss() - misses);
+
+ cache.clearCache();
+ }
+
+ private ExoCacheFactory getExoCacheFactoryInstance() throws ExoCacheInitException
+ {
+ PortalContainer pc = PortalContainer.getInstance();
+ return new ExoCacheFactoryImpl((ExoContainerContext)pc.getComponentInstanceOfType(ExoContainerContext.class),
+ "jar:/conf/portal/cache-configuration-template.xml", (ConfigurationManager)pc
+ .getComponentInstanceOfType(ConfigurationManager.class));
+ }
+
+ public void testMultiThreading() throws Exception
+ {
+ long time = System.currentTimeMillis();
+ final ExoCache<Serializable, Object> cache = service.getCacheInstance("test-multi-threading");
+ final int totalElement = 100;
+ final int totalTimes = 20;
+ int reader = 20;
+ int writer = 10;
+ int remover = 5;
+ int cleaner = 1;
+ final CountDownLatch startSignalWriter = new CountDownLatch(1);
+ final CountDownLatch startSignalOthers = new CountDownLatch(1);
+ final CountDownLatch doneSignal = new CountDownLatch(reader + writer + remover);
+ final List<Exception> errors = Collections.synchronizedList(new ArrayList<Exception>());
+ for (int i = 0; i < writer; i++)
+ {
+ final int index = i;
+ Thread thread = new Thread()
+ {
+ public void run()
+ {
+ try
+ {
+ startSignalWriter.await();
+ for (int j = 0; j < totalTimes; j++)
+ {
+ for (int i = 0; i < totalElement; i++)
+ {
+ cache.put(new MyKey("key" + i), "value" + i);
+ }
+ if (index == 0 && j == 0)
+ {
+ // The cache is full, we can launch the others
+ startSignalOthers.countDown();
+ }
+ sleep(50);
+ }
+ }
+ catch (Exception e)
+ {
+ errors.add(e);
+ }
+ finally
+ {
+ doneSignal.countDown();
+ }
+ }
+ };
+ thread.start();
+ }
+ startSignalWriter.countDown();
+ for (int i = 0; i < reader; i++)
+ {
+ Thread thread = new Thread()
+ {
+ public void run()
+ {
+ try
+ {
+ startSignalOthers.await();
+ for (int j = 0; j < totalTimes; j++)
+ {
+ for (int i = 0; i < totalElement; i++)
+ {
+ cache.get(new MyKey("key" + i));
+ }
+ sleep(50);
+ }
+ }
+ catch (Exception e)
+ {
+ errors.add(e);
+ }
+ finally
+ {
+ doneSignal.countDown();
+ }
+ }
+ };
+ thread.start();
+ }
+ for (int i = 0; i < remover; i++)
+ {
+ Thread thread = new Thread()
+ {
+ public void run()
+ {
+ try
+ {
+ startSignalOthers.await();
+ for (int j = 0; j < totalTimes; j++)
+ {
+ for (int i = 0; i < totalElement; i++)
+ {
+ cache.remove(new MyKey("key" + i));
+ }
+ sleep(50);
+ }
+ }
+ catch (Exception e)
+ {
+ errors.add(e);
+ }
+ finally
+ {
+ doneSignal.countDown();
+ }
+ }
+ };
+ thread.start();
+ }
+ doneSignal.await();
+ for (int i = 0; i < totalElement; i++)
+ {
+ cache.put(new MyKey("key" + i), "value" + i);
+ }
+ assertEquals(totalElement, cache.getCacheSize());
+ final CountDownLatch startSignal = new CountDownLatch(1);
+ final CountDownLatch doneSignal2 = new CountDownLatch(writer + cleaner);
+ for (int i = 0; i < writer; i++)
+ {
+ Thread thread = new Thread()
+ {
+ public void run()
+ {
+ try
+ {
+ startSignal.await();
+ for (int j = 0; j < totalTimes; j++)
+ {
+ for (int i = 0; i < totalElement; i++)
+ {
+ cache.put(new MyKey("key" + i), "value" + i);
+ }
+ sleep(50);
+ }
+ }
+ catch (Exception e)
+ {
+ errors.add(e);
+ }
+ finally
+ {
+ doneSignal2.countDown();
+ }
+ }
+ };
+ thread.start();
+ }
+ for (int i = 0; i < cleaner; i++)
+ {
+ Thread thread = new Thread()
+ {
+ public void run()
+ {
+ try
+ {
+ startSignal.await();
+ for (int j = 0; j < totalTimes; j++)
+ {
+ sleep(150);
+ cache.clearCache();
+ }
+ }
+ catch (Exception e)
+ {
+ errors.add(e);
+ }
+ finally
+ {
+ doneSignal2.countDown();
+ }
+ }
+ };
+ thread.start();
+ }
+ cache.clearCache();
+ assertEquals(0, cache.getCacheSize());
+ if (!errors.isEmpty())
+ {
+ for (Exception e : errors)
+ {
+ e.printStackTrace();
+ }
+ throw errors.get(0);
+ }
+ System.out.println("Total Time = " + (System.currentTimeMillis() - time));
+
+ cache.clearCache();
+ }
+
+ public static class MyCacheListener implements CacheListener<Serializable, Object>
+ {
+
+ public int clearCache;
+
+ public int expire;
+
+ public int get;
+
+ public int put;
+
+ public int remove;
+
+ public void onClearCache(ExoCache<Serializable, Object> cache) throws Exception
+ {
+ clearCache++;
+ }
+
+ public void onExpire(ExoCache<Serializable, Object> cache, Serializable key, Object obj) throws Exception
+ {
+ expire++;
+ }
+
+ public void onGet(ExoCache<Serializable, Object> cache, Serializable key, Object obj) throws Exception
+ {
+ get++;
+ }
+
+ public void onPut(ExoCache<Serializable, Object> cache, Serializable key, Object obj) throws Exception
+ {
+ put++;
+ }
+
+ public void onRemove(ExoCache<Serializable, Object> cache, Serializable key, Object obj) throws Exception
+ {
+ remove++;
+ }
+
+ public void onClearCache(CacheListenerContext context) throws Exception
+ {
+ clearCache++;
+ }
+
+ public void onExpire(CacheListenerContext context, Serializable key, Object obj) throws Exception
+ {
+ expire++;
+ }
+
+ public void onGet(CacheListenerContext context, Serializable key, Object obj) throws Exception
+ {
+ get++;
+ }
+
+ public void onPut(CacheListenerContext context, Serializable key, Object obj) throws Exception
+ {
+ put++;
+ }
+
+ public void onRemove(CacheListenerContext context, Serializable key, Object obj) throws Exception
+ {
+ remove++;
+ }
+ }
+
+ public static class MyKey implements Serializable
+ {
+ private static final long serialVersionUID = 1L;
+
+ public String value;
+
+ public MyKey(String value)
+ {
+ this.value = value;
+ }
+
+ @Override
+ public boolean equals(Object paramObject)
+ {
+ return paramObject instanceof MyKey && ((MyKey)paramObject).value.endsWith(value);
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return value.hashCode();
+ }
+
+ @Override
+ public String toString()
+ {
+ return value;
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testDistributedCache() throws Exception
+ {
+ // If the cache is still alive this test fails due to a TimeoutException.
+ cache.cache.getCacheManager().stop();
+
+ System.out
+ .println("WARNING: For Linux distributions the following JVM parameter must be set to true, java.net.preferIPv4Stack = "
+ + System.getProperty("java.net.preferIPv4Stack"));
+ ExoCacheConfig config = new ExoCacheConfig();
+ config.setName("MyCacheDistributed");
+ config.setMaxSize(5);
+ config.setLiveTime(1);
+ config.setImplementation("LRU");
+ config.setDistributed(true);
+ ExoCacheConfig config2 = new ExoCacheConfig();
+ config2.setName("MyCacheDistributed2");
+ config2.setMaxSize(5);
+ config2.setLiveTime(1);
+ config2.setImplementation("LRU");
+ config2.setDistributed(true);
+ AbstractExoCache<Serializable, Object> cache1 =
+ (AbstractExoCache<Serializable, Object>)getExoCacheFactoryInstance().createCache(config);
+ MyCacheListener listener1 = new MyCacheListener();
+ cache1.addCacheListener(listener1);
+ AbstractExoCache<Serializable, Object> cache2 =
+ (AbstractExoCache<Serializable, Object>)getExoCacheFactoryInstance().createCache(config);
+ MyCacheListener listener2 = new MyCacheListener();
+ cache2.addCacheListener(listener2);
+// Cache 3 creates a conflict with cache 1 and 2
+// AbstractExoCache<Serializable, Object> cache3 =
+// (AbstractExoCache<Serializable, Object>)getExoCacheFactoryInstance().createCache(config2);
+// MyCacheListener listener3 = new MyCacheListener();
+// cache3.addCacheListener(listener3);
+ try
+ {
+ cache1.put(new MyKey("a"), "b");
+ assertEquals(1, cache1.getCacheSize());
+ assertEquals("b", cache2.get(new MyKey("a")));
+ assertEquals(1, cache2.getCacheSize());
+// assertEquals(0, cache3.getCacheSize());
+ assertEquals(1, listener1.put);
+ assertEquals(1, listener2.put);
+// assertEquals(0, listener3.put);
+ assertEquals(0, listener1.get);
+ assertEquals(1, listener2.get);
+// assertEquals(0, listener3.get);
+ cache2.put(new MyKey("b"), "c");
+ assertEquals(2, cache1.getCacheSize());
+ assertEquals(2, cache2.getCacheSize());
+ assertEquals("c", cache1.get(new MyKey("b")));
+// assertEquals(0, cache3.getCacheSize());
+ assertEquals(2, listener1.put);
+ assertEquals(2, listener2.put);
+// assertEquals(0, listener3.put);
+ assertEquals(1, listener1.get);
+ assertEquals(1, listener2.get);
+// assertEquals(0, listener3.get);
+// cache3.put(new MyKey("c"), "d");
+ assertEquals(2, cache1.getCacheSize());
+ assertEquals(2, cache2.getCacheSize());
+// assertEquals(1, cache3.getCacheSize());
+// assertEquals("d", cache3.get(new MyKey("c")));
+ assertEquals(2, listener1.put);
+ assertEquals(2, listener2.put);
+// assertEquals(1, listener3.put);
+ assertEquals(1, listener1.get);
+ assertEquals(1, listener2.get);
+// assertEquals(1, listener3.get);
+ cache2.put(new MyKey("a"), "a");
+ assertEquals(2, cache1.getCacheSize());
+ assertEquals(2, cache2.getCacheSize());
+ assertEquals("a", cache1.get(new MyKey("a")));
+ assertEquals(3, listener1.put);
+ assertEquals(3, listener2.put);
+// assertEquals(1, listener3.put);
+ assertEquals(2, listener1.get);
+ assertEquals(1, listener2.get);
+// assertEquals(1, listener3.get);
+ cache2.remove(new MyKey("a"));
+ assertEquals(1, cache1.getCacheSize());
+ assertEquals(1, cache2.getCacheSize());
+ assertEquals(3, listener1.put);
+ assertEquals(3, listener2.put);
+// assertEquals(1, listener3.put);
+ assertEquals(2, listener1.get);
+ assertEquals(1, listener2.get);
+// assertEquals(1, listener3.get);
+ assertEquals(1, listener1.remove);
+ assertEquals(1, listener2.remove);
+// assertEquals(0, listener3.remove);
+ cache1.put(new MyKey("c"), "c");
+ cache1.clearCache();
+ assertEquals(0, cache1.getCacheSize());
+ assertEquals(null, cache1.get(new MyKey("b")));
+ assertEquals("c", cache2.get(new MyKey("b")));
+ assertEquals("c", cache2.get(new MyKey("c")));
+ assertEquals(2, cache2.getCacheSize());
+ assertEquals(4, listener1.put);
+ assertEquals(4, listener2.put);
+// assertEquals(1, listener3.put);
+ assertEquals(3, listener1.get);
+ assertEquals(3, listener2.get);
+// assertEquals(1, listener3.get);
+ assertEquals(1, listener1.remove);
+ assertEquals(1, listener2.remove);
+// assertEquals(0, listener3.remove);
+ assertEquals(1, listener1.clearCache);
+ assertEquals(0, listener2.clearCache);
+// assertEquals(0, listener3.clearCache);
+ Map<Serializable, Object> values = new HashMap<Serializable, Object>();
+ values.put(new MyKey("a"), "a");
+ values.put(new MyKey("b"), "b");
+ cache1.putMap(values);
+ assertEquals(2, cache1.getCacheSize());
+ Thread.sleep(40);
+ assertEquals("a", cache2.get(new MyKey("a")));
+ assertEquals("b", cache2.get(new MyKey("b")));
+ assertEquals(3, cache2.getCacheSize());
+ assertEquals(6, listener1.put);
+ assertEquals(6, listener2.put);
+// assertEquals(1, listener3.put);
+ assertEquals(3, listener1.get);
+ assertEquals(5, listener2.get);
+// assertEquals(1, listener3.get);
+ assertEquals(1, listener1.remove);
+ assertEquals(1, listener2.remove);
+// assertEquals(0, listener3.remove);
+ assertEquals(1, listener1.clearCache);
+ assertEquals(0, listener2.clearCache);
+// assertEquals(0, listener3.clearCache);
+ values = new HashMap<Serializable, Object>()
+ {
+ private static final long serialVersionUID = 1L;
+
+ public Set<Entry<Serializable, Object>> entrySet()
+ {
+ Set<Entry<Serializable, Object>> set = new LinkedHashSet<Entry<Serializable, Object>>(super.entrySet());
+ set.add(new Entry<Serializable, Object>()
+ {
+
+ public Object setValue(Object paramV)
+ {
+ return null;
+ }
+
+ public Object getValue()
+ {
+ throw new RuntimeException("An exception");
+ }
+
+ public Serializable getKey()
+ {
+ return "c";
+ }
+ });
+ return set;
+ }
+ };
+ values.put(new MyKey("e"), "e");
+ values.put(new MyKey("d"), "d");
+ cache1.putMap(values);
+ assertEquals(2, cache1.getCacheSize());
+ assertEquals(3, cache2.getCacheSize());
+// assertEquals(1, cache3.getCacheSize());
+ assertEquals(6, listener1.put);
+ assertEquals(6, listener2.put);
+// assertEquals(1, listener3.put);
+ assertEquals(3, listener1.get);
+ assertEquals(5, listener2.get);
+// assertEquals(1, listener3.get);
+ assertEquals(1, listener1.remove);
+ assertEquals(1, listener2.remove);
+// assertEquals(0, listener3.remove);
+ assertEquals(1, listener1.clearCache);
+ assertEquals(0, listener2.clearCache);
+// assertEquals(0, listener3.clearCache);
+ assertEquals(0, listener1.expire);
+ assertEquals(0, listener2.expire);
+// assertEquals(0, listener3.expire);
+ Thread.sleep(5600);
+ // The values are evicted lazily when we call it
+ cache1.get(new MyKey("a"));
+ cache1.get(new MyKey("b"));
+ cache2.get(new MyKey("a"));
+ cache2.get(new MyKey("b"));
+ cache2.get(new MyKey("c"));
+ assertEquals(0, cache1.getCacheSize());
+ assertEquals(0, cache2.getCacheSize());
+// assertEquals(0, cache3.getCacheSize());
+ assertEquals(6, listener1.put);
+ assertEquals(6, listener2.put);
+// assertEquals(1, listener3.put);
+ assertEquals(5, listener1.get);
+ assertEquals(8, listener2.get);
+// assertEquals(1, listener3.get);
+ assertEquals(1, listener1.remove);
+ assertEquals(1, listener2.remove);
+// assertEquals(0, listener3.remove);
+ assertEquals(1, listener1.clearCache);
+ assertEquals(0, listener2.clearCache);
+// assertEquals(0, listener3.clearCache);
+// Expiration events are not triggered in infinispan
+// assertEquals(2, listener1.expire);
+// assertEquals(3, listener2.expire);
+// assertEquals(1, listener3.expire);
+ }
+ finally
+ {
+ cache1.cache.getCacheManager().stop();
+ cache2.cache.getCacheManager().stop();
+// cache3.cache.getCacheManager().stop();
+ }
+ }
+}
Added: kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/java/org/exoplatform/services/cache/impl/infinispan/TestExoCacheConfig.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/java/org/exoplatform/services/cache/impl/infinispan/TestExoCacheConfig.java (rev 0)
+++ kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/java/org/exoplatform/services/cache/impl/infinispan/TestExoCacheConfig.java 2011-08-09 14:05:16 UTC (rev 4720)
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.cache.impl.infinispan;
+
+import org.exoplatform.services.cache.ExoCacheConfig;
+
+/**
+ * @author <a href="mailto:nicolas.filotto@exoplatform.com">Nicolas Filotto</a>
+ * @version $Id$
+ *
+ */
+public class TestExoCacheConfig extends ExoCacheConfig
+{
+
+}
Added: kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/java/org/exoplatform/services/cache/impl/infinispan/TestExoCacheCreator.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/java/org/exoplatform/services/cache/impl/infinispan/TestExoCacheCreator.java (rev 0)
+++ kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/java/org/exoplatform/services/cache/impl/infinispan/TestExoCacheCreator.java 2011-08-09 14:05:16 UTC (rev 4720)
@@ -0,0 +1,225 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.cache.impl.infinispan;
+
+import org.exoplatform.services.cache.CacheListener;
+import org.exoplatform.services.cache.CachedObjectSelector;
+import org.exoplatform.services.cache.ExoCache;
+import org.exoplatform.services.cache.ExoCacheConfig;
+import org.exoplatform.services.cache.ExoCacheInitException;
+import org.infinispan.Cache;
+import org.infinispan.config.Configuration;
+
+import java.io.Serializable;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.Callable;
+
+/**
+ * @author <a href="mailto:nicolas.filotto@exoplatform.com">Nicolas Filotto</a>
+ * @version $Id$
+ *
+ */
+public class TestExoCacheCreator implements ExoCacheCreator
+{
+
+ /**
+ * @see org.exoplatform.services.cache.impl.infinispan.ExoCacheCreator#create(org.exoplatform.services.cache.ExoCacheConfig, org.infinispan.config.Configuration, java.util.concurrent.Callable)
+ */
+ @Override
+ public ExoCache<Serializable, Object> create(ExoCacheConfig config, Configuration cacheConfig,
+ Callable<Cache<Serializable, Object>> cacheGetter) throws ExoCacheInitException
+ {
+ return new TestExoCache();
+ }
+
+ public Class<? extends ExoCacheConfig> getExpectedConfigType()
+ {
+ return TestExoCacheConfig.class;
+ }
+
+ public Set<String> getExpectedImplementations()
+ {
+ return Collections.singleton("TEST");
+ }
+
+ public static class TestExoCache implements ExoCache<Serializable, Object>
+ {
+
+ public void addCacheListener(CacheListener listener)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+
+ public int getCacheHit()
+ {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public int getCacheMiss()
+ {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public int getCacheSize()
+ {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public List getCachedObjects()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getLabel()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public long getLiveTime()
+ {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public int getMaxSize()
+ {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public String getName()
+ {
+ return "name";
+ }
+
+ public boolean isDistributed()
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean isLogEnabled()
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean isReplicated()
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+
+ public void select(CachedObjectSelector selector) throws Exception
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setDistributed(boolean b)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setLabel(String s)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setLiveTime(long period)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setLogEnabled(boolean b)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setMaxSize(int max)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setName(String name)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setReplicated(boolean b)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void clearCache()
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public Object get(Serializable key)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void put(Serializable key, Object value) throws NullPointerException
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void putMap(Map objs) throws NullPointerException, IllegalArgumentException
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public Object remove(Serializable key) throws NullPointerException
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public List removeCachedObjects()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ }
+}
Added: kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/java/org/exoplatform/services/cache/impl/infinispan/TestExoCacheFactoryImpl.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/java/org/exoplatform/services/cache/impl/infinispan/TestExoCacheFactoryImpl.java (rev 0)
+++ kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/java/org/exoplatform/services/cache/impl/infinispan/TestExoCacheFactoryImpl.java 2011-08-09 14:05:16 UTC (rev 4720)
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.cache.impl.infinispan;
+
+import org.exoplatform.container.PortalContainer;
+import org.exoplatform.services.cache.CacheService;
+import org.exoplatform.services.cache.ExoCache;
+import org.exoplatform.services.cache.impl.infinispan.TestExoCacheCreator.TestExoCache;
+import org.exoplatform.test.BasicTestCase;
+import org.infinispan.config.Configuration.CacheMode;
+import org.infinispan.manager.CacheContainer;
+
+/**
+ * @author <a href="mailto:nicolas.filotto@exoplatform.com">Nicolas Filotto</a>
+ * @version $Id$
+ *
+ */
+public class TestExoCacheFactoryImpl extends BasicTestCase
+{
+
+ CacheService service_;
+
+ public TestExoCacheFactoryImpl(String name)
+ {
+ super(name);
+ }
+
+ public void setUp() throws Exception
+ {
+ service_ = (CacheService)PortalContainer.getInstance().getComponentInstanceOfType(CacheService.class);
+ }
+
+ public void testCacheFactory()
+ {
+ ExoCache cache = service_.getCacheInstance("myCache");
+ assertTrue("expect an instance of AbstractExoCache", cache instanceof AbstractExoCache);
+ AbstractExoCache aCache = (AbstractExoCache)cache;
+ assertTrue("expect a local cache", aCache.cache.getConfiguration().getCacheMode() == CacheMode.LOCAL);
+ aCache.cache.stop();
+ cache = service_.getCacheInstance("cacheDistributed");
+ assertTrue("expect an instance of AbstractExoCache", cache instanceof AbstractExoCache);
+ aCache = (AbstractExoCache)cache;
+ assertTrue("expect a distributed cache", aCache.cache.getConfiguration().getCacheMode() == CacheMode.REPL_SYNC);
+ aCache.cache.stop();
+ cache = service_.getCacheInstance("myCustomCache");
+ assertTrue("expect an instance of AbstractExoCache", cache instanceof AbstractExoCache);
+ aCache = (AbstractExoCache)cache;
+ assertTrue("expect a distributed cache", aCache.cache.getConfiguration().getCacheMode() == CacheMode.REPL_SYNC);
+ aCache.cache.stop();
+ }
+
+ public void testExoCacheCreator()
+ {
+ ExoCache cache = service_.getCacheInstance("test-default-impl");
+ assertTrue("expect an instance of AbstractExoCache", cache instanceof AbstractExoCache);
+ AbstractExoCache aCache = (AbstractExoCache)cache;
+ aCache.cache.stop();
+ cache = service_.getCacheInstance("test-custom-impl-with-old-config");
+ assertTrue("expect an instance of TestExoCache", cache instanceof TestExoCache);
+ cache = service_.getCacheInstance("test-custom-impl-with-new-config");
+ assertTrue("expect an instance of TestExoCache", cache instanceof TestExoCache);
+ }
+
+ public void testSameCacheManager()
+ {
+ ExoCache cache1 = service_.getCacheInstance("myCustomCache");
+ assertTrue("expect an instance of AbstractExoCache", cache1 instanceof AbstractExoCache);
+ AbstractExoCache aCache1 = (AbstractExoCache)cache1;
+ CacheContainer cacheContainer1 = aCache1.cache.getCacheManager();
+
+ ExoCache cache2 = service_.getCacheInstance("myCustomCache-Bis");
+ assertTrue("expect an instance of AbstractExoCache", cache2 instanceof AbstractExoCache);
+ AbstractExoCache aCache2 = (AbstractExoCache)cache2;
+ CacheContainer cacheContainer2 = aCache2.cache.getCacheManager();
+ assertTrue("The CacheContainer should be the same", cacheContainer1 == cacheContainer2);
+
+ ExoCache cache3 = service_.getCacheInstance("myCustomCache-Bis2");
+ assertTrue("expect an instance of AbstractExoCache", cache3 instanceof AbstractExoCache);
+ AbstractExoCache aCache3 = (AbstractExoCache)cache3;
+ CacheContainer cacheContainer3 = aCache3.cache.getCacheManager();
+ assertTrue("The CacheContainer should be the same", cacheContainer1 == cacheContainer3);
+
+ aCache1.cache.stop();
+ aCache2.cache.stop();
+ }
+}
Added: kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/resources/conf/portal/cache-configuration-template.xml
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/resources/conf/portal/cache-configuration-template.xml (rev 0)
+++ kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/resources/conf/portal/cache-configuration-template.xml 2011-08-09 14:05:16 UTC (rev 4720)
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Copyright (C) 2010 eXo Platform SAS.
+
+ This is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+
+-->
+<infinispan xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:infinispan:config:5.0 http://www.infinispan.org/schemas/infinispan-config-5.0.xsd"
+ xmlns="urn:infinispan:config:5.0">
+ <global>
+ <asyncListenerExecutor factory="org.infinispan.executors.DefaultExecutorFactory">
+ <properties>
+ <property name="maxThreads" value="1"/>
+ <property name="queueSize" value="100000"/>
+ <property name="threadNamePrefix" value="AsyncListenerThread"/>
+ </properties>
+ </asyncListenerExecutor>
+ <asyncTransportExecutor factory="org.infinispan.executors.DefaultExecutorFactory">
+ <properties>
+ <property name="threadNamePrefix" value="AsyncSerializationThread"/>
+ </properties>
+ </asyncTransportExecutor>
+ <evictionScheduledExecutor factory="org.infinispan.executors.DefaultScheduledExecutorFactory">
+ <properties>
+ <property name="threadNamePrefix" value="EvictionThread"/>
+ </properties>
+ </evictionScheduledExecutor>
+ <replicationQueueScheduledExecutor factory="org.infinispan.executors.DefaultScheduledExecutorFactory">
+ <properties>
+ <property name="threadNamePrefix" value="ReplicationQueueThread"/>
+ </properties>
+ </replicationQueueScheduledExecutor>
+ <globalJmxStatistics jmxDomain="exo" enabled="true" allowDuplicateDomains="true" />
+ <transport transportClass="org.infinispan.remoting.transport.jgroups.JGroupsTransport" clusterName="Infinispan-cluster" distributedSyncTimeout="20000">
+ <properties>
+ <property name="configurationFile" value="flush-udp.xml"/>
+ </properties>
+ </transport>
+ <shutdown hookBehavior="DEFAULT"/>
+ </global>
+ <default>
+ <locking isolationLevel="READ_COMMITTED" lockAcquisitionTimeout="10000" writeSkewCheck="false" concurrencyLevel="500"/>
+ <transaction transactionManagerLookupClass="org.infinispan.transaction.lookup.GenericTransactionManagerLookup" syncRollbackPhase="false" syncCommitPhase="false"/>
+ <jmxStatistics enabled="true"/>
+ <clustering mode="replication">
+ <stateRetrieval timeout="20000" fetchInMemoryState="false"/>
+ <sync replTimeout="20000"/>
+ </clustering>
+ </default>
+</infinispan>
\ No newline at end of file
Added: kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/resources/conf/portal/distributed-cache-configuration-template.xml
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/resources/conf/portal/distributed-cache-configuration-template.xml (rev 0)
+++ kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/resources/conf/portal/distributed-cache-configuration-template.xml 2011-08-09 14:05:16 UTC (rev 4720)
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Copyright (C) 2010 eXo Platform SAS.
+
+ This is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+
+-->
+<infinispan xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:infinispan:config:5.0 http://www.infinispan.org/schemas/infinispan-config-5.0.xsd"
+ xmlns="urn:infinispan:config:5.0">
+ <global>
+ <asyncListenerExecutor factory="org.infinispan.executors.DefaultExecutorFactory">
+ <properties>
+ <property name="maxThreads" value="1"/>
+ <property name="queueSize" value="100000"/>
+ <property name="threadNamePrefix" value="AsyncListenerThread"/>
+ </properties>
+ </asyncListenerExecutor>
+ <asyncTransportExecutor factory="org.infinispan.executors.DefaultExecutorFactory">
+ <properties>
+ <property name="threadNamePrefix" value="AsyncSerializationThread"/>
+ </properties>
+ </asyncTransportExecutor>
+ <evictionScheduledExecutor factory="org.infinispan.executors.DefaultScheduledExecutorFactory">
+ <properties>
+ <property name="threadNamePrefix" value="EvictionThread"/>
+ </properties>
+ </evictionScheduledExecutor>
+ <replicationQueueScheduledExecutor factory="org.infinispan.executors.DefaultScheduledExecutorFactory">
+ <properties>
+ <property name="threadNamePrefix" value="ReplicationQueueThread"/>
+ </properties>
+ </replicationQueueScheduledExecutor>
+ <globalJmxStatistics jmxDomain="exo" enabled="true" allowDuplicateDomains="true"/>
+ <transport transportClass="org.infinispan.remoting.transport.jgroups.JGroupsTransport" clusterName="Infinispan-cluster" distributedSyncTimeout="20000">
+ <properties>
+ <property name="configurationFile" value="flush-udp.xml"/>
+ </properties>
+ </transport>
+ <shutdown hookBehavior="DEFAULT"/>
+ </global>
+ <default>
+ <locking isolationLevel="READ_COMMITTED" lockAcquisitionTimeout="20000" writeSkewCheck="false" concurrencyLevel="500"/>
+ <transaction transactionManagerLookupClass="org.infinispan.transaction.lookup.GenericTransactionManagerLookup" syncRollbackPhase="false" syncCommitPhase="false"/>
+ <jmxStatistics enabled="true"/>
+ <clustering mode="replication">
+ <stateRetrieval timeout="20000" fetchInMemoryState="false"/>
+ <sync replTimeout="20000"/>
+ </clustering>
+ </default>
+</infinispan>
\ No newline at end of file
Added: kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/resources/conf/portal/test-configuration.xml
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/resources/conf/portal/test-configuration.xml (rev 0)
+++ kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/resources/conf/portal/test-configuration.xml 2011-08-09 14:05:16 UTC (rev 4720)
@@ -0,0 +1,223 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+ Copyright (C) 2009 eXo Platform SAS.
+
+ This is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+
+-->
+<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd http://www.exoplaform.org/xml/ns/kernel_1_0.xsd"
+ xmlns="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd">
+
+ <component>
+ <key>org.exoplatform.services.cache.CacheService</key>
+ <type>org.exoplatform.services.cache.impl.CacheServiceImpl</type>
+
+ <init-params>
+ <object-param>
+ <name>cache.config.default</name>
+ <description>The default cache configuration</description>
+ <object type="org.exoplatform.services.cache.ExoCacheConfig">
+ <field name="name"><string>default</string></field>
+ <field name="maxSize"><int>5</int></field>
+ <field name="liveTime"><long>2</long></field>
+ </object>
+ </object-param>
+ <object-param>
+ <name>test-multi-threading</name>
+ <description>The default cache configuration</description>
+ <object type="org.exoplatform.services.cache.impl.infinispan.generic.GenericExoCacheConfig">
+ <field name="name"><string>test-multi-threading</string></field>
+ <field name="strategy"><string>NONE</string></field>
+ <field name="maxEntries"><int>-1</int></field>
+ <field name="lifespan"><long>-1</long></field>
+ </object>
+ </object-param>
+ <object-param>
+ <name>cacheDistributed</name>
+ <description>The default cache configuration</description>
+ <object type="org.exoplatform.services.cache.ExoCacheConfig">
+ <field name="name"><string>cacheDistributed</string></field>
+ <field name="maxSize"><int>5</int></field>
+ <field name="liveTime"><long>2</long></field>
+ <field name="distributed"><boolean>true</boolean></field>
+ </object>
+ </object-param>
+ <object-param>
+ <name>test-default-impl</name>
+ <description>The default cache configuration</description>
+ <object type="org.exoplatform.services.cache.ExoCacheConfig">
+ <field name="name"><string>test-default-impl</string></field>
+ <field name="maxSize"><int>5</int></field>
+ <field name="liveTime"><long>2</long></field>
+ </object>
+ </object-param>
+ <object-param>
+ <name>test-custom-impl-with-old-config</name>
+ <description>The default cache configuration</description>
+ <object type="org.exoplatform.services.cache.ExoCacheConfig">
+ <field name="name"><string>test-custom-impl-with-old-config</string></field>
+ <field name="maxSize"><int>5</int></field>
+ <field name="liveTime"><long>2</long></field>
+ <field name="implementation"><string>TEST</string></field>
+ </object>
+ </object-param>
+ <object-param>
+ <name>test-custom-impl-with-new-config</name>
+ <description>The default cache configuration</description>
+ <object type="org.exoplatform.services.cache.impl.infinispan.TestExoCacheConfig">
+ <field name="name"><string>test-custom-impl-with-new-config</string></field>
+ <field name="maxSize"><int>5</int></field>
+ <field name="liveTime"><long>2</long></field>
+ </object>
+ </object-param>
+<!-- <object-param>-->
+<!-- <name>test-fifo-with-old-config</name>-->
+<!-- <description>The default cache configuration</description>-->
+<!-- <object type="org.exoplatform.services.cache.ExoCacheConfig">-->
+<!-- <field name="name"><string>test-fifo-with-old-config</string></field>-->
+<!-- <field name="maxSize"><int>5</int></field>-->
+<!-- <field name="liveTime"><long>1</long></field>-->
+<!-- <field name="implementation"><string>FIFO</string></field>-->
+<!-- </object>-->
+<!-- </object-param> -->
+<!-- <object-param>-->
+<!-- <name>test-fifo</name>-->
+<!-- <description>The default cache configuration</description>-->
+<!-- <object type="org.exoplatform.services.cache.impl.infinispan.generic.GenericExoCacheConfig">-->
+<!-- <field name="name"><string>test-fifo</string></field>-->
+<!-- <field name="strategy"><string>FIFO</string></field>-->
+<!-- <field name="maxEntries"><int>5</int></field>-->
+<!-- <field name="lifespan"><long>1000</long></field>-->
+<!-- </object>-->
+<!-- </object-param> -->
+<!-- <object-param>-->
+<!-- <name>test-lru-with-old-config</name>-->
+<!-- <description>The default cache configuration</description>-->
+<!-- <object type="org.exoplatform.services.cache.ExoCacheConfig">-->
+<!-- <field name="name"><string>test-lru-with-old-config</string></field>-->
+<!-- <field name="maxSize"><int>4</int></field>-->
+<!-- <field name="liveTime"><long>1</long></field>-->
+<!-- <field name="implementation"><string>LRU</string></field>-->
+<!-- </object>-->
+<!-- </object-param> -->
+<!-- <object-param>-->
+<!-- <name>test-lru</name>-->
+<!-- <description>The default cache configuration</description>-->
+<!-- <object type="org.exoplatform.services.cache.impl.infinispan.generic.GenericExoCacheConfig">-->
+<!-- <field name="name"><string>test-lru</string></field>-->
+<!-- <field name="strategy"><string>LRU</string></field>-->
+<!-- <field name="maxEntries"><int>4</int></field>-->
+<!-- <field name="lifespan"><long>1000</long></field>-->
+<!-- <field name="maxIdle"><long>-1</long></field>-->
+<!-- </object>-->
+<!-- </object-param> -->
+<!-- <object-param>-->
+<!-- <name>test-ea-with-old-config</name>-->
+<!-- <description>The default cache configuration</description>-->
+<!-- <object type="org.exoplatform.services.cache.ExoCacheConfig">-->
+<!-- <field name="name"><string>test-ea-with-old-config</string></field>-->
+<!-- <field name="maxSize"><int>5</int></field>-->
+<!-- <field name="liveTime"><long>1</long></field>-->
+<!-- <field name="implementation"><string>NONE</string></field>-->
+<!-- </object>-->
+<!-- </object-param> -->
+<!-- <object-param>-->
+<!-- <name>test-ea</name>-->
+<!-- <description>The default cache configuration</description>-->
+<!-- <object type="org.exoplatform.services.cache.impl.infinispan.generic.GenericExoCacheConfig">-->
+<!-- <field name="name"><string>test-ea</string></field>-->
+<!-- <field name="strategy"><string>NONE</string></field>-->
+<!-- <field name="maxEntries"><int>5</int></field>-->
+<!-- <field name="maxIdle"><long>1000</long></field>-->
+<!-- <field name="lifespan"><long>2000</long></field>-->
+<!-- </object>-->
+<!-- </object-param> -->
+ </init-params>
+ </component>
+
+ <component>
+ <key>org.exoplatform.services.cache.ExoCacheFactory</key>
+ <type>org.exoplatform.services.cache.impl.infinispan.ExoCacheFactoryImpl</type>
+ <init-params>
+ <value-param>
+ <name>cache.config.template</name>
+ <value>jar:/conf/portal/cache-configuration-template.xml</value>
+ </value-param>
+ </init-params>
+ </component>
+
+ <external-component-plugins>
+ <target-component>org.exoplatform.services.cache.ExoCacheFactory</target-component>
+ <component-plugin>
+ <name>addConfig</name>
+ <set-method>addConfig</set-method>
+ <type>org.exoplatform.services.cache.impl.infinispan.ExoCacheFactoryConfigPlugin</type>
+ <description>add Custom Configurations</description>
+ <init-params>
+ <value-param>
+ <name>myCustomCache</name>
+ <value>jar:/conf/portal/distributed-cache-configuration-template.xml</value>
+ </value-param>
+ <value-param>
+ <name>myCustomCache-Bis</name>
+ <value>classpath:/conf/portal/distributed-cache-configuration-template.xml</value>
+ </value-param>
+ </init-params>
+ </component-plugin>
+ <component-plugin>
+ <name>addCreator</name>
+ <set-method>addCreator</set-method>
+ <type>org.exoplatform.services.cache.impl.infinispan.ExoCacheCreatorPlugin</type>
+ <description>add Exo Cache Creator</description>
+ <init-params>
+ <object-param>
+ <name>Test</name>
+ <description>The cache creator for testing purpose</description>
+ <object type="org.exoplatform.services.cache.impl.infinispan.TestExoCacheCreator"></object>
+ </object-param>
+ <object-param>
+ <name>GENERIC</name>
+ <description>The generic cache creator</description>
+ <object type="org.exoplatform.services.cache.impl.infinispan.generic.GenericExoCacheCreator">
+ <field name="implementations">
+ <collection type="java.util.HashSet">
+ <value>
+ <string>NONE</string>
+ </value>
+ <value>
+ <string>FIFO</string>
+ </value>
+ <value>
+ <string>LRU</string>
+ </value>
+ <value>
+ <string>UNORDERED</string>
+ </value>
+ <value>
+ <string>LIRS</string>
+ </value>
+ </collection>
+ </field>
+ <field name="defaultStrategy"><string>LRU</string></field>
+ <field name="defaultMaxIdle"><long>-1</long></field>
+ <field name="defaultWakeUpInterval"><long>500</long></field>
+ </object>
+ </object-param>
+ </init-params>
+ </component-plugin>
+ </external-component-plugins>
+</configuration>
Modified: kernel/trunk/pom.xml
===================================================================
--- kernel/trunk/pom.xml 2011-08-09 12:59:58 UTC (rev 4719)
+++ kernel/trunk/pom.xml 2011-08-09 14:05:16 UTC (rev 4720)
@@ -55,7 +55,7 @@
<module>exo.kernel.component.common</module>
<module>exo.kernel.component.cache</module>
<module>exo.kernel.component.ext.cache.impl.jboss.v3</module>
- <module>exo.kernel.component.ext.cache.impl.infinispan.v4</module>
+ <module>exo.kernel.component.ext.cache.impl.infinispan.v5</module>
<module>exo.kernel.component.command</module>
<module>exo.kernel.mc-integration</module>
<module>packaging/module</module>
@@ -212,7 +212,7 @@
<dependency>
<groupId>org.infinispan</groupId>
<artifactId>infinispan-core</artifactId>
- <version>4.2.1.FINAL</version>
+ <version>5.0.0.FINAL</version>
</dependency>
<dependency>
<groupId>org.jibx</groupId>
12 years, 9 months
exo-jcr SVN: r4719 - jcr/branches/1.12.x/patch/1.12.10-GA/JCR-1652.
by do-not-reply@jboss.org
Author: dkuleshov
Date: 2011-08-09 08:59:58 -0400 (Tue, 09 Aug 2011)
New Revision: 4719
Modified:
jcr/branches/1.12.x/patch/1.12.10-GA/JCR-1652/JCR-1652.patch
Log:
JCR-1652: applied remarks for patch
Modified: jcr/branches/1.12.x/patch/1.12.10-GA/JCR-1652/JCR-1652.patch
===================================================================
--- jcr/branches/1.12.x/patch/1.12.10-GA/JCR-1652/JCR-1652.patch 2011-08-09 12:00:30 UTC (rev 4718)
+++ jcr/branches/1.12.x/patch/1.12.10-GA/JCR-1652/JCR-1652.patch 2011-08-09 12:59:58 UTC (rev 4719)
@@ -254,7 +254,7 @@
+ // this is a property whose semantics and syntax are not enforced by the server
+ // the server only records the value of a dead property;
+ // the client is responsible for maintaining the consistency of the syntax and semantics of a dead property.
-+ propertyValue = new String();
++ propertyValue = "";
+ }
}
else
12 years, 9 months
exo-jcr SVN: r4718 - in jcr/branches/1.12.x/patch/1.12.10-GA: JCR-1633 and 1 other directory.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2011-08-09 08:00:30 -0400 (Tue, 09 Aug 2011)
New Revision: 4718
Added:
jcr/branches/1.12.x/patch/1.12.10-GA/JCR-1633/
jcr/branches/1.12.x/patch/1.12.10-GA/JCR-1633/JCR-1633.patch
Log:
JCR-1633 : Patch for allow to keep missing values into the JCR Cache was commited
Added: jcr/branches/1.12.x/patch/1.12.10-GA/JCR-1633/JCR-1633.patch
===================================================================
--- jcr/branches/1.12.x/patch/1.12.10-GA/JCR-1633/JCR-1633.patch (rev 0)
+++ jcr/branches/1.12.x/patch/1.12.10-GA/JCR-1633/JCR-1633.patch 2011-08-09 12:00:30 UTC (rev 4718)
@@ -0,0 +1,655 @@
+Index: exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/VersionableWorkspaceDataManager.java
+===================================================================
+--- exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/VersionableWorkspaceDataManager.java (revision 4692)
++++ exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/VersionableWorkspaceDataManager.java (working copy)
+@@ -28,6 +28,7 @@
+ import org.exoplatform.services.jcr.datamodel.ItemData;
+ import org.exoplatform.services.jcr.datamodel.ItemType;
+ import org.exoplatform.services.jcr.datamodel.NodeData;
++import org.exoplatform.services.jcr.datamodel.NullItemData;
+ import org.exoplatform.services.jcr.datamodel.PropertyData;
+ import org.exoplatform.services.jcr.datamodel.QPath;
+ import org.exoplatform.services.jcr.datamodel.QPathEntry;
+@@ -157,14 +158,14 @@
+ {
+ // from cache at first
+ ItemData cdata = persistentManager.getCachedItemData(identifier);
+- if (cdata != null)
++ if (cdata != null && !(cdata instanceof NullItemData))
+ return super.getItemData(identifier);
+
+ if (!this.equals(versionDataManager) && !identifier.equals(Constants.ROOT_UUID))
+ {
+ // search in System cache for /jcr:system nodes only
+ cdata = versionDataManager.persistentManager.getCachedItemData(identifier);
+- if (cdata != null)
++ if (cdata != null && !(cdata instanceof NullItemData))
+ if (isSystemDescendant(cdata.getQPath()))
+ return versionDataManager.getItemData(identifier);
+ else
+Index: exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java
+===================================================================
+--- exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java (revision 4692)
++++ exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java (working copy)
+@@ -30,6 +30,9 @@
+ import org.exoplatform.services.jcr.datamodel.ItemData;
+ import org.exoplatform.services.jcr.datamodel.ItemType;
+ import org.exoplatform.services.jcr.datamodel.NodeData;
++import org.exoplatform.services.jcr.datamodel.NullItemData;
++import org.exoplatform.services.jcr.datamodel.NullNodeData;
++import org.exoplatform.services.jcr.datamodel.NullPropertyData;
+ import org.exoplatform.services.jcr.datamodel.PropertyData;
+ import org.exoplatform.services.jcr.datamodel.QPath;
+ import org.exoplatform.services.jcr.datamodel.QPathEntry;
+@@ -396,6 +399,13 @@
+ */
+ public void put(ItemData item)
+ {
++ // There is different commit processing for NullNodeData and ordinary ItemData
++ if (item instanceof NullItemData)
++ {
++ putNullItem((NullItemData)item);
++ return;
++ }
++
+ boolean inTransaction = cache.isTransactionActive();
+ try
+ {
+@@ -507,7 +517,7 @@
+ for (String propId : set)
+ {
+ PropertyData prop = (PropertyData)cache.get(makeItemFqn(propId), ITEM_DATA);
+- if (prop == null)
++ if (prop == null || prop instanceof NullItemData)
+ {
+ return null;
+ }
+@@ -680,23 +690,48 @@
+ public ItemData get(String parentId, QPathEntry name, ItemType itemType)
+ {
+ String itemId = null;
+- if (itemType == ItemType.NODE || itemType == ItemType.UNKNOWN)
++ if (itemType == ItemType.UNKNOWN)
+ {
+- // try as node first
++ // Try as node first.
+ itemId = (String)cache.get(makeChildFqn(childNodes, parentId, name), ITEM_ID);
++
++ if (itemId == null || itemId.equals(NullItemData.NULL_ID))
++ {
++ // node with such a name is not found or marked as not-exist, so check the properties
++ String propId = (String)cache.get(makeChildFqn(childProps, parentId, name), ITEM_ID);
++ if (propId != null)
++ {
++ itemId = propId;
++ }
++ }
+ }
+-
+- if (itemType == ItemType.PROPERTY || itemType == ItemType.UNKNOWN && itemId == null)
++ else if (itemType == ItemType.NODE)
+ {
+- // try as property
++ itemId = (String)cache.get(makeChildFqn(childNodes, parentId, name), ITEM_ID);
++ }
++ else
++ {
+ itemId = (String)cache.get(makeChildFqn(childProps, parentId, name), ITEM_ID);
+ }
+
+ if (itemId != null)
+ {
+- return get(itemId);
++ if (itemId.equals(NullItemData.NULL_ID))
++ {
++ if (itemType == ItemType.UNKNOWN || itemType == ItemType.NODE)
++ {
++ return new NullNodeData();
++ }
++ else
++ {
++ return new NullPropertyData();
++ }
++ }
++ else
++ {
++ return get(itemId);
++ }
+ }
+-
+ return null;
+ }
+
+@@ -705,6 +740,7 @@
+ */
+ public ItemData get(String id)
+ {
++ // NullNodeData with id may be stored as ordinary NodeData or PropertyData
+ return (ItemData)cache.get(makeItemFqn(id), ITEM_DATA);
+ }
+
+@@ -723,7 +759,7 @@
+ for (Object child : set)
+ {
+ NodeData node = (NodeData)cache.get(makeItemFqn((String)child), ITEM_DATA);
+- if (node == null)
++ if (node == null || node instanceof NullItemData)
+ {
+ return null;
+ }
+@@ -788,7 +824,7 @@
+ for (Object child : set)
+ {
+ PropertyData prop = (PropertyData)cache.get(makeItemFqn((String)child), ITEM_DATA);
+- if (prop == null)
++ if (prop == null || prop instanceof NullItemData)
+ {
+ return null;
+ }
+@@ -944,6 +980,54 @@
+ modifyListsOfChild == ModifyChildOption.NOT_MODIFY);
+ }
+
++ /**
++ * Internal put NullNode.
++ *
++ * @param item, NullItemData, new data to put in the cache
++ */
++ protected void putNullItem(NullItemData item)
++ {
++ boolean inTransaction = cache.isTransactionActive();
++ try
++ {
++ if (!inTransaction)
++ {
++ cache.beginTransaction();
++ }
++ cache.setLocal(true);
++
++ if (!item.getIdentifier().equals(NullItemData.NULL_ID))
++ {
++ //put in $ITEMS
++ cache.putIfAbsent(makeItemFqn(item.getIdentifier()), ITEM_DATA, item);
++ }
++ else if (item.getName() != null && item.getParentIdentifier() != null)
++ {
++ if (item.isNode())
++ {
++ // put in $CHILD_NODES
++ cache.putIfAbsent(makeChildFqn(childNodes, item.getParentIdentifier(), item.getName()), ITEM_ID,
++ NullItemData.NULL_ID);
++ }
++ else
++ {
++ // put in $CHILD_PROPERTIES
++ cache.putIfAbsent(makeChildFqn(childProps, item.getParentIdentifier(), item.getName()), ITEM_ID,
++ NullItemData.NULL_ID);
++ }
++ }
++ }
++ finally
++ {
++ cache.setLocal(false);
++ if (!inTransaction)
++ {
++ dedicatedTxCommit();
++ }
++ }
++
++ }
++
+ protected ItemData putNodeInBufferedCache(NodeData node, ModifyChildOption modifyListsOfChild)
+ {
+ // if not a root node
+@@ -960,7 +1044,9 @@
+ }
+ }
+ // add in ITEMS
+- return (ItemData)cache.putInBuffer(makeItemFqn(node.getIdentifier()), ITEM_DATA, node);
++ // NullNodeData must never be returned inside internal cache operations.
++ ItemData returnedData = (ItemData)cache.putInBuffer(makeItemFqn(node.getIdentifier()), ITEM_DATA, node);
++ return (returnedData instanceof NullItemData) ? null : returnedData;
+ }
+
+ /**
+@@ -1008,8 +1094,11 @@
+ }
+
+ // add in ITEMS
+- return (PropertyData)cache.put(makeItemFqn(prop.getIdentifier()), ITEM_DATA, prop,
+- modifyListsOfChild == ModifyChildOption.NOT_MODIFY);
++ // NullItemData must never be returned inside internal cache operations.
++ ItemData returnedData =
++ (ItemData)cache.put(makeItemFqn(prop.getIdentifier()), ITEM_DATA, prop,
++ modifyListsOfChild == ModifyChildOption.NOT_MODIFY);
++ return (returnedData instanceof NullItemData) ? null : (PropertyData)returnedData;
+ }
+
+ protected void removeItem(ItemData item)
+@@ -1065,7 +1154,8 @@
+ protected void updateMixin(NodeData node)
+ {
+ NodeData prevData = (NodeData)cache.put(makeItemFqn(node.getIdentifier()), ITEM_DATA, node);
+- if (prevData != null)
++ // prevent update NullNodeData
++ if (prevData != null && !(prevData instanceof NullItemData))
+ {
+ // do update ACL if needed
+ if (prevData.getACL() == null || !prevData.getACL().equals(node.getACL()))
+@@ -1119,6 +1209,7 @@
+ */
+ protected void updateInBuffer(final NodeData node, final NodeData prevNode)
+ {
++ // I expect that NullNodeData will never update existing NodeData.
+ // get previously cached NodeData and using its name remove child on the parent
+ Fqn<String> prevFqn =
+ makeChildFqn(childNodes, node.getParentIdentifier(), prevNode.getQPath().getEntries()[prevNode.getQPath()
+@@ -1132,6 +1223,7 @@
+ }
+ }
+
++ // node and prevNode are not NullNodeDatas
+ // update childs paths if index changed
+ int nodeIndex = node.getQPath().getEntries()[node.getQPath().getEntries().length - 1].getIndex();
+ int prevNodeIndex = prevNode.getQPath().getEntries()[prevNode.getQPath().getEntries().length - 1].getIndex();
+@@ -1165,7 +1257,7 @@
+
+ // check is this descendant of prevRootPath
+ QPath nodeQPath = data.getQPath();
+- if (nodeQPath.isDescendantOf(prevRootPath))
++ if (nodeQPath != null && nodeQPath.isDescendantOf(prevRootPath))
+ {
+
+ //make relative path
+Index: exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java
+===================================================================
+--- exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java (revision 4692)
++++ exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java (working copy)
+@@ -23,6 +23,9 @@
+ import org.exoplatform.services.jcr.datamodel.ItemData;
+ import org.exoplatform.services.jcr.datamodel.ItemType;
+ import org.exoplatform.services.jcr.datamodel.NodeData;
++import org.exoplatform.services.jcr.datamodel.NullItemData;
++import org.exoplatform.services.jcr.datamodel.NullNodeData;
++import org.exoplatform.services.jcr.datamodel.NullPropertyData;
+ import org.exoplatform.services.jcr.datamodel.PropertyData;
+ import org.exoplatform.services.jcr.datamodel.QPathEntry;
+ import org.exoplatform.services.jcr.datamodel.ValueData;
+@@ -418,18 +421,20 @@
+ {
+ data = getPersistedItemData(parentData, name, itemType);
+ }
+- else if (!data.isNode())
+- {
+- fixPropertyValues((PropertyData)data);
+- }
+ }
+ finally
+ {
+ request.done();
+ }
+ }
+- else if (!data.isNode())
++
++ if (data instanceof NullItemData)
+ {
++ return null;
++ }
++
++ if (data != null && !data.isNode())
++ {
+ fixPropertyValues((PropertyData)data);
+ }
+
+@@ -460,18 +465,20 @@
+ {
+ data = getPersistedItemData(identifier);
+ }
+- else if (!data.isNode())
+- {
+- fixPropertyValues((PropertyData)data);
+- }
+ }
+ finally
+ {
+ request.done();
+ }
+ }
+- else if (!data.isNode())
++
++ if (data instanceof NullItemData)
+ {
++ return null;
++ }
++
++ if (data != null && !data.isNode())
++ {
+ fixPropertyValues((PropertyData)data);
+ }
+
+@@ -749,9 +756,23 @@
+ throws RepositoryException
+ {
+ ItemData data = super.getItemData(parentData, name, itemType);
+- if (data != null && cache.isEnabled())
++ if (cache.isEnabled())
+ {
+- cache.put(data);
++ if (data == null)
++ {
++ if (itemType == ItemType.NODE || itemType == ItemType.UNKNOWN)
++ {
++ cache.put(new NullNodeData(parentData, name));
++ }
++ else
++ {
++ cache.put(new NullPropertyData(parentData, name));
++ }
++ }
++ else
++ {
++ cache.put(data);
++ }
+ }
+ return data;
+ }
+@@ -766,9 +787,17 @@
+ protected ItemData getPersistedItemData(String identifier) throws RepositoryException
+ {
+ ItemData data = super.getItemData(identifier);
+- if (data != null && cache.isEnabled())
++ if (cache.isEnabled())
+ {
+- cache.put(data);
++ if (data != null)
++ {
++ cache.put(data);
++ }
++ else if (identifier != null)
++ {
++ // no matter does property or node expected - store NullNodeData
++ cache.put(new NullNodeData(identifier));
++ }
+ }
+ return data;
+ }
+Index: exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/NullPropertyData.java
+===================================================================
+--- exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/NullPropertyData.java (revision 0)
++++ exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/NullPropertyData.java (revision 0)
+@@ -0,0 +1,79 @@
++/*
++ * Copyright (C) 2003-2010 eXo Platform SAS.
++ *
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU Affero General Public License
++ * as published by the Free Software Foundation; either version 3
++ * of the License, or (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, see<http://www.gnu.org/licenses/>.
++ */
++package org.exoplatform.services.jcr.datamodel;
++
++import java.util.List;
++
++/**
++ * Created by The eXo Platform SAS.
++ *
++ * <br/>Date:
++ *
++ * @author <a href="karpenko.sergiy(a)gmail.com">Karpenko Sergiy</a>
++ * @version $Id: NullPropertyData.java 111 2011-05-30 11:11:11Z serg $
++ */
++public class NullPropertyData extends NullItemData implements PropertyData
++{
++
++ public NullPropertyData(NodeData parent, QPathEntry name)
++ {
++ super(parent, name);
++ }
++
++ public NullPropertyData(String id)
++ {
++ super(id);
++ }
++
++ public NullPropertyData()
++ {
++ super();
++ }
++
++ /**
++ * {@inheritDoc}
++ */
++ public int getType()
++ {
++ throw new UnsupportedOperationException("Method is not supported");
++ }
++
++ /**
++ * {@inheritDoc}
++ */
++ public List<ValueData> getValues()
++ {
++ throw new UnsupportedOperationException("Method is not supported");
++ }
++
++ /**
++ * {@inheritDoc}
++ */
++ public boolean isMultiValued()
++ {
++ throw new UnsupportedOperationException("Method is not supported");
++ }
++
++ /**
++ * {@inheritDoc}
++ */
++ public boolean isNode()
++ {
++ return false;
++ }
++
++}
+Index: exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/NullNodeData.java
+===================================================================
+--- exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/NullNodeData.java (revision 0)
++++ exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/NullNodeData.java (revision 0)
+@@ -0,0 +1,88 @@
++/*
++ * Copyright (C) 2010 eXo Platform SAS.
++ *
++ * This is free software; you can redistribute it and/or modify it
++ * under the terms of the GNU Lesser General Public License as
++ * published by the Free Software Foundation; either version 2.1 of
++ * the License, or (at your option) any later version.
++ *
++ * This software is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ * Lesser General Public License for more details.
++ *
++ * You should have received a copy of the GNU Lesser General Public
++ * License along with this software; if not, write to the Free
++ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
++ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
++ */
++package org.exoplatform.services.jcr.datamodel;
++
++import org.exoplatform.services.jcr.access.AccessControlList;
++
++/**
++ * This class is used to represent <code>null</code> value, it is designed to be used
++ * into the cache to represent missing value.
++ *
++ * @author <a href="anatoliy.bazko(a)exoplatform.org">Anatoliy Bazko</a>
++ * @version $Id: NullNodeData.java 111 2011-05-30 11:11:11Z tolusha $
++ */
++public class NullNodeData extends NullItemData implements NodeData
++{
++
++ public NullNodeData(NodeData parent, QPathEntry name)
++ {
++ super(parent, name);
++ }
++
++ public NullNodeData(String id)
++ {
++ super(id);
++ }
++
++ public NullNodeData()
++ {
++ super();
++ }
++
++ /**
++ * {@inheritDoc}
++ */
++ public boolean isNode()
++ {
++ return true;
++ }
++
++ /**
++ * {@inheritDoc}
++ */
++ public AccessControlList getACL()
++ {
++ throw new UnsupportedOperationException("Method is not supported");
++ }
++
++ /**
++ * {@inheritDoc}
++ */
++ public InternalQName[] getMixinTypeNames()
++ {
++ throw new UnsupportedOperationException("Method is not supported");
++ }
++
++ /**
++ * {@inheritDoc}
++ */
++ public int getOrderNumber()
++ {
++ throw new UnsupportedOperationException("Method is not supported");
++ }
++
++ /**
++ * {@inheritDoc}
++ */
++ public InternalQName getPrimaryTypeName()
++ {
++ throw new UnsupportedOperationException("Method is not supported");
++ }
++
++}
+Index: exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/NullItemData.java
+===================================================================
+--- exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/NullItemData.java (revision 0)
++++ exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/NullItemData.java (revision 0)
+@@ -0,0 +1,98 @@
++/*
++ * Copyright (C) 2003-2010 eXo Platform SAS.
++ *
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU Affero General Public License
++ * as published by the Free Software Foundation; either version 3
++ * of the License, or (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, see<http://www.gnu.org/licenses/>.
++ */
++package org.exoplatform.services.jcr.datamodel;
++
++import org.exoplatform.services.jcr.dataflow.ItemDataVisitor;
++
++import javax.jcr.RepositoryException;
++
++/**
++ * Created by The eXo Platform SAS.
++ *
++ * <br/>Date:
++ *
++ * @author <a href="karpenko.sergiy(a)gmail.com">Karpenko Sergiy</a>
++ * @version $Id: NullItemData.java 111 2011-05-30 11:11:11Z serg $
++ */
++public abstract class NullItemData implements ItemData
++{
++
++ public static final String NULL_ID = "_null_id";
++
++ private final String id;
++
++ private final String parentId;
++
++ private final QPathEntry name;
++
++ private final QPath path;
++
++ public NullItemData(NodeData parent, QPathEntry name)
++ {
++ this.parentId = parent.getIdentifier();
++ this.path = QPath.makeChildPath(parent.getQPath(), name);
++ this.name = name;
++ this.id = NULL_ID;
++ }
++
++ public NullItemData(String id)
++ {
++ this.parentId = null;
++ this.path = null;
++ this.name = null;
++ this.id = id;
++ }
++
++ public NullItemData()
++ {
++ this.parentId = null;
++ this.path = null;
++ this.name = null;
++ this.id = NULL_ID;
++ }
++
++ public void accept(ItemDataVisitor visitor) throws RepositoryException
++ {
++ throw new UnsupportedOperationException("Method is not supported");
++ }
++
++ public String getIdentifier()
++ {
++ return id;
++ }
++
++ public String getParentIdentifier()
++ {
++ return parentId;
++ }
++
++ public int getPersistedVersion()
++ {
++ throw new UnsupportedOperationException("Method is not supported");
++ }
++
++ public QPath getQPath()
++ {
++ return path;
++ }
++
++ public QPathEntry getName()
++ {
++ return name;
++ }
++
++}
12 years, 9 months
exo-jcr SVN: r4717 - in jcr/branches/1.12.x/patch/1.12.10-GA: JCR-1652 and 1 other directory.
by do-not-reply@jboss.org
Author: dkuleshov
Date: 2011-08-09 07:35:52 -0400 (Tue, 09 Aug 2011)
New Revision: 4717
Added:
jcr/branches/1.12.x/patch/1.12.10-GA/JCR-1652/
jcr/branches/1.12.x/patch/1.12.10-GA/JCR-1652/JCR-1652.patch
Log:
JCR-1652: patch added
Added: jcr/branches/1.12.x/patch/1.12.10-GA/JCR-1652/JCR-1652.patch
===================================================================
--- jcr/branches/1.12.x/patch/1.12.10-GA/JCR-1652/JCR-1652.patch (rev 0)
+++ jcr/branches/1.12.x/patch/1.12.10-GA/JCR-1652/JCR-1652.patch 2011-08-09 11:35:52 UTC (rev 4717)
@@ -0,0 +1,269 @@
+Index: exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/command/TestPropFind.java
+===================================================================
+--- exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/command/TestPropFind.java (revision 4699)
++++ exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/command/TestPropFind.java (working copy)
+@@ -46,17 +46,27 @@
+
+ protected Node testPropFind;
+
+- private final String author = "eXoPlatform";
++ private final static String AUTHOR = "eXoPlatform";
+
+- private final String authorProp = "webdav:Author";
++ private final static String WEBDAV_AUTHOR_PROPERTY = "webdav:Author";
+
+- private final String nt_webdave_file = "webdav:file";
++ private final static String WEBDAV_NT_FILE = "webdav:file";
+
++ private final static String WEBDAV_NT_RESOURCE = "exo:testResource";
++
++ private final static String WEBDAV_TEST_PROPERTY = "webdav:test-property";
++
++ private final static String CONTENT_TYPE = "text/xml";
++
+ private String propFindXML =
+ "<?xml version=\"1.0\" encoding=\"utf-8\" ?><D:propfind xmlns:D=\"DAV:\">"
+ + "<D:prop xmlns:webdav=\"http://www.exoplatform.org/jcr/webdav\">"
+ + "<webdav:Author/><webdav:author/><webdave:DingALing/></D:prop></D:propfind>";
+
++ private String multiPropFindXML = "<?xml version=\"1.0\" encoding=\"utf-8\" ?><D:propfind xmlns:D=\"DAV:\">"
++ + "<D:prop xmlns:webdav=\"http://www.exoplatform.org/jcr/webdav\">" + "<" + WEBDAV_TEST_PROPERTY
++ + "/></D:prop></D:propfind>";
++
+ private String propnameXML =
+ "<?xml version=\"1.0\" encoding=\"utf-8\" ?><propfind xmlns=\"DAV:\"><propname/></propfind>";
+
+@@ -97,7 +107,7 @@
+ {
+ String content = TestUtils.getFileContent();
+ String file = TestUtils.getFileName();
+- TestUtils.addContent(session, file, new ByteArrayInputStream(content.getBytes()), nt_webdave_file, "");
++ TestUtils.addContent(session, file, new ByteArrayInputStream(content.getBytes()), WEBDAV_NT_FILE, "");
+ ContainerResponse containerResponseFind = service(WebDAVMethods.PROPFIND, getPathWS() + file, "", null, null);
+ assertEquals(HTTPStatus.MULTISTATUS, containerResponseFind.getStatus());
+ }
+@@ -116,8 +126,8 @@
+ String encodedfileName = "%e3%81%82%e3%81%84%e3%81%86%e3%81%88%e3%81%8a";
+ String decodedfileName = URLDecoder.decode(encodedfileName, "UTF-8");
+ String content = TestUtils.getFileContent();
+- TestUtils.addContent(session, decodedfileName, new ByteArrayInputStream(content.getBytes()), nt_webdave_file, "");
+- TestUtils.addNodeProperty(session, decodedfileName, authorProp, author);
++ TestUtils.addContent(session, decodedfileName, new ByteArrayInputStream(content.getBytes()), WEBDAV_NT_FILE, "");
++ TestUtils.addNodeProperty(session, decodedfileName, WEBDAV_AUTHOR_PROPERTY, AUTHOR);
+
+ ContainerResponse response =
+ service(WebDAVMethods.PROPFIND, getPathWS() + "/" + encodedfileName, "", null, allPropsXML.getBytes());
+@@ -142,8 +152,8 @@
+ {
+ String content = TestUtils.getFileContent();
+ String file = TestUtils.getFileName();
+- TestUtils.addContent(session, file, new ByteArrayInputStream(content.getBytes()), nt_webdave_file, "");
+- TestUtils.addNodeProperty(session, file, authorProp, author);
++ TestUtils.addContent(session, file, new ByteArrayInputStream(content.getBytes()), WEBDAV_NT_FILE, "");
++ TestUtils.addNodeProperty(session, file, WEBDAV_AUTHOR_PROPERTY, AUTHOR);
+ MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
+ headers.add(HttpHeaders.CONTENT_TYPE, "text/xml");
+ ContainerResponse responseFind =
+@@ -153,16 +163,87 @@
+ PropFindResponseEntity entity = (PropFindResponseEntity)responseFind.getEntity();
+ entity.write(outputStream);
+ String find = outputStream.toString();
+- assertTrue(find.contains(authorProp));
+- assertTrue(find.contains(author));
++ assertTrue(find.contains(WEBDAV_AUTHOR_PROPERTY));
++ assertTrue(find.contains(AUTHOR));
+ }
+
++ /**
++ * Here we test WebDAV PROPFIND method implementation for correct response
++ * in case we are asking for a multi-valued property. It is expected
++ * to receive first value of a values list. That is basicly because WebDAV
++ * actually does not support multi-valued properties in the way JCR does,
++ * though it supports nested (hierarchical) properties.
++ * @throws Exception
++ */
++ public void testNonEmptyMultiPropFind() throws Exception
++ {
++ String content = TestUtils.getFileContent();
++ String file = TestUtils.getFileName();
++ String[] propValues =
++ new String[]{"No sacrifice is too great in the service of freedom.",
++ "Freedom is the right of all sentient beings."};
++
++ Node node =
++ TestUtils.addContent(session, file, new ByteArrayInputStream(content.getBytes()), WEBDAV_NT_FILE,
++ WEBDAV_NT_RESOURCE, CONTENT_TYPE);
++
++ // set multi-valued property
++ node.getNode("jcr:content").setProperty(WEBDAV_TEST_PROPERTY, propValues);
++ session.save();
++
++ MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
++ headers.add(HttpHeaders.CONTENT_TYPE, CONTENT_TYPE);
++
++ ContainerResponse responseFind =
++ service(WebDAVMethods.PROPFIND, getPathWS() + file, "", headers, multiPropFindXML.getBytes());
++ assertEquals(HTTPStatus.MULTISTATUS, responseFind.getStatus());
++ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
++ PropFindResponseEntity entity = (PropFindResponseEntity)responseFind.getEntity();
++ entity.write(outputStream);
++ String find = outputStream.toString();
++ assertTrue("Response should contain requested property element.", find.contains(WEBDAV_TEST_PROPERTY));
++ assertTrue("Property element should contain value data.",
++ find.contains("No sacrifice is too great in the service of freedom."));
++ }
++
++ /**
++ * Here we test WebDAV PROPFIND method implementation for correct response
++ * in case we are asking for an empty multi-valued property. It is expected
++ * to receive an empty value in response xml representation as it is 'dead'
++ * property and it is not a server responsibility to support its consistency.
++ * @throws Exception
++ */
++ public void testEmptyMultiPropFind() throws Exception
++ {
++ String content = TestUtils.getFileContent();
++ String file = TestUtils.getFileName();
++
++ Node node =
++ TestUtils.addContent(session, file, new ByteArrayInputStream(content.getBytes()), WEBDAV_NT_FILE,
++ WEBDAV_NT_RESOURCE, CONTENT_TYPE);
++ // set empty multi-valued property
++ node.getNode("jcr:content").setProperty(WEBDAV_TEST_PROPERTY, new String[]{});
++ session.save();
++
++ MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
++ headers.add(HttpHeaders.CONTENT_TYPE, CONTENT_TYPE);
++
++ ContainerResponse responseFind =
++ service(WebDAVMethods.PROPFIND, getPathWS() + file, "", headers, multiPropFindXML.getBytes());
++ assertEquals(HTTPStatus.MULTISTATUS, responseFind.getStatus());
++ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
++ PropFindResponseEntity entity = (PropFindResponseEntity)responseFind.getEntity();
++ entity.write(outputStream);
++ String find = outputStream.toString();
++ assertTrue("Response should contain requested property element.", find.contains(WEBDAV_TEST_PROPERTY));
++ }
++
+ public void testPropNames() throws Exception
+ {
+ String content = TestUtils.getFileContent();
+ String file = TestUtils.getFileName();
+- TestUtils.addContent(session, file, new ByteArrayInputStream(content.getBytes()), nt_webdave_file, "");
+- TestUtils.addNodeProperty(session, file, authorProp, author);
++ TestUtils.addContent(session, file, new ByteArrayInputStream(content.getBytes()), WEBDAV_NT_FILE, "");
++ TestUtils.addNodeProperty(session, file, WEBDAV_AUTHOR_PROPERTY, AUTHOR);
+ ContainerResponse responseFind =
+ service(WebDAVMethods.PROPFIND, getPathWS() + file, "", null, propnameXML.getBytes());
+ assertEquals(HTTPStatus.MULTISTATUS, responseFind.getStatus());
+@@ -170,7 +251,7 @@
+ PropFindResponseEntity entity = (PropFindResponseEntity)responseFind.getEntity();
+ entity.write(outputStream);
+ String find = outputStream.toString();
+- assertTrue(find.contains(authorProp));
++ assertTrue(find.contains(WEBDAV_AUTHOR_PROPERTY));
+ assertTrue(find.contains("D:getlastmodified"));
+ }
+
+@@ -178,8 +259,8 @@
+ {
+ String content = TestUtils.getFileContent();
+ String file = TestUtils.getFileName();
+- TestUtils.addContent(session, file, new ByteArrayInputStream(content.getBytes()), nt_webdave_file, "");
+- TestUtils.addNodeProperty(session, file, authorProp, author);
++ TestUtils.addContent(session, file, new ByteArrayInputStream(content.getBytes()), WEBDAV_NT_FILE, "");
++ TestUtils.addNodeProperty(session, file, WEBDAV_AUTHOR_PROPERTY, AUTHOR);
+ ContainerResponse responseFind =
+ service(WebDAVMethods.PROPFIND, getPathWS() + file, "", null, allPropsXML.getBytes());
+ assertEquals(HTTPStatus.MULTISTATUS, responseFind.getStatus());
+@@ -188,21 +269,17 @@
+ entity.write(outputStream);
+ String find = outputStream.toString();
+ assertTrue(find.contains("D:getlastmodified"));
+- assertTrue(find.contains(authorProp));
+- assertTrue(find.contains(author));
++ assertTrue(find.contains(WEBDAV_AUTHOR_PROPERTY));
++ assertTrue(find.contains(AUTHOR));
+ }
+-
+-
+-
+-
+-
++
+ public void testPropWithPercent() throws Exception
+ {
+ String content = TestUtils.getFileContent();
+ String file = TestUtils.getFileName();
+- TestUtils.addContent(session, file, new ByteArrayInputStream(content.getBytes()), nt_webdave_file, "");
++ TestUtils.addContent(session, file, new ByteArrayInputStream(content.getBytes()), WEBDAV_NT_FILE, "");
+ String authorValue = "bla % bla";
+- TestUtils.addNodeProperty(session, file, authorProp, authorValue);
++ TestUtils.addNodeProperty(session, file, WEBDAV_AUTHOR_PROPERTY, authorValue);
+ ContainerResponse responseFind =
+ service(WebDAVMethods.PROPFIND, getPathWS() + file, "", null, allPropsXML.getBytes());
+ assertEquals(HTTPStatus.MULTISTATUS, responseFind.getStatus());
+@@ -211,7 +288,7 @@
+ entity.write(outputStream);
+ String find = outputStream.toString();
+ assertTrue(find.contains("D:getlastmodified"));
+- assertTrue(find.contains(authorProp));
++ assertTrue(find.contains(WEBDAV_AUTHOR_PROPERTY));
+ assertTrue(find.contains(authorValue));
+ }
+
+Index: exo.jcr.component.webdav/src/test/resources/conf/test/webdav-nodetypes.xml
+===================================================================
+--- exo.jcr.component.webdav/src/test/resources/conf/test/webdav-nodetypes.xml (revision 4710)
++++ exo.jcr.component.webdav/src/test/resources/conf/test/webdav-nodetypes.xml (working copy)
+@@ -113,6 +113,18 @@
+ <supertype>nt:unstructured</supertype>
+ </supertypes>
+
++ <propertyDefinitions>
++ <propertyDefinition name="*" requiredType="undefined" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false"
++
++ multiple="false">
++ <valueConstraints />
++ </propertyDefinition>
++ <propertyDefinition name="webdav:test-property" requiredType="String" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false"
++ multiple="true">
++ <valueConstraints />
++ </propertyDefinition>
++ </propertyDefinitions>
++
+ </nodeType>
+
+ <nodeType name="exo:testContentResource" isMixin="false" hasOrderableChildNodes="true" primaryItemName="">
+Index: exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/resource/FileResource.java
+===================================================================
+--- exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/resource/FileResource.java (revision 4699)
++++ exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/resource/FileResource.java (working copy)
+@@ -315,7 +315,18 @@
+ String propertyValue;
+ if (property.getDefinition().isMultiple())
+ {
+- propertyValue = property.getValues()[0].getString();
++ if (property.getValues().length >= 1)
++ {
++ propertyValue = property.getValues()[0].getString();
++ }
++ else
++ {
++ // this means that we return empty value, because according to WebDAV spec:
++ // this is a property whose semantics and syntax are not enforced by the server
++ // the server only records the value of a dead property;
++ // the client is responsible for maintaining the consistency of the syntax and semantics of a dead property.
++ propertyValue = new String();
++ }
+ }
+ else
+ {
+@@ -323,7 +334,6 @@
+ }
+ return new HierarchicalProperty(name, propertyValue);
+ }
+-
+ }
+ }
+
12 years, 9 months
exo-jcr SVN: r4716 - in jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene: spell and 1 other directory.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2011-08-09 07:34:25 -0400 (Tue, 09 Aug 2011)
New Revision: 4716
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/directory/DirectoryManager.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/directory/FSDirectoryManager.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/spell/LuceneSpellChecker.java
Log:
EXOJCR-1437 : allow to set custom Directory and LockFactory implementation class.
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/directory/DirectoryManager.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/directory/DirectoryManager.java 2011-08-09 11:33:10 UTC (rev 4715)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/directory/DirectoryManager.java 2011-08-09 11:34:25 UTC (rev 4716)
@@ -17,7 +17,6 @@
package org.exoplatform.services.jcr.impl.core.query.lucene.directory;
import org.apache.lucene.store.Directory;
-import org.exoplatform.commons.utils.PropertyManager;
import org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex;
import java.io.IOException;
@@ -28,12 +27,6 @@
*/
public interface DirectoryManager {
- /**
- * The full qualified name of the lock factory to use by default, if not
- * specified org.apache.lucene.store.NativeFSLockFactory will be used
- */
- public static final String LOCK_FACTORY_CLASS = PropertyManager
- .getProperty("org.apache.lucene.store.FSDirectoryLockFactoryClass");
/**
* Initializes the directory manager with a reference to the search index.
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/directory/FSDirectoryManager.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/directory/FSDirectoryManager.java 2011-08-09 11:33:10 UTC (rev 4715)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/directory/FSDirectoryManager.java 2011-08-09 11:34:25 UTC (rev 4716)
@@ -19,8 +19,8 @@
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.FSDirectory;
import org.apache.lucene.store.NativeFSLockFactory;
+import org.exoplatform.commons.utils.PropertyManager;
import org.exoplatform.commons.utils.SecurityHelper;
-import org.exoplatform.commons.utils.PrivilegedFileHelper;
import org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex;
import java.io.File;
@@ -37,6 +37,41 @@
{
/**
+ * The full qualified name of the lock factory to use by default, if not
+ * specified org.apache.lucene.store.NativeFSLockFactory will be used
+ */
+ public static final String LOCK_FACTORY_CLASS;
+
+ /**
+ * The full qualified name of the lock factory to use by default, if not
+ * specified org.apache.lucene.store.NativeFSLockFactory will be used
+ */
+ public static final String FS_DIRECTORY_CLASS;
+
+ /**
+ * Static block, used to initialize (map) org.exoplatform.jcr.lucene*
+ * properties to org.apache.lucene.* and make it only once at a system
+ * start
+ *
+ * Required to set custom Index Directory and Lock Factory implementations for Lucene 2.x.
+ */
+ static
+ {
+ // get eXo system properties
+ LOCK_FACTORY_CLASS = PropertyManager.getProperty("org.exoplatform.jcr.lucene.store.FSDirectoryLockFactoryClass");
+ FS_DIRECTORY_CLASS = PropertyManager.getProperty("org.exoplatform.jcr.lucene.FSDirectory.class");
+ // map to Lucene ones. Works only with Lucene 2.x.
+ if (LOCK_FACTORY_CLASS != null)
+ {
+ PropertyManager.setProperty("org.apache.lucene.store.FSDirectoryLockFactoryClass", LOCK_FACTORY_CLASS);
+ }
+ if (FS_DIRECTORY_CLASS != null)
+ {
+ PropertyManager.setProperty("org.apache.lucene.FSDirectory.class", FS_DIRECTORY_CLASS);
+ }
+ }
+
+ /**
* The base directory.
*/
private File baseDir;
@@ -81,7 +116,7 @@
public Directory run() throws Exception
{
File dir;
- if (name.equals("."))
+ if (name.equals("."))
{
dir = baseDir;
}
@@ -97,7 +132,16 @@
throw new IOException("Cannot create directory: " + dir);
}
}
- return FSDirectory.getDirectory(dir, LOCK_FACTORY_CLASS != null ? null : new NativeFSLockFactory(dir));
+ // if both not defined, using FSDirectory.open
+ if (FS_DIRECTORY_CLASS == null && LOCK_FACTORY_CLASS == null)
+ {
+ return FSDirectory.open(dir, new NativeFSLockFactory(dir));
+ }
+ // LOCK FACTORY only defined, using deprecated getDirectory method
+ else
+ {
+ return FSDirectory.getDirectory(dir, LOCK_FACTORY_CLASS != null ? null : new NativeFSLockFactory(dir));
+ }
}
});
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/spell/LuceneSpellChecker.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/spell/LuceneSpellChecker.java 2011-08-09 11:33:10 UTC (rev 4715)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/spell/LuceneSpellChecker.java 2011-08-09 11:34:25 UTC (rev 4716)
@@ -250,7 +250,7 @@
* @param morePopular
* return only the suggest words that are as frequent or more frequent than the searched word
*/
- InternalSpellChecker(SearchIndex handler, float minDistance, boolean morePopular) throws IOException
+ InternalSpellChecker(final SearchIndex handler, float minDistance, boolean morePopular) throws IOException
{
this.handler = handler;
final String path = handler.getContext().getIndexDirectory() + File.separatorChar + "spellchecker";
@@ -259,9 +259,8 @@
{
public Object run() throws Exception
{
- spellIndexDirectory =
- FSDirectory.getDirectory(path, DirectoryManager.LOCK_FACTORY_CLASS != null ? null
- : new NativeFSLockFactory(path));
+ spellIndexDirectory = handler.getDirectoryManager().getDirectory(path);
+
if (IndexReader.indexExists(spellIndexDirectory))
{
lastRefresh = System.currentTimeMillis();
12 years, 9 months
exo-jcr SVN: r4715 - jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2011-08-09 07:33:10 -0400 (Tue, 09 Aug 2011)
New Revision: 4715
Modified:
jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/query-handler-config.xml
Log:
EXOJCR-1437 : updating documentation.
Modified: jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/query-handler-config.xml
===================================================================
--- jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/query-handler-config.xml 2011-08-09 11:26:02 UTC (rev 4714)
+++ jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/query-handler-config.xml 2011-08-09 11:33:10 UTC (rev 4715)
@@ -17,10 +17,10 @@
usage of cluster advantages. That's why eXo JCR offers three strategies
that are suitable for it's own usecases. They are standalone, clustered
with shared index and clustered with local indexes. Each one has it's pros
- and cons. </para>
+ and cons.</para>
<para>Stanadlone strategy provides a stack of indexes to achieve greater
- performance within single JVM. </para>
+ performance within single JVM.</para>
<mediaobject>
<imageobject>
@@ -33,11 +33,11 @@
file-system flushing. This index is called "Volatile" and it is invoked in
searches also. Within some conditions volatile index is flushed to the
persistent storage (file system) as new index directory. This allows to
- achieve great results for write operations. </para>
+ achieve great results for write operations.</para>
<para>Clustered implementation with local indexes is built upon same
strategy with volatile in-memory index buffer along with delayed flushing
- on persistent storage. </para>
+ on persistent storage.</para>
<mediaobject>
<imageobject>
@@ -57,11 +57,10 @@
for use. If no initial index found JCR uses automated sceneries. They are
controlled via configuration (see "index-recovery-mode" parameter)
offering full re-indexing from database or copying from another cluster
- node. </para>
+ node.</para>
<para>For some reasons having a multiple index copies on each instance can
- be costly. So shared index can be used instead (see diagram below).
- </para>
+ be costly. So shared index can be used instead (see diagram below).</para>
<mediaobject>
<imageobject>
@@ -93,7 +92,7 @@
<title>Query-handler configuration overview</title>
<para>Configuration example:</para>
-
+
<programlisting language="xml"><workspace name="ws">
<query-handler class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
<properties>
@@ -112,93 +111,94 @@
</query-handler>
</workspace>
</programlisting>
- <table>
- <title>Config properties description</title>
- <tgroup cols="2">
- <thead>
- <row>
- <entry>Property name</entry>
+ <table>
+ <title>Config properties description</title>
- <entry>Description</entry>
- </row>
- </thead>
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry>Property name</entry>
- <tbody>
- <row>
- <entry>index-dir</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
- <entry>path to index</entry>
- </row>
+ <tbody>
+ <row>
+ <entry>index-dir</entry>
- <row>
- <entry>changesfilter-class</entry>
+ <entry>path to index</entry>
+ </row>
- <entry>template of JBoss-cache configuration for all
- query-handlers in repository</entry>
- </row>
+ <row>
+ <entry>changesfilter-class</entry>
- <row>
- <entry>jbosscache-configuration</entry>
+ <entry>template of JBoss-cache configuration for all
+ query-handlers in repository</entry>
+ </row>
- <entry>template of JBoss-cache configuration for all
- query-handlers in repository</entry>
- </row>
+ <row>
+ <entry>jbosscache-configuration</entry>
- <row>
- <entry>jgroups-configuration</entry>
+ <entry>template of JBoss-cache configuration for all
+ query-handlers in repository</entry>
+ </row>
- <entry>jgroups-configuration is template configuration for all
- components (search, cache, locks) [Add link to document
- describing template configurations]</entry>
- </row>
+ <row>
+ <entry>jgroups-configuration</entry>
- <row>
- <entry>jgroups-multiplexer-stack</entry>
+ <entry>jgroups-configuration is template configuration for all
+ components (search, cache, locks) [Add link to document
+ describing template configurations]</entry>
+ </row>
- <entry>[TODO about jgroups-multiplexer-stack - add link to
- JBoss doc]</entry>
- </row>
+ <row>
+ <entry>jgroups-multiplexer-stack</entry>
- <row>
- <entry>jbosscache-cluster-name</entry>
+ <entry>[TODO about jgroups-multiplexer-stack - add link to JBoss
+ doc]</entry>
+ </row>
- <entry>cluster name (must be unique)</entry>
- </row>
+ <row>
+ <entry>jbosscache-cluster-name</entry>
- <row>
- <entry>max-volatile-time</entry>
+ <entry>cluster name (must be unique)</entry>
+ </row>
- <entry>max time to live for Volatile Index</entry>
- </row>
+ <row>
+ <entry>max-volatile-time</entry>
- <row>
- <entry>rdbms-reindexing</entry>
+ <entry>max time to live for Volatile Index</entry>
+ </row>
- <entry>indicate that need to use rdbms reindexing mechanism if
- possible, the default value is true</entry>
- </row>
+ <row>
+ <entry>rdbms-reindexing</entry>
- <row>
- <entry>reindexing-page-size</entry>
+ <entry>indicate that need to use rdbms reindexing mechanism if
+ possible, the default value is true</entry>
+ </row>
- <entry>maximum amount of nodes which can be retrieved from
- storage for re-indexing purpose, the default value is
- 100</entry>
- </row>
+ <row>
+ <entry>reindexing-page-size</entry>
- <row>
- <entry>index-recovery-mode</entry>
+ <entry>maximum amount of nodes which can be retrieved from
+ storage for re-indexing purpose, the default value is
+ 100</entry>
+ </row>
- <entry>If the parameter has been set to
- <command>from-indexing</command>, so a full indexing will be
- automatically launched (default behavior), if the parameter
- has been set to <command>from-coordinator</command>, the index
- will be retrieved from coordinator</entry>
- </row>
- </tbody>
- </tgroup>
- </table>
+ <row>
+ <entry>index-recovery-mode</entry>
+
+ <entry>If the parameter has been set to
+ <command>from-indexing</command>, so a full indexing will be
+ automatically launched (default behavior), if the parameter has
+ been set to <command>from-coordinator</command>, the index will
+ be retrieved from coordinator</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
</section>
<section>
@@ -208,7 +208,7 @@
also. Such parameters as "changesfilter-class", "jgroups-configuration"
and all the "jbosscache-*" must be skipped and not defined. Like the
configuration below.</para>
-
+
<programlisting language="xml"><workspace name="ws">
<query-handler class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
<properties>
@@ -219,7 +219,7 @@
<property name="index-recovery-mode" value="from-coordinator" />
</properties>
</query-handler>
-</workspace></programlisting>
+</workspace></programlisting>
</section>
<section>
@@ -232,7 +232,7 @@
Setting "changesfilter-class" to
"org.exoplatform.services.jcr.impl.core.query.jbosscache.JBossCacheIndexChangesFilter"
will enable shared index implementation.</para>
-
+
<programlisting language="xml"><workspace name="ws">
<query-handler class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
<properties>
@@ -251,11 +251,10 @@
</query-handler>
</workspace></programlisting>
- <para>In order to use cluster-ready strategy
- based on local indexes, when each node has own copy of index on local
- file system, the following configuration must be applied. Indexing
- directory must point to any folder on local file system and
- "changesfilter-class" must be set to
+ <para>In order to use cluster-ready strategy based on local indexes,
+ when each node has own copy of index on local file system, the following
+ configuration must be applied. Indexing directory must point to any
+ folder on local file system and "changesfilter-class" must be set to
"org.exoplatform.services.jcr.impl.core.query.jbosscache.LocalIndexChangesFilter".</para>
<programlisting language="xml"><workspace name="ws">
@@ -285,7 +284,7 @@
same for both clustered strategies.</para>
<para>jbosscache-indexer.xml</para>
-
+
<programlisting language="xml"><?xml version="1.0" encoding="UTF-8"?>
<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:jboss:jbosscache-core:config:3.1">
@@ -313,4 +312,31 @@
linkend="JCR.JBossCacheConfigurationTemplates">here</link>.</para>
</section>
</section>
+
+ <section>
+ <title>Advanced tuning</title>
+
+ <section>
+ <title>Lucene tuning</title>
+
+ <para>As mentioned above, JCR Indexing is based on Lucene indexing
+ library as underlying search engine. It uses Directories to store index
+ and manages access to index by Lock Factories. By default JCR
+ implementation uses optimal combination of Directory implementation and
+ Lock Factory implementation. When running on OS different from Windows,
+ NIOFSDirectory implementation used. And SimpleFSDirectory for Windows
+ stations. NativeFSLockFactory is an optimal solution for wide variety of
+ cases including clustered environment with NFS shared resources. But
+ those default can be overridden with the help of system properties.
+ There are two properties:
+ "org.exoplatform.jcr.lucene.store.FSDirectoryLockFactoryClass" and
+ "org.exoplatform.jcr.lucene.FSDirectory.class" that are responsible for
+ changing default behavior. First one defines implementation of abstract
+ Lucene LockFactory class and the second one sets implementation class
+ for FSDirectory instances. For more information please refer to Lucene
+ documentation. But be sure You know what You are changing. JCR allows
+ end users to change implementation classes of Lucene internals, but
+ doesn't guarantee it's stability and functionality.</para>
+ </section>
+ </section>
</chapter>
12 years, 9 months
exo-jcr SVN: r4714 - kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/management/jmx/impl.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2011-08-09 07:26:02 -0400 (Tue, 09 Aug 2011)
New Revision: 4714
Modified:
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/management/jmx/impl/JMXManagementProvider.java
Log:
EXOJCR-1473: WARNING: Could not unregister the MBean whenever server is shutdown
Modified: kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/management/jmx/impl/JMXManagementProvider.java
===================================================================
--- kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/management/jmx/impl/JMXManagementProvider.java 2011-08-09 10:00:23 UTC (rev 4713)
+++ kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/management/jmx/impl/JMXManagementProvider.java 2011-08-09 11:26:02 UTC (rev 4714)
@@ -200,7 +200,10 @@
{
public Void run() throws Exception
{
- server.unregisterMBean(name);
+ if (server.isRegistered(name))
+ {
+ server.unregisterMBean(name);
+ }
return null;
}
});
12 years, 9 months
exo-jcr SVN: r4713 - jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2011-08-09 06:00:23 -0400 (Tue, 09 Aug 2011)
New Revision: 4713
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionImpl.java
Log:
EXOJCR-1472 : The fix to avoid use IdGenerator.generate() as id of SessionImpl was committed.
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionImpl.java 2011-08-09 09:50:09 UTC (rev 4712)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionImpl.java 2011-08-09 10:00:23 UTC (rev 4713)
@@ -73,6 +73,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.concurrent.atomic.AtomicLong;
import javax.jcr.AccessDeniedException;
import javax.jcr.Credentials;
@@ -125,6 +126,8 @@
}
}
+ private static final AtomicLong SEQUENCE = new AtomicLong();
+
public static final int DEFAULT_LAZY_READ_THRESHOLD = 100;
private final RepositoryImpl repository;
@@ -193,7 +196,7 @@
this.workspaceName = workspaceName;
this.container = container;
this.live = true;
- this.id = IdGenerator.generate();
+ this.id = System.currentTimeMillis() + "_" + SEQUENCE.incrementAndGet();
this.userState = userState;
this.txResourceManager =
(TransactionableResourceManager)container.getComponentInstanceOfType(TransactionableResourceManager.class);
12 years, 9 months
exo-jcr SVN: r4712 - in jcr/branches/1.12.x/patch/1.12.10-GA: JCR-1654 and 1 other directory.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2011-08-09 05:50:09 -0400 (Tue, 09 Aug 2011)
New Revision: 4712
Added:
jcr/branches/1.12.x/patch/1.12.10-GA/JCR-1654/
jcr/branches/1.12.x/patch/1.12.10-GA/JCR-1654/JCR-1654.patch
Log:
JCR-1654 : Patch for avoid use IdGenerator.generate() as is id SessionImpl was committed.
Added: jcr/branches/1.12.x/patch/1.12.10-GA/JCR-1654/JCR-1654.patch
===================================================================
--- jcr/branches/1.12.x/patch/1.12.10-GA/JCR-1654/JCR-1654.patch (rev 0)
+++ jcr/branches/1.12.x/patch/1.12.10-GA/JCR-1654/JCR-1654.patch 2011-08-09 09:50:09 UTC (rev 4712)
@@ -0,0 +1,38 @@
+Index: exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionImpl.java
+===================================================================
+--- exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionImpl.java (revision 4711)
++++ exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionImpl.java (working copy)
+@@ -49,7 +49,6 @@
+ import org.exoplatform.services.jcr.impl.xml.exporting.BaseXmlExporter;
+ import org.exoplatform.services.jcr.impl.xml.importing.ContentImporter;
+ import org.exoplatform.services.jcr.impl.xml.importing.StreamImporter;
+-import org.exoplatform.services.jcr.util.IdGenerator;
+ import org.exoplatform.services.security.ConversationState;
+ import org.exoplatform.services.security.Identity;
+ import org.xml.sax.ContentHandler;
+@@ -67,6 +66,7 @@
+ import java.util.List;
+ import java.util.Map;
+ import java.util.Set;
++import java.util.concurrent.atomic.AtomicLong;
+
+ import javax.jcr.AccessDeniedException;
+ import javax.jcr.Credentials;
+@@ -100,6 +100,8 @@
+ public class SessionImpl implements ExtendedSession, NamespaceAccessor
+ {
+
++ private static final AtomicLong SEQUENCE = new AtomicLong();
++
+ public static final int DEFAULT_LAZY_READ_THRESHOLD = 100;
+
+ private final RepositoryImpl repository;
+@@ -150,7 +152,7 @@
+ this.workspaceName = workspaceName;
+ this.container = container;
+ this.live = true;
+- this.id = IdGenerator.generate();
++ this.id = System.currentTimeMillis() + "_" + SEQUENCE.incrementAndGet();
+ this.userState = userState;
+
+ this.repository = (RepositoryImpl)container.getComponentInstanceOfType(RepositoryImpl.class);
12 years, 9 months