Author: nfilotto
Date: 2012-01-19 13:45:11 -0500 (Thu, 19 Jan 2012)
New Revision: 5486
Added:
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/infinispan/AbstractMapper.java
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/infinispan/CacheKey.java
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/infinispan/CacheServer.java
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/resources/conf/cache-server-configuration.xml
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/resources/conf/distributed-cache-configuration.xml
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/resources/conf/tcp-mux.xml
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/resources/conf/udp-mux.xml
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/test/resources/conf/standalone/cluster/distributed-cache-configuration.xml
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/test/resources/conf/standalone/cluster/tcp-mux.xml
Removed:
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CacheKey.java
Modified:
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/pom.xml
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/core/lock/infinispan/ISPNCacheableLockManagerImpl.java
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/ChangesKey.java
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/ISPNIndexInfos.java
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/ISPNIndexUpdateMonitor.java
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/IndexInfosKey.java
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/IndexUpdateKey.java
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/IndexerCacheStore.java
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/BufferedISPNCache.java
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CacheId.java
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CacheNodesByPageId.java
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CacheNodesId.java
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CachePatternNodesId.java
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CachePatternPropsId.java
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CachePropsId.java
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CacheQPath.java
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CacheRefsId.java
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/ISPNCacheWorkspaceStorageCache.java
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/infinispan/ISPNCacheFactory.java
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/resources/conf/portal/cluster/infinispan-data.xml
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/resources/conf/portal/cluster/infinispan-indexer.xml
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/resources/conf/portal/cluster/infinispan-lock.xml
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/cache/infinispan/TestISPNCacheWorkspaceStorageCacheInClusterMode.java
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/test/java/org/exoplatform/services/jcr/lab/infinispan/TestISPNCache.java
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/test/resources/conf/standalone/cluster/test-configuration.xml
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/test/resources/conf/standalone/cluster/test-jcr-config.xml
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/test/resources/conf/standalone/test-infinispan-config.xml
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/test/resources/conf/standalone/test-infinispan-lock.xml
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/NullItemData.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/ByteArrayPersistedValueData.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java
jcr/trunk/pom.xml
Log:
EXOJCR-1682: Improve ISPN integration to support properly the distribution mode (jcr
part)
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/NullItemData.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/NullItemData.java 2012-01-19
14:28:39 UTC (rev 5485)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/NullItemData.java 2012-01-19
18:45:11 UTC (rev 5486)
@@ -17,7 +17,13 @@
package org.exoplatform.services.jcr.datamodel;
import org.exoplatform.services.jcr.dataflow.ItemDataVisitor;
+import org.exoplatform.services.jcr.impl.Constants;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
import javax.jcr.RepositoryException;
/**
@@ -28,18 +34,18 @@
* @author <a href="karpenko.sergiy(a)gmail.com">Karpenko Sergiy</a>
* @version $Id: NullItemData.java 111 2008-11-11 11:11:11Z serg $
*/
-public abstract class NullItemData implements ItemData
+public abstract class NullItemData implements ItemData, Externalizable
{
public static final String NULL_ID = "_null_id";
- private final String id;
+ private String id;
- private final String parentId;
+ private String parentId;
- private final QPathEntry name;
+ private QPathEntry name;
- private final QPath path;
+ private QPath path;
public NullItemData(NodeData parent, QPathEntry name)
{
@@ -51,18 +57,12 @@
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;
+ this(NULL_ID);
}
public void accept(ItemDataVisitor visitor) throws RepositoryException
@@ -94,5 +94,95 @@
{
return name;
}
+ /**
+ * {@inheritDoc}
+ *
+ * We need to make it serializable mostly for distributed cache in case we
+ * don't allow local caching
+ */
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
+ {
+ byte[] buf = new byte[in.readInt()];
+ in.readFully(buf);
+ id = new String(buf, Constants.DEFAULT_ENCODING);
+ int length = in.readInt();
+ if (length > 0)
+ {
+ buf = new byte[length];
+ in.readFully(buf);
+ parentId = new String(buf, Constants.DEFAULT_ENCODING);
+ }
+ length = in.readInt();
+ if (length > 0)
+ {
+ buf = new byte[length];
+ in.readFully(buf);
+ try
+ {
+ name = QPathEntry.parse(new String(buf, Constants.DEFAULT_ENCODING));
+ }
+ catch (Exception e)
+ {
+ throw new IOException("Deserialization error, could not parse the name.
", e);
+ }
+ }
+ length = in.readInt();
+ if (length > 0)
+ {
+ buf = new byte[length];
+ in.readFully(buf);
+ try
+ {
+ path = QPath.parse(new String(buf, Constants.DEFAULT_ENCODING));
+ }
+ catch (Exception e)
+ {
+ throw new IOException("Deserialization error, could not parse the path.
", e);
+ }
+ }
+ }
+ /**
+ * {@inheritDoc}
+ *
+ * We need to make it serializable mostly for distributed cache in case we
+ * don't allow local caching
+ */
+ public void writeExternal(ObjectOutput out) throws IOException
+ {
+ byte[] buf = id.getBytes(Constants.DEFAULT_ENCODING);
+ out.writeInt(buf.length);
+ out.write(buf);
+
+ if (parentId == null)
+ {
+ out.writeInt(-1);
+ }
+ else
+ {
+ buf = parentId.getBytes(Constants.DEFAULT_ENCODING);
+ out.writeInt(buf.length);
+ out.write(buf);
+ }
+ if (name == null)
+ {
+ out.writeInt(-1);
+ }
+ else
+ {
+ buf = name.getAsString(true).getBytes(Constants.DEFAULT_ENCODING);
+ out.writeInt(buf.length);
+ out.write(buf);
+ }
+ if (path == null)
+ {
+ out.writeInt(-1);
+ }
+ else
+ {
+ buf = path.getAsString().getBytes(Constants.DEFAULT_ENCODING);
+ out.writeInt(buf.length);
+ out.write(buf);
+ }
+ }
}
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/ByteArrayPersistedValueData.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/ByteArrayPersistedValueData.java 2012-01-19
14:28:39 UTC (rev 5485)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/ByteArrayPersistedValueData.java 2012-01-19
18:45:11 UTC (rev 5486)
@@ -169,7 +169,7 @@
orderNumber = in.readInt();
data = new byte[in.readInt()];
- in.readFully(data);
+ if (data.length > 0) in.readFully(data);
}
/**
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 2012-01-19
14:28:39 UTC (rev 5485)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java 2012-01-19
18:45:11 UTC (rev 5486)
@@ -497,7 +497,8 @@
try
{
transactionManager =
-
(TransactionManager)cache.getClass().getMethod("getTransactionManager",
null).invoke(null, null);
+
(TransactionManager)cache.getClass().getMethod("getTransactionManager",
(Class<?>[])null)
+ .invoke(cache, (Object[])null);
}
catch (Exception e)
{
@@ -1369,6 +1370,7 @@
while (patternIterator.hasNext())
{
QPathEntryFilter pattern = patternIterator.next();
+ @SuppressWarnings("unchecked")
List<NodeData> persistedNodeData =
(List<NodeData>)pattern.accept(persistedItemList);
if (pattern.isExactName())
{
@@ -1667,6 +1669,7 @@
while (patternIterator.hasNext())
{
QPathEntryFilter pattern = patternIterator.next();
+ @SuppressWarnings("unchecked")
List<PropertyData> persistedPropData =
(List<PropertyData>)pattern.accept(persistedItemList);
if (pattern.isExactName())
Modified: jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/pom.xml
===================================================================
--- jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/pom.xml 2012-01-19 14:28:39 UTC
(rev 5485)
+++ jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/pom.xml 2012-01-19 18:45:11 UTC
(rev 5486)
@@ -34,6 +34,7 @@
<cache.enabled>true</cache.enabled>
<value.storage.enabled>true</value.storage.enabled>
<statistics.enabled>false</statistics.enabled>
+ <use.distributed.cache>false</use.distributed.cache>
<properties.url.suffix>.properties</properties.url.suffix>
<properties.url.prefix>classpath:/conf/standalone/default</properties.url.prefix>
<test.cache.all>**/persistent/cache/**</test.cache.all>
@@ -58,8 +59,12 @@
<dependency>
<groupId>org.exoplatform.kernel</groupId>
<artifactId>exo.kernel.component.ext.rpc.impl.jgroups.v3</artifactId>
- </dependency>
+ </dependency>
<dependency>
+ <groupId>org.exoplatform.kernel</groupId>
+
<artifactId>exo.kernel.component.ext.cache.impl.infinispan.v5</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>exo.jcr.component.core</artifactId>
<exclusions>
@@ -72,7 +77,7 @@
<dependency>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>exo.jcr.component.core</artifactId>
- <classifier>sources</classifier>
+ <classifier>tests</classifier>
<scope>test</scope>
<version>${project.version}</version>
<exclusions>
@@ -104,6 +109,10 @@
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging-spi</artifactId>
</exclusion>
+ <exclusion>
+ <groupId>jgroups</groupId>
+ <artifactId>jgroups</artifactId>
+ </exclusion>
</exclusions>
</dependency>
<!-- TCK binaries and deps for repo stub, some eXo API test -->
@@ -181,8 +190,12 @@
<property>
<name>value-storage-enabled</name>
<value>${value.storage.enabled}</value>
- </property>
+ </property>
<property>
+ <name>use-distributed-cache</name>
+ <value>${use.distributed.cache}</value>
+ </property>
+ <property>
<name>JDBCWorkspaceDataContainer.statistics.enabled</name>
<value>${statistics.enabled}</value>
</property>
@@ -360,7 +373,11 @@
<property>
<name>value-storage-enabled</name>
<value>${value.storage.enabled}</value>
- </property>
+ </property>
+ <property>
+ <name>use-distributed-cache</name>
+ <value>${use.distributed.cache}</value>
+ </property>
<property>
<name>known.issues</name>
<value>org.apache.jackrabbit.test.api.version.RestoreTest#testRestoreName
@@ -440,6 +457,10 @@
<value>${value.storage.enabled}</value>
</property>
<property>
+ <name>use-distributed-cache</name>
+ <value>${use.distributed.cache}</value>
+ </property>
+ <property>
<name>known.issues</name>
<value>org.apache.jackrabbit.test.api.version.RestoreTest#testRestoreName
org.apache.jackrabbit.test.api.version.RestoreTest#testRestoreOrder2
Modified:
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/core/lock/infinispan/ISPNCacheableLockManagerImpl.java
===================================================================
---
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/core/lock/infinispan/ISPNCacheableLockManagerImpl.java 2012-01-19
14:28:39 UTC (rev 5485)
+++
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/core/lock/infinispan/ISPNCacheableLockManagerImpl.java 2012-01-19
18:45:11 UTC (rev 5486)
@@ -39,7 +39,6 @@
import org.exoplatform.services.naming.InitialContextInitializer;
import org.exoplatform.services.transaction.TransactionService;
import org.infinispan.Cache;
-import org.infinispan.config.Configuration.CacheMode;
import org.infinispan.lifecycle.ComponentStatus;
import java.io.Serializable;
@@ -112,7 +111,7 @@
if (config.getLockManager() != null)
{
// create cache using custom factory
- ISPNCacheFactory<Serializable, Object> factory = new
ISPNCacheFactory<Serializable, Object>(cfm);
+ ISPNCacheFactory<Serializable, Object> factory = new
ISPNCacheFactory<Serializable, Object>(cfm, transactionManager);
// configure cache loader parameters with correct DB data-types
configureJDBCCacheLoader(config.getLockManager());
@@ -431,8 +430,7 @@
@Override
protected boolean isAloneInCluster()
{
- return cache.getConfiguration().getCacheMode() == CacheMode.LOCAL
- || cache.getCacheManager().getMembers().size() == 1;
+ return cache.getAdvancedCache().getRpcManager() == null ||
cache.getCacheManager().getMembers().size() == 1;
}
/**
Modified:
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/ChangesKey.java
===================================================================
---
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/ChangesKey.java 2012-01-19
14:28:39 UTC (rev 5485)
+++
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/ChangesKey.java 2012-01-19
18:45:11 UTC (rev 5486)
@@ -19,7 +19,7 @@
package org.exoplatform.services.jcr.impl.core.query.ispn;
import org.exoplatform.services.jcr.impl.Constants;
-import org.exoplatform.services.jcr.impl.dataflow.persistent.infinispan.CacheKey;
+import org.exoplatform.services.jcr.infinispan.CacheKey;
import java.io.IOException;
import java.io.ObjectInput;
@@ -44,7 +44,7 @@
ChangesKey(String wsId, String id)
{
- super(id);
+ super(null, id);
this.wsId = wsId;
}
@@ -79,21 +79,4 @@
in.readFully(buf);
wsId = new String(buf, Constants.DEFAULT_ENCODING);
}
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(Object obj)
- {
- if (obj instanceof ChangesKey)
- {
- ChangesKey key = (ChangesKey)obj;
- return (key.hash == hash && key.id.equals(id));
- }
- else
- {
- return false;
- }
- }
}
Modified:
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/ISPNIndexInfos.java
===================================================================
---
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/ISPNIndexInfos.java 2012-01-19
14:28:39 UTC (rev 5485)
+++
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/ISPNIndexInfos.java 2012-01-19
18:45:11 UTC (rev 5486)
@@ -203,8 +203,9 @@
* @param event
* CacheEntryModifiedEvent
*/
+ @SuppressWarnings("unchecked")
@CacheEntryModified
- public void cacheEntryModified(CacheEntryModifiedEvent event)
+ public void cacheEntryModified(CacheEntryModifiedEvent<Serializable, Object>
event)
{
if (!event.isPre() && event.getKey().equals(namesKey))
{
Modified:
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/ISPNIndexUpdateMonitor.java
===================================================================
---
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/ISPNIndexUpdateMonitor.java 2012-01-19
14:28:39 UTC (rev 5485)
+++
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/ISPNIndexUpdateMonitor.java 2012-01-19
18:45:11 UTC (rev 5486)
@@ -215,7 +215,7 @@
* CacheEntryModifiedEvent
*/
@CacheEntryModified
- public void cacheEntryModified(CacheEntryModifiedEvent event)
+ public void cacheEntryModified(CacheEntryModifiedEvent<Serializable, Object>
event)
{
if (!event.isPre() && event.getKey().equals(updateKey))
{
Modified:
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/IndexInfosKey.java
===================================================================
---
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/IndexInfosKey.java 2012-01-19
14:28:39 UTC (rev 5485)
+++
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/IndexInfosKey.java 2012-01-19
18:45:11 UTC (rev 5486)
@@ -18,7 +18,7 @@
*/
package org.exoplatform.services.jcr.impl.core.query.ispn;
-import org.exoplatform.services.jcr.impl.dataflow.persistent.infinispan.CacheKey;
+import org.exoplatform.services.jcr.infinispan.CacheKey;
/**
* Created by The eXo Platform SAS.
@@ -37,23 +37,6 @@
IndexInfosKey(String id)
{
- super(id);
+ super(null, id);
}
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(Object obj)
- {
- if (obj instanceof IndexInfosKey)
- {
- IndexInfosKey key = (IndexInfosKey)obj;
- return (key.hash == hash && key.id.equals(id));
- }
- else
- {
- return false;
- }
- }
}
Modified:
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/IndexUpdateKey.java
===================================================================
---
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/IndexUpdateKey.java 2012-01-19
14:28:39 UTC (rev 5485)
+++
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/IndexUpdateKey.java 2012-01-19
18:45:11 UTC (rev 5486)
@@ -18,7 +18,7 @@
*/
package org.exoplatform.services.jcr.impl.core.query.ispn;
-import org.exoplatform.services.jcr.impl.dataflow.persistent.infinispan.CacheKey;
+import org.exoplatform.services.jcr.infinispan.CacheKey;
/**
* Created by The eXo Platform SAS.
@@ -38,23 +38,6 @@
IndexUpdateKey(String id)
{
- super(id);
+ super(null, id);
}
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(Object obj)
- {
- if (obj instanceof IndexUpdateKey)
- {
- IndexUpdateKey key = (IndexUpdateKey)obj;
- return (key.hash == hash && key.id.equals(id));
- }
- else
- {
- return false;
- }
- }
}
Modified:
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/IndexerCacheStore.java
===================================================================
---
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/IndexerCacheStore.java 2012-01-19
14:28:39 UTC (rev 5485)
+++
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/IndexerCacheStore.java 2012-01-19
18:45:11 UTC (rev 5486)
@@ -23,7 +23,6 @@
import org.exoplatform.services.jcr.impl.core.query.IndexerIoModeHandler;
import org.exoplatform.services.jcr.util.IdGenerator;
import org.infinispan.Cache;
-import org.infinispan.config.Configuration.CacheMode;
import org.infinispan.container.DataContainer;
import org.infinispan.container.entries.InternalCacheEntry;
import org.infinispan.lifecycle.ComponentStatus;
@@ -43,8 +42,8 @@
import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Set;
-import java.util.Map.Entry;
/**
* Implements Cache Store for clustered environment. It gives control of Index for
coordinator and
@@ -102,7 +101,7 @@
{
this.modeHandler =
new IndexerIoModeHandler(cacheManager.isCoordinator()
- || cache.getConfiguration().getCacheMode() == CacheMode.LOCAL ?
IndexerIoMode.READ_WRITE
+ || cache.getAdvancedCache().getRpcManager() == null ?
IndexerIoMode.READ_WRITE
: IndexerIoMode.READ_ONLY);
}
}
@@ -166,6 +165,7 @@
/**
* Flushes all cache content to underlying CacheStore
*/
+ @SuppressWarnings({"rawtypes", "unchecked"})
protected void doPushState()
{
final boolean debugEnabled = log.isDebugEnabled();
Modified:
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/BufferedISPNCache.java
===================================================================
---
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/BufferedISPNCache.java 2012-01-19
14:28:39 UTC (rev 5485)
+++
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/BufferedISPNCache.java 2012-01-19
18:45:11 UTC (rev 5486)
@@ -21,12 +21,12 @@
import org.exoplatform.commons.utils.SecurityHelper;
import org.exoplatform.services.jcr.datamodel.ItemData;
import org.exoplatform.services.jcr.impl.core.itemfilters.QPathEntryFilter;
+import org.exoplatform.services.jcr.infinispan.CacheKey;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
import org.infinispan.AdvancedCache;
import org.infinispan.Cache;
import org.infinispan.config.Configuration;
-import org.infinispan.config.Configuration.CacheMode;
import org.infinispan.context.Flag;
import org.infinispan.lifecycle.ComponentStatus;
import org.infinispan.manager.EmbeddedCacheManager;
@@ -53,7 +53,7 @@
* @version $Id: BufferedISPNCache.java 3514 2010-11-22 16:14:36Z nzamosenchuk $
*
*/
-@SuppressWarnings("unchecked")
+@SuppressWarnings({"unchecked", "deprecation"})
public class BufferedISPNCache implements Cache<CacheKey, Object>
{
/**
@@ -151,20 +151,9 @@
protected AdvancedCache<CacheKey, Object> setCacheLocalMode()
{
- if (localMode)
+ if (localMode && allowLocalChanges)
{
- if (allowLocalChanges == null)
- {
- CacheMode cacheMode = cache.getConfiguration().getCacheMode();
- if (cacheMode != CacheMode.DIST_ASYNC && cacheMode !=
CacheMode.DIST_SYNC)
- {
- return cache.withFlags(Flag.CACHE_MODE_LOCAL);
- }
- }
- else if (allowLocalChanges)
- {
- return cache.withFlags(Flag.CACHE_MODE_LOCAL);
- }
+ return cache.withFlags(Flag.CACHE_MODE_LOCAL);
}
return cache;
}
@@ -264,8 +253,7 @@
LOG.error("Unexpected object found by key " + key.toString() +
". Expected Set, but found:"
+ existingObject.getClass().getName());
}
- else if (!localMode && cache.getConfiguration().getCacheMode() !=
CacheMode.LOCAL
- && cache.getCacheManager().getMembers().size() > 1)
+ else if (!localMode && cache.getRpcManager() != null &&
cache.getCacheManager().getMembers().size() > 1)
{
// to prevent consistency issue since we don't have the list in the local
cache, we are in cluster env
// and we are in a non local mode, we clear the list in order to enforce
other cluster nodes to reload it from the db
@@ -327,8 +315,7 @@
LOG.error("Unexpected object found by key " + key.toString() +
". Expected Map, but found:"
+ existingObject.getClass().getName());
}
- else if (!localMode && cache.getConfiguration().getCacheMode() !=
CacheMode.LOCAL
- && cache.getCacheManager().getMembers().size() > 1)
+ else if (!localMode && cache.getRpcManager() != null &&
cache.getCacheManager().getMembers().size() > 1)
{
// to prevent consistency issue since we don't have the list in the local
cache, we are in cluster env
// and we are in a non local mode, we remove all the patterns in order to
enforce other cluster nodes
@@ -866,9 +853,15 @@
/**
* {@inheritDoc}
*/
- public Object get(Object key)
+ public Object get(final Object key)
{
- return parentCache.get(key);
+ return SecurityHelper.doPrivilegedAction(new PrivilegedAction<Object>()
+ {
+ public Object run()
+ {
+ return parentCache.get(key);
+ }
+ });
}
/**
@@ -895,6 +888,14 @@
}
/**
+ * {@inheritDoc}
+ */
+ public org.infinispan.configuration.cache.Configuration getCacheConfiguration()
+ {
+ return parentCache.getCacheConfiguration();
+ }
+
+ /**
* Put object in cache.
* @param key
* cache key
Modified:
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CacheId.java
===================================================================
---
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CacheId.java 2012-01-19
14:28:39 UTC (rev 5485)
+++
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CacheId.java 2012-01-19
18:45:11 UTC (rev 5486)
@@ -18,7 +18,9 @@
*/
package org.exoplatform.services.jcr.impl.dataflow.persistent.infinispan;
+import org.exoplatform.services.jcr.infinispan.CacheKey;
+
/**
*
* @author <a href="anatoliy.bazko(a)exoplatform.org">Anatoliy
Bazko</a>
@@ -32,25 +34,8 @@
super();
}
- CacheId(String id)
+ CacheId(String ownerId, String id)
{
- super(id);
+ super(ownerId, id);
}
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(Object obj)
- {
- if (obj instanceof CacheId)
- {
- CacheId cacheId = (CacheId)obj;
- return (cacheId.hash == hash && cacheId.id.equals(id));
- }
- else
- {
- return false;
- }
- }
}
Deleted:
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CacheKey.java
===================================================================
---
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CacheKey.java 2012-01-19
14:28:39 UTC (rev 5485)
+++
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CacheKey.java 2012-01-19
18:45:11 UTC (rev 5486)
@@ -1,153 +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.infinispan;
-
-import org.exoplatform.services.jcr.impl.Constants;
-import org.infinispan.distribution.group.Group;
-
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-
-/**
- * Created by The eXo Platform SAS. <br/>
- * Base class for WorkspaceCache keys.<br/>
- *
- * Date: 10.06.2008<br/>
- *
- * @author <a href="mailto:anatoliy.bazko@exoplatform.com.ua">Anatoliy
Bazko</a>
- * @version $Id: CacheKey.java 2845 2010-07-30 13:29:37Z tolusha $
- */
-public abstract class CacheKey implements Externalizable, Comparable<CacheKey>
-{
-
- protected String id;
-
- protected int hash;
-
- /**
- * The value used in case, the grouping is enabled
- */
- protected String group;
-
- public CacheKey()
- {
- }
-
- public CacheKey(String id)
- {
- this(id, null);
- }
-
- public CacheKey(String id, String group)
- {
- this.id = id;
- this.hash = id.hashCode();
- this.group = group;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode()
- {
- return this.hash;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString()
- {
- return this.getClass().getSimpleName() + "-" + this.id + "-" +
this.group;
- }
-
- /**
- * {@inheritDoc}
- */
- public int compareTo(CacheKey o)
- {
- int result = getClass().getName().compareTo(o.getClass().getName());
- return result == 0 ? id.compareTo(o.id) : result;
- }
-
- /**
- * This method is used for the grouping when its enabled. It will return
- * the value of the group if it has been explicitly set otherwise it will
- * return the value of the fullId
- * @return the group
- */
- @Group
- public String getGroup()
- {
- return group == null ? id : group;
- }
-
- /**
- * {@inheritDoc}
- */
- public void writeExternal(ObjectOutput out) throws IOException
- {
- byte[] buf;
- if (group == null)
- {
- out.writeInt(-1);
- }
- else
- {
- buf = group.getBytes(Constants.DEFAULT_ENCODING);
- out.writeInt(buf.length);
- out.write(buf);
- }
-
- buf = id.getBytes(Constants.DEFAULT_ENCODING);
- out.writeInt(buf.length);
- out.write(buf);
-
- }
-
- /**
- * {@inheritDoc}
- */
- public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
- {
- byte[] buf;
- int length = in.readInt();
- if (length >= 0)
- {
- buf = new byte[length];
- in.readFully(buf);
- group = new String(buf, Constants.DEFAULT_ENCODING);
- }
-
- buf = new byte[in.readInt()];
- in.readFully(buf);
- id = new String(buf, Constants.DEFAULT_ENCODING);
- hash = id.hashCode();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public abstract boolean equals(Object obj);
-}
\ No newline at end of file
Modified:
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CacheNodesByPageId.java
===================================================================
---
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CacheNodesByPageId.java 2012-01-19
14:28:39 UTC (rev 5485)
+++
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CacheNodesByPageId.java 2012-01-19
18:45:11 UTC (rev 5486)
@@ -18,6 +18,8 @@
*/
package org.exoplatform.services.jcr.impl.dataflow.persistent.infinispan;
+import org.exoplatform.services.jcr.infinispan.CacheKey;
+
/**
* @author <a href="abazko(a)exoplatform.com">Anatoliy Bazko</a>
* @version $Id: CachePagedNodes.java 34360 2009-07-22 23:58:59Z tolusha $
@@ -30,23 +32,8 @@
super();
}
- CacheNodesByPageId(String id)
+ CacheNodesByPageId(String ownerId, String id)
{
- super(id);
+ super(ownerId, id);
}
-
- @Override
- public boolean equals(Object obj)
- {
- if (obj instanceof CacheNodesByPageId)
- {
- CacheNodesByPageId cacheNodesByPageId = (CacheNodesByPageId)obj;
- return (cacheNodesByPageId.hash == hash &&
cacheNodesByPageId.id.equals(id));
- }
- else
- {
- return false;
- }
- }
-
}
Modified:
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CacheNodesId.java
===================================================================
---
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CacheNodesId.java 2012-01-19
14:28:39 UTC (rev 5485)
+++
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CacheNodesId.java 2012-01-19
18:45:11 UTC (rev 5486)
@@ -18,6 +18,8 @@
*/
package org.exoplatform.services.jcr.impl.dataflow.persistent.infinispan;
+import org.exoplatform.services.jcr.infinispan.CacheKey;
+
/**
* Created by The eXo Platform SAS
*
@@ -36,22 +38,8 @@
super();
}
- CacheNodesId(String id)
+ CacheNodesId(String ownerId, String id)
{
- super(id);
+ super(ownerId, id);
}
-
- @Override
- public boolean equals(Object obj)
- {
- if (obj instanceof CacheNodesId)
- {
- CacheNodesId cacheNodesId = (CacheNodesId)obj;
- return (cacheNodesId.hash == hash && cacheNodesId.id.equals(id));
- }
- else
- {
- return false;
- }
- }
}
Modified:
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CachePatternNodesId.java
===================================================================
---
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CachePatternNodesId.java 2012-01-19
14:28:39 UTC (rev 5485)
+++
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CachePatternNodesId.java 2012-01-19
18:45:11 UTC (rev 5486)
@@ -16,6 +16,8 @@
*/
package org.exoplatform.services.jcr.impl.dataflow.persistent.infinispan;
+import org.exoplatform.services.jcr.infinispan.CacheKey;
+
/**
* Created by The eXo Platform SAS.
*
@@ -32,22 +34,8 @@
super();
}
- CachePatternNodesId(String id)
+ CachePatternNodesId(String ownerId, String id)
{
- super(id);
+ super(ownerId, id);
}
-
- @Override
- public boolean equals(Object obj)
- {
- if (obj instanceof CachePatternNodesId)
- {
- CachePatternNodesId cacheNodesId = (CachePatternNodesId)obj;
- return (cacheNodesId.hash == hash && cacheNodesId.id.equals(id));
- }
- else
- {
- return false;
- }
- }
}
Modified:
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CachePatternPropsId.java
===================================================================
---
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CachePatternPropsId.java 2012-01-19
14:28:39 UTC (rev 5485)
+++
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CachePatternPropsId.java 2012-01-19
18:45:11 UTC (rev 5486)
@@ -16,6 +16,8 @@
*/
package org.exoplatform.services.jcr.impl.dataflow.persistent.infinispan;
+import org.exoplatform.services.jcr.infinispan.CacheKey;
+
/**
* Created by The eXo Platform SAS.
*
@@ -32,22 +34,8 @@
super();
}
- CachePatternPropsId(String parentId)
+ CachePatternPropsId(String ownerId, String parentId)
{
- super(parentId);
+ super(ownerId, parentId);
}
-
- @Override
- public boolean equals(Object obj)
- {
- if (obj instanceof CachePatternPropsId)
- {
- CachePatternPropsId cachePatternPropsId = (CachePatternPropsId)obj;
- return (cachePatternPropsId.hash == hash &&
cachePatternPropsId.id.equals(id));
- }
- else
- {
- return false;
- }
- }
}
Modified:
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CachePropsId.java
===================================================================
---
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CachePropsId.java 2012-01-19
14:28:39 UTC (rev 5485)
+++
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CachePropsId.java 2012-01-19
18:45:11 UTC (rev 5486)
@@ -18,6 +18,8 @@
*/
package org.exoplatform.services.jcr.impl.dataflow.persistent.infinispan;
+import org.exoplatform.services.jcr.infinispan.CacheKey;
+
/**
* Created by The eXo Platform SAS
*
@@ -36,22 +38,8 @@
super();
}
- CachePropsId(String id)
+ CachePropsId(String ownerId, String id)
{
- super(id);
+ super(ownerId, id);
}
-
- @Override
- public boolean equals(Object obj)
- {
- if (obj instanceof CachePropsId)
- {
- CachePropsId cachePropsId = (CachePropsId)obj;
- return (cachePropsId.hash == hash && cachePropsId.id.equals(id));
- }
- else
- {
- return false;
- }
- }
}
Modified:
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CacheQPath.java
===================================================================
---
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CacheQPath.java 2012-01-19
14:28:39 UTC (rev 5485)
+++
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CacheQPath.java 2012-01-19
18:45:11 UTC (rev 5486)
@@ -22,6 +22,7 @@
import org.exoplatform.services.jcr.datamodel.QPath;
import org.exoplatform.services.jcr.datamodel.QPathEntry;
import org.exoplatform.services.jcr.impl.Constants;
+import org.exoplatform.services.jcr.infinispan.CacheKey;
/**
* Created by The eXo Platform SAS. <br/>
@@ -40,28 +41,14 @@
super();
}
- CacheQPath(String parentId, QPath path, ItemType itemType)
+ CacheQPath(String ownerId, String parentId, QPath path, ItemType itemType)
{
- this(parentId, path.getEntries()[path.getEntries().length - 1], itemType);
+ this(ownerId, parentId, path.getEntries()[path.getEntries().length - 1],
itemType);
}
- CacheQPath(String parentId, QPathEntry name, ItemType itemType)
+ CacheQPath(String ownerId, String parentId, QPathEntry name, ItemType itemType)
{
- super(new StringBuilder().append(parentId != null ? parentId :
Constants.ROOT_PARENT_UUID)
+ super(ownerId, new StringBuilder().append(parentId != null ? parentId :
Constants.ROOT_PARENT_UUID)
.append(name.getAsString(true)).append(itemType.toString()).toString(),
parentId);
}
-
- @Override
- public boolean equals(Object obj)
- {
- if (obj instanceof CacheQPath)
- {
- CacheQPath cacheQPath = (CacheQPath)obj;
- return (cacheQPath.hash == hash && cacheQPath.id.equals(id));
- }
- else
- {
- return false;
- }
- }
}
Modified:
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CacheRefsId.java
===================================================================
---
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CacheRefsId.java 2012-01-19
14:28:39 UTC (rev 5485)
+++
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CacheRefsId.java 2012-01-19
18:45:11 UTC (rev 5486)
@@ -18,6 +18,8 @@
*/
package org.exoplatform.services.jcr.impl.dataflow.persistent.infinispan;
+import org.exoplatform.services.jcr.infinispan.CacheKey;
+
/**
* Created by The eXo Platform SAS
*
@@ -35,22 +37,8 @@
super();
}
- CacheRefsId(String id)
+ CacheRefsId(String ownerId, String id)
{
- super(id);
+ super(ownerId, id);
}
-
- @Override
- public boolean equals(Object obj)
- {
- if (obj instanceof CacheRefsId)
- {
- CacheRefsId cachePropsId = (CacheRefsId)obj;
- return (cachePropsId.hash == hash && cachePropsId.id.equals(id));
- }
- else
- {
- return false;
- }
- }
}
Modified:
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/ISPNCacheWorkspaceStorageCache.java
===================================================================
---
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/ISPNCacheWorkspaceStorageCache.java 2012-01-19
14:28:39 UTC (rev 5485)
+++
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/ISPNCacheWorkspaceStorageCache.java 2012-01-19
18:45:11 UTC (rev 5486)
@@ -18,9 +18,13 @@
*/
package org.exoplatform.services.jcr.impl.dataflow.persistent.infinispan;
+import org.exoplatform.commons.utils.SecurityHelper;
+import org.exoplatform.container.ExoContainer;
+import org.exoplatform.container.ExoContainerContext;
import org.exoplatform.container.configuration.ConfigurationManager;
import org.exoplatform.management.annotations.Managed;
import org.exoplatform.management.annotations.ManagedDescription;
+import org.exoplatform.services.ispn.DistributedCacheManager;
import org.exoplatform.services.jcr.access.AccessControlList;
import org.exoplatform.services.jcr.config.CacheEntry;
import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
@@ -49,11 +53,20 @@
import org.exoplatform.services.jcr.impl.core.itemfilters.QPathEntryFilter;
import org.exoplatform.services.jcr.impl.dataflow.TransientNodeData;
import org.exoplatform.services.jcr.impl.dataflow.TransientPropertyData;
+import org.exoplatform.services.jcr.infinispan.AbstractMapper;
+import org.exoplatform.services.jcr.infinispan.CacheKey;
import org.exoplatform.services.jcr.infinispan.ISPNCacheFactory;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
import org.exoplatform.services.transaction.ActionNonTxAware;
+import org.exoplatform.services.transaction.TransactionService;
import org.infinispan.Cache;
+import org.infinispan.configuration.cache.CacheMode;
+import org.infinispan.configuration.cache.Configuration;
+import org.infinispan.context.Flag;
+import org.infinispan.distexec.mapreduce.Collector;
+import org.infinispan.distexec.mapreduce.MapReduceTask;
+import org.infinispan.distexec.mapreduce.Reducer;
import org.infinispan.lifecycle.ComponentStatus;
import org.infinispan.notifications.Listener;
import org.infinispan.notifications.cachelistener.annotation.CacheEntryModified;
@@ -61,6 +74,9 @@
import java.io.File;
import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@@ -75,6 +91,9 @@
import javax.jcr.PropertyType;
import javax.jcr.RepositoryException;
+import javax.transaction.Status;
+import javax.transaction.Synchronization;
+import javax.transaction.SystemException;
import javax.transaction.TransactionManager;
/**
@@ -98,23 +117,42 @@
* @author <a href="anatoliy.bazko(a)exoplatform.org">Anatoliy
Bazko</a>
* @version $Id: ISPNCacheWorkspaceStorageCache.java 3514 2010-11-22 16:14:36Z
nzamosenchuk $
*/
+@SuppressWarnings("unchecked")
public class ISPNCacheWorkspaceStorageCache implements WorkspaceStorageCache, Backupable
{
- private static final Log LOG =
ExoLogger.getLogger("exo.jcr.component.core.impl.infinispan.v5.ISPNCacheWorkspaceStorageCache");
+ private static final Log LOG = ExoLogger
+
.getLogger("exo.jcr.component.core.impl.infinispan.v5.ISPNCacheWorkspaceStorageCache");
+ /**
+ * Name of the cache in case of the distributed cache
+ */
+ private static final String CACHE_NAME = "JCRCache";
+
+ /**
+ * This id will be the unique identifier of the workspace in case the
+ * distributed mode is enabled as the cache will be then shared so we
+ * need this id to prevent mixing data of different workspace. In case
+ * the workspace is not distributed the value of this variable will be
+ * null to avoid consuming more memory for nothing
+ */
+ protected final String ownerId;
+
private final boolean enabled;
-
+
protected final BufferedISPNCache cache;
-
+
+ private final GlobalOperationCaller caller;
+
/**
* The list of all the listeners
*/
- private final List<WorkspaceStorageCacheListener> listeners = new
CopyOnWriteArrayList<WorkspaceStorageCacheListener>();
+ private final List<WorkspaceStorageCacheListener> listeners =
+ new CopyOnWriteArrayList<WorkspaceStorageCacheListener>();
private final CacheActionNonTxAware<Void, Void> commitTransaction = new
CacheActionNonTxAware<Void, Void>()
{
@Override
- protected Void execute(Void arg) throws RuntimeException
+ protected Void execute(Void arg)
{
cache.commitTransaction();
return null;
@@ -125,9 +163,9 @@
new CacheActionNonTxAware<ItemData, String>()
{
@Override
- protected ItemData execute(String id) throws RuntimeException
+ protected ItemData execute(String id)
{
- return id == null ? null : (ItemData)cache.get(new CacheId(id));
+ return id == null ? null : (ItemData)cache.get(new CacheId(getOwnerId(),
id));
}
};
@@ -135,10 +173,10 @@
new CacheActionNonTxAware<List<NodeData>, NodeData>()
{
@Override
- protected List<NodeData> execute(NodeData parent) throws RuntimeException
+ protected List<NodeData> execute(NodeData parent)
{
// get list of children uuids
- final Set<String> set = (Set<String>)cache.get(new
CacheNodesId(parent.getIdentifier()));
+ final Set<String> set = (Set<String>)cache.get(new
CacheNodesId(getOwnerId(), parent.getIdentifier()));
if (set != null)
{
@@ -146,7 +184,7 @@
for (String childId : set)
{
- NodeData child = (NodeData)cache.get(new CacheId(childId));
+ NodeData child = (NodeData)cache.get(new CacheId(getOwnerId(),
childId));
if (child == null)
{
return null;
@@ -170,7 +208,7 @@
new CacheActionNonTxAware<ItemData, Object>()
{
@Override
- protected ItemData execute(Object... args) throws RuntimeException
+ protected ItemData execute(Object... args)
{
String parentIdentifier = (String)args[0];
QPathEntry name = (QPathEntry)args[1];
@@ -180,12 +218,13 @@
if (itemType == ItemType.UNKNOWN)
{
// Try as node first.
- itemId = (String)cache.get(new CacheQPath(parentIdentifier, name,
ItemType.NODE));
+ itemId = (String)cache.get(new CacheQPath(getOwnerId(), parentIdentifier,
name, ItemType.NODE));
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(new CacheQPath(parentIdentifier,
name, ItemType.PROPERTY));
+ String propId =
+ (String)cache.get(new CacheQPath(getOwnerId(), parentIdentifier,
name, ItemType.PROPERTY));
if (propId != null)
{
itemId = propId;
@@ -194,11 +233,11 @@
}
else if (itemType == ItemType.NODE)
{
- itemId = (String)cache.get(new CacheQPath(parentIdentifier, name,
ItemType.NODE));;
+ itemId = (String)cache.get(new CacheQPath(getOwnerId(), parentIdentifier,
name, ItemType.NODE));;
}
else
{
- itemId = (String)cache.get(new CacheQPath(parentIdentifier, name,
ItemType.PROPERTY));;
+ itemId = (String)cache.get(new CacheQPath(getOwnerId(), parentIdentifier,
name, ItemType.PROPERTY));;
}
if (itemId != null)
@@ -227,9 +266,9 @@
new CacheActionNonTxAware<Integer, NodeData>()
{
@Override
- protected Integer execute(NodeData parent) throws RuntimeException
+ protected Integer execute(NodeData parent)
{
- Set<String> list = (Set<String>)cache.get(new
CacheNodesId(parent.getIdentifier()));
+ Set<String> list = (Set<String>)cache.get(new
CacheNodesId(getOwnerId(), parent.getIdentifier()));
return list != null ? list.size() : -1;
}
};
@@ -238,19 +277,19 @@
new CacheActionNonTxAware<List<PropertyData>, Object>()
{
@Override
- protected List<PropertyData> execute(Object... args) throws
RuntimeException
+ protected List<PropertyData> execute(Object... args)
{
String parentId = (String)args[0];
boolean withValue = (Boolean)args[1];
// get list of children uuids
- final Set<String> set = (Set<String>)cache.get(new
CachePropsId(parentId));
+ final Set<String> set = (Set<String>)cache.get(new
CachePropsId(getOwnerId(), parentId));
if (set != null)
{
final List<PropertyData> childs = new
ArrayList<PropertyData>();
for (String childId : set)
{
- PropertyData child = (PropertyData)cache.get(new CacheId(childId));
+ PropertyData child = (PropertyData)cache.get(new CacheId(getOwnerId(),
childId));
if (child == null)
{
@@ -275,17 +314,17 @@
new CacheActionNonTxAware<List<PropertyData>, String>()
{
@Override
- protected List<PropertyData> execute(String identifier) throws
RuntimeException
+ protected List<PropertyData> execute(String identifier)
{
// get list of children uuids
- final Set<String> set = (Set<String>)cache.get(new
CacheRefsId(identifier));
+ final Set<String> set = (Set<String>)cache.get(new
CacheRefsId(getOwnerId(), identifier));
if (set != null)
{
final List<PropertyData> props = new
ArrayList<PropertyData>();
for (String childId : set)
{
- PropertyData prop = (PropertyData)cache.get(new CacheId(childId));
+ PropertyData prop = (PropertyData)cache.get(new CacheId(getOwnerId(),
childId));
if (prop == null || prop instanceof NullItemData)
{
@@ -327,9 +366,9 @@
private final CacheActionNonTxAware<Long, Void> getSize = new
CacheActionNonTxAware<Long, Void>()
{
@Override
- protected Long execute(Void arg) throws RuntimeException
+ protected Long execute(Void arg)
{
- return (long)cache.size();
+ return (long)caller.getCacheSize();
}
};
@@ -377,7 +416,7 @@
T n = null;
do
{
- n = (T)cache.get(new CacheId(childs.next()));
+ n = (T)cache.get(new CacheId(getOwnerId(), childs.next()));
}
while (n == null && childs.hasNext());
next = n;
@@ -415,7 +454,7 @@
{
ChildNodesIterator(String parentId)
{
- super(new CacheNodesId(parentId));
+ super(new CacheNodesId(getOwnerId(), parentId));
}
@Override
@@ -430,7 +469,7 @@
ChildPropertiesIterator(String parentId)
{
- super(new CachePropsId(parentId));
+ super(new CachePropsId(getOwnerId(), parentId));
}
@Override
@@ -441,41 +480,130 @@
}
/**
- * Cache constructor with eXo TransactionService support.
+ * Cache constructor.
*
- * @param wsConfig WorkspaceEntry workspace config
+ * @param wsConfig WorkspaceEntry workspace configuration
+ * @param cfm The configuration manager
* @throws RepositoryException if error of initialization
* @throws RepositoryConfigurationException if error of configuration
*/
public ISPNCacheWorkspaceStorageCache(WorkspaceEntry wsConfig, ConfigurationManager
cfm) throws RepositoryException,
RepositoryConfigurationException
{
+ this(null, wsConfig, cfm, null, null);
+ }
+
+ /**
+ * Cache constructor.
+ *
+ * @param ctx The {@link ExoContainerContext} that owns the current component
+ * @param wsConfig WorkspaceEntry workspace configuration
+ * @param cfm The configuration manager
+ * @param ts TransactionService external transaction service
+ * @throws RepositoryException if error of initialization
+ * @throws RepositoryConfigurationException if error of configuration
+ */
+ public ISPNCacheWorkspaceStorageCache(ExoContainerContext ctx, WorkspaceEntry
wsConfig, ConfigurationManager cfm,
+ TransactionService ts) throws RepositoryException,
RepositoryConfigurationException
+ {
+ this(ctx, wsConfig, cfm, null, ts);
+ }
+
+ /**
+ * Cache constructor.
+ *
+ * @param ctx The {@link ExoContainerContext} that owns the current component
+ * @param wsConfig WorkspaceEntry workspace configuration
+ * @param cfm The configuration manager
+ * @param dcm The distributed cache manager
+ * @throws RepositoryException if error of initialization
+ * @throws RepositoryConfigurationException if error of configuration
+ */
+ public ISPNCacheWorkspaceStorageCache(ExoContainerContext ctx, WorkspaceEntry
wsConfig, ConfigurationManager cfm,
+ DistributedCacheManager dcm) throws RepositoryException,
RepositoryConfigurationException
+ {
+ this(ctx, wsConfig, cfm, dcm, null);
+ }
+
+ /**
+ * Cache constructor.
+ *
+ * @param ctx The {@link ExoContainerContext} that owns the current component
+ * @param wsConfig WorkspaceEntry workspace configuration
+ * @param cfm The configuration manager
+ * @param dcm The distributed cache manager
+ * @param ts TransactionService external transaction service
+ * @throws RepositoryException if error of initialization
+ * @throws RepositoryConfigurationException if error of configuration
+ */
+ public ISPNCacheWorkspaceStorageCache(ExoContainerContext ctx, WorkspaceEntry
wsConfig, ConfigurationManager cfm,
+ DistributedCacheManager dcm, TransactionService ts) throws RepositoryException,
RepositoryConfigurationException
+ {
if (wsConfig.getCache() == null)
{
throw new RepositoryConfigurationException("Cache configuration not
found");
}
this.enabled = wsConfig.getCache().isEnabled();
-
+
// create cache using custom factory
- ISPNCacheFactory<CacheKey, Object> factory = new
ISPNCacheFactory<CacheKey, Object>(cfm);
+ ISPNCacheFactory<CacheKey, Object> factory =
+ new ISPNCacheFactory<CacheKey, Object>(cfm, ts == null ? null :
ts.getTransactionManager());
// create parent Infinispan instance
CacheEntry cacheEntry = wsConfig.getCache();
- Cache<CacheKey, Object> parentCache = factory.createCache("Data_" +
wsConfig.getUniqueName(), cacheEntry);
-
- Boolean allowLocalChanges = null;
- try
+ boolean useDistributedCache =
cacheEntry.getParameterBoolean("use-distributed-cache", false);
+ Cache<CacheKey, Object> parentCache;
+ if (useDistributedCache)
{
- allowLocalChanges =
cacheEntry.getParameterBoolean("allow-local-changes");
+ // We expect a distributed cache
+ if (dcm == null)
+ {
+ throw new IllegalArgumentException("The DistributedCacheManager has not
been defined in the configuration,"
+ + " please configure it at root container level if you want to use a
distributed cache.");
+ }
+ parentCache = dcm.getCache(CACHE_NAME);
+ this.ownerId = ctx.getName();
+ if (LOG.isDebugEnabled())
+ {
+ LOG.debug("The distributed cache has been enabled for the workspace
whose unique id is " + ownerId);
+ }
}
- catch (RepositoryConfigurationException e)
+ else
{
- // do n't nothing
+ parentCache = factory.createCache("Data_" + wsConfig.getUniqueName(),
cacheEntry);
+ Configuration config = parentCache.getCacheConfiguration();
+ if (config.clustering().cacheMode() == CacheMode.DIST_SYNC
+ || config.clustering().cacheMode() == CacheMode.DIST_ASYNC)
+ {
+ throw new IllegalArgumentException("Cache configuration not allowed, if
you want to use the distributed "
+ + "cache please enable the parameter 'use-distributed-cache'
and configure the DistributedCacheManager.");
+ }
+ this.ownerId = null;
}
+ Boolean allowLocalChanges =
+ useDistributedCache ?
cacheEntry.getParameterBoolean("allow-local-changes", Boolean.TRUE) :
Boolean.TRUE;
this.cache = new BufferedISPNCache(parentCache, allowLocalChanges);
- cache.addListener(new CacheEventListener());
+ if (useDistributedCache)
+ {
+ this.caller = new DistributedOperationCaller();
+ }
+ else
+ {
+ this.caller = new GlobalOperationCaller();
+ cache.addListener(new CacheEventListener());
+ }
}
+ private boolean isDistributedMode()
+ {
+ return ownerId != null;
+ }
+
+ private String getOwnerId()
+ {
+ return ownerId;
+ }
+
/**
* Return TransactionManager used by ISPN backing the JCR cache.
*
@@ -615,7 +743,7 @@
cache.setLocal(true);
- CacheNodesByPageId cacheId = new CacheNodesByPageId(parent.getIdentifier());
+ CacheNodesByPageId cacheId = new CacheNodesByPageId(getOwnerId(),
parent.getIdentifier());
Map<Integer, Set<String>> pages = (Map<Integer,
Set<String>>)cache.get(cacheId);
if (pages == null)
{
@@ -673,12 +801,12 @@
putNode(child, ModifyChildOption.NOT_MODIFY);
set.add(child.getIdentifier());
}
- cache.putIfAbsent(new CacheNodesId(parent.getIdentifier()), set);
+ cache.putIfAbsent(new CacheNodesId(getOwnerId(), parent.getIdentifier()),
set);
}
else
{
// cache fact of empty childs list
- cache.putIfAbsent(new CacheNodesId(parent.getIdentifier()), new
HashSet<Object>());
+ cache.putIfAbsent(new CacheNodesId(getOwnerId(), parent.getIdentifier()), new
HashSet<Object>());
}
}
finally
@@ -713,7 +841,7 @@
set.add(child.getIdentifier());
}
- CachePatternNodesId cacheId = new CachePatternNodesId(parent.getIdentifier());
+ CachePatternNodesId cacheId = new CachePatternNodesId(getOwnerId(),
parent.getIdentifier());
Map<QPathEntryFilter, Set<String>> patterns =
(Map<QPathEntryFilter, Set<String>>)cache.get(cacheId);
if (patterns == null)
{
@@ -754,7 +882,7 @@
putProperty(child, ModifyChildOption.NOT_MODIFY);
set.add(child.getIdentifier());
}
- cache.putIfAbsent(new CachePropsId(parent.getIdentifier()), set);
+ cache.putIfAbsent(new CachePropsId(getOwnerId(), parent.getIdentifier()),
set);
}
else
@@ -795,7 +923,7 @@
set.add(child.getIdentifier());
}
- CachePatternPropsId cacheId = new
CachePatternPropsId(parent.getIdentifier());
+ CachePatternPropsId cacheId = new CachePatternPropsId(getOwnerId(),
parent.getIdentifier());
Map<QPathEntryFilter, Set<String>> patterns =
(Map<QPathEntryFilter, Set<String>>)cache.get(cacheId);
if (patterns == null)
{
@@ -862,7 +990,7 @@
{
// get list of children uuids
final Map<Integer, Set<String>> pages =
- (Map<Integer, Set<String>>)cache.get(new
CacheNodesByPageId(parent.getIdentifier()));
+ (Map<Integer, Set<String>>)cache.get(new
CacheNodesByPageId(getOwnerId(), parent.getIdentifier()));
if (pages == null)
{
@@ -878,7 +1006,7 @@
final List<NodeData> childs = new ArrayList<NodeData>();
for (String childId : set)
{
- NodeData child = (NodeData)cache.get(new CacheId(childId));
+ NodeData child = (NodeData)cache.get(new CacheId(getOwnerId(), childId));
if (child == null)
{
return null;
@@ -899,7 +1027,7 @@
{
// get list of children uuids
final Map<QPathEntryFilter, Set<String>> patterns =
- (Map<QPathEntryFilter, Set<String>>)cache.get(new
CachePatternNodesId(parent.getIdentifier()));
+ (Map<QPathEntryFilter, Set<String>>)cache.get(new
CachePatternNodesId(getOwnerId(), parent.getIdentifier()));
if (patterns == null)
{
@@ -916,7 +1044,7 @@
for (String childId : set)
{
- NodeData child = (NodeData)cache.get(new CacheId(childId));
+ NodeData child = (NodeData)cache.get(new CacheId(getOwnerId(), childId));
if (child == null)
{
return null;
@@ -951,7 +1079,7 @@
{
// get list of children uuids
final Map<QPathEntryFilter, Set<String>> patterns =
- (Map<QPathEntryFilter, Set<String>>)cache.get(new
CachePatternPropsId(parent.getIdentifier()));
+ (Map<QPathEntryFilter, Set<String>>)cache.get(new
CachePatternPropsId(getOwnerId(), parent.getIdentifier()));
if (patterns == null)
{
@@ -968,7 +1096,7 @@
for (String childId : set)
{
- PropertyData child = (PropertyData)cache.get(new CacheId(childId));
+ PropertyData child = (PropertyData)cache.get(new CacheId(getOwnerId(),
childId));
if (child == null)
{
@@ -1027,7 +1155,7 @@
{
return true;
}
-
+
/**
* {@inheritDoc}
*/
@@ -1079,32 +1207,33 @@
{
if (modifyListsOfChild == ModifyChildOption.NOT_MODIFY)
{
- cache.putIfAbsent(new CacheQPath(node.getParentIdentifier(), node.getQPath(),
ItemType.NODE), node
- .getIdentifier());
+ cache.putIfAbsent(new CacheQPath(getOwnerId(), node.getParentIdentifier(),
node.getQPath(), ItemType.NODE),
+ node.getIdentifier());
}
else
{
- cache.put(new CacheQPath(node.getParentIdentifier(), node.getQPath(),
ItemType.NODE), node.getIdentifier());
+ cache.put(new CacheQPath(getOwnerId(), node.getParentIdentifier(),
node.getQPath(), ItemType.NODE),
+ node.getIdentifier());
}
// if MODIFY and List present OR FORCE_MODIFY, then write
if (modifyListsOfChild != ModifyChildOption.NOT_MODIFY)
{
- cache.addToPatternList(new CachePatternNodesId(node.getParentIdentifier()),
node);
- cache.addToList(new CacheNodesId(node.getParentIdentifier()),
node.getIdentifier(),
+ cache.addToPatternList(new CachePatternNodesId(getOwnerId(),
node.getParentIdentifier()), node);
+ cache.addToList(new CacheNodesId(getOwnerId(), node.getParentIdentifier()),
node.getIdentifier(),
modifyListsOfChild == ModifyChildOption.FORCE_MODIFY);
- cache.remove(new CacheNodesByPageId(node.getParentIdentifier()));
+ cache.remove(new CacheNodesByPageId(getOwnerId(),
node.getParentIdentifier()));
}
}
if (modifyListsOfChild == ModifyChildOption.NOT_MODIFY)
{
- return (ItemData)cache.putIfAbsent(new CacheId(node.getIdentifier()), node);
+ return (ItemData)cache.putIfAbsent(new CacheId(getOwnerId(),
node.getIdentifier()), node);
}
else
{
- return (ItemData)cache.put(new CacheId(node.getIdentifier()), node, true);
+ return (ItemData)cache.put(new CacheId(getOwnerId(), node.getIdentifier()),
node, true);
}
}
@@ -1112,18 +1241,19 @@
{
if (node.getParentIdentifier() != null)
{
- cache.put(new CacheQPath(node.getParentIdentifier(), node.getQPath(),
ItemType.NODE), node.getIdentifier());
+ cache.put(new CacheQPath(getOwnerId(), node.getParentIdentifier(),
node.getQPath(), ItemType.NODE),
+ node.getIdentifier());
// if MODIFY and List present OR FORCE_MODIFY, then write
if (modifyListsOfChild != ModifyChildOption.NOT_MODIFY)
{
- cache.addToList(new CacheNodesId(node.getParentIdentifier()),
node.getIdentifier(),
+ cache.addToList(new CacheNodesId(getOwnerId(), node.getParentIdentifier()),
node.getIdentifier(),
modifyListsOfChild == ModifyChildOption.FORCE_MODIFY);
}
}
// NullNodeData must never be returned inside internal cache operations.
- ItemData itemData = (ItemData)cache.putInBuffer(new CacheId(node.getIdentifier()),
node);
+ ItemData itemData = (ItemData)cache.putInBuffer(new CacheId(getOwnerId(),
node.getIdentifier()), node);
return (itemData instanceof NullItemData) ? null : itemData;
}
@@ -1145,11 +1275,12 @@
if (!item.getIdentifier().equals(NullItemData.NULL_ID))
{
- cache.putIfAbsent(new CacheId(item.getIdentifier()), item);
+ cache.putIfAbsent(new CacheId(getOwnerId(), item.getIdentifier()), item);
}
else if (item.getName() != null && item.getParentIdentifier() != null)
{
- cache.putIfAbsent(new CacheQPath(item.getParentIdentifier(), item.getName(),
ItemType.getItemType(item)),
+ cache.putIfAbsent(
+ new CacheQPath(getOwnerId(), item.getParentIdentifier(), item.getName(),
ItemType.getItemType(item)),
NullItemData.NULL_ID);
}
}
@@ -1174,20 +1305,22 @@
// if MODIFY and List present OR FORCE_MODIFY, then write
if (modifyListsOfChild != ModifyChildOption.NOT_MODIFY)
{
- cache.addToPatternList(new CachePatternPropsId(prop.getParentIdentifier()),
prop);
- cache.addToList(new CachePropsId(prop.getParentIdentifier()),
prop.getIdentifier(),
+ cache.addToPatternList(new CachePatternPropsId(getOwnerId(),
prop.getParentIdentifier()), prop);
+ cache.addToList(new CachePropsId(getOwnerId(), prop.getParentIdentifier()),
prop.getIdentifier(),
modifyListsOfChild == ModifyChildOption.FORCE_MODIFY);
}
if (modifyListsOfChild == ModifyChildOption.NOT_MODIFY)
{
- cache.putIfAbsent(new CacheQPath(prop.getParentIdentifier(), prop.getQPath(),
ItemType.PROPERTY), prop.getIdentifier());
+ cache.putIfAbsent(
+ new CacheQPath(getOwnerId(), prop.getParentIdentifier(), prop.getQPath(),
ItemType.PROPERTY),
+ prop.getIdentifier());
}
else
{
- cache.put(new CacheQPath(prop.getParentIdentifier(), prop.getQPath(),
ItemType.PROPERTY), prop.getIdentifier());
+ cache.put(new CacheQPath(getOwnerId(), prop.getParentIdentifier(),
prop.getQPath(), ItemType.PROPERTY),
+ prop.getIdentifier());
}
-
// add referenced property
if (modifyListsOfChild != ModifyChildOption.NOT_MODIFY && prop.getType() ==
PropertyType.REFERENCE)
{
@@ -1208,7 +1341,7 @@
{
// Do nothing. Never happens.
}
- cache.addToList(new CacheRefsId(nodeIdentifier), prop.getIdentifier(),
+ cache.addToList(new CacheRefsId(getOwnerId(), nodeIdentifier),
prop.getIdentifier(),
modifyListsOfChild == ModifyChildOption.FORCE_MODIFY);
}
}
@@ -1216,41 +1349,42 @@
PropertyData propData;
if (modifyListsOfChild == ModifyChildOption.NOT_MODIFY)
{
- propData = (PropertyData)cache.putIfAbsent(new CacheId(prop.getIdentifier()),
prop);
+ propData = (PropertyData)cache.putIfAbsent(new CacheId(getOwnerId(),
prop.getIdentifier()), prop);
}
else
{
- propData = (PropertyData)cache.put(new CacheId(prop.getIdentifier()), prop,
true);
+ propData = (PropertyData)cache.put(new CacheId(getOwnerId(),
prop.getIdentifier()), prop, true);
}
-
+
return (propData instanceof NullPropertyData) ? null : propData;
}
protected void removeItem(ItemData item)
{
- cache.remove(new CacheId(item.getIdentifier()));
- cache.remove(new CacheQPath(item.getParentIdentifier(), item.getQPath(),
ItemType.getItemType(item)));
+ cache.remove(new CacheId(getOwnerId(), item.getIdentifier()));
+ cache
+ .remove(new CacheQPath(getOwnerId(), item.getParentIdentifier(),
item.getQPath(), ItemType.getItemType(item)));
if (item.isNode())
{
if (item.getParentIdentifier() != null)
{
- cache.removeFromPatternList(new
CachePatternNodesId(item.getParentIdentifier()), item);
- cache.removeFromList(new CacheNodesId(item.getParentIdentifier()),
item.getIdentifier());
- cache.remove(new CacheNodesByPageId(item.getParentIdentifier()));
+ cache.removeFromPatternList(new CachePatternNodesId(getOwnerId(),
item.getParentIdentifier()), item);
+ cache.removeFromList(new CacheNodesId(getOwnerId(),
item.getParentIdentifier()), item.getIdentifier());
+ cache.remove(new CacheNodesByPageId(getOwnerId(),
item.getParentIdentifier()));
}
- cache.remove(new CacheNodesId(item.getIdentifier()));
- cache.remove(new CachePropsId(item.getIdentifier()));
- cache.remove(new CacheNodesByPageId(item.getIdentifier()));
- cache.remove(new CachePatternNodesId(item.getIdentifier()));
- cache.remove(new CachePatternPropsId(item.getIdentifier()));
- cache.remove(new CacheRefsId(item.getIdentifier()));
+ cache.remove(new CacheNodesId(getOwnerId(), item.getIdentifier()));
+ cache.remove(new CachePropsId(getOwnerId(), item.getIdentifier()));
+ cache.remove(new CacheNodesByPageId(getOwnerId(), item.getIdentifier()));
+ cache.remove(new CachePatternNodesId(getOwnerId(), item.getIdentifier()));
+ cache.remove(new CachePatternPropsId(getOwnerId(), item.getIdentifier()));
+ cache.remove(new CacheRefsId(getOwnerId(), item.getIdentifier()));
}
else
{
- cache.removeFromPatternList(new CachePatternPropsId(item.getParentIdentifier()),
item);
- cache.removeFromList(new CachePropsId(item.getParentIdentifier()),
item.getIdentifier());
+ cache.removeFromPatternList(new CachePatternPropsId(getOwnerId(),
item.getParentIdentifier()), item);
+ cache.removeFromList(new CachePropsId(getOwnerId(), item.getParentIdentifier()),
item.getIdentifier());
}
}
@@ -1261,7 +1395,7 @@
*/
protected void updateMixin(NodeData node)
{
- NodeData prevData = (NodeData)cache.put(new CacheId(node.getIdentifier()), node,
true);
+ NodeData prevData = (NodeData)cache.put(new CacheId(getOwnerId(),
node.getIdentifier()), node, true);
// prevent update NullNodeData
if (!(prevData instanceof NullNodeData))
{
@@ -1291,7 +1425,7 @@
protected void updateInBuffer(final NodeData node, final NodeData prevNode)
{
// I expect that NullNodeData will never update existing NodeData.
- CacheQPath prevKey = new CacheQPath(node.getParentIdentifier(),
prevNode.getQPath(), ItemType.NODE);
+ CacheQPath prevKey = new CacheQPath(getOwnerId(), node.getParentIdentifier(),
prevNode.getQPath(), ItemType.NODE);
if (node.getIdentifier().equals(cache.getFromBuffer(prevKey)))
{
cache.remove(prevKey);
@@ -1316,75 +1450,7 @@
*/
protected void updateTreePath(final QPath prevRootPath, final QPath newRootPath, final
AccessControlList acl)
{
- boolean inheritACL = acl != null;
-
- // check all ITEMS in cache
- Iterator<CacheKey> keys = cache.keySet().iterator();
-
- while (keys.hasNext())
- {
- CacheKey key = keys.next();
- if (key instanceof CacheId)
- {
- ItemData data = (ItemData)cache.get(key);
-
- if (data != null)
- {
- // check is this descendant of prevRootPath
- QPath nodeQPath = data.getQPath();
- if (nodeQPath != null && nodeQPath.isDescendantOf(prevRootPath))
- {
- //make relative path
- QPathEntry[] relativePath = null;
- try
- {
- relativePath = nodeQPath.getRelPath(nodeQPath.getDepth() -
prevRootPath.getDepth());
- }
- catch (IllegalPathException e)
- {
- // Do nothing. Never happens.
- }
-
- // make new path - no matter node or property
- QPath newPath = QPath.makeChildPath(newRootPath, relativePath);
-
- if (data.isNode())
- {
- // update node
- NodeData prevNode = (NodeData)data;
-
- TransientNodeData newNode =
- new TransientNodeData(newPath, prevNode.getIdentifier(),
prevNode.getPersistedVersion(),
- prevNode.getPrimaryTypeName(), prevNode.getMixinTypeNames(),
prevNode.getOrderNumber(),
- prevNode.getParentIdentifier(), inheritACL ? acl :
prevNode.getACL());
-
- // update this node
- cache.put(new CacheId(newNode.getIdentifier()), newNode);
- }
- else
- {
- //update property
- PropertyData prevProp = (PropertyData)data;
-
- if (inheritACL
- &&
(prevProp.getQPath().getName().equals(Constants.EXO_PERMISSIONS) || prevProp.getQPath()
- .getName().equals(Constants.EXO_OWNER)))
- {
- inheritACL = false;
- }
-
- TransientPropertyData newProp =
- new TransientPropertyData(newPath, prevProp.getIdentifier(),
prevProp.getPersistedVersion(),
- prevProp.getType(), prevProp.getParentIdentifier(),
prevProp.isMultiValued(), prevProp
- .getValues());
-
- // update this property
- cache.put(new CacheId(newProp.getIdentifier()), newProp);
- }
- }
- }
- }
- }
+ caller.updateTreePath(prevRootPath, newRootPath, acl);
}
/**
@@ -1393,33 +1459,9 @@
* @param parentId String - root node id of JCR subtree.
* @param acl AccessControlList
*/
- protected void updateChildsACL(final String parentId, final AccessControlList acl)
+ protected void updateChildsACL(String parentId, AccessControlList acl)
{
- loop: for (Iterator<NodeData> iter = new
ChildNodesIterator<NodeData>(parentId); iter.hasNext();)
- {
- NodeData prevNode = iter.next();
-
- // is ACL changes on this node (i.e. ACL inheritance brokes)
- for (InternalQName mixin : prevNode.getMixinTypeNames())
- {
- if (mixin.equals(Constants.EXO_PRIVILEGEABLE) ||
mixin.equals(Constants.EXO_OWNEABLE))
- {
- continue loop;
- }
- }
-
- // recreate with new path for child Nodes only
- TransientNodeData newNode =
- new TransientNodeData(prevNode.getQPath(), prevNode.getIdentifier(),
prevNode.getPersistedVersion(),
- prevNode.getPrimaryTypeName(), prevNode.getMixinTypeNames(),
prevNode.getOrderNumber(), prevNode
- .getParentIdentifier(), acl);
-
- // update this node
- cache.put(new CacheId(newNode.getIdentifier()), newNode);
-
- // update childs recursive
- updateChildsACL(newNode.getIdentifier(), acl);
- }
+ caller.updateChildsACL(parentId, acl);
}
public void beginTransaction()
@@ -1485,7 +1527,7 @@
putProperty(prop, ModifyChildOption.NOT_MODIFY);
set.add(prop.getIdentifier());
}
- cache.putIfAbsent(new CacheRefsId(identifier), set);
+ cache.putIfAbsent(new CacheRefsId(getOwnerId(), identifier), set);
}
finally
{
@@ -1504,7 +1546,7 @@
{
return getReferencedProperties.run(identifier);
}
-
+
/**
* {@inheritDoc}
*/
@@ -1516,12 +1558,12 @@
* {@inheritDoc}
*/
@Managed
- @ManagedDescription("Remove all the existing items from the cache")
+ @ManagedDescription("Remove all the existing items from the cache")
public void clean() throws BackupException
{
if (cache.getStatus() == ComponentStatus.RUNNING)
{
- cache.clear();
+ caller.clearCache();
}
}
@@ -1537,7 +1579,7 @@
*/
public void clean() throws BackupException
{
- cache.clear();
+ caller.clearCache();
}
/**
@@ -1576,6 +1618,11 @@
*/
public void addListener(WorkspaceStorageCacheListener listener)
{
+ if (isDistributedMode())
+ {
+ throw new UnsupportedOperationException("The cache listeners are not
supported by the "
+ + "ISPNCacheWorkspaceStorageCache in case of the distributed
mode");
+ }
listeners.add(listener);
}
@@ -1584,9 +1631,14 @@
*/
public void removeListener(WorkspaceStorageCacheListener listener)
{
+ if (isDistributedMode())
+ {
+ throw new UnsupportedOperationException("The cache listeners are not
supported by the "
+ + "ISPNCacheWorkspaceStorageCache in case of the distributed
mode");
+ }
listeners.remove(listener);
}
-
+
/**
* Called when a cache entry corresponding to the given node has item updated
* @param data the item corresponding to the updated cache entry
@@ -1596,7 +1648,7 @@
if (data == null || data instanceof NullItemData)
{
return;
- }
+ }
for (WorkspaceStorageCacheListener listener : listeners)
{
try
@@ -1607,9 +1659,71 @@
{
LOG.warn("The method onCacheEntryUpdated fails for the listener " +
listener.getClass(), e);
}
- }
+ }
}
-
+
+ private static void updateTreePath(Cache<CacheKey, Object> cache, String
ownerId, ItemData data, QPath prevRootPath,
+ QPath newRootPath, AccessControlList acl)
+ {
+ if (data == null)
+ {
+ return;
+ }
+
+ boolean inheritACL = acl != null;
+ // check is this descendant of prevRootPath
+ QPath nodeQPath = data.getQPath();
+ if (nodeQPath != null && nodeQPath.isDescendantOf(prevRootPath))
+ {
+ //make relative path
+ QPathEntry[] relativePath = null;
+ try
+ {
+ relativePath = nodeQPath.getRelPath(nodeQPath.getDepth() -
prevRootPath.getDepth());
+ }
+ catch (IllegalPathException e)
+ {
+ // Do nothing. Never happens.
+ }
+
+ // make new path - no matter node or property
+ QPath newPath = QPath.makeChildPath(newRootPath, relativePath);
+
+ if (data.isNode())
+ {
+ // update node
+ NodeData prevNode = (NodeData)data;
+
+ TransientNodeData newNode =
+ new TransientNodeData(newPath, prevNode.getIdentifier(),
prevNode.getPersistedVersion(),
+ prevNode.getPrimaryTypeName(), prevNode.getMixinTypeNames(),
prevNode.getOrderNumber(),
+ prevNode.getParentIdentifier(), inheritACL ? acl : prevNode.getACL());
+
+ // update this node
+ cache.put(new CacheId(ownerId, newNode.getIdentifier()), newNode);
+ }
+ else
+ {
+ //update property
+ PropertyData prevProp = (PropertyData)data;
+
+ if (inheritACL
+ &&
(prevProp.getQPath().getName().equals(Constants.EXO_PERMISSIONS) ||
prevProp.getQPath().getName()
+ .equals(Constants.EXO_OWNER)))
+ {
+ inheritACL = false;
+ }
+
+ TransientPropertyData newProp =
+ new TransientPropertyData(newPath, prevProp.getIdentifier(),
prevProp.getPersistedVersion(),
+ prevProp.getType(), prevProp.getParentIdentifier(),
prevProp.isMultiValued(), prevProp.getValues());
+
+ // update this property
+ cache.put(new CacheId(ownerId, newProp.getIdentifier()), newProp);
+ }
+ }
+ }
+
/**
* Actions that are not supposed to be called within a transaction
*
@@ -1628,7 +1742,7 @@
return ISPNCacheWorkspaceStorageCache.this.getTransactionManager();
}
}
-
+
@SuppressWarnings("rawtypes")
@Listener
public class CacheEventListener
@@ -1643,5 +1757,546 @@
onCacheEntryUpdated(value);
}
}
- }
+ }
+
+ /**
+ * This class defines all the methods that could change between the replicated and the
distributed mode. By default it implements
+ * the methods for the local and replicated mode.
+ *
+ */
+ private class GlobalOperationCaller
+ {
+ protected int getCacheSize()
+ {
+ return cache.size();
+ }
+
+ protected void clearCache()
+ {
+ cache.clear();
+ }
+
+ /**
+ * Update child Nodes ACLs.
+ *
+ * @param parentId String - root node id of JCR subtree.
+ * @param acl AccessControlList
+ */
+ protected void updateChildsACL(String parentId, AccessControlList acl)
+ {
+ loop : for (Iterator<NodeData> iter = new
ChildNodesIterator<NodeData>(parentId); iter.hasNext();)
+ {
+ NodeData prevNode = iter.next();
+
+ // is ACL changes on this node (i.e. ACL inheritance brokes)
+ for (InternalQName mixin : prevNode.getMixinTypeNames())
+ {
+ if (mixin.equals(Constants.EXO_PRIVILEGEABLE) ||
mixin.equals(Constants.EXO_OWNEABLE))
+ {
+ continue loop;
+ }
+ }
+
+ // recreate with new path for child Nodes only
+ TransientNodeData newNode =
+ new TransientNodeData(prevNode.getQPath(), prevNode.getIdentifier(),
prevNode.getPersistedVersion(),
+ prevNode.getPrimaryTypeName(), prevNode.getMixinTypeNames(),
prevNode.getOrderNumber(),
+ prevNode.getParentIdentifier(), acl);
+
+ // update this node
+ cache.put(new CacheId(getOwnerId(), newNode.getIdentifier()), newNode);
+
+ // update childs recursive
+ updateChildsACL(newNode.getIdentifier(), acl);
+ }
+ }
+
+ /**
+ * Check all items in cache - is it descendant of prevRootPath, and update path
according newRootPath.
+ *
+ * @param prevRootPath
+ * @param newRootPath
+ * @param acl
+ */
+ protected void updateTreePath(QPath prevRootPath, QPath newRootPath,
AccessControlList acl)
+ {
+
+ // check all ITEMS in cache
+ Iterator<CacheKey> keys = cache.keySet().iterator();
+
+ while (keys.hasNext())
+ {
+ CacheKey key = keys.next();
+ if (key instanceof CacheId)
+ {
+ ItemData data = (ItemData)cache.get(key);
+ ISPNCacheWorkspaceStorageCache.updateTreePath(cache, getOwnerId(), data,
prevRootPath, newRootPath, acl);
+ }
+ }
+ }
+ }
+
+ /**
+ * This class implements all the global operations for the distributed mode
+ *
+ */
+ private class DistributedOperationCaller extends GlobalOperationCaller
+ {
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected int getCacheSize()
+ {
+ Map<String, Integer> map = SecurityHelper.doPrivilegedAction(new
PrivilegedAction<Map<String, Integer>>()
+ {
+ public Map<String, Integer> run()
+ {
+ MapReduceTask<CacheKey, Object, String, Integer> task =
+ new MapReduceTask<CacheKey, Object, String, Integer>(cache);
+ task.mappedWith(new GetSizeMapper(getOwnerId())).reducedWith(new
GetSizeReducer<String>());
+ return task.execute();
+ }
+
+ });
+ int sum = 0;
+ for (Integer i : map.values())
+ {
+ sum += i;
+ }
+ return sum;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void clearCache()
+ {
+ SecurityHelper.doPrivilegedAction(new PrivilegedAction<Void>()
+ {
+ public Void run()
+ {
+ MapReduceTask<CacheKey, Object, Void, Void> task =
+ new MapReduceTask<CacheKey, Object, Void, Void>(cache);
+ task.mappedWith(new ClearCacheMapper(getOwnerId())).reducedWith(new
IdentityReducer());
+ task.execute();
+ return null;
+ }
+ });
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void updateTreePath(final QPath prevRootPath, final QPath newRootPath,
final AccessControlList acl)
+ {
+ final TransactionManager tm = getTransactionManager();
+ if (tm != null)
+ {
+ try
+ {
+ // Add the action out of the current transaction to avoid deadlocks
+ tm.getTransaction().registerSynchronization(new Synchronization()
+ {
+
+ public void beforeCompletion()
+ {
+ }
+
+ public void afterCompletion(int status)
+ {
+ if (status == Status.STATUS_COMMITTED)
+ {
+ try
+ {
+ // Since the tx is successfully committed we can call
components non tx aware
+
+ // The listeners will need to be executed outside the current
tx so we suspend
+ // the current tx we can face enlistment issues on product
like ISPN
+ tm.suspend();
+ _updateTreePath(prevRootPath, newRootPath, acl);
+ }
+ catch (SystemException e)
+ {
+ LOG.warn("Cannot suspend the transaction", e);
+ }
+ }
+ }
+ });
+ return;
+ }
+ catch (Exception e)
+ {
+ if (LOG.isDebugEnabled())
+ {
+ LOG.debug("Cannot register the synchronization to the current
transaction in order to update"
+ + " the path out of the transaction", e);
+ }
+ }
+ }
+ _updateTreePath(prevRootPath, newRootPath, acl);
+ }
+
+ private void _updateTreePath(final QPath prevRootPath, final QPath newRootPath,
final AccessControlList acl)
+ {
+ SecurityHelper.doPrivilegedAction(new PrivilegedAction<Void>()
+ {
+ public Void run()
+ {
+ MapReduceTask<CacheKey, Object, Void, Void> task =
+ new MapReduceTask<CacheKey, Object, Void, Void>(cache);
+ task.mappedWith(new UpdateTreePathMapper(getOwnerId(), prevRootPath,
newRootPath, acl))
+ .reducedWith(new IdentityReducer());
+ task.execute();
+ return null;
+ }
+ });
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void updateChildsACL(String parentId, final AccessControlList acl)
+ {
+ ItemData parentItem = get(parentId);
+ if (!(parentItem instanceof NodeData))
+ {
+ return;
+ }
+ final QPath parentPath = ((NodeData)parentItem).getQPath();
+ SecurityHelper.doPrivilegedAction(new PrivilegedAction<Void>()
+ {
+ public Void run()
+ {
+ MapReduceTask<CacheKey, Object, Void, Void> task =
+ new MapReduceTask<CacheKey, Object, Void, Void>(cache);
+ task.mappedWith(new UpdateChildsACLMapper(getOwnerId(), parentPath,
acl)).reducedWith(
+ new IdentityReducer());
+ task.execute();
+ return null;
+ }
+ });
+ }
+ }
+
+ public static class GetSizeMapper extends AbstractMapper<String, Integer>
+ {
+
+ public GetSizeMapper()
+ {
+ }
+
+ public GetSizeMapper(String ownerId)
+ {
+ super(ownerId);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void _map(CacheKey key, Object value, Collector<String, Integer>
collector)
+ {
+ collector.emit("total", Integer.valueOf(1));
+ }
+ }
+
+ public static class GetSizeReducer<K> implements Reducer<K, Integer>
+ {
+
+ /**
+ * The serial version UID
+ */
+ private static final long serialVersionUID = 7877781449514234007L;
+
+ /**
+ * @see org.infinispan.distexec.mapreduce.Reducer#reduce(java.lang.Object,
java.util.Iterator)
+ */
+ public Integer reduce(K reducedKey, Iterator<Integer> iter)
+ {
+ int sum = 0;
+ while (iter.hasNext())
+ {
+ Integer i = iter.next();
+ sum += i;
+ }
+ return sum;
+ }
+ }
+
+ public static class ClearCacheMapper extends AbstractMapper<Void, Void>
+ {
+ public ClearCacheMapper()
+ {
+ }
+
+ public ClearCacheMapper(String ownerId)
+ {
+ super(ownerId);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void _map(CacheKey key, Object value, Collector<Void, Void>
collector)
+ {
+ ExoContainer container = ExoContainerContext.getTopContainer();
+ if (container == null)
+ {
+ LOG.error("The top container could not be found");
+ return;
+ }
+ DistributedCacheManager dcm =
+
(DistributedCacheManager)container.getComponentInstanceOfType(DistributedCacheManager.class);
+ if (dcm == null)
+ {
+ LOG.error("The DistributedCacheManager could not be found at top
container level, please configure it.");
+ return;
+ }
+ Cache<CacheKey, Object> cache = dcm.getCache(CACHE_NAME);
+ cache.getAdvancedCache().withFlags(Flag.SKIP_REMOTE_LOOKUP,
Flag.FAIL_SILENTLY).remove(key);
+ }
+ }
+
+ public static class IdentityReducer implements Reducer<Void, Void>
+ {
+
+ /**
+ * The serial version UID
+ */
+ private static final long serialVersionUID = -6193360351201912040L;
+
+ /**
+ * @see org.infinispan.distexec.mapreduce.Reducer#reduce(java.lang.Object,
java.util.Iterator)
+ */
+ public Void reduce(Void reducedKey, Iterator<Void> iter)
+ {
+ return null;
+ }
+ }
+
+ public static class UpdateTreePathMapper extends AbstractMapper<Void, Void>
+ {
+ private QPath prevRootPath, newRootPath;
+
+ private AccessControlList acl;
+
+ public UpdateTreePathMapper()
+ {
+ }
+
+ public UpdateTreePathMapper(String ownerId, QPath prevRootPath, QPath newRootPath,
AccessControlList acl)
+ {
+ super(ownerId);
+ this.prevRootPath = prevRootPath;
+ this.newRootPath = newRootPath;
+ this.acl = acl;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected boolean isValid(CacheKey key)
+ {
+ return super.isValid(key) && key instanceof CacheId;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void writeExternal(ObjectOutput out) throws IOException
+ {
+ super.writeExternal(out);
+ byte[] buf = prevRootPath.getAsString().getBytes(Constants.DEFAULT_ENCODING);
+ out.writeInt(buf.length);
+ out.write(buf);
+
+ buf = newRootPath.getAsString().getBytes(Constants.DEFAULT_ENCODING);
+ out.writeInt(buf.length);
+ out.write(buf);
+
+ out.writeBoolean(acl != null);
+ if (acl != null)
+ {
+ acl.writeExternal(out);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void readExternal(ObjectInput in) throws IOException,
ClassNotFoundException
+ {
+ super.readExternal(in);
+ byte[] buf;
+
+ try
+ {
+ buf = new byte[in.readInt()];
+ in.readFully(buf);
+ String sQPath = new String(buf, Constants.DEFAULT_ENCODING);
+ prevRootPath = QPath.parse(sQPath);
+ buf = new byte[in.readInt()];
+ in.readFully(buf);
+ sQPath = new String(buf, Constants.DEFAULT_ENCODING);
+ newRootPath = QPath.parse(sQPath);
+ }
+ catch (IllegalPathException e)
+ {
+ throw new IOException("Deserialization error. ", e);
+ }
+ if (in.readBoolean())
+ {
+ this.acl = new AccessControlList();
+ acl.readExternal(in);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void _map(CacheKey key, Object value, Collector<Void, Void>
collector)
+ {
+ ExoContainer container = ExoContainerContext.getTopContainer();
+ if (container == null)
+ {
+ LOG.error("The top container could not be found");
+ return;
+ }
+ DistributedCacheManager dcm =
+
(DistributedCacheManager)container.getComponentInstanceOfType(DistributedCacheManager.class);
+ if (dcm == null)
+ {
+ LOG.error("The DistributedCacheManager could not be found at top
container level, please configure it.");
+ return;
+ }
+ Cache<CacheKey, Object> cache = dcm.getCache(CACHE_NAME);
+
ISPNCacheWorkspaceStorageCache.updateTreePath(cache.getAdvancedCache().withFlags(Flag.SKIP_REMOTE_LOOKUP),
ownerId, (ItemData)value, prevRootPath, newRootPath, acl);
+ }
+ }
+
+ public static class UpdateChildsACLMapper extends AbstractMapper<Void, Void>
+ {
+ private QPath parentPath;
+
+ private AccessControlList acl;
+
+ public UpdateChildsACLMapper()
+ {
+ }
+
+ public UpdateChildsACLMapper(String ownerId, QPath parentPath, AccessControlList
acl)
+ {
+ super(ownerId);
+ this.parentPath = parentPath;
+ this.acl = acl;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected boolean isValid(CacheKey key)
+ {
+ return super.isValid(key) && key instanceof CacheId;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void writeExternal(ObjectOutput out) throws IOException
+ {
+ super.writeExternal(out);
+ byte[] buf = parentPath.getAsString().getBytes(Constants.DEFAULT_ENCODING);
+ out.writeInt(buf.length);
+ out.write(buf);
+
+ out.writeBoolean(acl != null);
+ if (acl != null)
+ {
+ acl.writeExternal(out);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void readExternal(ObjectInput in) throws IOException,
ClassNotFoundException
+ {
+ super.readExternal(in);
+ byte[] buf;
+
+ try
+ {
+ buf = new byte[in.readInt()];
+ in.readFully(buf);
+ String sQPath = new String(buf, Constants.DEFAULT_ENCODING);
+ parentPath = QPath.parse(sQPath);
+ }
+ catch (IllegalPathException e)
+ {
+ throw new IOException("Deserialization error. ", e);
+ }
+ if (in.readBoolean())
+ {
+ this.acl = new AccessControlList();
+ acl.readExternal(in);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void _map(CacheKey key, Object value, Collector<Void, Void>
collector)
+ {
+ if (!(value instanceof NodeData))
+ {
+ return;
+ }
+ NodeData prevNode = (NodeData)value;
+ // check is this descendant of parentPath
+ QPath nodeQPath = prevNode.getQPath();
+ if (nodeQPath == null || !nodeQPath.isDescendantOf(parentPath))
+ {
+ return;
+ }
+
+ // is ACL changes on this node (i.e. ACL inheritance brokes)
+ for (InternalQName mixin : prevNode.getMixinTypeNames())
+ {
+ if (mixin.equals(Constants.EXO_PRIVILEGEABLE) ||
mixin.equals(Constants.EXO_OWNEABLE))
+ {
+ return;
+ }
+ }
+ ExoContainer container = ExoContainerContext.getTopContainer();
+ if (container == null)
+ {
+ LOG.error("The top container could not be found");
+ return;
+ }
+ DistributedCacheManager dcm =
+
(DistributedCacheManager)container.getComponentInstanceOfType(DistributedCacheManager.class);
+ if (dcm == null)
+ {
+ LOG.error("The DistributedCacheManager could not be found at top
container level, please configure it.");
+ return;
+ }
+ Cache<CacheKey, Object> cache = dcm.getCache(CACHE_NAME);
+ // we force the reloading
+ cache.getAdvancedCache().withFlags(Flag.SKIP_REMOTE_LOOKUP,
Flag.FAIL_SILENTLY).remove(key);
+ }
+ }
}
Added:
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/infinispan/AbstractMapper.java
===================================================================
---
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/infinispan/AbstractMapper.java
(rev 0)
+++
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/infinispan/AbstractMapper.java 2012-01-19
18:45:11 UTC (rev 5486)
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2012 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.infinispan;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
+/**
+ * This is the main class of all the mapper used in jcr
+ *
+ * @author <a href="mailto:nfilotto@exoplatform.com">Nicolas
Filotto</a>
+ * @version $Id$
+ *
+ */
+public abstract class AbstractMapper<KOut, VOut> extends
+ org.exoplatform.services.ispn.AbstractMapper<CacheKey, Object, KOut, VOut>
implements Externalizable
+{
+ /**
+ * This id will be the unique identifier of the workspace in case the
+ * distributed mode is enabled as the cache will be then shared so we
+ * need this id to prevent mixing data of different workspace. In case
+ * the workspace is not distributed the value of this variable will be
+ * null to avoid consuming more memory for nothing
+ */
+ protected String ownerId;
+
+ public AbstractMapper()
+ {
+ }
+
+ public AbstractMapper(String ownerId)
+ {
+ this.ownerId = ownerId;
+ }
+
+ /**
+ * @see org.exoplatform.services.ispn.AbstractMapper#isValid(java.lang.Object)
+ */
+ @Override
+ protected boolean isValid(CacheKey key)
+ {
+ return ownerId.equals(key.getOwnerId());
+ }
+
+ /**
+ * @see java.io.Externalizable#writeExternal(java.io.ObjectOutput)
+ */
+ public void writeExternal(ObjectOutput out) throws IOException
+ {
+ byte[] buf = ownerId.getBytes("UTF-8");
+ out.writeInt(buf.length);
+ out.write(buf);
+ }
+
+ /**
+ * @see java.io.Externalizable#readExternal(java.io.ObjectInput)
+ */
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
+ {
+ byte[] buf = new byte[in.readInt()];
+ in.readFully(buf);
+ ownerId = new String(buf, "UTF-8");
+ }
+}
\ No newline at end of file
Copied:
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/infinispan/CacheKey.java
(from rev 5416,
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CacheKey.java)
===================================================================
---
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/infinispan/CacheKey.java
(rev 0)
+++
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/infinispan/CacheKey.java 2012-01-19
18:45:11 UTC (rev 5486)
@@ -0,0 +1,220 @@
+/*
+ * 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.infinispan;
+
+import org.exoplatform.services.jcr.impl.Constants;
+import org.infinispan.distribution.group.Group;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
+/**
+ * Created by The eXo Platform SAS. <br/>
+ * Base class for WorkspaceCache keys.<br/>
+ *
+ * Date: 10.06.2008<br/>
+ *
+ * @author <a href="mailto:anatoliy.bazko@exoplatform.com.ua">Anatoliy
Bazko</a>
+ * @version $Id: CacheKey.java 2845 2010-07-30 13:29:37Z tolusha $
+ */
+public abstract class CacheKey implements Externalizable, Comparable<CacheKey>
+{
+
+ /**
+ * This id will be the unique identifier of the workspace in case the
+ * distributed mode is enabled as the cache will be then shared so we
+ * need this id to prevent mixing data of different workspace. In case
+ * the workspace is not distributed the value of this variable will be
+ * null to avoid consuming more memory for nothing
+ */
+ protected String ownerId;
+
+ protected String id;
+
+ protected int hash;
+
+ /**
+ * The value used in case, the grouping is enabled
+ */
+ protected String group;
+
+ /**
+ * The full name of the group
+ */
+ protected String fullGroupName;
+
+ public CacheKey()
+ {
+ }
+
+ public CacheKey(String ownerId, String id)
+ {
+ this(ownerId, id, null);
+ }
+
+ public CacheKey(String ownerId, String id, String group)
+ {
+ this.ownerId = ownerId;
+ this.id = id;
+ this.hash = id.hashCode();
+ this.group = group;
+ }
+
+ /**
+ * @return the ownerId
+ */
+ public String getOwnerId()
+ {
+ return ownerId;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int hashCode()
+ {
+ return this.hash;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString()
+ {
+ return getClass().getSimpleName() + "-" + (ownerId == null ? ""
: (ownerId + "-")) + id + "-" + group;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int compareTo(CacheKey o)
+ {
+ int result = getClass().getName().compareTo(o.getClass().getName());
+ if (result == 0 && ownerId != null)
+ {
+ // The key is of the same type and we assume that the distributed mode is
enabled
+ result = ownerId.compareTo(o.ownerId);
+ }
+ return result == 0 ? id.compareTo(o.id) : result;
+ }
+
+ /**
+ * This method is used for the grouping when its enabled. It will return
+ * the value of the group if it has been explicitly set otherwise it will
+ * return the value of the fullId
+ * @return the group
+ */
+ @Group
+ public String getGroup()
+ {
+ if (fullGroupName != null)
+ {
+ return fullGroupName;
+ }
+ StringBuilder sb = new StringBuilder();
+ if (ownerId != null)
+ {
+ sb.append(ownerId).append('-');
+ }
+ return fullGroupName = sb.append(group == null ? id : group).toString();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void writeExternal(ObjectOutput out) throws IOException
+ {
+ byte[] buf;
+ if (ownerId == null)
+ {
+ out.writeInt(-1);
+ }
+ else
+ {
+ buf = ownerId.getBytes(Constants.DEFAULT_ENCODING);
+ out.writeInt(buf.length);
+ out.write(buf);
+ }
+ if (group == null)
+ {
+ out.writeInt(-1);
+ }
+ else
+ {
+ buf = group.getBytes(Constants.DEFAULT_ENCODING);
+ out.writeInt(buf.length);
+ out.write(buf);
+ }
+
+ buf = id.getBytes(Constants.DEFAULT_ENCODING);
+ out.writeInt(buf.length);
+ out.write(buf);
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
+ {
+ byte[] buf;
+ int length = in.readInt();
+ if (length >= 0)
+ {
+ buf = new byte[length];
+ in.readFully(buf);
+ ownerId = new String(buf, Constants.DEFAULT_ENCODING);
+ }
+ length = in.readInt();
+ if (length >= 0)
+ {
+ buf = new byte[length];
+ in.readFully(buf);
+ group = new String(buf, Constants.DEFAULT_ENCODING);
+ }
+ buf = new byte[in.readInt()];
+ in.readFully(buf);
+ id = new String(buf, Constants.DEFAULT_ENCODING);
+ hash = id.hashCode();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ CacheKey cacheKey = (CacheKey)obj;
+ if (cacheKey.hash == hash && cacheKey.id.equals(id))
+ {
+ return ownerId != null ? ownerId.equals(cacheKey.ownerId) : true;
+ }
+ return false;
+ }
+}
\ No newline at end of file
Added:
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/infinispan/CacheServer.java
===================================================================
---
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/infinispan/CacheServer.java
(rev 0)
+++
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/infinispan/CacheServer.java 2012-01-19
18:45:11 UTC (rev 5486)
@@ -0,0 +1,83 @@
+/*
+ * 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.jcr.infinispan;
+
+import org.exoplatform.container.StandaloneContainer;
+
+import java.net.URL;
+
+/**
+ * This class is used to be able to launch a cache instance as a JVM in standalone mode,
it
+ * will then be able to join an existing cluster of distributed caches.
+ * It will be launched using the standalone container initialized thanks to the
configuration
+ * file whose path is expected as the first argument, by default it will
+ * use <i>/conf/cache-server-configuration.xml</i> that is bundled into the
current jar file.
+ *
+ * The expected path is an absolute path or a relative path from the user directory
+ * or from the {@link ClassLoader}.
+ *
+ * Please note that this cache server should be used only for a distributed cache.
+ *
+ * @author <a href="mailto:nfilotto@exoplatform.com">Nicolas
Filotto</a>
+ * @version $Id$
+ *
+ */
+public class CacheServer
+{
+
+ private static final String DEFAULT_CONFIG_FILE_PATH =
"/conf/cache-server-configuration.xml";
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) throws Exception
+ {
+ String configPath;
+ if (args == null || args.length == 0)
+ {
+ configPath = DEFAULT_CONFIG_FILE_PATH;
+ //NOSONAR
+ System.out.println("The configuration file will be loaded from '"
+ DEFAULT_CONFIG_FILE_PATH + "'");
+ }
+ else if (args.length == 1)
+ {
+ configPath = args[0];
+ //NOSONAR
+ System.out.println("The configuration file will be loaded from '"
+ args[0] + "'");
+ }
+ else
+ {
+ //NOSONAR
+ System.err.println("Too many arguments, the expected syntax is: java
CacheServer <configuration-file-path>");
+ return;
+ }
+
+ URL configUrl = CacheServer.class.getResource(configPath);
+ if (configUrl != null)
+ {
+ StandaloneContainer.addConfigurationURL(configUrl.toString());
+ }
+ else
+ {
+ StandaloneContainer.addConfigurationPath(configPath);
+ }
+ StandaloneContainer.getInstance();
+ }
+
+}
Modified:
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/infinispan/ISPNCacheFactory.java
===================================================================
---
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/infinispan/ISPNCacheFactory.java 2012-01-19
14:28:39 UTC (rev 5485)
+++
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/infinispan/ISPNCacheFactory.java 2012-01-19
18:45:11 UTC (rev 5486)
@@ -22,30 +22,38 @@
import org.exoplatform.container.ExoContainer;
import org.exoplatform.container.ExoContainerContext;
import org.exoplatform.container.configuration.ConfigurationManager;
+import org.exoplatform.services.ispn.Utils;
import org.exoplatform.services.jcr.config.MappedParametrizedObjectEntry;
import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
import org.exoplatform.services.jcr.config.TemplateConfigurationHelper;
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.GlobalConfiguration;
+import org.infinispan.configuration.cache.Configuration;
+import org.infinispan.configuration.cache.ConfigurationBuilder;
+import org.infinispan.configuration.global.GlobalConfiguration;
+import org.infinispan.configuration.global.GlobalConfigurationBuilder;
+import org.infinispan.configuration.parsing.ConfigurationBuilderHolder;
+import org.infinispan.configuration.parsing.Parser;
+import org.infinispan.distribution.ch.ConsistentHash;
+import org.infinispan.distribution.ch.DefaultConsistentHash;
import org.infinispan.jmx.MBeanServerLookup;
import org.infinispan.manager.DefaultCacheManager;
import org.infinispan.manager.EmbeddedCacheManager;
+import org.infinispan.transaction.lookup.TransactionManagerLookup;
+import org.infinispan.util.Util;
import java.io.IOException;
import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.StringWriter;
-import java.net.URL;
import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import javax.management.MBeanServer;
+import javax.transaction.TransactionManager;
/**
* Factory that creates and starts pre-configured instances of Infinispan.
@@ -64,16 +72,17 @@
private final ConfigurationManager configurationManager;
+ private final TransactionManager transactionManager;
+
private final TemplateConfigurationHelper configurationHelper;
- private static final Log log =
ExoLogger.getLogger("exo.jcr.component.core.impl.infinispan.v5.InfinispanCacheFactory");
+ private static final Log log = ExoLogger
+
.getLogger("exo.jcr.component.core.impl.infinispan.v5.InfinispanCacheFactory");
/**
- * A Map that contains all the registered CacheManager order by {@link ExoContainer}
- * instances and {@link GlobalConfiguration}.
+ * A Map that contains all the registered CacheManager order by cluster name.
*/
- private static Map<GlobalConfiguration, EmbeddedCacheManager> CACHE_MANAGERS =
- new HashMap<GlobalConfiguration, EmbeddedCacheManager>();
+ private static Map<String, EmbeddedCacheManager> CACHE_MANAGERS = new
HashMap<String, EmbeddedCacheManager>();
private static final MBeanServerLookup MBEAN_SERVER_LOOKUP = new MBeanServerLookup()
{
@@ -88,14 +97,26 @@
* Transaction manager will later be injected to cache instance.
*
* @param configurationManager
+ * @param transactionManager
*/
- public ISPNCacheFactory(ConfigurationManager configurationManager)
+ public ISPNCacheFactory(ConfigurationManager configurationManager, TransactionManager
transactionManager)
{
this.configurationManager = configurationManager;
this.configurationHelper = new ISPNCacheHelper(configurationManager);
+ this.transactionManager = transactionManager;
}
/**
+ * Creates InfinispanCacheFactory with provided configuration transaction managers.
+ *
+ * @param configurationManager
+ */
+ public ISPNCacheFactory(ConfigurationManager configurationManager)
+ {
+ this(configurationManager, null);
+ }
+
+ /**
* Factory that creates and starts pre-configured instances of Infinispan.
* Path to Infinispan configuration or template should be provided as
* "infinispan-configuration" property in parameterEntry instance.
@@ -132,20 +153,24 @@
{
// creating new CacheManager using SecurityHelper
- manager = SecurityHelper.doPrivilegedIOExceptionAction(new
PrivilegedExceptionAction<EmbeddedCacheManager>()
+ manager = SecurityHelper.doPrivilegedExceptionAction(new
PrivilegedExceptionAction<EmbeddedCacheManager>()
{
- public EmbeddedCacheManager run() throws IOException
+ public EmbeddedCacheManager run() throws Exception
{
- DefaultCacheManager manager = new DefaultCacheManager(configStream,
false);
- loadJGroupsConfig(manager);
- return getUniqueInstance(regionIdEscaped, manager);
+ Parser parser = new
Parser(Thread.currentThread().getContextClassLoader());
+ // Loads the configuration from the input stream
+ ConfigurationBuilderHolder holder = parser.parse(configStream);
+ GlobalConfigurationBuilder configBuilder =
holder.getGlobalConfigurationBuilder();
+ Utils.loadJGroupsConfig(configurationManager, configBuilder.build(),
configBuilder);
+ return getUniqueInstance(regionIdEscaped, holder, transactionManager);
}
});
}
- catch (IOException e)
+ catch (PrivilegedActionException pae)
{
- throw new RepositoryConfigurationException(e);
+ Throwable cause = pae.getCause();
+ throw new RepositoryConfigurationException(cause);
}
PrivilegedAction<Cache<K, V>> action = new
PrivilegedAction<Cache<K, V>>()
@@ -161,95 +186,69 @@
}
/**
- * This method is used to load the file corresponding to the path set on the property
- * <tt>configurationFile</tt> using the configuration manager, then set
the XML content
- * as value of the property <tt>configurationXml</tt>.
- * @param manager the manager from which we extract the transport properties in which
- * we will find the path of the JGroups configuration
- * @throws IOException if the configuration file cannot be read
- */
- private void loadJGroupsConfig(DefaultCacheManager manager) throws IOException
- {
- Properties p = manager.getGlobalConfiguration().getTransportProperties();
- if (p != null && p.containsKey("configurationFile"))
- {
- URL jgroupsConfigURL = null;
- InputStream jgroupsConfigInputStream = null;
- try
- {
- // Trying to get the configuration from the configuration manager
- String configurationFile = p.getProperty("configurationFile");
- jgroupsConfigInputStream =
configurationManager.getInputStream(configurationFile);
- jgroupsConfigURL = configurationManager.getResource(configurationFile);
- }
- catch (Exception e)
- {
- // ignore me
- }
- if (jgroupsConfigInputStream != null)
- {
- try
- {
- log.info("Custom JGroups configuration set: " +
jgroupsConfigURL);
-
- // Read stream content into StringWriter
- StringWriter sw = new StringWriter();
- InputStreamReader in = new InputStreamReader(jgroupsConfigInputStream);
-
- char[] buffer = new char[1024];
- int n = 0;
- while (-1 != (n = in.read(buffer)))
- {
- sw.write(buffer, 0, n);
- }
-
- p.setProperty("configurationXml", sw.toString());
- p.remove("configurationFile");
- }
- finally
- {
- jgroupsConfigInputStream.close();
- }
- }
- }
- }
-
- /**
- * Try to find if a {@link EmbeddedCacheManager} of the same type (i.e. their {@link
GlobalConfiguration} are equals)
+ * Try to find if a {@link EmbeddedCacheManager} of the same type (i.e. the cluster
names are equal)
* has already been registered for the same current container.
* If no cache manager has been registered, we register the given cache manager
otherwise we
* use the previously registered cache manager and we define a dedicated region for
the related cache.
* @param regionId the unique id of the cache region to create
- * @param manager the current cache manager of the cache to create
+ * @param holder the configuration holder of the the cache to create
+ * @param tm the transaction manager to put into the configuration of the cache
* @return the given cache manager if it has not been registered otherwise the cache
manager of the same
* type that has already been registered..
*/
- private static synchronized EmbeddedCacheManager getUniqueInstance(String regionId,
EmbeddedCacheManager manager)
+ private static synchronized EmbeddedCacheManager getUniqueInstance(String regionId,
+ ConfigurationBuilderHolder holder, final TransactionManager tm)
{
- GlobalConfiguration gc = manager.getGlobalConfiguration();
+ GlobalConfigurationBuilder configBuilder = holder.getGlobalConfigurationBuilder();
+ GlobalConfiguration gc = configBuilder.build();
ExoContainer container = ExoContainerContext.getCurrentContainer();
// Ensure that the cluster name won't be used between 2 ExoContainers
- gc.fluent().transport().clusterName(gc.getClusterName() + "_" +
container.getContext().getName())
- .globalJmxStatistics().cacheManagerName(gc.getCacheManagerName() + "_"
+ container.getContext().getName()).
+ configBuilder.transport().clusterName(gc.transport().clusterName() + "_"
+ container.getContext().getName())
+ .globalJmxStatistics()
+ .cacheManagerName(gc.globalJmxStatistics().cacheManagerName() + "_" +
container.getContext().getName()).
// Configure the MBeanServerLookup
mBeanServerLookup(MBEAN_SERVER_LOOKUP);
- Configuration conf = manager.getDefaultConfiguration();
- if (CACHE_MANAGERS.containsKey(gc))
+ EmbeddedCacheManager manager;
+ gc = configBuilder.build();
+ String clusterName = gc.transport().clusterName();
+ if (CACHE_MANAGERS.containsKey(clusterName))
{
- manager = CACHE_MANAGERS.get(gc);
+ manager = CACHE_MANAGERS.get(clusterName);
}
else
{
// Reset the manager before storing it into the map since the default config is
used as
// template to define a new configuration
manager = new DefaultCacheManager(gc);
- CACHE_MANAGERS.put(gc, manager);
+ CACHE_MANAGERS.put(clusterName, manager);
if (log.isInfoEnabled())
{
log.info("A new ISPN Cache Manager instance has been registered for the
region " + regionId
+ " and the container " + container.getContext().getName());
}
}
+ ConfigurationBuilder confBuilder = holder.getDefaultConfigurationBuilder();
+ if (tm != null)
+ {
+ TransactionManagerLookup tml = new TransactionManagerLookup()
+ {
+ public TransactionManager getTransactionManager() throws Exception
+ {
+ return tm;
+ }
+ };
+ confBuilder.transaction().transactionManagerLookup(tml);
+ }
+ //TODO remove it once ISPN-1687 will be fixed
+ confBuilder.storeAsBinary().enabled(false);
+ //TODO remove it once ISPN-1689 will be fixed
+ confBuilder
+ .clustering()
+ .hash()
+ .consistentHash(
+ Util.<ConsistentHash>
getInstance(DefaultConsistentHash.class.getName(), Thread.currentThread()
+ .getContextClassLoader()));
+ Configuration conf = holder.getDefaultConfigurationBuilder().build();
// Define the configuration of the cache
manager.defineConfiguration(regionId, conf);
if (log.isInfoEnabled())
Added:
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/resources/conf/cache-server-configuration.xml
===================================================================
---
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/resources/conf/cache-server-configuration.xml
(rev 0)
+++
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/resources/conf/cache-server-configuration.xml 2012-01-19
18:45:11 UTC (rev 5486)
@@ -0,0 +1,79 @@
+<?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_2.xsd
http://www.exoplatform.org/xml/ns/kernel_1_2.xsd"
+
xmlns="http://www.exoplatform.org/xml/ns/kernel_1_2.xsd">
+ <component>
+ <type>org.exoplatform.services.ispn.DistributedCacheManager</type>
+ <init-params>
+ <value-param>
+ <name>infinispan-configuration</name>
+ <value>jar:/conf/distributed-cache-configuration.xml</value>
+ </value-param>
+ </init-params>
+ </component>
+ <component>
+ <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.infinispan.JBossTransactionsService</type>
+ <init-params>
+ <value-param>
+ <name>timeout</name>
+ <value>3000</value>
+ </value-param>
+ </init-params>
+ </component>
+ <component>
+ <key>org.exoplatform.services.log.LogConfigurationInitializer</key>
+ <type>org.exoplatform.services.log.LogConfigurationInitializer</type>
+ <init-params>
+ <value-param>
+ <name>logger</name>
+ <value>org.exoplatform.services.log.impl.BufferedLog4JLogger</value>
+ </value-param>
+ <value-param>
+ <name>configurator</name>
+ <value>org.exoplatform.services.log.impl.Log4JConfigurator</value>
+ </value-param>
+ <properties-param>
+ <name>properties</name>
+ <description>Log4J properties</description>
+ <property name="log4j.rootLogger" value="INFO, stdout, file"
/>
+
+ <property name="log4j.appender.stdout"
value="org.apache.log4j.ConsoleAppender" />
+ <property name="log4j.appender.stdout.threshold" value="DEBUG"
/>
+
+ <property name="log4j.appender.stdout.layout"
value="org.apache.log4j.PatternLayout" />
+ <property name="log4j.appender.stdout.layout.ConversionPattern"
value="%d{dd.MM.yyyy HH:mm:ss} *%-5p* [%t] %c{1}: %m (%F, line %L) %n" />
+
+ <property name="log4j.appender.file"
value="org.apache.log4j.FileAppender" />
+ <property name="log4j.appender.file.File"
value="jcr-cache-server.log" />
+
+ <property name="log4j.appender.file.layout"
value="org.apache.log4j.PatternLayout" />
+ <property name="log4j.appender.file.layout.ConversionPattern"
value="%d{dd.MM.yyyy HH:mm:ss} *%-5p* [%t] %c{1}: %m (%F, line %L) %n" />
+ </properties-param>
+ </init-params>
+ </component>
+</configuration>
Added:
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/resources/conf/distributed-cache-configuration.xml
===================================================================
---
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/resources/conf/distributed-cache-configuration.xml
(rev 0)
+++
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/resources/conf/distributed-cache-configuration.xml 2012-01-19
18:45:11 UTC (rev 5486)
@@ -0,0 +1,45 @@
+<?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.1
http://www.infinispan.org/schemas/infinispan-config-5.1.xsd"
+ xmlns="urn:infinispan:config:5.1">
+ <global>
+ <globalJmxStatistics jmxDomain="exo" enabled="true"
allowDuplicateDomains="true"/>
+ <transport
transportClass="org.infinispan.remoting.transport.jgroups.JGroupsTransport"
clusterName="JCR-cluster" distributedSyncTimeout="20000">
+ <properties>
+ <property name="configurationFile"
value="tcp-mux.xml"/>
+ </properties>
+ </transport>
+ <shutdown hookBehavior="DEFAULT"/>
+ </global>
+ <namedCache name="JCRCache">
+ <locking isolationLevel="READ_COMMITTED"
lockAcquisitionTimeout="20000" writeSkewCheck="false"
concurrencyLevel="500" useLockStriping="true" />
+ <transaction
transactionManagerLookupClass="org.infinispan.transaction.lookup.GenericTransactionManagerLookup"
syncRollbackPhase="true" syncCommitPhase="true"
eagerLockSingleNode="true" transactionMode="TRANSACTIONAL"/>
+ <jmxStatistics enabled="true"/>
+ <clustering mode="distribution">
+ <l1 enabled="true" invalidationThreshold="-1"/>
+ <hash numOwners="2" rehashRpcTimeout="120000">
+ <groups enabled="true"/>
+ </hash>
+ <sync/>
+ </clustering>
+ </namedCache>
+</infinispan>
\ No newline at end of file
Modified:
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/resources/conf/portal/cluster/infinispan-data.xml
===================================================================
---
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/resources/conf/portal/cluster/infinispan-data.xml 2012-01-19
14:28:39 UTC (rev 5485)
+++
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/resources/conf/portal/cluster/infinispan-data.xml 2012-01-19
18:45:11 UTC (rev 5486)
@@ -47,7 +47,7 @@
</clustering>
<locking isolationLevel="READ_COMMITTED"
lockAcquisitionTimeout="20000" writeSkewCheck="false"
concurrencyLevel="500" useLockStriping="true"/>
- <transaction
transactionManagerLookupClass="org.exoplatform.services.transaction.infinispan.JBossStandaloneJTAManagerLookup"
syncRollbackPhase="true" syncCommitPhase="true"/>
+ <transaction
transactionManagerLookupClass="org.exoplatform.services.transaction.infinispan.JBossStandaloneJTAManagerLookup"
syncRollbackPhase="true" syncCommitPhase="true"
transactionMode="TRANSACTIONAL"/>
<jmxStatistics enabled="true"/>
<eviction strategy="LRU" threadPolicy="DEFAULT"
maxEntries="1000000"/>
<expiration wakeUpInterval="5000"/>
Modified:
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/resources/conf/portal/cluster/infinispan-indexer.xml
===================================================================
---
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/resources/conf/portal/cluster/infinispan-indexer.xml 2012-01-19
14:28:39 UTC (rev 5485)
+++
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/resources/conf/portal/cluster/infinispan-indexer.xml 2012-01-19
18:45:11 UTC (rev 5486)
@@ -47,7 +47,7 @@
</clustering>
<locking isolationLevel="READ_COMMITTED"
lockAcquisitionTimeout="20000" writeSkewCheck="false"
concurrencyLevel="500" useLockStriping="false"/>
- <transaction
transactionManagerLookupClass="org.exoplatform.services.transaction.infinispan.JBossStandaloneJTAManagerLookup"
syncRollbackPhase="true" syncCommitPhase="true"/>
+ <transaction
transactionManagerLookupClass="org.exoplatform.services.transaction.infinispan.JBossStandaloneJTAManagerLookup"
syncRollbackPhase="true" syncCommitPhase="true"
transactionMode="TRANSACTIONAL"/>
<jmxStatistics enabled="true"/>
<eviction strategy="NONE"/>
Modified:
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/resources/conf/portal/cluster/infinispan-lock.xml
===================================================================
---
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/resources/conf/portal/cluster/infinispan-lock.xml 2012-01-19
14:28:39 UTC (rev 5485)
+++
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/resources/conf/portal/cluster/infinispan-lock.xml 2012-01-19
18:45:11 UTC (rev 5486)
@@ -47,7 +47,7 @@
</clustering>
<locking isolationLevel="READ_COMMITTED"
lockAcquisitionTimeout="20000" writeSkewCheck="false"
concurrencyLevel="500" useLockStriping="false"/>
- <transaction
transactionManagerLookupClass="org.exoplatform.services.transaction.infinispan.JBossStandaloneJTAManagerLookup"
syncRollbackPhase="true" syncCommitPhase="true"/>
+ <transaction
transactionManagerLookupClass="org.exoplatform.services.transaction.infinispan.JBossStandaloneJTAManagerLookup"
syncRollbackPhase="true" syncCommitPhase="true"
transactionMode="TRANSACTIONAL"/>
<jmxStatistics enabled="true"/>
<eviction strategy="NONE"/>
Added:
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/resources/conf/tcp-mux.xml
===================================================================
---
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/resources/conf/tcp-mux.xml
(rev 0)
+++
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/resources/conf/tcp-mux.xml 2012-01-19
18:45:11 UTC (rev 5486)
@@ -0,0 +1,70 @@
+<!--
+ TCP based stack, with flow control and message bundling. This is usually used when
IP
+ multicasting cannot be used in a network, e.g. because it is disabled (routers
discard multicast).
+ Note that TCP.bind_addr and TCPPING.initial_hosts should be set, possibly via system
properties, e.g.
+ -Djgroups.bind_addr=192.168.5.2 and
-Djgroups.tcpping.initial_hosts=192.168.5.2[7800]
+ author: Bela Ban
+-->
+<config xmlns="urn:org:jgroups"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:org:jgroups
http://www.jgroups.org/schema/JGroups-3.0.xsd">
+ <TCP singleton_name="JCR-cluster"
+ bind_port="7800"
+ loopback="false"
+ recv_buf_size="${tcp.recv_buf_size:20M}"
+ send_buf_size="${tcp.send_buf_size:640K}"
+ discard_incompatible_packets="true"
+ max_bundle_size="64K"
+ max_bundle_timeout="30"
+ enable_bundling="true"
+ use_send_queues="true"
+ sock_conn_timeout="300"
+
+ timer_type="new"
+ timer.min_threads="4"
+ timer.max_threads="10"
+ timer.keep_alive_time="3000"
+ timer.queue_max_size="500"
+
+ thread_pool.enabled="true"
+ thread_pool.min_threads="1"
+ thread_pool.max_threads="10"
+ thread_pool.keep_alive_time="5000"
+ thread_pool.queue_enabled="false"
+ thread_pool.queue_max_size="100"
+ thread_pool.rejection_policy="discard"
+
+ oob_thread_pool.enabled="true"
+ oob_thread_pool.min_threads="1"
+ oob_thread_pool.max_threads="8"
+ oob_thread_pool.keep_alive_time="5000"
+ oob_thread_pool.queue_enabled="false"
+ oob_thread_pool.queue_max_size="100"
+ oob_thread_pool.rejection_policy="discard"/>
+
+ <TCPPING timeout="3000"
+
initial_hosts="${jgroups.tcpping.initial_hosts:localhost[7800],localhost[7801]}"
+ port_range="1"
+ num_initial_members="3"/>
+ <MERGE2 min_interval="10000"
+ max_interval="30000"/>
+ <FD_SOCK/>
+ <FD timeout="3000" max_tries="3" />
+ <VERIFY_SUSPECT timeout="1500" />
+ <BARRIER />
+ <pbcast.NAKACK use_mcast_xmit="false"
+ exponential_backoff="500"
+ discard_delivered_msgs="true"/>
+ <UNICAST />
+ <pbcast.STABLE stability_delay="1000"
desired_avg_gossip="50000"
+ max_bytes="4M"/>
+ <pbcast.GMS print_local_addr="true" join_timeout="3000"
+
+ view_bundling="true"/>
+ <UFC max_credits="2M"
+ min_threshold="0.4"/>
+ <MFC max_credits="2M"
+ min_threshold="0.4"/>
+ <FRAG2 frag_size="60K" />
+ <pbcast.STATE_TRANSFER/>
+</config>
\ No newline at end of file
Added:
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/resources/conf/udp-mux.xml
===================================================================
---
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/resources/conf/udp-mux.xml
(rev 0)
+++
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/resources/conf/udp-mux.xml 2012-01-19
18:45:11 UTC (rev 5486)
@@ -0,0 +1,74 @@
+
+<!--
+ Default stack using IP multicasting. It is similar to the "udp"
+ stack in stacks.xml, but doesn't use streaming state transfer and flushing
+ author: Bela Ban
+-->
+
+<config xmlns="urn:org:jgroups"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:org:jgroups
http://www.jgroups.org/schema/JGroups-3.0.xsd">
+ <UDP
+ singleton_name="JCR-cluster"
+ mcast_port="${jgroups.udp.mcast_port:45588}"
+ tos="8"
+ ucast_recv_buf_size="20M"
+ ucast_send_buf_size="640K"
+ mcast_recv_buf_size="25M"
+ mcast_send_buf_size="640K"
+ loopback="true"
+ discard_incompatible_packets="true"
+ max_bundle_size="64K"
+ max_bundle_timeout="30"
+ ip_ttl="${jgroups.udp.ip_ttl:8}"
+ enable_bundling="true"
+ enable_diagnostics="true"
+ thread_naming_pattern="cl"
+
+ timer_type="new"
+ timer.min_threads="4"
+ timer.max_threads="10"
+ timer.keep_alive_time="3000"
+ timer.queue_max_size="500"
+
+ thread_pool.enabled="true"
+ thread_pool.min_threads="2"
+ thread_pool.max_threads="8"
+ thread_pool.keep_alive_time="5000"
+ thread_pool.queue_enabled="true"
+ thread_pool.queue_max_size="10000"
+ thread_pool.rejection_policy="discard"
+
+ oob_thread_pool.enabled="true"
+ oob_thread_pool.min_threads="1"
+ oob_thread_pool.max_threads="8"
+ oob_thread_pool.keep_alive_time="5000"
+ oob_thread_pool.queue_enabled="false"
+ oob_thread_pool.queue_max_size="100"
+ oob_thread_pool.rejection_policy="Run"/>
+
+ <PING timeout="2000"
+ num_initial_members="3"/>
+ <MERGE2 max_interval="30000"
+ min_interval="10000"/>
+ <FD_SOCK/>
+ <FD_ALL/>
+ <VERIFY_SUSPECT timeout="1500" />
+ <BARRIER />
+ <pbcast.NAKACK exponential_backoff="300"
+ xmit_stagger_timeout="200"
+ use_mcast_xmit="false"
+ discard_delivered_msgs="true"/>
+ <UNICAST />
+ <pbcast.STABLE stability_delay="1000"
desired_avg_gossip="50000"
+ max_bytes="4M"/>
+ <pbcast.GMS print_local_addr="true" join_timeout="3000"
+ view_bundling="true"/>
+ <UFC max_credits="2M"
+ min_threshold="0.4"/>
+ <MFC max_credits="2M"
+ min_threshold="0.4"/>
+ <FRAG2 frag_size="60K" />
+ <pbcast.STATE_TRANSFER />
+ <!-- pbcast.FLUSH /-->
+</config>
\ No newline at end of file
Modified:
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/cache/infinispan/TestISPNCacheWorkspaceStorageCacheInClusterMode.java
===================================================================
---
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/cache/infinispan/TestISPNCacheWorkspaceStorageCacheInClusterMode.java 2012-01-19
14:28:39 UTC (rev 5485)
+++
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/cache/infinispan/TestISPNCacheWorkspaceStorageCacheInClusterMode.java 2012-01-19
18:45:11 UTC (rev 5486)
@@ -23,8 +23,8 @@
import org.exoplatform.services.jcr.config.SimpleParameterEntry;
import org.exoplatform.services.jcr.config.WorkspaceEntry;
import
org.exoplatform.services.jcr.impl.dataflow.persistent.TestWorkspaceStorageCacheInClusterMode;
+import
org.exoplatform.services.jcr.impl.dataflow.persistent.infinispan.ISPNCacheWorkspaceStorageCache;
import
org.exoplatform.services.jcr.impl.dataflow.persistent.infinispan.TesterISPNCacheWorkspaceStorageCache;
-import
org.exoplatform.services.jcr.impl.dataflow.persistent.infinispan.ISPNCacheWorkspaceStorageCache;
import org.exoplatform.services.jcr.infinispan.ISPNCacheFactory;
import java.lang.reflect.Field;
Modified:
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/test/java/org/exoplatform/services/jcr/lab/infinispan/TestISPNCache.java
===================================================================
---
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/test/java/org/exoplatform/services/jcr/lab/infinispan/TestISPNCache.java 2012-01-19
14:28:39 UTC (rev 5485)
+++
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/test/java/org/exoplatform/services/jcr/lab/infinispan/TestISPNCache.java 2012-01-19
18:45:11 UTC (rev 5486)
@@ -21,8 +21,10 @@
import junit.framework.TestCase;
import org.infinispan.Cache;
-import org.infinispan.config.Configuration;
-import org.infinispan.config.GlobalConfiguration;
+import org.infinispan.configuration.cache.Configuration;
+import org.infinispan.configuration.cache.ConfigurationBuilder;
+import org.infinispan.configuration.global.GlobalConfiguration;
+import org.infinispan.configuration.global.GlobalConfigurationBuilder;
import org.infinispan.manager.DefaultCacheManager;
import org.infinispan.manager.EmbeddedCacheManager;
@@ -62,13 +64,13 @@
public void testGetCache() throws Exception
{
// Create cache manager
- GlobalConfiguration myGlobalConfig = new GlobalConfiguration();
+ GlobalConfiguration myGlobalConfig = new GlobalConfigurationBuilder().build();
EmbeddedCacheManager manager = new DefaultCacheManager(myGlobalConfig);
// Create a cache
- Configuration config = new Configuration();
+ Configuration config = new ConfigurationBuilder().build();
manager.defineConfiguration("cache", config);
- Cache cache = manager.getCache("cache");
+ Cache<String, String> cache = manager.getCache("cache");
cache.put("key", "value");
assertTrue(cache.size() == 1);
@@ -98,11 +100,12 @@
*/
public void testGetClusterCache() throws Exception
{
+ GlobalConfiguration myGlobalConfig = new
GlobalConfigurationBuilder().clusteredDefault().build();
// Create cache manager
- EmbeddedCacheManager manager = new
DefaultCacheManager(GlobalConfiguration.getClusteredDefault());
+ EmbeddedCacheManager manager = new DefaultCacheManager(myGlobalConfig);
// Create a cache
- Cache cache = manager.getCache();
+ Cache<String, String> cache = manager.getCache();
cache.put("key", "value");
assertTrue(cache.size() == 1);
Added:
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/test/resources/conf/standalone/cluster/distributed-cache-configuration.xml
===================================================================
---
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/test/resources/conf/standalone/cluster/distributed-cache-configuration.xml
(rev 0)
+++
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/test/resources/conf/standalone/cluster/distributed-cache-configuration.xml 2012-01-19
18:45:11 UTC (rev 5486)
@@ -0,0 +1,45 @@
+<?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.1
http://www.infinispan.org/schemas/infinispan-config-5.1.xsd"
+ xmlns="urn:infinispan:config:5.1">
+ <global>
+ <globalJmxStatistics jmxDomain="exo" enabled="true"
allowDuplicateDomains="true"/>
+ <transport
transportClass="org.infinispan.remoting.transport.jgroups.JGroupsTransport"
clusterName="JCR-cluster" distributedSyncTimeout="20000">
+ <properties>
+ <property name="configurationFile"
value="tcp-mux.xml"/>
+ </properties>
+ </transport>
+ <shutdown hookBehavior="DEFAULT"/>
+ </global>
+ <namedCache name="JCRCache">
+ <locking isolationLevel="READ_COMMITTED"
lockAcquisitionTimeout="20000" writeSkewCheck="false"
concurrencyLevel="500" useLockStriping="true" />
+ <transaction
transactionManagerLookupClass="org.infinispan.transaction.lookup.GenericTransactionManagerLookup"
syncRollbackPhase="true" syncCommitPhase="true"
eagerLockSingleNode="true" transactionMode="TRANSACTIONAL"/>
+ <jmxStatistics enabled="true"/>
+ <clustering mode="distribution">
+ <l1 enabled="true" invalidationThreshold="-1"/>
+ <hash numOwners="2" rehashRpcTimeout="120000">
+ <groups enabled="true"/>
+ </hash>
+ <sync replTimeout="60000"/>
+ </clustering>
+ </namedCache>
+</infinispan>
\ No newline at end of file
Added:
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/test/resources/conf/standalone/cluster/tcp-mux.xml
===================================================================
---
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/test/resources/conf/standalone/cluster/tcp-mux.xml
(rev 0)
+++
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/test/resources/conf/standalone/cluster/tcp-mux.xml 2012-01-19
18:45:11 UTC (rev 5486)
@@ -0,0 +1,70 @@
+<!--
+ TCP based stack, with flow control and message bundling. This is usually used when
IP
+ multicasting cannot be used in a network, e.g. because it is disabled (routers
discard multicast).
+ Note that TCP.bind_addr and TCPPING.initial_hosts should be set, possibly via system
properties, e.g.
+ -Djgroups.bind_addr=192.168.5.2 and
-Djgroups.tcpping.initial_hosts=192.168.5.2[7800]
+ author: Bela Ban
+-->
+<config xmlns="urn:org:jgroups"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:org:jgroups
http://www.jgroups.org/schema/JGroups-3.0.xsd">
+ <TCP singleton_name="JCR-cluster"
+ bind_port="7800"
+ loopback="false"
+ recv_buf_size="${tcp.recv_buf_size:20M}"
+ send_buf_size="${tcp.send_buf_size:640K}"
+ discard_incompatible_packets="true"
+ max_bundle_size="64K"
+ max_bundle_timeout="30"
+ enable_bundling="true"
+ use_send_queues="true"
+ sock_conn_timeout="300"
+
+ timer_type="new"
+ timer.min_threads="4"
+ timer.max_threads="10"
+ timer.keep_alive_time="3000"
+ timer.queue_max_size="500"
+
+ thread_pool.enabled="true"
+ thread_pool.min_threads="1"
+ thread_pool.max_threads="10"
+ thread_pool.keep_alive_time="5000"
+ thread_pool.queue_enabled="false"
+ thread_pool.queue_max_size="100"
+ thread_pool.rejection_policy="discard"
+
+ oob_thread_pool.enabled="true"
+ oob_thread_pool.min_threads="1"
+ oob_thread_pool.max_threads="8"
+ oob_thread_pool.keep_alive_time="5000"
+ oob_thread_pool.queue_enabled="false"
+ oob_thread_pool.queue_max_size="100"
+ oob_thread_pool.rejection_policy="discard"/>
+
+ <TCPPING timeout="3000"
+
initial_hosts="${jgroups.tcpping.initial_hosts:localhost[7800],localhost[7801]}"
+ port_range="1"
+ num_initial_members="3"/>
+ <MERGE2 min_interval="10000"
+ max_interval="30000"/>
+ <FD_SOCK/>
+ <FD timeout="3000" max_tries="3" />
+ <VERIFY_SUSPECT timeout="1500" />
+ <BARRIER />
+ <pbcast.NAKACK use_mcast_xmit="false"
+ exponential_backoff="500"
+ discard_delivered_msgs="true"/>
+ <UNICAST />
+ <pbcast.STABLE stability_delay="1000"
desired_avg_gossip="50000"
+ max_bytes="4M"/>
+ <pbcast.GMS print_local_addr="true" join_timeout="3000"
+
+ view_bundling="true"/>
+ <UFC max_credits="2M"
+ min_threshold="0.4"/>
+ <MFC max_credits="2M"
+ min_threshold="0.4"/>
+ <FRAG2 frag_size="60K" />
+ <pbcast.STATE_TRANSFER/>
+</config>
\ No newline at end of file
Modified:
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/test/resources/conf/standalone/cluster/test-configuration.xml
===================================================================
---
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/test/resources/conf/standalone/cluster/test-configuration.xml 2012-01-19
14:28:39 UTC (rev 5485)
+++
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/test/resources/conf/standalone/cluster/test-configuration.xml 2012-01-19
18:45:11 UTC (rev 5486)
@@ -214,7 +214,15 @@
</value-param>
</init-params>
</component>
-
+ <component>
+ <type>org.exoplatform.services.ispn.DistributedCacheManager</type>
+ <init-params>
+ <value-param>
+ <name>infinispan-configuration</name>
+ <value>jar:/conf/standalone/cluster/distributed-cache-configuration.xml</value>
+ </value-param>
+ </init-params>
+ </component>
<component>
<key>org.exoplatform.services.rpc.RPCService</key>
<type>org.exoplatform.services.rpc.jgv3.RPCServiceImpl</type>
Modified:
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/test/resources/conf/standalone/cluster/test-jcr-config.xml
===================================================================
---
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/test/resources/conf/standalone/cluster/test-jcr-config.xml 2012-01-19
14:28:39 UTC (rev 5485)
+++
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/test/resources/conf/standalone/cluster/test-jcr-config.xml 2012-01-19
18:45:11 UTC (rev 5486)
@@ -58,6 +58,7 @@
<property name="infinispan-configuration"
value="conf/standalone/cluster/test-infinispan-config.xml" />
<property name="jgroups-configuration"
value="udp-mux.xml" />
<property name="infinispan-cluster-name"
value="JCR-cluster" />
+ <property name="use-distributed-cache"
value="${use-distributed-cache}" />
</properties>
</cache>
<query-handler
class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
@@ -117,6 +118,7 @@
<property name="infinispan-configuration"
value="conf/standalone/cluster/test-infinispan-config.xml" />
<property name="jgroups-configuration"
value="udp-mux.xml" />
<property name="infinispan-cluster-name"
value="JCR-cluster" />
+ <property name="use-distributed-cache"
value="${use-distributed-cache}" />
</properties>
</cache>
<query-handler
class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
@@ -184,6 +186,7 @@
<property name="infinispan-configuration"
value="conf/standalone/cluster/test-infinispan-config.xml" />
<property name="jgroups-configuration"
value="udp-mux.xml" />
<property name="infinispan-cluster-name"
value="JCR-cluster" />
+ <property name="use-distributed-cache"
value="${use-distributed-cache}" />
</properties>
</cache>
<query-handler
class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
@@ -275,6 +278,7 @@
<property name="infinispan-configuration"
value="conf/standalone/cluster/test-infinispan-config.xml" />
<property name="jgroups-configuration"
value="udp-mux.xml" />
<property name="infinispan-cluster-name"
value="JCR-cluster" />
+ <property name="use-distributed-cache"
value="${use-distributed-cache}" />
</properties>
</cache>
<query-handler
class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
@@ -359,6 +363,7 @@
<property name="infinispan-configuration"
value="conf/standalone/cluster/test-infinispan-config.xml" />
<property name="jgroups-configuration"
value="udp-mux.xml" />
<property name="infinispan-cluster-name"
value="JCR-cluster" />
+ <property name="use-distributed-cache"
value="${use-distributed-cache}" />
</properties>
</cache>
<query-handler
class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
@@ -424,6 +429,7 @@
<property name="infinispan-configuration"
value="conf/standalone/cluster/test-infinispan-config.xml" />
<property name="jgroups-configuration"
value="udp-mux.xml" />
<property name="infinispan-cluster-name"
value="JCR-cluster" />
+ <property name="use-distributed-cache"
value="${use-distributed-cache}" />
</properties>
</cache>
<query-handler
class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
@@ -500,6 +506,7 @@
<property name="infinispan-configuration"
value="conf/standalone/cluster/test-infinispan-config.xml" />
<property name="jgroups-configuration"
value="udp-mux.xml" />
<property name="infinispan-cluster-name"
value="JCR-cluster" />
+ <property name="use-distributed-cache"
value="${use-distributed-cache}" />
</properties>
</cache>
<query-handler
class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
@@ -575,6 +582,7 @@
<property name="infinispan-configuration"
value="conf/standalone/cluster/test-infinispan-config.xml" />
<property name="jgroups-configuration"
value="udp-mux.xml" />
<property name="infinispan-cluster-name"
value="JCR-cluster" />
+ <property name="use-distributed-cache"
value="${use-distributed-cache}" />
</properties>
</cache>
<query-handler
class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
@@ -649,6 +657,7 @@
<property name="infinispan-configuration"
value="conf/standalone/cluster/test-infinispan-config.xml" />
<property name="jgroups-configuration"
value="udp-mux.xml" />
<property name="infinispan-cluster-name"
value="JCR-cluster" />
+ <property name="use-distributed-cache"
value="${use-distributed-cache}" />
</properties>
</cache>
<query-handler
class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
Modified:
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/test/resources/conf/standalone/test-infinispan-config.xml
===================================================================
---
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/test/resources/conf/standalone/test-infinispan-config.xml 2012-01-19
14:28:39 UTC (rev 5485)
+++
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/test/resources/conf/standalone/test-infinispan-config.xml 2012-01-19
18:45:11 UTC (rev 5486)
@@ -36,7 +36,7 @@
<default>
<locking isolationLevel="READ_COMMITTED"
lockAcquisitionTimeout="20000" writeSkewCheck="false"
concurrencyLevel="500" useLockStriping="true"/>
- <transaction
transactionManagerLookupClass="org.exoplatform.services.transaction.infinispan.JBossStandaloneJTAManagerLookup"
syncRollbackPhase="true" syncCommitPhase="true"/>
+ <transaction
transactionManagerLookupClass="org.exoplatform.services.transaction.infinispan.JBossStandaloneJTAManagerLookup"
syncRollbackPhase="true" syncCommitPhase="true"
transactionMode="TRANSACTIONAL"/>
<jmxStatistics enabled="true"/>
<eviction strategy="LRU" threadPolicy="DEFAULT"
maxEntries="1000000"/>
<expiration wakeUpInterval="5000"/>
Modified:
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/test/resources/conf/standalone/test-infinispan-lock.xml
===================================================================
---
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/test/resources/conf/standalone/test-infinispan-lock.xml 2012-01-19
14:28:39 UTC (rev 5485)
+++
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/test/resources/conf/standalone/test-infinispan-lock.xml 2012-01-19
18:45:11 UTC (rev 5486)
@@ -36,7 +36,7 @@
<default>
<locking isolationLevel="READ_COMMITTED"
lockAcquisitionTimeout="20000" writeSkewCheck="false"
concurrencyLevel="500" useLockStriping="false"/>
- <transaction
transactionManagerLookupClass="org.exoplatform.services.transaction.infinispan.JBossStandaloneJTAManagerLookup"
syncRollbackPhase="true" syncCommitPhase="true"/>
+ <transaction
transactionManagerLookupClass="org.exoplatform.services.transaction.infinispan.JBossStandaloneJTAManagerLookup"
syncRollbackPhase="true" syncCommitPhase="true"
transactionMode="TRANSACTIONAL"/>
<jmxStatistics enabled="true"/>
<eviction strategy="NONE"/>
Modified: jcr/trunk/pom.xml
===================================================================
--- jcr/trunk/pom.xml 2012-01-19 14:28:39 UTC (rev 5485)
+++ jcr/trunk/pom.xml 2012-01-19 18:45:11 UTC (rev 5486)
@@ -85,8 +85,13 @@
<groupId>org.exoplatform.kernel</groupId>
<artifactId>exo.kernel.component.ext.rpc.impl.jgroups.v3</artifactId>
<version>${org.exoplatform.kernel.version}</version>
- </dependency>
+ </dependency>
<dependency>
+ <groupId>org.exoplatform.kernel</groupId>
+
<artifactId>exo.kernel.component.ext.cache.impl.infinispan.v5</artifactId>
+ <version>${org.exoplatform.kernel.version}</version>
+ </dependency>
+ <dependency>
<groupId>org.exoplatform.core</groupId>
<artifactId>exo.core.component.database</artifactId>
<version>${org.exoplatform.core.version}</version>
@@ -392,12 +397,12 @@
<dependency>
<groupId>org.infinispan</groupId>
<artifactId>infinispan-core</artifactId>
- <version>5.1.0.CR1</version>
+ <version>5.1.0.CR3</version>
</dependency>
<dependency>
<groupId>org.infinispan</groupId>
<artifactId>infinispan-cachestore-jdbc</artifactId>
- <version>5.1.0.CR1</version>
+ <version>5.1.0.CR3</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>