exo-jcr SVN: r5929 - in jcr/branches/1.14.x/patch: JCR-1722 and 1 other directory.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2012-03-21 10:51:47 -0400 (Wed, 21 Mar 2012)
New Revision: 5929
Added:
jcr/branches/1.14.x/patch/JCR-1722/
jcr/branches/1.14.x/patch/JCR-1722/JCR-1722.patch
Log:
cd /home/exo/java/jboss/jcr/branches/1.14.x/patch/JCR-1722
Added: jcr/branches/1.14.x/patch/JCR-1722/JCR-1722.patch
===================================================================
--- jcr/branches/1.14.x/patch/JCR-1722/JCR-1722.patch (rev 0)
+++ jcr/branches/1.14.x/patch/JCR-1722/JCR-1722.patch 2012-03-21 14:51:47 UTC (rev 5929)
@@ -0,0 +1,34 @@
+Index: exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java
+===================================================================
+--- exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java (revision 5928)
++++ exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java (working copy)
+@@ -3300,7 +3300,7 @@
+ switch (mode)
+ {
+ case READ_ONLY :
+- setReadOny();
++ setReadOnly();
+ break;
+ case READ_WRITE :
+ setReadWrite();
+@@ -3316,7 +3316,7 @@
+ /**
+ * Sets mode to READ_ONLY, discarding flush task
+ */
+- protected void setReadOny()
++ protected void setReadOnly()
+ {
+ // try to stop merger in safe way
+ if (merger != null)
+@@ -3325,7 +3325,10 @@
+ merger = null;
+ }
+
+- flushTask.cancel();
++ if (flushTask != null)
++ {
++ flushTask.cancel();
++ }
+ FLUSH_TIMER.purge();
+ this.redoLog = null;
+ }
12 years, 2 months
exo-jcr SVN: r5928 - jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2012-03-21 10:39:11 -0400 (Wed, 21 Mar 2012)
New Revision: 5928
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java
Log:
EXOJCR-1821 : rename setReadOny() -> setReadOnly(), check if flush task not null, before canceling it.
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java 2012-03-21 13:58:04 UTC (rev 5927)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java 2012-03-21 14:39:11 UTC (rev 5928)
@@ -1155,8 +1155,7 @@
try
{
index =
- new PersistentIndex(indexName, handler.getTextAnalyzer(), handler.getSimilarity(), cache,
- directoryManager);
+ new PersistentIndex(indexName, handler.getTextAnalyzer(), handler.getSimilarity(), cache, directoryManager);
}
catch (IOException e)
{
@@ -1861,8 +1860,7 @@
}
}
- private long createIndex(NodeData node, ItemDataConsumer stateMgr) throws IOException,
- RepositoryException
+ private long createIndex(NodeData node, ItemDataConsumer stateMgr) throws IOException, RepositoryException
{
MultithreadedIndexing indexing = new MultithreadedIndexing(node, stateMgr);
return indexing.launch(false);
@@ -2577,8 +2575,8 @@
/**
* The maximum length of a AddNode String.
*/
- private static final int ENTRY_LENGTH =
- Long.toString(Long.MAX_VALUE).length() + Action.ADD_NODE.length() + Constants.UUID_FORMATTED_LENGTH + 2;
+ private static final int ENTRY_LENGTH = Long.toString(Long.MAX_VALUE).length() + Action.ADD_NODE.length()
+ + Constants.UUID_FORMATTED_LENGTH + 2;
/**
* The uuid of the node to add.
@@ -2979,8 +2977,8 @@
/**
* The maximum length of a DeleteNode String.
*/
- private static final int ENTRY_LENGTH =
- Long.toString(Long.MAX_VALUE).length() + Action.DELETE_NODE.length() + Constants.UUID_FORMATTED_LENGTH + 2;
+ private static final int ENTRY_LENGTH = Long.toString(Long.MAX_VALUE).length() + Action.DELETE_NODE.length()
+ + Constants.UUID_FORMATTED_LENGTH + 2;
/**
* The uuid of the node to remove.
@@ -3261,7 +3259,7 @@
switch (mode)
{
case READ_ONLY :
- setReadOny();
+ setReadOnly();
break;
case READ_WRITE :
setReadWrite();
@@ -3277,7 +3275,7 @@
/**
* Sets mode to READ_ONLY, discarding flush task
*/
- protected void setReadOny()
+ protected void setReadOnly()
{
// try to stop merger in safe way
if (merger != null)
@@ -3286,7 +3284,10 @@
merger = null;
}
- flushTask.cancel();
+ if (flushTask != null)
+ {
+ flushTask.cancel();
+ }
FLUSH_TIMER.purge();
this.redoLog = null;
}
@@ -3386,8 +3387,7 @@
continue;
}
PersistentIndex index =
- new PersistentIndex(name, handler.getTextAnalyzer(), handler.getSimilarity(), cache,
- directoryManager);
+ new PersistentIndex(name, handler.getTextAnalyzer(), handler.getSimilarity(), cache, directoryManager);
index.setMaxFieldLength(handler.getMaxFieldLength());
index.setUseCompoundFile(handler.getUseCompoundFile());
index.setTermInfosIndexDivisor(handler.getTermInfosIndexDivisor());
12 years, 2 months
exo-jcr SVN: r5927 - in jcr/trunk: exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl and 1 other directory.
by do-not-reply@jboss.org
Author: tolusha
Date: 2012-03-21 09:58:04 -0400 (Wed, 21 Mar 2012)
New Revision: 5927
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCDataContainerConfig.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainer.java
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistingRepositorySameConfigRestore.java
Log:
EXOJCR-1754: testing on DB, share same connection for database cleaning in case of isolated db
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCDataContainerConfig.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCDataContainerConfig.java 2012-03-21 07:15:06 UTC (rev 5926)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCDataContainerConfig.java 2012-03-21 13:58:04 UTC (rev 5927)
@@ -42,6 +42,12 @@
{
return true;
}
+
+ @Override
+ public boolean isShareSameDatasource()
+ {
+ return false;
+ }
},
/**
* All workspaces from each repositories can be stored in a single database within one set of
@@ -53,6 +59,12 @@
{
return false;
}
+
+ @Override
+ public boolean isShareSameDatasource()
+ {
+ return true;
+ }
},
/**
* "ISOLATED" database structure combines SINGLE and MULTI, by offering workspace and repository
@@ -65,16 +77,27 @@
{
return true;
}
+
+ @Override
+ public boolean isShareSameDatasource()
+ {
+ return true;
+ }
};
/**
* @return true if every workspace stores data in separate table within one repository
*/
public abstract boolean isMultiDatabase();
+
+ /**
+ * @return true if every workspace should have same datasource name parameter in container
+ */
+ public abstract boolean isShareSameDatasource();
}
/**
- * Use additional connection to databse to check same name siblings
+ * Use additional connection to database to check same name siblings
*/
public boolean checkSNSNewConnection;
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainer.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainer.java 2012-03-21 07:15:06 UTC (rev 5926)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainer.java 2012-03-21 13:58:04 UTC (rev 5927)
@@ -405,7 +405,7 @@
if (wsSourceName != null && newWsSourceName != null)
{
- if (!dbType.isMultiDatabase() || dbType == DatabaseStructureType.ISOLATED)
+ if (dbType.isShareSameDatasource())
{
if (!wsSourceName.equals(newWsSourceName))
{
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistingRepositorySameConfigRestore.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistingRepositorySameConfigRestore.java 2012-03-21 07:15:06 UTC (rev 5926)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistingRepositorySameConfigRestore.java 2012-03-21 13:58:04 UTC (rev 5927)
@@ -35,6 +35,7 @@
import org.exoplatform.services.jcr.impl.clean.rdbms.DBCleanerTool;
import org.exoplatform.services.jcr.impl.clean.rdbms.DummyDBCleanerTool;
import org.exoplatform.services.jcr.impl.dataflow.persistent.WorkspacePersistentDataManager;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig.DatabaseStructureType;
import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer;
import org.exoplatform.services.jcr.impl.util.io.FileCleanerHolder;
@@ -91,9 +92,9 @@
// define one common database cleaner for all restores for single db case
DBCleanerTool dbCleaner = null;
- Boolean isMultiDb = JDBCWorkspaceDataContainer.getDatabaseType(wsEntry).isMultiDatabase();
+ DatabaseStructureType dbType = JDBCWorkspaceDataContainer.getDatabaseType(wsEntry);
- if (!isMultiDb)
+ if (dbType.isShareSameDatasource())
{
String dsName = wsEntry.getContainer().getParameterValue(JDBCWorkspaceDataContainer.SOURCE_NAME);
@@ -113,7 +114,10 @@
});
jdbcConn.setAutoCommit(false);
- dbCleaner = DBCleanService.getRepositoryDBCleaner(jdbcConn, repositoryEntry);
+ if (dbType == DatabaseStructureType.SINGLE)
+ {
+ dbCleaner = DBCleanService.getRepositoryDBCleaner(jdbcConn, repositoryEntry);
+ }
}
ManageableRepository repository = repositoryService.getRepository(this.repositoryEntry.getName());
@@ -142,7 +146,7 @@
if (jdbcConn != null)
{
- if (!isMultiDb)
+ if (dbType == DatabaseStructureType.SINGLE)
{
context = new DataRestoreContext(
new String[]{
12 years, 2 months
exo-jcr SVN: r5926 - jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/standalone.
by do-not-reply@jboss.org
Author: tolusha
Date: 2012-03-21 03:15:06 -0400 (Wed, 21 Mar 2012)
New Revision: 5926
Modified:
jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-mssql.xml
Log:
EXOJCR-1754: testing on DB, fix configuration
Modified: jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-mssql.xml
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-mssql.xml 2012-03-21 07:10:51 UTC (rev 5925)
+++ jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-mssql.xml 2012-03-21 07:15:06 UTC (rev 5926)
@@ -189,7 +189,7 @@
<init-params>
<value-param>
<name>bind-name</name>
- <value>jdbcjcr30</value>
+ <value>jdbcjcr6</value>
</value-param>
<value-param>
<name>class-name</name>
@@ -202,10 +202,10 @@
<properties-param>
<name>ref-addresses</name>
<description>ref-addresses</description>
- <property name="driverClassName" value="org.hsqldb.jdbcDriver" />
- <property name="url" value="jdbc:hsqldb:file:target/temp/data/db8ws" />
- <property name="username" value="sa" />
- <property name="password" value="" />
+ <property name="driverClassName" value="com.microsoft.sqlserver.jdbc.SQLServerDriver" />
+ <property name="url" value="jdbc:sqlserver://localhost:1433;databaseName=db1;" />
+ <property name="username" value="tester" />
+ <property name="password" value="tester" />
</properties-param>
</init-params>
</component-plugin>
@@ -216,7 +216,7 @@
<init-params>
<value-param>
<name>bind-name</name>
- <value>jdbcjcr31</value>
+ <value>jdbcjcr7</value>
</value-param>
<value-param>
<name>class-name</name>
@@ -229,35 +229,8 @@
<properties-param>
<name>ref-addresses</name>
<description>ref-addresses</description>
- <property name="driverClassName" value="org.hsqldb.jdbcDriver" />
- <property name="url" value="jdbc:hsqldb:file:target/temp/data/db8ws2" />
- <property name="username" value="sa" />
- <property name="password" value="" />
- </properties-param>
- </init-params>
- </component-plugin>
- <component-plugin>
- <name>bind.datasource</name>
- <set-method>addPlugin</set-method>
- <type>org.exoplatform.services.naming.BindReferencePlugin</type>
- <init-params>
- <value-param>
- <name>bind-name</name>
- <value>jdbcjcr6</value>
- </value-param>
- <value-param>
- <name>class-name</name>
- <value>javax.sql.DataSource</value>
- </value-param>
- <value-param>
- <name>factory</name>
- <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
- </value-param>
- <properties-param>
- <name>ref-addresses</name>
- <description>ref-addresses</description>
<property name="driverClassName" value="com.microsoft.sqlserver.jdbc.SQLServerDriver" />
- <property name="url" value="jdbc:sqlserver://localhost:1433;databaseName=db1;" />
+ <property name="url" value="jdbc:sqlserver://localhost:1433;databaseName=db2;" />
<property name="username" value="tester" />
<property name="password" value="tester" />
</properties-param>
@@ -270,7 +243,7 @@
<init-params>
<value-param>
<name>bind-name</name>
- <value>jdbcjcr7</value>
+ <value>jdbcjcr8</value>
</value-param>
<value-param>
<name>class-name</name>
@@ -284,7 +257,7 @@
<name>ref-addresses</name>
<description>ref-addresses</description>
<property name="driverClassName" value="com.microsoft.sqlserver.jdbc.SQLServerDriver" />
- <property name="url" value="jdbc:sqlserver://localhost:1433;databaseName=db2_ws;" />
+ <property name="url" value="jdbc:sqlserver://localhost:1433;databaseName=db1_ws;" />
<property name="username" value="tester" />
<property name="password" value="tester" />
</properties-param>
@@ -297,7 +270,7 @@
<init-params>
<value-param>
<name>bind-name</name>
- <value>jdbcjcr8</value>
+ <value>jdbcjcr9</value>
</value-param>
<value-param>
<name>class-name</name>
@@ -311,7 +284,7 @@
<name>ref-addresses</name>
<description>ref-addresses</description>
<property name="driverClassName" value="com.microsoft.sqlserver.jdbc.SQLServerDriver" />
- <property name="url" value="jdbc:sqlserver://localhost:1433;databaseName=db2_ws1;" />
+ <property name="url" value="jdbc:sqlserver://localhost:1433;databaseName=db1_ws1;" />
<property name="username" value="tester" />
<property name="password" value="tester" />
</properties-param>
12 years, 2 months
exo-jcr SVN: r5925 - in jcr/trunk: exo.jcr.component.ext/src/test/resources/conf/standalone and 1 other directory.
by do-not-reply@jboss.org
Author: tolusha
Date: 2012-03-21 03:10:51 -0400 (Wed, 21 Mar 2012)
New Revision: 5925
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCWorkspaceDataContainer.java
jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-db2.xml
jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-mysql.xml
jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-oracle.xml
jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-pgsql.xml
jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-sybase.xml
jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup.xml
jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/standalone/test-jcr-ext-config-backup.xml
Log:
EXOJCR-1754: testing on DB, fix bugs
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCWorkspaceDataContainer.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCWorkspaceDataContainer.java 2012-03-20 15:38:57 UTC (rev 5924)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCWorkspaceDataContainer.java 2012-03-21 07:10:51 UTC (rev 5925)
@@ -97,14 +97,13 @@
{
LOG.warn(DBConstants.DB_DIALECT_ORACLEOCI + " dialect is experimental!");
this.connFactory = new DefaultOracleConnectionFactory(getDataSource(), containerConfig);
-
- // a particular db initializer may be configured here too
dbInitializer =
new OracleDBInitializer(this.connFactory.getJdbcConnection(), containerConfig);
}
else if (containerConfig.dbDialect == DBConstants.DB_DIALECT_ORACLE)
{
this.connFactory = new DefaultOracleConnectionFactory(getDataSource(), containerConfig);
+ dbInitializer = new OracleDBInitializer(this.connFactory.getJdbcConnection(), containerConfig);
}
else if (containerConfig.dbDialect == DBConstants.DB_DIALECT_PGSQL)
{
@@ -140,7 +139,7 @@
}
else if (containerConfig.dbDialect == DBConstants.DB_DIALECT_DB2)
{
- new DB2ConnectionFactory(getDataSource(), containerConfig);
+ this.connFactory = new DB2ConnectionFactory(getDataSource(), containerConfig);
dbInitializer = defaultDBInitializer();
}
else if (containerConfig.dbDialect == DBConstants.DB_DIALECT_DB2V8)
Modified: jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-db2.xml
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-db2.xml 2012-03-20 15:38:57 UTC (rev 5924)
+++ jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-db2.xml 2012-03-21 07:10:51 UTC (rev 5925)
@@ -230,7 +230,7 @@
<name>ref-addresses</name>
<description>ref-addresses</description>
<property name="driverClassName" value="com.ibm.db2.jcc.DB2Driver" />
- <property name="url" value="jdbc:db2://dbs-jcr.exoplatform.com.ua:50002/db2_ws" />
+ <property name="url" value="jdbc:db2://dbs-jcr.exoplatform.com.ua:50002/db2" />
<property name="username" value="db2inst1" />
<property name="password" value="eXoAdmin" />
</properties-param>
@@ -243,7 +243,7 @@
<init-params>
<value-param>
<name>bind-name</name>
- <value>jdbcjcr30</value>
+ <value>jdbcjcr8</value>
</value-param>
<value-param>
<name>class-name</name>
@@ -256,10 +256,10 @@
<properties-param>
<name>ref-addresses</name>
<description>ref-addresses</description>
- <property name="driverClassName" value="org.hsqldb.jdbcDriver" />
- <property name="url" value="jdbc:hsqldb:file:target/temp/data/db8ws" />
- <property name="username" value="sa" />
- <property name="password" value="" />
+ <property name="driverClassName" value="com.ibm.db2.jcc.DB2Driver" />
+ <property name="url" value="jdbc:db2://dbs-jcr.exoplatform.com.ua:50002/db1_ws" />
+ <property name="username" value="db2inst1" />
+ <property name="password" value="eXoAdmin" />
</properties-param>
</init-params>
</component-plugin>
@@ -270,7 +270,7 @@
<init-params>
<value-param>
<name>bind-name</name>
- <value>jdbcjcr31</value>
+ <value>jdbcjcr9</value>
</value-param>
<value-param>
<name>class-name</name>
@@ -283,35 +283,8 @@
<properties-param>
<name>ref-addresses</name>
<description>ref-addresses</description>
- <property name="driverClassName" value="org.hsqldb.jdbcDriver" />
- <property name="url" value="jdbc:hsqldb:file:target/temp/data/db8ws2" />
- <property name="username" value="sa" />
- <property name="password" value="" />
- </properties-param>
- </init-params>
- </component-plugin>
- <component-plugin>
- <name>bind.datasource</name>
- <set-method>addPlugin</set-method>
- <type>org.exoplatform.services.naming.BindReferencePlugin</type>
- <init-params>
- <value-param>
- <name>bind-name</name>
- <value>jdbcjcr8</value>
- </value-param>
- <value-param>
- <name>class-name</name>
- <value>javax.sql.DataSource</value>
- </value-param>
- <value-param>
- <name>factory</name>
- <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
- </value-param>
- <properties-param>
- <name>ref-addresses</name>
- <description>ref-addresses</description>
<property name="driverClassName" value="com.ibm.db2.jcc.DB2Driver" />
- <property name="url" value="jdbc:db2://dbs-jcr.exoplatform.com.ua:50002/db2_ws1" />
+ <property name="url" value="jdbc:db2://dbs-jcr.exoplatform.com.ua:50002/db1_ws1" />
<property name="username" value="db2inst1" />
<property name="password" value="eXoAdmin" />
</properties-param>
Modified: jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-mysql.xml
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-mysql.xml 2012-03-20 15:38:57 UTC (rev 5924)
+++ jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-mysql.xml 2012-03-21 07:10:51 UTC (rev 5925)
@@ -230,7 +230,7 @@
<name>ref-addresses</name>
<description>ref-addresses</description>
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
- <property name="url" value="jdbc:mysql://localhost/db2_ws" />
+ <property name="url" value="jdbc:mysql://localhost/db2" />
<property name="username" value="root" />
<property name="password" value="eXoAdmin" />
</properties-param>
@@ -243,7 +243,7 @@
<init-params>
<value-param>
<name>bind-name</name>
- <value>jdbcjcr30</value>
+ <value>jdbcjcr8</value>
</value-param>
<value-param>
<name>class-name</name>
@@ -256,10 +256,10 @@
<properties-param>
<name>ref-addresses</name>
<description>ref-addresses</description>
- <property name="driverClassName" value="org.hsqldb.jdbcDriver" />
- <property name="url" value="jdbc:hsqldb:file:target/temp/data/db8ws" />
- <property name="username" value="sa" />
- <property name="password" value="" />
+ <property name="driverClassName" value="com.mysql.jdbc.Driver" />
+ <property name="url" value="jdbc:mysql://localhost/db1_ws" />
+ <property name="username" value="root" />
+ <property name="password" value="eXoAdmin" />
</properties-param>
</init-params>
</component-plugin>
@@ -270,7 +270,7 @@
<init-params>
<value-param>
<name>bind-name</name>
- <value>jdbcjcr31</value>
+ <value>jdbcjcr9</value>
</value-param>
<value-param>
<name>class-name</name>
@@ -283,41 +283,12 @@
<properties-param>
<name>ref-addresses</name>
<description>ref-addresses</description>
- <property name="driverClassName" value="org.hsqldb.jdbcDriver" />
- <property name="url" value="jdbc:hsqldb:file:target/temp/data/db8ws2" />
- <property name="username" value="sa" />
- <property name="password" value="" />
+ <property name="driverClassName" value="com.mysql.jdbc.Driver" />
+ <property name="url" value="jdbc:mysql://localhost/db1_ws1" />
+ <property name="username" value="root" />
+ <property name="password" value="eXoAdmin" />
</properties-param>
</init-params>
</component-plugin>
-
- <component-plugin>
- <name>bind.datasource</name>
- <set-method>addPlugin</set-method>
- <type>org.exoplatform.services.naming.BindReferencePlugin</type>
- <init-params>
- <value-param>
- <name>bind-name</name>
- <value>jdbcjcr8</value>
- </value-param>
- <value-param>
- <name>class-name</name>
- <value>javax.sql.DataSource</value>
- </value-param>
- <value-param>
- <name>factory</name>
- <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
- </value-param>
- <properties-param>
- <name>ref-addresses</name>
- <description>ref-addresses</description>
- <property name="driverClassName" value="com.mysql.jdbc.Driver" />
- <property name="url" value="jdbc:mysql://localhost/db2_ws1" />
- <property name="username" value="root" />
- <property name="password" value="eXoAdmin" />
- </properties-param>
- </init-params>
- </component-plugin>
-
</external-component-plugins>
</configuration>
Modified: jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-oracle.xml
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-oracle.xml 2012-03-20 15:38:57 UTC (rev 5924)
+++ jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-oracle.xml 2012-03-21 07:10:51 UTC (rev 5925)
@@ -236,60 +236,6 @@
</properties-param>
</init-params>
</component-plugin>
- <component-plugin>
- <name>bind.datasource</name>
- <set-method>addPlugin</set-method>
- <type>org.exoplatform.services.naming.BindReferencePlugin</type>
- <init-params>
- <value-param>
- <name>bind-name</name>
- <value>jdbcjcr30</value>
- </value-param>
- <value-param>
- <name>class-name</name>
- <value>javax.sql.DataSource</value>
- </value-param>
- <value-param>
- <name>factory</name>
- <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
- </value-param>
- <properties-param>
- <name>ref-addresses</name>
- <description>ref-addresses</description>
- <property name="driverClassName" value="org.hsqldb.jdbcDriver" />
- <property name="url" value="jdbc:hsqldb:file:target/temp/data/db8ws" />
- <property name="username" value="sa" />
- <property name="password" value="" />
- </properties-param>
- </init-params>
- </component-plugin>
- <component-plugin>
- <name>bind.datasource</name>
- <set-method>addPlugin</set-method>
- <type>org.exoplatform.services.naming.BindReferencePlugin</type>
- <init-params>
- <value-param>
- <name>bind-name</name>
- <value>jdbcjcr31</value>
- </value-param>
- <value-param>
- <name>class-name</name>
- <value>javax.sql.DataSource</value>
- </value-param>
- <value-param>
- <name>factory</name>
- <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
- </value-param>
- <properties-param>
- <name>ref-addresses</name>
- <description>ref-addresses</description>
- <property name="driverClassName" value="org.hsqldb.jdbcDriver" />
- <property name="url" value="jdbc:hsqldb:file:target/temp/data/db8ws2" />
- <property name="username" value="sa" />
- <property name="password" value="" />
- </properties-param>
- </init-params>
- </component-plugin>
<component-plugin>
<name>bind.datasource</name>
<set-method>addPlugin</set-method>
@@ -317,5 +263,32 @@
</properties-param>
</init-params>
</component-plugin>
+ <component-plugin>
+ <name>bind.datasource</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
+ <value>jdbcjcr9</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.sql.DataSource</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+ </value-param>
+ <properties-param>
+ <name>ref-addresses</name>
+ <description>ref-addresses</description>
+ <property name="driverClassName" value="oracle.jdbc.OracleDriver" />
+ <property name="url" value="jdbc:oracle:thin:@v06.storm.exoplatform.com.ua:1521:orclvm" />
+ <property name="username" value="exoperf3" />
+ <property name="password" value="exo12321" />
+ </properties-param>
+ </init-params>
+ </component-plugin>
</external-component-plugins>
</configuration>
Modified: jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-pgsql.xml
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-pgsql.xml 2012-03-20 15:38:57 UTC (rev 5924)
+++ jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-pgsql.xml 2012-03-21 07:10:51 UTC (rev 5925)
@@ -231,67 +231,13 @@
<name>ref-addresses</name>
<description>ref-addresses</description>
<property name="driverClassName" value="org.postgresql.Driver" />
- <property name="url" value="jdbc:postgresql://localhost:5433/db1_ws" />
+ <property name="url" value="jdbc:postgresql://localhost:5433/db2" />
<property name="username" value="root" />
<property name="password" value="eXoAdmin" />
<property name="maxActive" value="20" />
</properties-param>
</init-params>
</component-plugin>
- <component-plugin>
- <name>bind.datasource</name>
- <set-method>addPlugin</set-method>
- <type>org.exoplatform.services.naming.BindReferencePlugin</type>
- <init-params>
- <value-param>
- <name>bind-name</name>
- <value>jdbcjcr30</value>
- </value-param>
- <value-param>
- <name>class-name</name>
- <value>javax.sql.DataSource</value>
- </value-param>
- <value-param>
- <name>factory</name>
- <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
- </value-param>
- <properties-param>
- <name>ref-addresses</name>
- <description>ref-addresses</description>
- <property name="driverClassName" value="org.hsqldb.jdbcDriver" />
- <property name="url" value="jdbc:hsqldb:file:target/temp/data/db8ws" />
- <property name="username" value="sa" />
- <property name="password" value="" />
- </properties-param>
- </init-params>
- </component-plugin>
- <component-plugin>
- <name>bind.datasource</name>
- <set-method>addPlugin</set-method>
- <type>org.exoplatform.services.naming.BindReferencePlugin</type>
- <init-params>
- <value-param>
- <name>bind-name</name>
- <value>jdbcjcr31</value>
- </value-param>
- <value-param>
- <name>class-name</name>
- <value>javax.sql.DataSource</value>
- </value-param>
- <value-param>
- <name>factory</name>
- <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
- </value-param>
- <properties-param>
- <name>ref-addresses</name>
- <description>ref-addresses</description>
- <property name="driverClassName" value="org.hsqldb.jdbcDriver" />
- <property name="url" value="jdbc:hsqldb:file:target/temp/data/db8ws2" />
- <property name="username" value="sa" />
- <property name="password" value="" />
- </properties-param>
- </init-params>
- </component-plugin>
<component-plugin>
<name>bind.datasource</name>
<set-method>addPlugin</set-method>
@@ -313,6 +259,34 @@
<name>ref-addresses</name>
<description>ref-addresses</description>
<property name="driverClassName" value="org.postgresql.Driver" />
+ <property name="url" value="jdbc:postgresql://localhost:5433/db1_ws" />
+ <property name="username" value="root" />
+ <property name="password" value="eXoAdmin" />
+ <property name="maxActive" value="20" />
+ </properties-param>
+ </init-params>
+ </component-plugin>
+ <component-plugin>
+ <name>bind.datasource</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
+ <value>jdbcjcr9</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.sql.DataSource</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+ </value-param>
+ <properties-param>
+ <name>ref-addresses</name>
+ <description>ref-addresses</description>
+ <property name="driverClassName" value="org.postgresql.Driver" />
<property name="url" value="jdbc:postgresql://localhost:5433/db1_ws1" />
<property name="username" value="root" />
<property name="password" value="eXoAdmin" />
Modified: jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-sybase.xml
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-sybase.xml 2012-03-20 15:38:57 UTC (rev 5924)
+++ jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-sybase.xml 2012-03-21 07:10:51 UTC (rev 5925)
@@ -230,7 +230,7 @@
<name>ref-addresses</name>
<description>ref-addresses</description>
<property name="driverClassName" value="com.sybase.jdbc4.jdbc.SybDriver" />
- <property name="url" value="jdbc:sybase:Tds:localhost:5003/db2_ws" />
+ <property name="url" value="jdbc:sybase:Tds:localhost:5003/db2" />
<property name="username" value="sa" />
<property name="password" value="" />
</properties-param>
@@ -243,7 +243,7 @@
<init-params>
<value-param>
<name>bind-name</name>
- <value>jdbcjcr30</value>
+ <value>jdbcjcr8</value>
</value-param>
<value-param>
<name>class-name</name>
@@ -256,10 +256,10 @@
<properties-param>
<name>ref-addresses</name>
<description>ref-addresses</description>
- <property name="driverClassName" value="org.hsqldb.jdbcDriver" />
- <property name="url" value="jdbc:hsqldb:file:target/temp/data/db8ws" />
- <property name="username" value="sa" />
- <property name="password" value="" />
+ <property name="driverClassName" value="com.sybase.jdbc4.jdbc.SybDriver" />
+ <property name="url" value="jdbc:sybase:Tds:localhost:5003/db1_ws" />
+ <property name="username" value="sa" />
+ <property name="password" value="" />
</properties-param>
</init-params>
</component-plugin>
@@ -270,7 +270,7 @@
<init-params>
<value-param>
<name>bind-name</name>
- <value>jdbcjcr31</value>
+ <value>jdbcjcr9</value>
</value-param>
<value-param>
<name>class-name</name>
@@ -283,35 +283,8 @@
<properties-param>
<name>ref-addresses</name>
<description>ref-addresses</description>
- <property name="driverClassName" value="org.hsqldb.jdbcDriver" />
- <property name="url" value="jdbc:hsqldb:file:target/temp/data/db8ws2" />
- <property name="username" value="sa" />
- <property name="password" value="" />
- </properties-param>
- </init-params>
- </component-plugin>
- <component-plugin>
- <name>bind.datasource</name>
- <set-method>addPlugin</set-method>
- <type>org.exoplatform.services.naming.BindReferencePlugin</type>
- <init-params>
- <value-param>
- <name>bind-name</name>
- <value>jdbcjcr8</value>
- </value-param>
- <value-param>
- <name>class-name</name>
- <value>javax.sql.DataSource</value>
- </value-param>
- <value-param>
- <name>factory</name>
- <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
- </value-param>
- <properties-param>
- <name>ref-addresses</name>
- <description>ref-addresses</description>
<property name="driverClassName" value="com.sybase.jdbc4.jdbc.SybDriver" />
- <property name="url" value="jdbc:sybase:Tds:localhost:5003/db2_ws1" />
+ <property name="url" value="jdbc:sybase:Tds:localhost:5003/db1_ws1" />
<property name="username" value="sa" />
<property name="password" value="" />
</properties-param>
Modified: jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup.xml
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup.xml 2012-03-20 15:38:57 UTC (rev 5924)
+++ jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup.xml 2012-03-21 07:10:51 UTC (rev 5925)
@@ -230,7 +230,7 @@
<name>ref-addresses</name>
<description>ref-addresses</description>
<property name="driverClassName" value="org.hsqldb.jdbcDriver" />
- <property name="url" value="jdbc:hsqldb:file:target/temp/data/db4ws" />
+ <property name="url" value="jdbc:hsqldb:file:target/temp/data/db4" />
<property name="username" value="sa" />
<property name="password" value="" />
</properties-param>
@@ -257,33 +257,6 @@
<name>ref-addresses</name>
<description>ref-addresses</description>
<property name="driverClassName" value="org.hsqldb.jdbcDriver" />
- <property name="url" value="jdbc:hsqldb:file:target/temp/data/db4ws2" />
- <property name="username" value="sa" />
- <property name="password" value="" />
- </properties-param>
- </init-params>
- </component-plugin>
- <component-plugin>
- <name>bind.datasource</name>
- <set-method>addPlugin</set-method>
- <type>org.exoplatform.services.naming.BindReferencePlugin</type>
- <init-params>
- <value-param>
- <name>bind-name</name>
- <value>jdbcjcr30</value>
- </value-param>
- <value-param>
- <name>class-name</name>
- <value>javax.sql.DataSource</value>
- </value-param>
- <value-param>
- <name>factory</name>
- <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
- </value-param>
- <properties-param>
- <name>ref-addresses</name>
- <description>ref-addresses</description>
- <property name="driverClassName" value="org.hsqldb.jdbcDriver" />
<property name="url" value="jdbc:hsqldb:file:target/temp/data/db8ws" />
<property name="username" value="sa" />
<property name="password" value="" />
@@ -297,7 +270,7 @@
<init-params>
<value-param>
<name>bind-name</name>
- <value>jdbcjcr31</value>
+ <value>jdbcjcr9</value>
</value-param>
<value-param>
<name>class-name</name>
@@ -311,7 +284,7 @@
<name>ref-addresses</name>
<description>ref-addresses</description>
<property name="driverClassName" value="org.hsqldb.jdbcDriver" />
- <property name="url" value="jdbc:hsqldb:file:target/temp/data/db8ws2" />
+ <property name="url" value="jdbc:hsqldb:file:target/temp/data/db8ws1" />
<property name="username" value="sa" />
<property name="password" value="" />
</properties-param>
Modified: jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/standalone/test-jcr-ext-config-backup.xml
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/standalone/test-jcr-ext-config-backup.xml 2012-03-20 15:38:57 UTC (rev 5924)
+++ jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/standalone/test-jcr-ext-config-backup.xml 2012-03-21 07:10:51 UTC (rev 5925)
@@ -191,7 +191,7 @@
<workspace name="ws1">
<container class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCWorkspaceDataContainer">
<properties>
- <property name="source-name" value="jdbcjcr8" />
+ <property name="source-name" value="jdbcjcr7" />
<property name="db-structure-type" value="isolated" />
<property name="max-buffer-size" value="200k" />
<property name="swap-directory" value="target/temp/swap/db4ws1" />
@@ -234,7 +234,7 @@
<property name="jbosscache-cl-cache.jdbc.fqn.column" value="fqn" />
<property name="jbosscache-cl-cache.jdbc.node.column" value="node" />
<property name="jbosscache-cl-cache.jdbc.parent.column" value="parent" />
- <property name="jbosscache-cl-cache.jdbc.datasource" value="jdbcjcr8" />
+ <property name="jbosscache-cl-cache.jdbc.datasource" value="jdbcjcr7" />
<property name="jbosscache-shareable" value="true" />
</properties>
</lock-manager>
@@ -250,7 +250,7 @@
<workspace name="ws">
<container class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCWorkspaceDataContainer">
<properties>
- <property name="source-name" value="jdbcjcr30" />
+ <property name="source-name" value="jdbcjcr8" />
<property name="db-structure-type" value="multi" />
<property name="max-buffer-size" value="200k" />
<property name="swap-directory" value="target/temp/swap/db4ws" />
@@ -293,7 +293,7 @@
<property name="jbosscache-cl-cache.jdbc.fqn.column" value="fqn" />
<property name="jbosscache-cl-cache.jdbc.node.column" value="node" />
<property name="jbosscache-cl-cache.jdbc.parent.column" value="parent" />
- <property name="jbosscache-cl-cache.jdbc.datasource" value="jdbcjcr30" />
+ <property name="jbosscache-cl-cache.jdbc.datasource" value="jdbcjcr8" />
<property name="jbosscache-shareable" value="true" />
</properties>
</lock-manager>
@@ -302,7 +302,7 @@
<workspace name="ws1">
<container class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCWorkspaceDataContainer">
<properties>
- <property name="source-name" value="jdbcjcr31" />
+ <property name="source-name" value="jdbcjcr9" />
<property name="db-structure-type" value="multi" />
<property name="max-buffer-size" value="200k" />
<property name="swap-directory" value="target/temp/swap/db8ws1" />
@@ -345,7 +345,7 @@
<property name="jbosscache-cl-cache.jdbc.fqn.column" value="fqn" />
<property name="jbosscache-cl-cache.jdbc.node.column" value="node" />
<property name="jbosscache-cl-cache.jdbc.parent.column" value="parent" />
- <property name="jbosscache-cl-cache.jdbc.datasource" value="jdbcjcr31" />
+ <property name="jbosscache-cl-cache.jdbc.datasource" value="jdbcjcr9" />
<property name="jbosscache-shareable" value="true" />
</properties>
</lock-manager>
12 years, 2 months
exo-jcr SVN: r5924 - in jcr/trunk: exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene and 3 other directories.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2012-03-20 11:38:57 -0400 (Tue, 20 Mar 2012)
New Revision: 5924
Added:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/ScorerWrapper.java
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/AbstractExcerpt.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/AbstractIndex.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/DescendantSelfAxisQuery.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JcrQueryParser.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JcrStandartAnalyzer.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MoreLikeThis.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/NotQuery.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/PersistentIndex.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/ReadOnlyIndexReader.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SearchIndex.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SingletonTokenStream.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/spell/LuceneSpellChecker.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/query/TestIndexingConfig.java
jcr/trunk/packaging/module/src/main/javascript/jcr.packaging.module.js
jcr/trunk/pom.xml
Log:
EXOJCR-1752 : upgrade to lucene 3.5
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/AbstractExcerpt.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/AbstractExcerpt.java 2012-03-20 14:01:39 UTC (rev 5923)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/AbstractExcerpt.java 2012-03-20 15:38:57 UTC (rev 5924)
@@ -17,8 +17,8 @@
package org.exoplatform.services.jcr.impl.core.query.lucene;
import org.apache.lucene.analysis.TokenStream;
+import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
import org.apache.lucene.analysis.tokenattributes.OffsetAttribute;
-import org.apache.lucene.analysis.tokenattributes.TermAttribute;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Fieldable;
import org.apache.lucene.index.IndexReader;
@@ -268,9 +268,9 @@
{
while (ts.incrementToken())
{
- OffsetAttribute offset = (OffsetAttribute)ts.getAttribute(OffsetAttribute.class);
- TermAttribute term = (TermAttribute)ts.getAttribute(TermAttribute.class);
- String termText = term.term();
+ OffsetAttribute offset = ts.getAttribute(OffsetAttribute.class);
+ CharTermAttribute term = ts.getAttribute(CharTermAttribute.class);
+ String termText = new String(term.buffer(), 0, term.length());
TermVectorOffsetInfo[] info = termMap.get(termText);
if (info == null)
{
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/AbstractIndex.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/AbstractIndex.java 2012-03-20 14:01:39 UTC (rev 5923)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/AbstractIndex.java 2012-03-20 15:38:57 UTC (rev 5924)
@@ -20,9 +20,12 @@
import org.apache.lucene.document.Document;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.index.IndexWriterConfig;
+import org.apache.lucene.index.LogMergePolicy;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.Similarity;
import org.apache.lucene.store.Directory;
+import org.apache.lucene.util.Version;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -54,9 +57,6 @@
/** PrintStream that pipes all calls to println(String) into log.info() */
private static final LoggingPrintStream STREAM_LOGGER = new LoggingPrintStream();
- /** Executor with a pool size equal to the number of available processors */
- private static final DynamicPooledExecutor EXECUTOR = new DynamicPooledExecutor();
-
/** The currently set IndexWriter or <code>null</code> if none is set */
private IndexWriter indexWriter;
@@ -124,7 +124,8 @@
if (!isExisting)
{
- indexWriter = new IndexWriter(directory, analyzer, IndexWriter.MaxFieldLength.LIMITED);
+ IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_30, analyzer);
+ indexWriter = new IndexWriter(directory, config);
// immediately close, now that index has been created
indexWriter.close();
indexWriter = null;
@@ -231,7 +232,7 @@
log.debug("closing IndexWriter.");
indexWriter = null;
}
-
+
if (indexReader == null || !indexReader.isCurrent())
{
IndexReader reader = IndexReader.open(getDirectory(), null, false, termInfosIndexDivisor);
@@ -335,9 +336,17 @@
}
if (indexWriter == null)
{
- indexWriter = new IndexWriter(getDirectory(), analyzer, new IndexWriter.MaxFieldLength(maxFieldLength));
- indexWriter.setSimilarity(similarity);
- indexWriter.setUseCompoundFile(useCompoundFile);
+ IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_30, analyzer);
+ config.setSimilarity(similarity);
+ if (config.getMergePolicy() instanceof LogMergePolicy)
+ {
+ ((LogMergePolicy)config.getMergePolicy()).setUseCompoundFile(useCompoundFile);
+ }
+ else
+ {
+ log.error("Can't set \"UseCompoundFile\". Merge policy is not an instance of LogMergePolicy. ");
+ }
+ indexWriter = new IndexWriter(directory, config);
indexWriter.setInfoStream(STREAM_LOGGER);
}
return indexWriter;
@@ -501,7 +510,15 @@
useCompoundFile = b;
if (indexWriter != null)
{
- indexWriter.setUseCompoundFile(b);
+ IndexWriterConfig config = indexWriter.getConfig();
+ if (config.getMergePolicy() instanceof LogMergePolicy)
+ {
+ ((LogMergePolicy)config.getMergePolicy()).setUseCompoundFile(useCompoundFile);
+ }
+ else
+ {
+ log.error("Can't set \"UseCompoundFile\". Merge policy is not an instance of LogMergePolicy. ");
+ }
}
}
@@ -513,7 +530,7 @@
this.maxFieldLength = maxFieldLength;
if (indexWriter != null)
{
- indexWriter.setMaxFieldLength(maxFieldLength);
+ indexWriter.setMaxFieldLength(this.maxFieldLength);
}
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/DescendantSelfAxisQuery.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/DescendantSelfAxisQuery.java 2012-03-20 14:01:39 UTC (rev 5923)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/DescendantSelfAxisQuery.java 2012-03-20 15:38:57 UTC (rev 5924)
@@ -542,7 +542,18 @@
}
collectContextHits();
- currentDoc = subScorer.nextDoc();
+ try
+ {
+ currentDoc = subScorer.nextDoc();
+ }
+ catch (UnsupportedOperationException e)
+ {
+ // workaround. Consider getting rid of it
+ ScorerWrapper collector = new ScorerWrapper(subScorer.getSimilarity());
+ subScorer.score(collector.getCollector());
+ subScorer = collector;
+ currentDoc = subScorer.nextDoc();
+ }
if (contextHits.isEmpty())
{
currentDoc = NO_MORE_DOCS;
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JcrQueryParser.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JcrQueryParser.java 2012-03-20 14:01:39 UTC (rev 5923)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JcrQueryParser.java 2012-03-20 15:38:57 UTC (rev 5924)
@@ -48,7 +48,7 @@
*/
public JcrQueryParser(String fieldName, Analyzer analyzer, SynonymProvider synonymProvider)
{
- super(Version.LUCENE_24, fieldName, analyzer);
+ super(Version.LUCENE_30, fieldName, analyzer);
this.synonymProvider = synonymProvider;
setAllowLeadingWildcard(true);
setDefaultOperator(Operator.AND);
@@ -155,7 +155,7 @@
}
else
{
- return super.getFieldQuery(field, queryText);
+ return super.getFieldQuery(field, queryText, true);
}
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JcrStandartAnalyzer.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JcrStandartAnalyzer.java 2012-03-20 14:01:39 UTC (rev 5923)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JcrStandartAnalyzer.java 2012-03-20 15:38:57 UTC (rev 5924)
@@ -36,7 +36,7 @@
* index the text of the property and to parse searchtext for this property.
*/
-public class JcrStandartAnalyzer extends Analyzer
+public final class JcrStandartAnalyzer extends Analyzer
{
/**
@@ -47,7 +47,7 @@
{
public Analyzer run()
{
- return new StandardAnalyzer(Version.LUCENE_24, Collections.EMPTY_SET);
+ return new StandardAnalyzer(Version.LUCENE_30, Collections.EMPTY_SET);
}
});
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MoreLikeThis.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MoreLikeThis.java 2012-03-20 14:01:39 UTC (rev 5923)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MoreLikeThis.java 2012-03-20 15:38:57 UTC (rev 5924)
@@ -19,7 +19,7 @@
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
-import org.apache.lucene.analysis.tokenattributes.TermAttribute;
+import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
import org.apache.lucene.document.Document;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.Term;
@@ -153,7 +153,7 @@
* Default analyzer to parse source doc with.
* @see #getAnalyzer
*/
- public static final Analyzer DEFAULT_ANALYZER = new StandardAnalyzer(Version.LUCENE_24);
+ public static final Analyzer DEFAULT_ANALYZER = new StandardAnalyzer(Version.LUCENE_30);
/**
* Ignore terms with less than this frequency in the source doc.
@@ -203,12 +203,12 @@
* @see #setStopWords
* @see #getStopWords
*/
- public static final Set DEFAULT_STOP_WORDS = null;
+ public static final Set<String> DEFAULT_STOP_WORDS = null;
/**
* Current set of stop words.
*/
- private Set stopWords = DEFAULT_STOP_WORDS;
+ private Set<String> stopWords = DEFAULT_STOP_WORDS;
/**
* Return a Query with no more than this many terms.
@@ -466,7 +466,7 @@
* @see org.apache.lucene.analysis.StopFilter#makeStopSet StopFilter.makeStopSet()
* @see #getStopWords
*/
- public void setStopWords(Set stopWords)
+ public void setStopWords(Set<String> stopWords)
{
this.stopWords = stopWords;
}
@@ -475,7 +475,7 @@
* Get the current stop words being used.
* @see #setStopWords
*/
- public Set getStopWords()
+ public Set<String> getStopWords()
{
return stopWords;
}
@@ -530,8 +530,8 @@
if (fieldNames == null)
{
// gather list of valid fields from lucene
- Collection fields = ir.getFieldNames(IndexReader.FieldOption.INDEXED);
- fieldNames = (String[])fields.toArray(new String[fields.size()]);
+ Collection<String> fields = ir.getFieldNames(IndexReader.FieldOption.INDEXED);
+ fieldNames = fields.toArray(new String[fields.size()]);
}
return createQuery(retrieveTerms(docNum));
@@ -547,8 +547,8 @@
if (fieldNames == null)
{
// gather list of valid fields from lucene
- Collection fields = ir.getFieldNames(IndexReader.FieldOption.INDEXED);
- fieldNames = (String[])fields.toArray(new String[fields.size()]);
+ Collection<String> fields = ir.getFieldNames(IndexReader.FieldOption.INDEXED);
+ fieldNames = fields.toArray(new String[fields.size()]);
}
return like(new FileReader(f));
@@ -585,9 +585,9 @@
}
/**
- * Create the More like query from a PriorityQueue
+ * Create the More like query from a PriorityQueue<Object[]>
*/
- private Query createQuery(PriorityQueue q)
+ private Query createQuery(PriorityQueue<Object[]> q)
{
BooleanQuery query = new BooleanQuery();
Object cur;
@@ -630,22 +630,22 @@
}
/**
- * Create a PriorityQueue from a word->tf map.
+ * Create a PriorityQueue<Object[]> from a word->tf map.
*
* @param words a map of words keyed on the word(String) with Int objects as the values.
*/
- private PriorityQueue createQueue(Map words) throws IOException
+ private PriorityQueue<Object[]> createQueue(Map<String, Int> words) throws IOException
{
// have collected all words in doc and their freqs
int numDocs = ir.numDocs();
FreqQ res = new FreqQ(words.size()); // will order words by score
- Iterator it = words.keySet().iterator();
+ Iterator<String> it = words.keySet().iterator();
while (it.hasNext())
{ // for every word
- String word = (String)it.next();
+ String word = it.next();
- int tf = ((Int)words.get(word)).x; // term freq in the source doc
+ int tf = words.get(word).x; // term freq in the source doc
if (minTermFreq > 0 && tf < minTermFreq)
{
continue; // filter out words that don't occur enough times in the source
@@ -714,9 +714,9 @@
*
* @param docNum the id of the lucene document from which to find terms
*/
- public PriorityQueue retrieveTerms(int docNum) throws IOException
+ public PriorityQueue<Object[]> retrieveTerms(int docNum) throws IOException
{
- Map termFreqMap = new HashMap();
+ Map<String, Int> termFreqMap = new HashMap<String, Int>();
for (int i = 0; i < fieldNames.length; i++)
{
String fieldName = fieldNames[i];
@@ -750,7 +750,7 @@
* @param termFreqMap a Map of terms and their frequencies
* @param vector List of terms and their frequencies for a doc/field
*/
- private void addTermFrequencies(Map termFreqMap, TermFreqVector vector)
+ private void addTermFrequencies(Map<String, Int> termFreqMap, TermFreqVector vector)
{
String[] terms = vector.getTerms();
int[] freqs = vector.getTermFrequencies();
@@ -763,7 +763,7 @@
continue;
}
// increment frequency
- Int cnt = (Int)termFreqMap.get(term);
+ Int cnt = termFreqMap.get(term);
if (cnt == null)
{
cnt = new Int();
@@ -790,8 +790,8 @@
// for every token
while (ts.incrementToken())
{
- TermAttribute term = (TermAttribute)ts.getAttribute(TermAttribute.class);
- String word = term.term();
+ CharTermAttribute term = ts.getAttribute(CharTermAttribute.class);
+ String word = new String(term.buffer(), 0, term.length());
tokenCount++;
if (tokenCount > maxNumTokensParsed)
{
@@ -862,9 +862,9 @@
*
* @see #retrieveInterestingTerms
*/
- public PriorityQueue retrieveTerms(Reader r) throws IOException
+ public PriorityQueue<Object[]> retrieveTerms(Reader r) throws IOException
{
- Map words = new HashMap();
+ Map<String, Int> words = new HashMap<String, Int>();
for (int i = 0; i < fieldNames.length; i++)
{
String fieldName = fieldNames[i];
@@ -878,8 +878,8 @@
*/
public String[] retrieveInterestingTerms(int docNum) throws IOException
{
- ArrayList al = new ArrayList(maxQueryTerms);
- PriorityQueue pq = retrieveTerms(docNum);
+ ArrayList<Object> al = new ArrayList<Object>(maxQueryTerms);
+ PriorityQueue<Object[]> pq = retrieveTerms(docNum);
Object cur;
// have to be careful, retrieveTerms returns all words but that's probably not useful to our caller...
int lim = maxQueryTerms;
@@ -890,7 +890,7 @@
al.add(ar[0]); // the 1st entry is the interesting word
}
String[] res = new String[al.size()];
- return (String[])al.toArray(res);
+ return al.toArray(res);
}
/**
@@ -904,8 +904,8 @@
*/
public String[] retrieveInterestingTerms(Reader r) throws IOException
{
- ArrayList al = new ArrayList(maxQueryTerms);
- PriorityQueue pq = retrieveTerms(r);
+ ArrayList<Object> al = new ArrayList<Object>(maxQueryTerms);
+ PriorityQueue<Object[]> pq = retrieveTerms(r);
Object cur;
// have to be careful, retrieveTerms returns all words but that's probably not useful to our caller...
int lim = maxQueryTerms;
@@ -916,25 +916,23 @@
al.add(ar[0]); // the 1st entry is the interesting word
}
String[] res = new String[al.size()];
- return (String[])al.toArray(res);
+ return al.toArray(res);
}
/**
- * PriorityQueue that orders words by score.
+ * PriorityQueue<Object[]> that orders words by score.
*/
- private static class FreqQ extends PriorityQueue
+ private static class FreqQ extends PriorityQueue<Object[]>
{
FreqQ(int s)
{
initialize(s);
}
- protected boolean lessThan(Object a, Object b)
+ protected boolean lessThan(Object[] a, Object[] b)
{
- Object[] aa = (Object[])a;
- Object[] bb = (Object[])b;
- Float fa = (Float)aa[2];
- Float fb = (Float)bb[2];
+ Float fa = (Float)a[2];
+ Float fb = (Float)b[2];
return fa.floatValue() > fb.floatValue();
}
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/NotQuery.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/NotQuery.java 2012-03-20 14:01:39 UTC (rev 5923)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/NotQuery.java 2012-03-20 15:38:57 UTC (rev 5924)
@@ -220,7 +220,7 @@
if (docNo == -1)
{
// get first doc of context scorer
- int docId = contextScorer.nextDoc();
+ int docId = contextScorer == null ? NO_MORE_DOCS : contextScorer.nextDoc();
if (docId != NO_MORE_DOCS)
{
contextNo = docId;
@@ -237,7 +237,7 @@
while (contextNo != -1 && contextNo == docNo)
{
docNo++;
- int docId = contextScorer.nextDoc();
+ int docId = contextScorer == null ? NO_MORE_DOCS : contextScorer.nextDoc();
contextNo = docId == NO_MORE_DOCS ? -1 : docId;
}
if (docNo >= reader.maxDoc())
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/PersistentIndex.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/PersistentIndex.java 2012-03-20 14:01:39 UTC (rev 5923)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/PersistentIndex.java 2012-03-20 15:38:57 UTC (rev 5924)
@@ -91,7 +91,7 @@
void addIndexes(IndexReader[] readers) throws IOException
{
getIndexWriter().addIndexes(readers);
- getIndexWriter().optimize();
+ getIndexWriter().maybeMerge();
}
/**
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/ReadOnlyIndexReader.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/ReadOnlyIndexReader.java 2012-03-20 14:01:39 UTC (rev 5923)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/ReadOnlyIndexReader.java 2012-03-20 15:38:57 UTC (rev 5924)
@@ -190,6 +190,10 @@
*/
protected final void doCommit(Map commitUserData)
{
+ if (!hasChanges)
+ {
+ return;
+ }
throw new UnsupportedOperationException("IndexReader is read-only");
}
Added: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/ScorerWrapper.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/ScorerWrapper.java (rev 0)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/ScorerWrapper.java 2012-03-20 15:38:57 UTC (rev 5924)
@@ -0,0 +1,173 @@
+/*
+ * Copyright (C) 2003-2012 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.services.jcr.impl.core.query.lucene;
+
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.search.Collector;
+import org.apache.lucene.search.Scorer;
+import org.apache.lucene.search.Similarity;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * WorkAround wrapper, used as bridge between Scorer.score(Collector) and DocIdSetIterator.
+ * Some Scorers inside Lucene (BooleanScorer) doesn't support DocIdSetIterator interface,
+ * but required for JCR needs.
+ * Consider getting rid of this solution.
+ *
+ * @author <a href="mailto:nzamosenchuk@exoplatform.com">Nikolay Zamosenchuk</a>
+ * @version $Id: ScorerWrapper.java 34360 2009-07-22 23:58:59Z nzamosenchuk $
+ *
+ */
+public class ScorerWrapper extends Scorer
+{
+
+ List<DocData> docs = new ArrayList<DocData>();
+
+ int index;
+
+ DocData currentDocData = null;
+
+ CollectorWrapper collectorWrapper;
+
+ static class DocData
+ {
+ public int docID;
+
+ public float freq;
+
+ public float score;
+
+ public DocData(int docID, float freq, float score)
+ {
+ super();
+ this.docID = docID;
+ this.freq = freq;
+ this.score = score;
+ }
+
+ }
+
+ class CollectorWrapper extends Collector
+ {
+ private Scorer subScrorer;
+
+ @Override
+ public void setScorer(Scorer scorer) throws IOException
+ {
+ this.subScrorer = scorer;
+ }
+
+ @Override
+ public void collect(int doc) throws IOException
+ {
+ ScorerWrapper.this.docs.add(new DocData(doc, subScrorer.freq(), subScrorer.score()));
+ }
+
+ @Override
+ public void setNextReader(IndexReader reader, int docBase) throws IOException
+ {
+ }
+
+ @Override
+ public boolean acceptsDocsOutOfOrder()
+ {
+ return true;
+ }
+
+ }
+
+ /**
+ * @param similarity
+ */
+ protected ScorerWrapper(Similarity similarity)
+ {
+ super(similarity);
+
+ collectorWrapper = new CollectorWrapper();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public float score() throws IOException
+ {
+ if (currentDocData != null)
+ {
+ return currentDocData.score;
+ }
+ return 0;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int docID()
+ {
+ if (currentDocData != null)
+ {
+ return currentDocData.docID;
+ }
+ return NO_MORE_DOCS;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int nextDoc() throws IOException
+ {
+ if (index < docs.size())
+ {
+ currentDocData = docs.get(index);
+ index++;
+ return currentDocData.docID;
+ }
+ else
+ {
+ currentDocData = null;
+ return NO_MORE_DOCS;
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int advance(int target) throws IOException
+ {
+ int doc;
+ while ((doc = nextDoc()) < target)
+ {
+ if (doc == NO_MORE_DOCS || doc == -1)
+ {
+ return NO_MORE_DOCS;
+ }
+ }
+ return doc;
+ }
+
+ public Collector getCollector()
+ {
+ return collectorWrapper;
+ }
+
+}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SearchIndex.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SearchIndex.java 2012-03-20 14:01:39 UTC (rev 5923)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SearchIndex.java 2012-03-20 15:38:57 UTC (rev 5924)
@@ -21,7 +21,6 @@
import org.apache.commons.collections.collection.TransformedCollection;
import org.apache.commons.collections.iterators.TransformIterator;
import org.apache.lucene.analysis.Analyzer;
-import org.apache.lucene.analysis.Token;
import org.apache.lucene.analysis.tokenattributes.PayloadAttribute;
import org.apache.lucene.analysis.tokenattributes.TermAttribute;
import org.apache.lucene.document.Document;
@@ -1959,7 +1958,6 @@
{
// find the right fields to transfer
Fieldable[] fields = aDoc.getFieldables(FieldNames.PROPERTIES);
- Token t = new Token();
for (int k = 0; k < fields.length; k++)
{
Fieldable field = fields[k];
@@ -1967,12 +1965,11 @@
// SingleTokenStream
//t = field.tokenStreamValue().next(t);
field.tokenStreamValue().incrementToken();
- TermAttribute term =
- field.tokenStreamValue().getAttribute(TermAttribute.class);
- PayloadAttribute payload =
- field.tokenStreamValue().getAttribute(PayloadAttribute.class);
+ TermAttribute term = field.tokenStreamValue().getAttribute(TermAttribute.class);
+ PayloadAttribute payload = field.tokenStreamValue().getAttribute(PayloadAttribute.class);
- String value = new String(t.termBuffer(), 0, t.termLength());
+ String value = new String(term.termBuffer(), 0, term.termLength());
+
if (value.startsWith(namePrefix))
{
// extract value
@@ -1981,7 +1978,8 @@
QPath p = getRelativePath(state, propState);
String path = getNamespaceMappings().translatePath(p);
value = FieldNames.createNamedValue(path, value);
- t.setTermBuffer(value);
+
+ term.setTermBuffer(value);
doc.add(new Field(field.name(), new SingletonTokenStream(term.term(), payload
.getPayload())));
doc.add(new Field(FieldNames.AGGREGATED_NODE_UUID, parent.getIdentifier(),
@@ -2026,30 +2024,8 @@
* if an error occurs while reading item states.
*/
protected QPath getRelativePath(NodeData nodeState, PropertyData propState) throws RepositoryException
-
{
-
- QPath nodePath = nodeState.getQPath();
- QPath propPath = propState.getQPath();
throw new RepositoryException();
- // Path p = nodePath.computeRelativePath(propPath);
- // // make sure it does not contain indexes
- // boolean clean = true;
- // Path.Element[] elements = p.getElements();
- // for (int i = 0; i < elements.length; i++)
- // {
- // if (elements[i].getIndex() != 0)
- // {
- // elements[i] = PATH_FACTORY.createElement(elements[i].getName());
- // clean = false;
- // }
- // }
- // if (!clean)
- // {
- // p = PATH_FACTORY.create(elements);
- // }
-
- // return p;
}
/**
@@ -2101,7 +2077,6 @@
* value=NodeState.
*/
protected void retrieveAggregateRoot(final Set<String> removedNodeIds, final Map<String, NodeData> map)
-
{
if (indexingConfig != null)
{
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SingletonTokenStream.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SingletonTokenStream.java 2012-03-20 14:01:39 UTC (rev 5923)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SingletonTokenStream.java 2012-03-20 15:38:57 UTC (rev 5924)
@@ -62,7 +62,8 @@
*/
public SingletonTokenStream()
{
-
+ termAttribute = addAttribute(TermAttribute.class);
+ payloadAttribute = addAttribute(PayloadAttribute.class);
}
/**
@@ -77,8 +78,8 @@
{
this.value = value;
this.payload = payload;
- termAttribute = (TermAttribute)addAttribute(TermAttribute.class);
- payloadAttribute = (PayloadAttribute)addAttribute(PayloadAttribute.class);
+ termAttribute = addAttribute(TermAttribute.class);
+ payloadAttribute = addAttribute(PayloadAttribute.class);
}
/**
@@ -95,17 +96,6 @@
this(value, new Payload(new PropertyMetaData(type).toByteArray()));
}
- /**
- * Creates a new SingleTokenStream with the given token.
- *
- * @param t the token.
- */
- @Deprecated
- public SingletonTokenStream(Token t)
- {
- this(t.term(), t.getPayload());
- }
-
@Override
public boolean incrementToken() throws IOException
{
@@ -136,8 +126,6 @@
public void close() throws IOException
{
consumed = true;
- value = null;
- payload = null;
payloadAttribute = null;
termAttribute = null;
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/spell/LuceneSpellChecker.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/spell/LuceneSpellChecker.java 2012-03-20 14:01:39 UTC (rev 5923)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/spell/LuceneSpellChecker.java 2012-03-20 15:38:57 UTC (rev 5924)
@@ -17,15 +17,19 @@
package org.exoplatform.services.jcr.impl.core.query.lucene.spell;
import org.apache.lucene.analysis.TokenStream;
+import org.apache.lucene.analysis.standard.StandardAnalyzer;
+import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
import org.apache.lucene.analysis.tokenattributes.OffsetAttribute;
import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
-import org.apache.lucene.analysis.tokenattributes.TermAttribute;
import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.search.spell.Dictionary;
import org.apache.lucene.search.spell.LuceneDictionary;
import org.apache.lucene.search.spell.SpellChecker;
+import org.apache.lucene.search.spell.SuggestMode;
import org.apache.lucene.store.AlreadyClosedException;
import org.apache.lucene.store.Directory;
+import org.apache.lucene.util.Version;
import org.exoplatform.commons.utils.SecurityHelper;
import org.exoplatform.services.jcr.impl.core.query.QueryHandler;
import org.exoplatform.services.jcr.impl.core.query.QueryRootNode;
@@ -362,23 +366,23 @@
private void tokenize(String statement, List<String> words, List<TokenData> tokens) throws IOException
{
TokenStream ts = handler.getTextAnalyzer().tokenStream(FieldNames.FULLTEXT, new StringReader(statement));
- TermAttribute term = (TermAttribute)ts.getAttribute(TermAttribute.class);
- PositionIncrementAttribute positionIncrement =
- (PositionIncrementAttribute)ts.getAttribute(PositionIncrementAttribute.class);
- OffsetAttribute offset = (OffsetAttribute)ts.getAttribute(OffsetAttribute.class);
+ CharTermAttribute term = ts.getAttribute(CharTermAttribute.class);
+ PositionIncrementAttribute positionIncrement = ts.getAttribute(PositionIncrementAttribute.class);
+ OffsetAttribute offset = ts.getAttribute(OffsetAttribute.class);
try
{
+ String word;
while (ts.incrementToken())
{
- String word = term.term();
+ word = new String(term.buffer(), 0, term.length());
// while ((t = ts.next()) != null)
// {
String origWord = statement.substring(offset.startOffset(), offset.endOffset());
if (positionIncrement.getPositionIncrement() > 0)
{
words.add(word);
- tokens.add(new TokenData(offset.startOffset(), offset.endOffset(), term.term()));
+ tokens.add(new TokenData(offset.startOffset(), offset.endOffset(), word));
}
else
{
@@ -389,8 +393,7 @@
{
// replace current token and word
words.set(words.size() - 1, word);
- tokens
- .set(tokens.size() - 1, new TokenData(offset.startOffset(), offset.endOffset(), term.term()));
+ tokens.set(tokens.size() - 1, new TokenData(offset.startOffset(), offset.endOffset(), word));
}
}
}
@@ -459,8 +462,9 @@
{
public String[] run() throws Exception
{
- return spellChecker.suggestSimilar(words[currentIndex], 5, reader, FieldNames.FULLTEXT,
- morePopular);
+ return spellChecker
+ .suggestSimilar(words[currentIndex], 5, reader, FieldNames.FULLTEXT, morePopular
+ ? SuggestMode.SUGGEST_MORE_POPULAR : SuggestMode.SUGGEST_WHEN_NOT_IN_INDEX);
}
});
@@ -548,7 +552,8 @@
long time = System.currentTimeMillis();
Dictionary dict = new LuceneDictionary(reader, FieldNames.FULLTEXT);
LOG.debug("Starting spell checker index refresh");
- spellChecker.indexDictionary(dict);
+ spellChecker.indexDictionary(dict, new IndexWriterConfig(Version.LUCENE_30,
+ new StandardAnalyzer(Version.LUCENE_30)), true);
time = System.currentTimeMillis() - time;
time = time / 1000;
LOG.info("Spell checker index refreshed in: " + new Long(time) + " s.");
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/query/TestIndexingConfig.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/query/TestIndexingConfig.java 2012-03-20 14:01:39 UTC (rev 5923)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/query/TestIndexingConfig.java 2012-03-20 15:38:57 UTC (rev 5924)
@@ -101,9 +101,9 @@
IndexingConfigurationImpl indexingConfigurationImpl = (IndexingConfigurationImpl)searchIndex.getIndexingConfig();
assertNotNull(indexingConfigurationImpl);
- indexingConfigurationImpl.addPropertyAnalyzer("FULL:" + simple, new SimpleAnalyzer());
- indexingConfigurationImpl.addPropertyAnalyzer("FULL:" + whitespace, new WhitespaceAnalyzer());
- indexingConfigurationImpl.addPropertyAnalyzer("FULL:" + stop, new StopAnalyzer(Version.LUCENE_24));
+ indexingConfigurationImpl.addPropertyAnalyzer("FULL:" + simple, new SimpleAnalyzer(Version.LUCENE_30));
+ indexingConfigurationImpl.addPropertyAnalyzer("FULL:" + whitespace, new WhitespaceAnalyzer(Version.LUCENE_30));
+ indexingConfigurationImpl.addPropertyAnalyzer("FULL:" + stop, new StopAnalyzer(Version.LUCENE_30));
testRoot = testSession.getRootNode().addNode("testrootAnalyzers");
root.save();
}
Modified: jcr/trunk/packaging/module/src/main/javascript/jcr.packaging.module.js
===================================================================
--- jcr/trunk/packaging/module/src/main/javascript/jcr.packaging.module.js 2012-03-20 14:01:39 UTC (rev 5923)
+++ jcr/trunk/packaging/module/src/main/javascript/jcr.packaging.module.js 2012-03-20 15:38:57 UTC (rev 5924)
@@ -26,9 +26,10 @@
addDependency(new Project("jboss.jbossts","jbossjts","jar","4.6.1.GA")).
addDependency(new Project("jboss.jbossts","jbossts-common","jar","4.6.1.GA")).
addDependency(new Project("org.apache.ws.commons","ws-commons-util","jar","1.0.1")).
- addDependency(new Project("org.apache.lucene", "lucene-core", "jar", "2.9.4")).
- addDependency(new Project("org.apache.lucene", "lucene-spellchecker", "jar", "2.9.4")).
- addDependency(new Project("org.apache.lucene", "lucene-memory", "jar", "2.9.4"));
+ addDependency(new Project("org.apache.lucene", "lucene-core", "jar", "3.5.0")).
+ addDependency(new Project("org.apache.lucene", "lucene-spellchecker", "jar", "3.5.0")).
+ addDependency(new Project("org.apache.lucene", "lucene-wordnet", "jar", "3.3.0")).
+ addDependency(new Project("org.apache.lucene", "lucene-memory", "jar", "3.5.0"));
module.frameworks = {}
module.frameworks.web =
Modified: jcr/trunk/pom.xml
===================================================================
--- jcr/trunk/pom.xml 2012-03-20 14:01:39 UTC (rev 5923)
+++ jcr/trunk/pom.xml 2012-03-20 15:38:57 UTC (rev 5924)
@@ -279,22 +279,22 @@
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-core</artifactId>
- <version>3.0.3</version>
+ <version>3.5.0</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-spellchecker</artifactId>
- <version>3.0.3</version>
+ <version>3.5.0</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-memory</artifactId>
- <version>3.0.3</version>
+ <version>3.5.0</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-wordnet</artifactId>
- <version>3.0.3</version>
+ <version>3.3.0</version>
</dependency>
<dependency>
<groupId>com.sun.xml.stream</groupId>
12 years, 2 months
exo-jcr SVN: r5923 - in jcr/trunk: exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel and 11 other directories.
by do-not-reply@jboss.org
Author: dkuleshov
Date: 2012-03-20 10:01:39 -0400 (Tue, 20 Mar 2012)
New Revision: 5923
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
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-ijdbc-ispn.xml
jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/test/resources/conf/standalone/cluster/test-jcr-config-ijdbc-ispn.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-1739: ported EXOJCR-1682
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-03-20 13:45:55 UTC (rev 5922)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/NullItemData.java 2012-03-20 14:01:39 UTC (rev 5923)
@@ -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-03-20 13:45:55 UTC (rev 5922)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/ByteArrayPersistedValueData.java 2012-03-20 14:01:39 UTC (rev 5923)
@@ -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-03-20 13:45:55 UTC (rev 5922)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java 2012-03-20 14:01:39 UTC (rev 5923)
@@ -1360,6 +1360,7 @@
while (patternIterator.hasNext())
{
QPathEntryFilter pattern = patternIterator.next();
+ @SuppressWarnings("unchecked")
List<NodeData> persistedNodeData = (List<NodeData>)pattern.accept(persistedItemList);
if (pattern.isExactName())
{
@@ -1658,6 +1659,7 @@
while (patternIterator.hasNext())
{
QPathEntryFilter pattern = patternIterator.next();
+ @SuppressWarnings("unchecked")
List<PropertyData> persistedPropData =
(List<PropertyData>)pattern.accept(persistedItemList);
if (pattern.isExactName())
@@ -2449,6 +2451,10 @@
*/
public void stop()
{
+ if (filtersEnabled.get())
+ {
+ cache.removeListener(this);
+ }
}
/**
Modified: jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/pom.xml
===================================================================
--- jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/pom.xml 2012-03-20 13:45:55 UTC (rev 5922)
+++ jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/pom.xml 2012-03-20 14:01:39 UTC (rev 5923)
@@ -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>-sjdbc.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>test-sources</classifier>
<scope>test</scope>
<version>${project.version}</version>
<exclusions>
@@ -111,11 +116,6 @@
<artifactId>ow2-jta-1.1-spec</artifactId>
</dependency>
<dependency>
- <groupId>org.jgroups</groupId>
- <artifactId>jgroups</artifactId>
- <version>3.0.0.Final</version>
- </dependency>
- <dependency>
<groupId>org.exoplatform.kernel</groupId>
<artifactId>exo.kernel.component.common</artifactId>
</dependency>
@@ -141,6 +141,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 -->
@@ -218,8 +222,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>
@@ -398,7 +406,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
@@ -483,6 +495,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-03-20 13:45:55 UTC (rev 5922)
+++ jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/core/lock/infinispan/ISPNCacheableLockManagerImpl.java 2012-03-20 14:01:39 UTC (rev 5923)
@@ -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;
@@ -114,7 +113,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());
@@ -434,8 +433,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-03-20 13:45:55 UTC (rev 5922)
+++ jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/ChangesKey.java 2012-03-20 14:01:39 UTC (rev 5923)
@@ -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-03-20 13:45:55 UTC (rev 5922)
+++ jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/ISPNIndexInfos.java 2012-03-20 14:01:39 UTC (rev 5923)
@@ -206,8 +206,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-03-20 13:45:55 UTC (rev 5922)
+++ jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/ISPNIndexUpdateMonitor.java 2012-03-20 14:01:39 UTC (rev 5923)
@@ -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-03-20 13:45:55 UTC (rev 5922)
+++ jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/IndexInfosKey.java 2012-03-20 14:01:39 UTC (rev 5923)
@@ -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-03-20 13:45:55 UTC (rev 5922)
+++ jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/IndexUpdateKey.java 2012-03-20 14:01:39 UTC (rev 5923)
@@ -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-03-20 13:45:55 UTC (rev 5922)
+++ jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/IndexerCacheStore.java 2012-03-20 14:01:39 UTC (rev 5923)
@@ -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-03-20 13:45:55 UTC (rev 5922)
+++ jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/BufferedISPNCache.java 2012-03-20 14:01:39 UTC (rev 5923)
@@ -18,21 +18,23 @@
*/
package org.exoplatform.services.jcr.impl.dataflow.persistent.infinispan;
+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.jcr.infinispan.PrivilegedISPNCacheHelper;
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;
import org.infinispan.util.concurrent.NotifyingFuture;
import org.infinispan.util.concurrent.locks.LockManager;
+import java.security.PrivilegedAction;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
@@ -57,7 +59,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>
{
/**
@@ -155,20 +157,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;
}
@@ -268,8 +259,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
@@ -331,8 +321,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
@@ -870,9 +859,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);
+ }
+ });
}
/**
@@ -899,6 +894,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-03-20 13:45:55 UTC (rev 5922)
+++ jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CacheId.java 2012-03-20 14:01:39 UTC (rev 5923)
@@ -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;
- }
- }
}
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-03-20 13:45:55 UTC (rev 5922)
+++ jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CacheNodesByPageId.java 2012-03-20 14:01:39 UTC (rev 5923)
@@ -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-03-20 13:45:55 UTC (rev 5922)
+++ jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CacheNodesId.java 2012-03-20 14:01:39 UTC (rev 5923)
@@ -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-03-20 13:45:55 UTC (rev 5922)
+++ jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CachePatternNodesId.java 2012-03-20 14:01:39 UTC (rev 5923)
@@ -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-03-20 13:45:55 UTC (rev 5922)
+++ jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CachePatternPropsId.java 2012-03-20 14:01:39 UTC (rev 5923)
@@ -16,13 +16,15 @@
*/
package org.exoplatform.services.jcr.impl.dataflow.persistent.infinispan;
+import org.exoplatform.services.jcr.infinispan.CacheKey;
+
/**
* Created by The eXo Platform SAS.
*
* <br/>Date:
*
* @author <a href="karpenko.sergiy(a)gmail.com">Karpenko Sergiy</a>
- * @version $Id: CachePatternPropsId.java 111 28 ���. 2011 serg $
+ * @version $Id: CachePatternPropsId.java 111 28 ���. 2011 serg $
*/
public class CachePatternPropsId extends CacheKey
{
@@ -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-03-20 13:45:55 UTC (rev 5922)
+++ jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CachePropsId.java 2012-03-20 14:01:39 UTC (rev 5923)
@@ -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-03-20 13:45:55 UTC (rev 5922)
+++ jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CacheQPath.java 2012-03-20 14:01:39 UTC (rev 5923)
@@ -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-03-20 13:45:55 UTC (rev 5922)
+++ jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/CacheRefsId.java 2012-03-20 14:01:39 UTC (rev 5923)
@@ -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-03-20 13:45:55 UTC (rev 5922)
+++ jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/ISPNCacheWorkspaceStorageCache.java 2012-03-20 14:01:39 UTC (rev 5923)
@@ -18,17 +18,19 @@
*/
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;
import org.exoplatform.services.jcr.config.WorkspaceEntry;
import org.exoplatform.services.jcr.dataflow.ItemState;
import org.exoplatform.services.jcr.dataflow.ItemStateChangesLog;
-import org.exoplatform.services.jcr.dataflow.persistent.PersistedNodeData;
-import org.exoplatform.services.jcr.dataflow.persistent.PersistedPropertyData;
import org.exoplatform.services.jcr.dataflow.persistent.WorkspaceStorageCache;
import org.exoplatform.services.jcr.dataflow.persistent.WorkspaceStorageCacheListener;
import org.exoplatform.services.jcr.datamodel.IllegalPathException;
@@ -51,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;
@@ -64,6 +75,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;
@@ -78,6 +92,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;
/**
@@ -103,21 +120,39 @@
*/
public class ISPNCacheWorkspaceStorageCache implements WorkspaceStorageCache, Backupable, Startable
{
- 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;
@@ -128,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));
}
};
@@ -138,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)
{
@@ -149,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;
@@ -173,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];
@@ -183,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;
@@ -197,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)
@@ -230,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;
}
};
@@ -241,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)
{
@@ -278,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)
{
@@ -330,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();
}
};
@@ -380,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;
@@ -418,7 +454,7 @@
{
ChildNodesIterator(String parentId)
{
- super(new CacheNodesId(parentId));
+ super(new CacheNodesId(getOwnerId(), parentId));
}
@Override
@@ -433,7 +469,7 @@
ChildPropertiesIterator(String parentId)
{
- super(new CachePropsId(parentId));
+ super(new CachePropsId(getOwnerId(), parentId));
}
@Override
@@ -444,15 +480,65 @@
}
/**
- * 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");
@@ -460,30 +546,66 @@
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
{
- if (LOG.isTraceEnabled())
+ parentCache = factory.createCache("Data_" + wsConfig.getUniqueName(), cacheEntry);
+ Configuration config = parentCache.getCacheConfiguration();
+ if (config.clustering().cacheMode() == CacheMode.DIST_SYNC
+ || config.clustering().cacheMode() == CacheMode.DIST_ASYNC)
{
- LOG.trace("An exception occurred: " + e.getMessage());
+ 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());
+ }
this.cache.start();
}
+ private boolean isDistributedMode()
+ {
+ return ownerId != null;
+ }
+
+ private String getOwnerId()
+ {
+ return ownerId;
+ }
+
/**
* Return TransactionManager used by ISPN backing the JCR cache.
*
@@ -623,7 +745,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)
{
@@ -681,12 +803,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
@@ -721,7 +843,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)
{
@@ -762,7 +884,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
@@ -803,7 +925,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 +984,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 +1000,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 +1021,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 +1038,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 +1073,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 +1090,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 +1149,7 @@
{
return true;
}
-
+
/**
* {@inheritDoc}
*/
@@ -1079,32 +1201,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 +1235,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 +1269,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 +1299,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)
{
@@ -1214,7 +1341,7 @@
LOG.trace("An exception occurred: " + e.getMessage());
}
}
- cache.addToList(new CacheRefsId(nodeIdentifier), prop.getIdentifier(),
+ cache.addToList(new CacheRefsId(getOwnerId(), nodeIdentifier), prop.getIdentifier(),
modifyListsOfChild == ModifyChildOption.FORCE_MODIFY);
}
}
@@ -1222,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());
}
}
@@ -1267,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))
{
@@ -1297,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);
@@ -1322,78 +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)
- {
- if (LOG.isTraceEnabled())
- {
- LOG.trace("An exception occurred: " + e.getMessage());
- }
- }
-
- // 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);
}
/**
@@ -1402,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()
@@ -1494,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
{
@@ -1513,7 +1546,7 @@
{
return getReferencedProperties.run(identifier);
}
-
+
/**
* {@inheritDoc}
*/
@@ -1525,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();
}
}
@@ -1546,7 +1579,7 @@
*/
public void clean() throws BackupException
{
- cache.clear();
+ caller.clearCache();
}
/**
@@ -1585,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);
}
@@ -1593,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
@@ -1605,7 +1648,7 @@
if (data == null || data instanceof NullItemData)
{
return;
- }
+ }
for (WorkspaceStorageCacheListener listener : listeners)
{
try
@@ -1616,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
*
@@ -1637,7 +1742,7 @@
return ISPNCacheWorkspaceStorageCache.this.getTransactionManager();
}
}
-
+
@SuppressWarnings("rawtypes")
@Listener
public class CacheEventListener
@@ -1655,6 +1760,548 @@
}
/**
+ * 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);
+ }
+ }
+
+ /**
* {@inheritDoc}
*/
public void start()
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-03-20 14:01:39 UTC (rev 5923)
@@ -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
Added: 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/CacheKey.java (rev 0)
+++ jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/infinispan/CacheKey.java 2012-03-20 14:01:39 UTC (rev 5923)
@@ -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-03-20 14:01:39 UTC (rev 5923)
@@ -0,0 +1,80 @@
+/*
+ * 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;
+ System.out.println("The configuration file will be loaded from '" + DEFAULT_CONFIG_FILE_PATH + "'");//NOSONAR
+ }
+ else if (args.length == 1)
+ {
+ configPath = args[0];
+ System.out.println("The configuration file will be loaded from '" + args[0] + "'");//NOSONAR
+ }
+ else
+ {
+ System.err.println("Too many arguments, the expected syntax is: java CacheServer <configuration-file-path>");//NOSONAR
+ 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-03-20 13:45:55 UTC (rev 5922)
+++ jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/infinispan/ISPNCacheFactory.java 2012-03-20 14:01:39 UTC (rev 5923)
@@ -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.
@@ -63,17 +71,18 @@
public static final String INFINISPAN_CONFIG = "infinispan-configuration";
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,98 +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)
- {
- if (LOG.isTraceEnabled())
- {
- LOG.trace("An exception occurred: " + e.getMessage());
- }
- }
- 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 holder the configuration holder of the the cache to create
+ * @param tm the transaction manager to put into the configuration of the cache
* @param manager the current cache manager of the cache to create
* @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())
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-03-20 13:45:55 UTC (rev 5922)
+++ jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/resources/conf/portal/cluster/infinispan-data.xml 2012-03-20 14:01:39 UTC (rev 5923)
@@ -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-03-20 13:45:55 UTC (rev 5922)
+++ jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/resources/conf/portal/cluster/infinispan-indexer.xml 2012-03-20 14:01:39 UTC (rev 5923)
@@ -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-03-20 13:45:55 UTC (rev 5922)
+++ jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/main/resources/conf/portal/cluster/infinispan-lock.xml 2012-03-20 14:01:39 UTC (rev 5923)
@@ -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/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-03-20 13:45:55 UTC (rev 5922)
+++ jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/cache/infinispan/TestISPNCacheWorkspaceStorageCacheInClusterMode.java 2012-03-20 14:01:39 UTC (rev 5923)
@@ -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-03-20 13:45:55 UTC (rev 5922)
+++ jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/test/java/org/exoplatform/services/jcr/lab/infinispan/TestISPNCache.java 2012-03-20 14:01:39 UTC (rev 5923)
@@ -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);
Modified: jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/test/resources/conf/standalone/cluster/test-configuration-ijdbc-ispn.xml
===================================================================
--- jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/test/resources/conf/standalone/cluster/test-configuration-ijdbc-ispn.xml 2012-03-20 13:45:55 UTC (rev 5922)
+++ jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/test/resources/conf/standalone/cluster/test-configuration-ijdbc-ispn.xml 2012-03-20 14:01:39 UTC (rev 5923)
@@ -139,7 +139,7 @@
<value>jar:/conf/test/nodetypes-publication-config.xml</value>
<value>jar:/conf/test/publication-plugins-nodetypes-config.xml</value>
</values-param>
-
+
<values-param>
<name>testInitNodeTypesRepository</name>
<description>
@@ -215,6 +215,16 @@
</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>
@@ -298,7 +308,7 @@
<property name="url" value="jdbc:hsqldb:file:target/temp/data/jcrtest"/>
<property name="username" value="sa"/>
<property name="password" value=""/>
- <property name="maxActive" value="100" />
+ <property name="maxActive" value="100" />
</properties-param>
</init-params>
</component-plugin>
@@ -461,7 +471,7 @@
<property name="url" value="${testdbcleaner.url:jdbc:hsqldb:file:target/temp/data/testdbcleaner}"/>
<property name="username" value="${testdbcleaner.username:sa}"/>
<property name="password" value="${testdbcleaner.password:}"/>
- <property name="maxActive" value="20" />
+ <property name="maxActive" value="20" />
</properties-param>
</init-params>
</component-plugin>
Modified: jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/test/resources/conf/standalone/cluster/test-jcr-config-ijdbc-ispn.xml
===================================================================
--- jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/test/resources/conf/standalone/cluster/test-jcr-config-ijdbc-ispn.xml 2012-03-20 13:45:55 UTC (rev 5922)
+++ jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/test/resources/conf/standalone/cluster/test-jcr-config-ijdbc-ispn.xml 2012-03-20 14:01:39 UTC (rev 5923)
@@ -57,6 +57,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">
@@ -115,6 +116,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">
@@ -181,6 +183,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">
@@ -271,6 +274,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">
@@ -354,6 +358,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">
@@ -418,6 +423,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">
@@ -493,6 +499,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">
@@ -567,6 +574,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">
@@ -640,6 +648,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-03-20 13:45:55 UTC (rev 5922)
+++ jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/test/resources/conf/standalone/test-infinispan-config.xml 2012-03-20 14:01:39 UTC (rev 5923)
@@ -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-03-20 13:45:55 UTC (rev 5922)
+++ jcr/trunk/exo.jcr.component.core.impl.infinispan.v5/src/test/resources/conf/standalone/test-infinispan-lock.xml 2012-03-20 14:01:39 UTC (rev 5923)
@@ -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-03-20 13:45:55 UTC (rev 5922)
+++ jcr/trunk/pom.xml 2012-03-20 14:01:39 UTC (rev 5923)
@@ -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>
@@ -397,12 +402,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>
12 years, 2 months
exo-jcr SVN: r5922 - in kernel/trunk: exo.kernel.component.ext.cache.impl.infinispan.v5 and 9 other directories.
by do-not-reply@jboss.org
Author: dkuleshov
Date: 2012-03-20 09:45:55 -0400 (Tue, 20 Mar 2012)
New Revision: 5922
Modified:
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/pom.xml
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/java/org/exoplatform/services/cache/impl/infinispan/AbstractExoCache.java
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/java/org/exoplatform/services/cache/impl/infinispan/ExoCacheCreator.java
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/java/org/exoplatform/services/cache/impl/infinispan/ExoCacheFactoryImpl.java
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/java/org/exoplatform/services/cache/impl/infinispan/distributed/DistributedExoCache.java
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/java/org/exoplatform/services/cache/impl/infinispan/generic/GenericExoCacheCreator.java
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/java/org/exoplatform/services/ispn/DistributedCacheManager.java
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/java/org/exoplatform/services/ispn/Utils.java
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/resources/conf/portal/cache-configuration-template.xml
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/java/org/exoplatform/services/cache/impl/infinispan/TestAbstractExoCache.java
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/java/org/exoplatform/services/cache/impl/infinispan/TestExoCacheCreator.java
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/java/org/exoplatform/services/cache/impl/infinispan/TestExoCacheFactoryImpl.java
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/java/org/exoplatform/services/cache/impl/infinispan/distributed/TestDistributedExoCache.java
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/resources/conf/portal/cache-configuration-template.xml
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/resources/conf/portal/distributed-cache-configuration-template.xml
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/resources/conf/portal/distributed-cache-configuration.xml
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/resources/conf/portal/test-configuration.xml
kernel/trunk/exo.kernel.component.ext.rpc.impl.jgroups.v3/pom.xml
kernel/trunk/pom.xml
Log:
EXOJCR-1739: ported EXOJCR-1682
Modified: kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/pom.xml
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/pom.xml 2012-03-20 11:47:42 UTC (rev 5921)
+++ kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/pom.xml 2012-03-20 13:45:55 UTC (rev 5922)
@@ -24,13 +24,17 @@
<artifactId>exo.kernel.component.cache</artifactId>
</dependency>
<dependency>
+ <groupId>org.exoplatform.kernel</groupId>
+ <artifactId>exo.kernel.component.common</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.infinispan</groupId>
<artifactId>infinispan-core</artifactId>
</dependency>
<dependency>
<groupId>org.jgroups</groupId>
<artifactId>jgroups</artifactId>
- <version>3.0.0.Final</version>
+ <version>3.0.2.Final</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
Modified: kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/java/org/exoplatform/services/cache/impl/infinispan/AbstractExoCache.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/java/org/exoplatform/services/cache/impl/infinispan/AbstractExoCache.java 2012-03-20 11:47:42 UTC (rev 5921)
+++ kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/java/org/exoplatform/services/cache/impl/infinispan/AbstractExoCache.java 2012-03-20 13:45:55 UTC (rev 5922)
@@ -62,7 +62,7 @@
/**
* Logger.
*/
- private static final Log LOG = ExoLogger.getLogger("exo.kernel.component.ext.cache.impl.infinispan.v5.AbstractExoCache");
+ private static final Log LOG = ExoLogger.getLogger("exo.kernel.component.ext.cache.impl.infinispan.v5.AbstractExoCache"); //NOSONAR
private final AtomicInteger hits = new AtomicInteger(0);
@@ -227,6 +227,11 @@
{
throw new IllegalArgumentException("No null cache key accepted");
}
+ else if (value == null)
+ {
+ // ignore null values
+ return;
+ }
SecurityHelper.doPrivilegedAction(new PrivilegedAction<Void>()
{
@@ -285,7 +290,7 @@
onPut(entry.getKey(), entry.getValue());
}
}
- catch (Exception e)
+ catch (Exception e) //NOSONAR
{
cache.endBatch(false);
LOG.warn("An error occurs while executing the putMap method", e);
@@ -416,7 +421,7 @@
{
context.onExpire(key, obj);
}
- catch (Exception e)
+ catch (Exception e)//NOSONAR
{
if (LOG.isWarnEnabled())
LOG.warn("Cannot execute the CacheListener properly", e);
@@ -436,7 +441,7 @@
{
context.onRemove(key, obj);
}
- catch (Exception e)
+ catch (Exception e)//NOSONAR
{
if (LOG.isWarnEnabled())
LOG.warn("Cannot execute the CacheListener properly", e);
@@ -455,7 +460,7 @@
{
context.onPut(key, obj);
}
- catch (Exception e)
+ catch (Exception e)//NOSONAR
{
if (LOG.isWarnEnabled())
LOG.warn("Cannot execute the CacheListener properly", e);
@@ -473,7 +478,7 @@
{
context.onGet(key, obj);
}
- catch (Exception e)
+ catch (Exception e)//NOSONAR
{
if (LOG.isWarnEnabled())
LOG.warn("Cannot execute the CacheListener properly", e);
@@ -491,7 +496,7 @@
{
context.onClearCache();
}
- catch (Exception e)
+ catch (Exception e)//NOSONAR
{
if (LOG.isWarnEnabled())
LOG.warn("Cannot execute the CacheListener properly", e);
Modified: kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/java/org/exoplatform/services/cache/impl/infinispan/ExoCacheCreator.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/java/org/exoplatform/services/cache/impl/infinispan/ExoCacheCreator.java 2012-03-20 11:47:42 UTC (rev 5921)
+++ kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/java/org/exoplatform/services/cache/impl/infinispan/ExoCacheCreator.java 2012-03-20 13:45:55 UTC (rev 5922)
@@ -22,7 +22,7 @@
import org.exoplatform.services.cache.ExoCacheConfig;
import org.exoplatform.services.cache.ExoCacheInitException;
import org.infinispan.Cache;
-import org.infinispan.config.Configuration;
+import org.infinispan.configuration.cache.ConfigurationBuilder;
import java.io.Serializable;
import java.util.Set;
@@ -41,11 +41,11 @@
/**
* Creates an eXo cache according to the given configuration {@link org.exoplatform.services.cache.ExoCacheConfig}
* @param config the configuration of the cache to apply
- * @param cacheConfig the configuration of the infinispan cache
+ * @param confBuilder the configuration builder of the infinispan cache
* @param cacheGetter a {@link Callable} instance from which we can get the cache
* @exception ExoCacheInitException if an exception happens while initializing the cache
*/
- public ExoCache<Serializable, Object> create(ExoCacheConfig config, Configuration cacheConfig,
+ public ExoCache<Serializable, Object> create(ExoCacheConfig config, ConfigurationBuilder confBuilder,
Callable<Cache<Serializable, Object>> cacheGetter) throws ExoCacheInitException;
/**
Modified: kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/java/org/exoplatform/services/cache/impl/infinispan/ExoCacheFactoryImpl.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/java/org/exoplatform/services/cache/impl/infinispan/ExoCacheFactoryImpl.java 2012-03-20 11:47:42 UTC (rev 5921)
+++ kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/java/org/exoplatform/services/cache/impl/infinispan/ExoCacheFactoryImpl.java 2012-03-20 13:45:55 UTC (rev 5922)
@@ -34,12 +34,19 @@
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
import org.infinispan.Cache;
-import org.infinispan.config.Configuration;
-import org.infinispan.config.Configuration.CacheMode;
-import org.infinispan.config.GlobalConfiguration;
+import org.infinispan.configuration.cache.CacheMode;
+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.eviction.EvictionStrategy;
import org.infinispan.jmx.MBeanServerLookup;
import org.infinispan.manager.DefaultCacheManager;
+import org.infinispan.util.Util;
import java.io.InputStream;
import java.io.Serializable;
@@ -67,8 +74,8 @@
/**
* The logger
*/
- private static final Log LOG = ExoLogger
- .getLogger("exo.kernel.component.ext.cache.impl.infinispan.v5.ExoCacheFactoryImpl");
+ private static final Log LOG = ExoLogger //NOSONAR
+ .getLogger("exo.kernel.component.ext.cache.impl.infinispan.v5.ExoCacheFactoryImpl");//NOSONAR
/**
* The initial parameter key that defines the full path of the configuration template
@@ -113,10 +120,10 @@
private final Map<String, String> mappingCacheNameConfig = new HashMap<String, String>();
/**
- * The mapping between the global configuration and the cache managers
+ * The mapping between the cluster name and the cache managers
*/
- private final Map<GlobalConfiguration, DefaultCacheManager> mappingGlobalConfigCacheManager =
- new HashMap<GlobalConfiguration, DefaultCacheManager>();
+ private final Map<String, DefaultCacheManager> mappingGlobalConfigCacheManager =
+ new HashMap<String, DefaultCacheManager>();
/**
* The default creator
@@ -157,12 +164,13 @@
this.configManager = configManager;
if (cacheConfigTemplate == null)
{
- throw new RuntimeException("The parameter '" + CACHE_CONFIG_TEMPLATE_KEY + "' must be set");
+ throw new IllegalArgumentException("The parameter '" + CACHE_CONFIG_TEMPLATE_KEY + "' must be set");
}
// Initialize the main cache manager
this.cacheManager = initCacheManager(cacheConfigTemplate);
// Register the main cache manager
- mappingGlobalConfigCacheManager.put(cacheManager.getGlobalConfiguration(), cacheManager);
+ mappingGlobalConfigCacheManager.put(cacheManager.getCacheManagerConfiguration().transport().clusterName(),
+ cacheManager);
}
/**
@@ -183,7 +191,7 @@
// Read the configuration file of the cache
is = configManager.getInputStream(cacheConfigTemplate);
}
- catch (Exception e)
+ catch (Exception e)//NOSONAR
{
throw new ExoCacheInitException("The configuration of the CacheManager cannot be loaded from '"
+ cacheConfigTemplate + "'", e);
@@ -193,24 +201,32 @@
throw new ExoCacheInitException("The configuration of the CacheManager cannot be found at '"
+ cacheConfigTemplate + "'");
}
- DefaultCacheManager cacheManager = null;
+ GlobalConfigurationBuilder configBuilder;
+ Configuration config;
try
{
- // Create the CacheManager from the input stream
- cacheManager = new DefaultCacheManager(is, false);
+ Parser parser = new Parser(Thread.currentThread().getContextClassLoader());
+ // Loads the configuration from the input stream
+ ConfigurationBuilderHolder holder = parser.parse(is);
+ configBuilder = holder.getGlobalConfigurationBuilder();
+ config = holder.getDefaultConfigurationBuilder().build();
}
- catch (Exception e)
+ catch (RuntimeException e) //NOSONAR
{
+ throw new ExoCacheInitException("Cannot parse the configuration '" + cacheConfigTemplate + "'", e);
+ }
+ configureCacheManager(configBuilder);
+ try
+ {
+ // Create the CacheManager from the new configuration
+ return new DefaultCacheManager(configBuilder.build(), config);
+ }
+ catch (RuntimeException e) //NOSONAR
+ {
throw new ExoCacheInitException(
"Cannot initialize the CacheManager corresponding to the configuration '" + cacheConfigTemplate
+ "'", e);
}
-
- GlobalConfiguration config = cacheManager.getGlobalConfiguration();
-
- configureCacheManager(config);
- cacheManager.start();
- return cacheManager;
}
});
}
@@ -219,7 +235,7 @@
Throwable cause = e.getCause();
if (cause instanceof ExoCacheInitException)
{
- throw (ExoCacheInitException)cause;
+ throw (ExoCacheInitException)cause;//NOSONAR
}
else
{
@@ -231,16 +247,18 @@
/**
* Configure the cache manager
*
- * @param config
+ * @param configBuilder the configuration builder on which we applied all the required changes
* @throws ExoCacheInitException
*/
- private void configureCacheManager(GlobalConfiguration config) throws ExoCacheInitException
+ private void configureCacheManager(GlobalConfigurationBuilder configBuilder) throws ExoCacheInitException
{
+ GlobalConfiguration config = configBuilder.build();
// Configure JGroups
- configureJGroups(config);
+ configureJGroups(config, configBuilder);
// Configure the name of the cache manager
- config.fluent().globalJmxStatistics().cacheManagerName(config.getCacheManagerName() + "_" + ctx.getName()).
- // Configure the MBeanServerLookup
+ configBuilder.globalJmxStatistics().enable()
+ .cacheManagerName(config.globalJmxStatistics().cacheManagerName() + "_" + ctx.getName()).
+ // Configure the MBeanServerLookup
mBeanServerLookup(MBEAN_SERVER_LOOKUP);
}
@@ -249,27 +267,31 @@
* the cluster name by adding as suffix the name of the {@link ExoContainerContext}
*
* @param config the global configuration from which the JGroups config will be extracted
+ * @param configBuilder the related configuration builder
* @throws ExoCacheInitException if any exception occurs while configuring JGroups
*/
- private void configureJGroups(GlobalConfiguration config) throws ExoCacheInitException
+ private void configureJGroups(GlobalConfiguration config, GlobalConfigurationBuilder configBuilder)
+ throws ExoCacheInitException
{
- if (loadJGroupsConfig(config))
+ if (loadJGroupsConfig(config, configBuilder))
{
// The JGroups Config could be loaded which means that the configuration is for a cluster
- config.fluent().transport().clusterName(config.getClusterName() + "-" + ctx.getName());
+ configBuilder.transport().clusterName(config.transport().clusterName() + "-" + ctx.getName());
}
}
/**
* Load the JGroups configuration file thanks to the {@link ConfigurationManager}
* @param config the global configuration from which the JGroups config will be extracted
+ * @param configBuilder the related configuration builder
* @return <code>true</code> if the JGoups config could be loaded successfully,
* <code>false</code> if there were no JGroups config to load
* @throws ExoCacheInitException if the JGroups config could not be loaded
*/
- private boolean loadJGroupsConfig(GlobalConfiguration config) throws ExoCacheInitException
+ private boolean loadJGroupsConfig(GlobalConfiguration config, GlobalConfigurationBuilder configBuilder)
+ throws ExoCacheInitException
{
- return Utils.loadJGroupsConfig(configManager, config);
+ return Utils.loadJGroupsConfig(configManager, config, configBuilder);
}
/**
@@ -289,7 +311,7 @@
final DefaultCacheManager cacheManager;
try
{
- final Configuration conf;
+ final ConfigurationBuilder confBuilder = new ConfigurationBuilder();
if (customConfig != null)
{
try
@@ -302,24 +324,34 @@
// A custom configuration has been set
if (LOG.isInfoEnabled())
LOG.info("A custom configuration has been set for the cache '" + region + "'.");
- // Create the CacheManager by loading the configuration
- DefaultCacheManager customCacheManager =
- new DefaultCacheManager(configManager.getInputStream(customConfig), false);
- GlobalConfiguration gc = customCacheManager.getGlobalConfiguration();
+ Parser parser = new Parser(Thread.currentThread().getContextClassLoader());
+ // Load the configuration
+ ConfigurationBuilderHolder holder = parser.parse(configManager.getInputStream(customConfig));
+ GlobalConfigurationBuilder configBuilder = holder.getGlobalConfigurationBuilder();
// Configure JGroups and JMX since it could affect the state of the Global Config
- configureCacheManager(gc);
+ configureCacheManager(configBuilder);
+ GlobalConfiguration gc = configBuilder.build();
+
// Check if a CacheManager with the same GlobalConfiguration exists
- DefaultCacheManager currentCacheManager = mappingGlobalConfigCacheManager.get(gc);
+ DefaultCacheManager currentCacheManager =
+ mappingGlobalConfigCacheManager.get(gc.transport().clusterName());
if (currentCacheManager == null)
{
+ // Use a different cache manager name to prevent naming conflict
+ configBuilder.globalJmxStatistics().cacheManagerName(
+ gc.globalJmxStatistics().cacheManagerName() + "_" + region + "_" + ctx.getName());
// No cache manager has been defined so far for this Cache Configuration
- currentCacheManager = customCacheManager;
- // Use a different cache manager name to prevent naming conflict
- gc.fluent().globalJmxStatistics()
- .cacheManagerName(gc.getCacheManagerName() + "_" + region + "_" + ctx.getName());
+ currentCacheManager =
+ new DefaultCacheManager(configBuilder.build(), holder.getDefaultConfigurationBuilder()
+ .build(), false);
+ for (ConfigurationBuilder b : holder.getConfigurationBuilders())
+ {
+ Configuration c = b.build();
+ currentCacheManager.defineConfiguration(c.name(), c);
+ }
currentCacheManager.start();
// We register this new cache manager
- mappingGlobalConfigCacheManager.put(gc, customCacheManager);
+ mappingGlobalConfigCacheManager.put(gc.transport().clusterName(), currentCacheManager);
}
return currentCacheManager;
}
@@ -330,14 +362,23 @@
Throwable cause = e.getCause();
if (cause instanceof Exception)
{
- throw (Exception)cause;
+ throw (Exception)cause;//NOSONAR
}
else
{
throw new Exception(e);
}
}
- conf = cacheManager.getDefaultConfiguration().clone();
+ confBuilder.read(cacheManager.getDefaultCacheConfiguration());
+ //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()));
}
else if (config.isDistributed())
{
@@ -357,20 +398,28 @@
// No custom configuration has been found, a configuration template will be used
if (LOG.isInfoEnabled())
LOG.info("The configuration template will be used for the the cache '" + region + "'.");
- conf = cacheManager.getDefaultConfiguration().clone();
+ confBuilder.read(cacheManager.getDefaultCacheConfiguration());
+ //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()));
if (!config.isRepicated())
{
// The cache is local
- conf.fluent().clustering().mode(CacheMode.LOCAL);
+ confBuilder.clustering().cacheMode(CacheMode.LOCAL);
}
}
// Reset the configuration to avoid conflicts
- resetConfiguration(conf);
+ resetConfiguration(confBuilder);
final ExoCacheCreator creator = getExoCacheCreator(config);
// Create the cache
- eXoCache = creator.create(config, conf, new Callable<Cache<Serializable, Object>>()
+ eXoCache = creator.create(config, confBuilder, new Callable<Cache<Serializable, Object>>()
{
- @Override
public Cache<Serializable, Object> call() throws Exception
{
try
@@ -381,7 +430,7 @@
public Cache<Serializable, Object> run() throws Exception
{
// Define the configuration
- cacheManager.defineConfiguration(region, conf);
+ cacheManager.defineConfiguration(region, confBuilder.build());
// create and start the cache
return cacheManager.getCache(region);
}
@@ -392,7 +441,7 @@
Throwable cause = e.getCause();
if (cause instanceof Exception)
{
- throw (Exception)cause;
+ throw (Exception)cause;//NOSONAR
}
else
{
@@ -402,7 +451,7 @@
}
});
}
- catch (Exception e)
+ catch (Exception e) //NOSONAR
{
throw new ExoCacheInitException("The cache '" + region + "' could not be initialized", e);
}
@@ -486,9 +535,9 @@
/**
* Clean the configuration template to prevent conflicts
*/
- protected void resetConfiguration(Configuration config)
+ protected void resetConfiguration(ConfigurationBuilder confBuilder)
{
- config.fluent().invocationBatching().eviction().strategy(EvictionStrategy.NONE).maxEntries(-1).expiration()
+ confBuilder.invocationBatching().enable().eviction().strategy(EvictionStrategy.NONE).maxEntries(-1).expiration()
.lifespan(-1L).maxIdle(-1L).wakeUpInterval(60000L);
}
}
Modified: kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/java/org/exoplatform/services/cache/impl/infinispan/distributed/DistributedExoCache.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/java/org/exoplatform/services/cache/impl/infinispan/distributed/DistributedExoCache.java 2012-03-20 11:47:42 UTC (rev 5921)
+++ kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/java/org/exoplatform/services/cache/impl/infinispan/distributed/DistributedExoCache.java 2012-03-20 13:45:55 UTC (rev 5922)
@@ -48,7 +48,6 @@
import org.infinispan.notifications.cachelistener.event.CacheEntriesEvictedEvent;
import org.infinispan.notifications.cachelistener.event.CacheEntryModifiedEvent;
import org.infinispan.notifications.cachelistener.event.CacheEntryRemovedEvent;
-import org.infinispan.util.concurrent.locks.LockManager;
import java.io.Externalizable;
import java.io.IOException;
@@ -58,12 +57,9 @@
import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.CopyOnWriteArrayList;
@@ -80,8 +76,8 @@
/**
* Logger.
*/
- private static final Log LOG = ExoLogger
- .getLogger("exo.kernel.component.ext.cache.impl.infinispan.v5.DistributedExoCache");
+ private static final Log LOG = ExoLogger//NOSONAR
+ .getLogger("exo.kernel.component.ext.cache.impl.infinispan.v5.DistributedExoCache");//NOSONAR
public static final String CACHE_NAME = "eXoCache";
@@ -123,6 +119,14 @@
{
return cache;
}
+
+ /**
+ * @return the fullName
+ */
+ String getFullName()
+ {
+ return fullName;
+ }
/**
* {@inheritDoc}
@@ -199,9 +203,9 @@
@Override
public Void run()
{
- MapReduceTask<CacheKey<K>, V, String, CacheKey<K>> task =
- new MapReduceTask<CacheKey<K>, V, String, CacheKey<K>>(cache);
- task.mappedWith(new ClearCacheMapper<K, V>(fullName)).reducedWith(new ClearCacheReducer<String, V, K>());
+ MapReduceTask<CacheKey<K>, V, Void, Void> task =
+ new MapReduceTask<CacheKey<K>, V, Void, Void>(cache);
+ task.mappedWith(new ClearCacheMapper<K, V>(fullName)).reducedWith(new ClearCacheReducer());
task.execute();
return null;
}
@@ -362,6 +366,11 @@
{
throw new IllegalArgumentException("No null cache key accepted");
}
+ else if (value == null)
+ {
+ // ignore null values
+ return;
+ }
SecurityHelper.doPrivilegedAction(new PrivilegedAction<Void>()
{
@@ -421,7 +430,7 @@
onPut(entry.getKey(), entry.getValue());
}
}
- catch (Exception e)
+ catch (Exception e)//NOSONAR
{
cache.endBatch(false);
LOG.warn("An error occurs while executing the putMap method", e);
@@ -561,7 +570,7 @@
{
context.onExpire(key.getKey(), obj);
}
- catch (Exception e)
+ catch (Exception e)//NOSONAR
{
if (LOG.isWarnEnabled())
LOG.warn("Cannot execute the CacheListener properly", e);
@@ -583,7 +592,7 @@
{
context.onRemove(key, obj);
}
- catch (Exception e)
+ catch (Exception e)//NOSONAR
{
if (LOG.isWarnEnabled())
LOG.warn("Cannot execute the CacheListener properly", e);
@@ -615,7 +624,7 @@
{
context.onPut(key, obj);
}
- catch (Exception e)
+ catch (Exception e)//NOSONAR
{
if (LOG.isWarnEnabled())
LOG.warn("Cannot execute the CacheListener properly", e);
@@ -637,7 +646,7 @@
{
context.onGet(key, obj);
}
- catch (Exception e)
+ catch (Exception e)//NOSONAR
{
if (LOG.isWarnEnabled())
LOG.warn("Cannot execute the CacheListener properly", e);
@@ -659,7 +668,7 @@
{
context.onClearCache();
}
- catch (Exception e)
+ catch (Exception e)//NOSONAR
{
if (LOG.isWarnEnabled())
LOG.warn("Cannot execute the CacheListener properly", e);
@@ -790,7 +799,7 @@
@ManagedDescription("Maximum number of entries in a cache instance. -1 means no limit.")
public int getMaxSize()
{
- return cache.getConfiguration().getEvictionMaxEntries();
+ return cache.getCacheConfiguration().eviction().maxEntries();
}
@ManagedName("Lifespan")
@@ -798,7 +807,7 @@
+ " -1 means the entries never expire.")
public long getLiveTime()
{
- return cache.getConfiguration().getExpirationLifespan();
+ return cache.getCacheConfiguration().expiration().lifespan();
}
@Managed
@@ -807,7 +816,7 @@
+ "If the idle time is exceeded, the entry will be expired cluster-wide. -1 means the entries never expire.")
public long getMaxIdle()
{
- return cache.getConfiguration().getExpirationMaxIdle();
+ return cache.getCacheConfiguration().expiration().maxIdle();
}
@Managed
@@ -816,7 +825,7 @@
+ "process altogether, set wakeupInterval to -1.")
public long getWakeUpInterval()
{
- return cache.getConfiguration().getExpirationWakeUpInterval();
+ return cache.getCacheConfiguration().expiration().wakeUpInterval();
}
public static class CacheKey<K> implements Externalizable
@@ -1074,7 +1083,7 @@
}
}
- public static class ClearCacheMapper<K, V> extends AbstractExoCacheMapper<K, V, String, CacheKey<K>>
+ public static class ClearCacheMapper<K, V> extends AbstractExoCacheMapper<K, V, Void, Void>
{
public ClearCacheMapper()
@@ -1090,14 +1099,27 @@
* {@inheritDoc}
*/
@Override
- protected void _map(CacheKey<K> key, V value, Collector<String, CacheKey<K>> collector)
+ protected void _map(CacheKey<K> key, V value, Collector<Void, Void> collector)
{
- collector.emit("keys", key);
+ 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<K>, V> cache = dcm.getCache(CACHE_NAME);
+ cache.getAdvancedCache().withFlags(Flag.SKIP_REMOTE_LOOKUP, Flag.FAIL_SILENTLY).remove(key);
}
-
}
- public static class ClearCacheReducer<K, V, KIn> implements Reducer<K, CacheKey<KIn>>
+ public static class ClearCacheReducer implements Reducer<Void, Void>
{
/**
@@ -1109,46 +1131,8 @@
* @see org.infinispan.distexec.mapreduce.Reducer#reduce(java.lang.Object, java.util.Iterator)
*/
@Override
- public CacheKey<KIn> reduce(K reducedKey, Iterator<CacheKey<KIn>> iter)
+ public Void reduce(Void reducedKey, Iterator<Void> iter)
{
- CacheKey<KIn> firstKey;
- if (iter == null || !iter.hasNext() || (firstKey = iter.next()) == null)
- {
- return null;
- }
- ExoContainer container = ExoContainerContext.getTopContainer();
- if (container == null)
- {
- LOG.error("The top container could not be found");
- return null;
- }
- 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 null;
- }
- Cache<CacheKey<K>, V> cache = dcm.getCache(CACHE_NAME);
- final LockManager lm = cache.getAdvancedCache().getLockManager();
- // Sort the keys to prevent deadlocks
- Set<CacheKey<KIn>> keys = new TreeSet<CacheKey<KIn>>(new Comparator<CacheKey<KIn>>()
- {
- public int compare(CacheKey<KIn> o1, CacheKey<KIn> o2)
- {
- int result = lm.getLockId(o1) - lm.getLockId(o2);
- return result == 0 ? System.identityHashCode(o1) - System.identityHashCode(o2) : result;
- }
- });
- keys.add(firstKey);
- while (iter.hasNext())
- {
- keys.add(iter.next());
- }
- for (CacheKey<KIn> key : keys)
- {
- cache.getAdvancedCache().withFlags(Flag.SKIP_REMOTE_LOOKUP, Flag.FAIL_SILENTLY).remove(key);
- }
return null;
}
}
Modified: kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/java/org/exoplatform/services/cache/impl/infinispan/generic/GenericExoCacheCreator.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/java/org/exoplatform/services/cache/impl/infinispan/generic/GenericExoCacheCreator.java 2012-03-20 11:47:42 UTC (rev 5921)
+++ kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/java/org/exoplatform/services/cache/impl/infinispan/generic/GenericExoCacheCreator.java 2012-03-20 13:45:55 UTC (rev 5922)
@@ -27,7 +27,7 @@
import org.exoplatform.services.cache.impl.infinispan.AbstractExoCache;
import org.exoplatform.services.cache.impl.infinispan.ExoCacheCreator;
import org.infinispan.Cache;
-import org.infinispan.config.Configuration;
+import org.infinispan.configuration.cache.ConfigurationBuilder;
import org.infinispan.eviction.EvictionStrategy;
import java.io.Serializable;
@@ -84,20 +84,20 @@
/**
* {@inheritDoc}
*/
- public ExoCache<Serializable, Object> create(ExoCacheConfig config, Configuration cacheConfig,
+ public ExoCache<Serializable, Object> create(ExoCacheConfig config, ConfigurationBuilder confBuilder,
Callable<Cache<Serializable, Object>> cacheGetter) throws ExoCacheInitException
{
if (config instanceof GenericExoCacheConfig)
{
final GenericExoCacheConfig gConfig = (GenericExoCacheConfig)config;
- return create(config, cacheConfig, cacheGetter, gConfig.getStrategy(), gConfig.getMaxEntries(),
+ return create(config, confBuilder, cacheGetter, gConfig.getStrategy(), gConfig.getMaxEntries(),
gConfig.getLifespan(), gConfig.getMaxIdle() == 0 ? defaultMaxIdle : gConfig.getMaxIdle(),
gConfig.getWakeUpInterval() == 0 ? defaultWakeUpInterval : gConfig.getWakeUpInterval());
}
else
{
final long period = config.getLiveTime();
- return create(config, cacheConfig, cacheGetter,
+ return create(config, confBuilder, cacheGetter,
config.getImplementation() == null ? defaultStrategy : config.getImplementation(), config.getMaxSize(),
period > 0 ? period * 1000 : -1, defaultMaxIdle, defaultWakeUpInterval);
}
@@ -107,7 +107,7 @@
* Creates a new ExoCache instance with the relevant parameters
* @throws ExoCacheInitException If any exception occurs while creating the cache
*/
- private ExoCache<Serializable, Object> create(ExoCacheConfig config, Configuration cacheConfig,
+ private ExoCache<Serializable, Object> create(ExoCacheConfig config, ConfigurationBuilder confBuilder,
Callable<Cache<Serializable, Object>> cacheGetter, String strategy, int maxEntries, long lifespan, long maxIdle,
long wakeUpInterval) throws ExoCacheInitException
{
@@ -118,13 +118,13 @@
{
es = EvictionStrategy.LRU;
}
- cacheConfig.fluent().eviction().strategy(EvictionStrategy.valueOf(strategy)).maxEntries(maxEntries).expiration()
+ confBuilder.eviction().strategy(EvictionStrategy.valueOf(strategy)).maxEntries(maxEntries).expiration()
.lifespan(lifespan).maxIdle(maxIdle).wakeUpInterval(wakeUpInterval);
try
{
- return new GenericExoCache(cacheConfig, config, cacheGetter.call());
+ return new GenericExoCache(config, cacheGetter.call());
}
- catch (Exception e)
+ catch (Exception e)//NOSONAR
{
throw new ExoCacheInitException("Cannot create the cache '" + config.getName() + "'", e);
}
@@ -136,41 +136,26 @@
public static class GenericExoCache extends AbstractExoCache<Serializable, Object>
{
- private final Configuration cacheConfig;
-
- public GenericExoCache(Configuration cacheConfig, ExoCacheConfig config, Cache<Serializable, Object> cache)
+ public GenericExoCache(ExoCacheConfig config, Cache<Serializable, Object> cache)
{
super(config, cache);
- this.cacheConfig = cacheConfig;
}
public void setMaxSize(int max)
{
- cacheConfig.fluent().eviction().maxEntries(max);
+ throw new UnsupportedOperationException("The configuration of the cache cannot not be modified");
}
public void setLiveTime(long period)
{
- cacheConfig.fluent().expiration().lifespan(period);
+ throw new UnsupportedOperationException("The configuration of the cache cannot not be modified");
}
- @Managed
- public void setMaxIdle(long maxIdle)
- {
- cacheConfig.fluent().expiration().maxIdle(maxIdle);
- }
-
- @Managed
- public void setWakeUpInterval(long wakeUpInterval)
- {
- cacheConfig.fluent().expiration().wakeUpInterval(wakeUpInterval);
- }
-
@ManagedName("MaxEntries")
@ManagedDescription("Maximum number of entries in a cache instance. -1 means no limit.")
public int getMaxSize()
{
- return cacheConfig.getEvictionMaxEntries();
+ return cache.getCacheConfiguration().eviction().maxEntries();
}
@ManagedName("Lifespan")
@@ -178,7 +163,7 @@
+ " -1 means the entries never expire.")
public long getLiveTime()
{
- return cacheConfig.getExpirationLifespan();
+ return cache.getCacheConfiguration().expiration().lifespan();
}
@Managed
@@ -187,7 +172,7 @@
+ "If the idle time is exceeded, the entry will be expired cluster-wide. -1 means the entries never expire.")
public long getMaxIdle()
{
- return cacheConfig.getExpirationMaxIdle();
+ return cache.getCacheConfiguration().expiration().maxIdle();
}
@Managed
@@ -196,7 +181,7 @@
+ "process altogether, set wakeupInterval to -1.")
public long getWakeUpInterval()
{
- return cacheConfig.getExpirationWakeUpInterval();
+ return cache.getCacheConfiguration().expiration().wakeUpInterval();
}
}
}
\ No newline at end of file
Modified: kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/java/org/exoplatform/services/ispn/DistributedCacheManager.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/java/org/exoplatform/services/ispn/DistributedCacheManager.java 2012-03-20 11:47:42 UTC (rev 5921)
+++ kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/java/org/exoplatform/services/ispn/DistributedCacheManager.java 2012-03-20 13:45:55 UTC (rev 5922)
@@ -27,14 +27,26 @@
import org.exoplatform.container.xml.ValueParam;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
+import org.exoplatform.services.transaction.TransactionService;
import org.infinispan.Cache;
+import org.infinispan.configuration.cache.Configuration;
+import org.infinispan.configuration.cache.ConfigurationBuilder;
+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.manager.DefaultCacheManager;
import org.infinispan.manager.EmbeddedCacheManager;
+import org.infinispan.transaction.lookup.TransactionManagerLookup;
+import org.infinispan.util.Util;
import org.picocontainer.Startable;
import java.security.PrivilegedExceptionAction;
import java.util.Map;
+import javax.transaction.TransactionManager;
+
/**
* This class is used to allow to use infinispan in distribution mode with
* the ability to launch infinispan instances in standalone mode, in other
@@ -52,8 +64,8 @@
/**
* The logger
*/
- private static final Log LOG = ExoLogger
- .getLogger("exo.kernel.component.ext.cache.impl.infinispan.v5.DistributedCacheManager");
+ private static final Log LOG = ExoLogger //NOSONAR
+ .getLogger("exo.kernel.component.ext.cache.impl.infinispan.v5.DistributedCacheManager");//NOSONAR
/**
* The parameter name corresponding to the infinispan configuration
@@ -77,7 +89,7 @@
public DistributedCacheManager(String configurationFile, Map<String, String> parameters,
ConfigurationManager configManager)
{
- this.manager = init(configurationFile, parameters, configManager);
+ this.manager = init(configurationFile, parameters, configManager, null);
}
/**
@@ -85,13 +97,23 @@
*/
public DistributedCacheManager(InitParams params, ConfigurationManager configManager)
{
+ this(params, configManager, null);
+ }
+
+ /**
+ * Default constructor
+ */
+ public DistributedCacheManager(InitParams params, ConfigurationManager configManager, TransactionService ts)
+ {
ValueParam vp;
final String result;
if (params != null && (vp = params.getValueParam(CONFIG_FILE_PARAMETER_NAME)) != null
&& (result = vp.getValue()) != null && !result.isEmpty())
{
PropertiesParam pp = params.getPropertiesParam(PARAMS_PARAMETER_NAME);
- this.manager = init(result, pp == null ? null : pp.getProperties(), configManager);
+ this.manager =
+ init(result, pp == null ? null : pp.getProperties(), configManager,
+ ts == null ? null : ts.getTransactionManager());
}
else
{
@@ -104,10 +126,11 @@
* @param configurationFile the path of the configuration file
* @param parameters the parameters to inject into the configuration file
* @param configManager the configuration manager used to get the configuration file
+ * @param tm the transaction manager
* @return the CacheManager initialized
*/
private EmbeddedCacheManager init(final String configurationFile, final Map<String, String> parameters,
- final ConfigurationManager configManager)
+ final ConfigurationManager configManager, final TransactionManager tm)
{
try
{
@@ -128,25 +151,46 @@
}
return SecurityHelper.doPrivilegedIOExceptionAction(new PrivilegedExceptionAction<EmbeddedCacheManager>()
{
-
- @Override
public EmbeddedCacheManager run() throws Exception
{
+ Parser parser = new Parser(Thread.currentThread().getContextClassLoader());
+ // Load the configuration
+ ConfigurationBuilderHolder holder = parser.parse(helper.fillTemplate(configurationFile, parameters));
+ GlobalConfigurationBuilder configBuilder = holder.getGlobalConfigurationBuilder();
+ Utils.loadJGroupsConfig(configManager, configBuilder.build(), configBuilder);
+ // Create the CacheManager from the new configuration
EmbeddedCacheManager manager =
- new DefaultCacheManager(helper.fillTemplate(configurationFile, parameters), false);
- Utils.loadJGroupsConfig(configManager, manager.getGlobalConfiguration());
- manager.start();
- for (String cacheName : manager.getCacheNames())
+ new DefaultCacheManager(configBuilder.build(), holder.getDefaultConfigurationBuilder().build());
+ TransactionManagerLookup tml = new TransactionManagerLookup()
{
- manager.getCache(cacheName);
+ public TransactionManager getTransactionManager() throws Exception
+ {
+ return tm;
+ }
+ };
+ for (ConfigurationBuilder b : holder.getConfigurationBuilders())
+ {
+ if (tm != null)
+ {
+ b.transaction().transactionManagerLookup(tml);
+ }
+ //TODO remove it once ISPN-1689 will be fixed
+ b.clustering()
+ .hash()
+ .consistentHash(
+ Util.<ConsistentHash> getInstance(DefaultConsistentHash.class.getName(), Thread.currentThread()
+ .getContextClassLoader()));
+ Configuration c = b.build();
+ manager.defineConfiguration(c.name(), c);
+ manager.getCache(c.name());
}
return manager;
}
});
}
- catch (Exception e)
+ catch (Exception e)//NOSONAR
{
- throw new RuntimeException("Could not initialize the cache manager corresponding to the configuration file "
+ throw new IllegalStateException("Could not initialize the cache manager corresponding to the configuration file "
+ configurationFile, e);
}
}
Modified: kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/java/org/exoplatform/services/ispn/Utils.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/java/org/exoplatform/services/ispn/Utils.java 2012-03-20 11:47:42 UTC (rev 5921)
+++ kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/java/org/exoplatform/services/ispn/Utils.java 2012-03-20 13:45:55 UTC (rev 5922)
@@ -23,7 +23,8 @@
import org.exoplatform.services.cache.ExoCacheInitException;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
-import org.infinispan.config.GlobalConfiguration;
+import org.infinispan.configuration.global.GlobalConfiguration;
+import org.infinispan.configuration.global.GlobalConfigurationBuilder;
import org.infinispan.remoting.transport.jgroups.JGroupsTransport;
import java.io.IOException;
@@ -41,22 +42,24 @@
/**
* The logger
*/
- private static final Log LOG = ExoLogger
- .getLogger("exo.kernel.component.ext.cache.impl.infinispan.v5.Utils");
-
- private Utils() {}
-
+ private static final Log LOG = ExoLogger.getLogger("exo.kernel.component.ext.cache.impl.infinispan.v5.Utils");//NOSONAR
+ private Utils()
+ {
+ }
+
/**
* Load the JGroups configuration file thanks to the {@link ConfigurationManager}
* @param config the global configuration from which the JGroups config will be extracted
+ * @param configBuilder the related configuration builder
* @return <code>true</code> if the JGoups config could be loaded successfully,
* <code>false</code> if there were no JGroups config to load
* @throws IllegalStateException if the JGroups config could not be loaded
*/
- public static boolean loadJGroupsConfig(ConfigurationManager cfm, GlobalConfiguration config) throws ExoCacheInitException
+ public static boolean loadJGroupsConfig(ConfigurationManager cfm, GlobalConfiguration config,
+ GlobalConfigurationBuilder configBuilder) throws ExoCacheInitException
{
- Properties properties = config.getTransportProperties();
+ Properties properties = config.transport().properties();
if (properties == null || !properties.containsKey(JGroupsTransport.CONFIGURATION_FILE))
{
return false;
@@ -67,9 +70,8 @@
// inputStream still remains null, so file was not opened
if (inputStream == null)
{
- throw new IllegalStateException("The jgroups configuration cannot be loaded from '" + filename
- + "'");
- }
+ throw new IllegalStateException("The jgroups configuration cannot be loaded from '" + filename + "'");
+ }
try
{
// Set the jgroups configuration as XML
@@ -77,15 +79,14 @@
}
catch (IOException e)
{
- throw new IllegalStateException("The jgroups configuration cannot be read from '" + filename
- + "'");
+ throw new IllegalStateException("The jgroups configuration cannot be read from '" + filename + "'", e);
}
// Remove the property corresponding to the configuration file
properties.remove(JGroupsTransport.CONFIGURATION_FILE);
+ configBuilder.transport().withProperties(properties);
return true;
}
-
/**
* Reads bytes from input stream and builds a string from them
*
@@ -110,7 +111,7 @@
{
inputStream.close();
}
- catch (Exception e)
+ catch (IOException e)
{
LOG.debug("Cannot close stream", e);
}
Modified: kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/resources/conf/portal/cache-configuration-template.xml
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/resources/conf/portal/cache-configuration-template.xml 2012-03-20 11:47:42 UTC (rev 5921)
+++ kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/main/resources/conf/portal/cache-configuration-template.xml 2012-03-20 13:45:55 UTC (rev 5922)
@@ -53,8 +53,8 @@
<shutdown hookBehavior="DEFAULT"/>
</global>
<default>
- <locking isolationLevel="READ_COMMITTED" lockAcquisitionTimeout="10000" writeSkewCheck="false" concurrencyLevel="500"/>
- <transaction transactionManagerLookupClass="org.infinispan.transaction.lookup.GenericTransactionManagerLookup" syncRollbackPhase="true" syncCommitPhase="true"/>
+ <locking isolationLevel="READ_COMMITTED" lockAcquisitionTimeout="10000" writeSkewCheck="false" concurrencyLevel="500" useLockStriping="true"/>
+ <transaction transactionManagerLookupClass="org.infinispan.transaction.lookup.GenericTransactionManagerLookup" syncRollbackPhase="true" syncCommitPhase="true" transactionMode="TRANSACTIONAL"/>
<jmxStatistics enabled="true"/>
<invocationBatching enabled="true"/>
<clustering mode="replication">
Modified: kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/java/org/exoplatform/services/cache/impl/infinispan/TestAbstractExoCache.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/java/org/exoplatform/services/cache/impl/infinispan/TestAbstractExoCache.java 2012-03-20 11:47:42 UTC (rev 5921)
+++ kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/java/org/exoplatform/services/cache/impl/infinispan/TestAbstractExoCache.java 2012-03-20 13:45:55 UTC (rev 5922)
@@ -519,7 +519,7 @@
@Override
public boolean equals(Object paramObject)
{
- return paramObject instanceof MyKey && ((MyKey)paramObject).value.endsWith(value);
+ return paramObject instanceof MyKey && ((MyKey)paramObject).value.equals(value);
}
@Override
@@ -546,13 +546,13 @@
+ System.getProperty("java.net.preferIPv4Stack"));
ExoCacheConfig config = new ExoCacheConfig();
config.setName("MyCacheDistributed");
- config.setMaxSize(5);
+ config.setMaxSize(8);
config.setLiveTime(1);
config.setImplementation("LRU");
config.setReplicated(true);
ExoCacheConfig config2 = new ExoCacheConfig();
config2.setName("MyCacheDistributed2");
- config2.setMaxSize(5);
+ config2.setMaxSize(8);
config2.setLiveTime(1);
config2.setImplementation("LRU");
config2.setReplicated(true);
Modified: kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/java/org/exoplatform/services/cache/impl/infinispan/TestExoCacheCreator.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/java/org/exoplatform/services/cache/impl/infinispan/TestExoCacheCreator.java 2012-03-20 11:47:42 UTC (rev 5921)
+++ kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/java/org/exoplatform/services/cache/impl/infinispan/TestExoCacheCreator.java 2012-03-20 13:45:55 UTC (rev 5922)
@@ -24,7 +24,7 @@
import org.exoplatform.services.cache.ExoCacheConfig;
import org.exoplatform.services.cache.ExoCacheInitException;
import org.infinispan.Cache;
-import org.infinispan.config.Configuration;
+import org.infinispan.configuration.cache.ConfigurationBuilder;
import java.io.Serializable;
import java.util.Collections;
@@ -42,10 +42,10 @@
{
/**
- * @see org.exoplatform.services.cache.impl.infinispan.ExoCacheCreator#create(org.exoplatform.services.cache.ExoCacheConfig, org.infinispan.config.Configuration, java.util.concurrent.Callable)
+ * {@inheritDoc}
*/
@Override
- public ExoCache<Serializable, Object> create(ExoCacheConfig config, Configuration cacheConfig,
+ public ExoCache<Serializable, Object> create(ExoCacheConfig config, ConfigurationBuilder confBuilder,
Callable<Cache<Serializable, Object>> cacheGetter) throws ExoCacheInitException
{
return new TestExoCache();
@@ -61,55 +61,46 @@
return Collections.singleton("TEST");
}
+ @SuppressWarnings({"rawtypes", "unchecked"})
public static class TestExoCache implements ExoCache<Serializable, Object>
{
public void addCacheListener(CacheListener listener)
{
- // TODO Auto-generated method stub
-
}
-
public int getCacheHit()
{
- // TODO Auto-generated method stub
return 0;
}
public int getCacheMiss()
{
- // TODO Auto-generated method stub
return 0;
}
public int getCacheSize()
{
- // TODO Auto-generated method stub
return 0;
}
public List getCachedObjects()
{
- // TODO Auto-generated method stub
return null;
}
public String getLabel()
{
- // TODO Auto-generated method stub
return null;
}
public long getLiveTime()
{
- // TODO Auto-generated method stub
return 0;
}
public int getMaxSize()
{
- // TODO Auto-generated method stub
return 0;
}
@@ -120,104 +111,86 @@
public boolean isDistributed()
{
- // TODO Auto-generated method stub
return false;
}
public boolean isLogEnabled()
{
- // TODO Auto-generated method stub
return false;
}
public boolean isReplicated()
{
- // TODO Auto-generated method stub
return false;
}
-
public void select(CachedObjectSelector selector) throws Exception
{
- // TODO Auto-generated method stub
}
public void setDistributed(boolean b)
{
- // TODO Auto-generated method stub
}
public void setLabel(String s)
{
- // TODO Auto-generated method stub
}
public void setLiveTime(long period)
{
- // TODO Auto-generated method stub
}
public void setLogEnabled(boolean b)
{
- // TODO Auto-generated method stub
}
public void setMaxSize(int max)
{
- // TODO Auto-generated method stub
}
public void setName(String name)
{
- // TODO Auto-generated method stub
}
public void setReplicated(boolean b)
{
- // TODO Auto-generated method stub
}
public void clearCache()
{
- // TODO Auto-generated method stub
-
+
}
public Object get(Serializable key)
{
- // TODO Auto-generated method stub
return null;
}
public void put(Serializable key, Object value) throws NullPointerException
{
- // TODO Auto-generated method stub
-
+
}
public void putMap(Map objs) throws NullPointerException, IllegalArgumentException
{
- // TODO Auto-generated method stub
-
+
}
public Object remove(Serializable key) throws NullPointerException
{
- // TODO Auto-generated method stub
return null;
}
public List removeCachedObjects()
{
- // TODO Auto-generated method stub
return null;
}
Modified: kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/java/org/exoplatform/services/cache/impl/infinispan/TestExoCacheFactoryImpl.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/java/org/exoplatform/services/cache/impl/infinispan/TestExoCacheFactoryImpl.java 2012-03-20 11:47:42 UTC (rev 5921)
+++ kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/java/org/exoplatform/services/cache/impl/infinispan/TestExoCacheFactoryImpl.java 2012-03-20 13:45:55 UTC (rev 5922)
@@ -23,7 +23,7 @@
import org.exoplatform.services.cache.ExoCache;
import org.exoplatform.services.cache.impl.infinispan.TestExoCacheCreator.TestExoCache;
import org.exoplatform.test.BasicTestCase;
-import org.infinispan.config.Configuration.CacheMode;
+import org.infinispan.configuration.cache.CacheMode;
import org.infinispan.manager.CacheContainer;
/**
@@ -31,6 +31,7 @@
* @version $Id$
*
*/
+@SuppressWarnings("rawtypes")
public class TestExoCacheFactoryImpl extends BasicTestCase
{
@@ -51,17 +52,20 @@
ExoCache cache = service_.getCacheInstance("myCache");
assertTrue("expect an instance of AbstractExoCache", cache instanceof AbstractExoCache);
AbstractExoCache aCache = (AbstractExoCache)cache;
- assertTrue("expect a local cache", aCache.cache.getConfiguration().getCacheMode() == CacheMode.LOCAL);
+ assertTrue("expect a local cache",
+ aCache.cache.getCacheConfiguration().clustering().cacheMode() == CacheMode.LOCAL);
aCache.cache.stop();
cache = service_.getCacheInstance("cacheDistributed");
assertTrue("expect an instance of AbstractExoCache", cache instanceof AbstractExoCache);
aCache = (AbstractExoCache)cache;
- assertTrue("expect a distributed cache", aCache.cache.getConfiguration().getCacheMode() == CacheMode.REPL_SYNC);
+ assertTrue("expect a distributed cache",
+ aCache.cache.getCacheConfiguration().clustering().cacheMode() == CacheMode.REPL_SYNC);
aCache.cache.stop();
cache = service_.getCacheInstance("myCustomCache");
assertTrue("expect an instance of AbstractExoCache", cache instanceof AbstractExoCache);
aCache = (AbstractExoCache)cache;
- assertTrue("expect a distributed cache", aCache.cache.getConfiguration().getCacheMode() == CacheMode.REPL_SYNC);
+ assertTrue("expect a distributed cache",
+ aCache.cache.getCacheConfiguration().clustering().cacheMode() == CacheMode.REPL_SYNC);
aCache.cache.stop();
}
@@ -76,27 +80,27 @@
cache = service_.getCacheInstance("test-custom-impl-with-new-config");
assertTrue("expect an instance of TestExoCache", cache instanceof TestExoCache);
}
-
+
public void testSameCacheManager()
{
ExoCache cache1 = service_.getCacheInstance("myCustomCache");
assertTrue("expect an instance of AbstractExoCache", cache1 instanceof AbstractExoCache);
AbstractExoCache aCache1 = (AbstractExoCache)cache1;
CacheContainer cacheContainer1 = aCache1.cache.getCacheManager();
-
+
ExoCache cache2 = service_.getCacheInstance("myCustomCache-Bis");
assertTrue("expect an instance of AbstractExoCache", cache2 instanceof AbstractExoCache);
AbstractExoCache aCache2 = (AbstractExoCache)cache2;
CacheContainer cacheContainer2 = aCache2.cache.getCacheManager();
assertTrue("The CacheContainer should be the same", cacheContainer1 == cacheContainer2);
-
+
ExoCache cache3 = service_.getCacheInstance("myCustomCache-Bis2");
assertTrue("expect an instance of AbstractExoCache", cache3 instanceof AbstractExoCache);
AbstractExoCache aCache3 = (AbstractExoCache)cache3;
CacheContainer cacheContainer3 = aCache3.cache.getCacheManager();
assertTrue("The CacheContainer should be the same", cacheContainer1 == cacheContainer3);
-
+
aCache1.cache.stop();
- aCache2.cache.stop();
+ aCache2.cache.stop();
}
}
Modified: kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/java/org/exoplatform/services/cache/impl/infinispan/distributed/TestDistributedExoCache.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/java/org/exoplatform/services/cache/impl/infinispan/distributed/TestDistributedExoCache.java 2012-03-20 11:47:42 UTC (rev 5921)
+++ kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/java/org/exoplatform/services/cache/impl/infinispan/distributed/TestDistributedExoCache.java 2012-03-20 13:45:55 UTC (rev 5922)
@@ -32,6 +32,9 @@
import org.exoplatform.services.cache.impl.infinispan.ExoCacheFactoryImpl;
import org.exoplatform.services.ispn.DistributedCacheManager;
import org.exoplatform.test.BasicTestCase;
+import org.infinispan.affinity.KeyAffinityService;
+import org.infinispan.affinity.KeyAffinityServiceFactory;
+import org.infinispan.affinity.KeyGenerator;
import org.infinispan.distribution.DistributionManager;
import java.io.Serializable;
@@ -42,8 +45,10 @@
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Random;
import java.util.Set;
import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;
/**
@@ -467,17 +472,29 @@
{
private static final long serialVersionUID = 1L;
- public String value;
- public MyKey(){}
- public MyKey(String value)
+ public Object value;
+
+ public String displayValue;
+
+ public MyKey()
{
+ }
+
+ public MyKey(Object value)
+ {
this.value = value;
}
+ public MyKey(String displayValue, Object value)
+ {
+ this.displayValue = displayValue;
+ this.value = value;
+ }
+
@Override
public boolean equals(Object paramObject)
{
- return paramObject instanceof MyKey && ((MyKey)paramObject).value.endsWith(value);
+ return paramObject instanceof MyKey && ((MyKey)paramObject).value.equals(value);
}
@Override
@@ -489,10 +506,30 @@
@Override
public String toString()
{
- return value;
+ return displayValue == null ? value.toString() : displayValue;
}
}
-
+
+ public static class MyKeyGenerator implements KeyGenerator<DistributedExoCache.CacheKey<MyKey>>
+ {
+
+ public static final Random rnd = new Random();
+
+ private String fullName;
+
+ public MyKeyGenerator(String fullName)
+ {
+ this.fullName = fullName;
+ }
+
+ @Override
+ public DistributedExoCache.CacheKey<MyKey> getKey()
+ {
+ return new DistributedExoCache.CacheKey<MyKey>(fullName, new MyKey(rnd.nextLong()));
+ }
+ }
+
+ @SuppressWarnings({"rawtypes", "unchecked"})
public void testDistributedCache() throws Exception
{
PortalContainer pc = PortalContainer.getInstance();
@@ -511,191 +548,312 @@
DistributedCacheManager dcm2 =
new DistributedCacheManager("jar:/conf/portal/distributed-cache-configuration.xml", params, cm);
- @SuppressWarnings("unchecked")
DistributedExoCache<Serializable, Object> cache1 =
(DistributedExoCache<Serializable, Object>)((ExoCacheFactory)pc
.getComponentInstanceOfType(ExoCacheFactory.class)).createCache(config);
DistributionManager dm = cache1.getCache().getDistributionManager();
- MyCacheListener listener1 = new MyCacheListener();
- cache1.addCacheListener(listener1);
DistributedExoCache<Serializable, Object> cache2 =
(DistributedExoCache<Serializable, Object>)new ExoCacheFactoryImpl(
(ExoContainerContext)pc.getComponentInstanceOfType(ExoContainerContext.class),
"jar:/conf/portal/cache-configuration-template.xml", cm, dcm2).createCache(config);
- MyCacheListener listener2 = new MyCacheListener();
- cache2.addCacheListener(listener2);
+ KeyAffinityService kas1 =
+ KeyAffinityServiceFactory.newLocalKeyAffinityService(cache1.getCache(),
+ new MyKeyGenerator(cache1.getFullName()), Executors.newSingleThreadExecutor(), 100);
+ KeyAffinityService kas2 =
+ KeyAffinityServiceFactory.newLocalKeyAffinityService(cache2.getCache(),
+ new MyKeyGenerator(cache1.getFullName()), Executors.newSingleThreadExecutor(), 100);
+
try
{
- MyKey key;
- cache1.put(key = new MyKey("a"), "b");
- assertEquals(1, cache1.getCacheSize());
- assertEquals("b", cache2.get(new MyKey("a")));
- assertEquals(1, cache2.getCacheSize());
-
-// int put1 = 1;
-// int put2 = dm.getLocality(key).isLocal() ? 0 : 1;
-//
-// assertEquals(put1, listener1.put);
-// assertEquals(put2, listener2.put);
+ Object a, b, c;
+ for (int i = 0; i < 2; i++)
+ {
+ if (i == 0)
+ {
+ a =
+ new MyKey("a", ((DistributedExoCache.CacheKey<MyKey>)kas1.getKeyForAddress(cache1.getCache()
+ .getRpcManager().getAddress())).getKey().value);
+ }
+ else
+ {
+ a =
+ new MyKey("a", ((DistributedExoCache.CacheKey<MyKey>)kas2.getKeyForAddress(cache2.getCache()
+ .getRpcManager().getAddress())).getKey().value);
+ }
+ for (int j = 0; j < 2; j++)
+ {
+ if (j == 0)
+ {
+ b =
+ new MyKey("b", ((DistributedExoCache.CacheKey<MyKey>)kas1.getKeyForAddress(cache1.getCache()
+ .getRpcManager().getAddress())).getKey().value);
+ }
+ else
+ {
+ b =
+ new MyKey("b", ((DistributedExoCache.CacheKey<MyKey>)kas2.getKeyForAddress(cache2.getCache()
+ .getRpcManager().getAddress())).getKey().value);
+ }
+ for (int k = 0; k < 2; k++)
+ {
+ if (k == 0)
+ {
+ c =
+ new MyKey("c", ((DistributedExoCache.CacheKey<MyKey>)kas1.getKeyForAddress(cache1.getCache()
+ .getRpcManager().getAddress())).getKey().value);
+ }
+ else
+ {
+ c =
+ new MyKey("c", ((DistributedExoCache.CacheKey<MyKey>)kas2.getKeyForAddress(cache2.getCache()
+ .getRpcManager().getAddress())).getKey().value);
+ }
+ checkUseCase(cache1, cache2, dm, a, b, c);
+ }
+ }
+ }
+ }
+ finally
+ {
+ dcm2.stop();
+ }
+ }
- assertEquals(0, listener1.get);
- assertEquals(1, listener2.get);
-
- MyKey key2;
- cache2.put(key2 = new MyKey("b"), "c");
- assertEquals(2, cache1.getCacheSize());
- assertEquals(2, cache2.getCacheSize());
- assertEquals("c", cache1.get(new MyKey("b")));
-
-// put1 += dm.getLocality(key2).isLocal() ? 1 : 0;
-// put2++;
-//
-// assertEquals(put1, listener1.put);
-// assertEquals(put2, listener2.put);
+ @SuppressWarnings({"unchecked", "rawtypes"})
+ private void checkUseCase(DistributedExoCache<Serializable, Object> cache1,
+ DistributedExoCache<Serializable, Object> cache2, DistributionManager dm, Object a, Object b, Object c)
+ throws InterruptedException
+ {
+ MyCacheListener listener1 = new MyCacheListener();
+ cache1.addCacheListener(listener1);
+ MyCacheListener listener2 = new MyCacheListener();
+ cache2.addCacheListener(listener2);
+ boolean isALocal = dm.getLocality(new DistributedExoCache.CacheKey(cache1.getFullName(), new MyKey(a))).isLocal();
+ boolean isBLocal = dm.getLocality(new DistributedExoCache.CacheKey(cache1.getFullName(), new MyKey(b))).isLocal();
+ boolean isCLocal = dm.getLocality(new DistributedExoCache.CacheKey(cache1.getFullName(), new MyKey(c))).isLocal();
+ System.out.println("#####################################");
+ System.out.println("'a' is local = " + isALocal);
+ System.out.println("'b' is local = " + isBLocal);
+ System.out.println("'c' is local = " + isCLocal);
+ MyKey key = new MyKey(a);
+ cache1.put(key, "b");
+ assertEquals(1, cache1.getCacheSize());
+ assertEquals("b", cache2.get(new MyKey(a)));
+ assertEquals(1, cache2.getCacheSize());
- assertEquals(1, listener1.get);
- assertEquals(1, listener2.get);
+ int put1 = 1;
+ int put2 = isALocal ? 0 : 1;
- assertEquals(2, cache1.getCacheSize());
- assertEquals(2, cache2.getCacheSize());
+ assertEquals(put1, listener1.put);
+ assertEquals(put2, listener2.put);
-// assertEquals(put1, listener1.put);
-// assertEquals(put2, listener2.put);
+ assertEquals(0, listener1.get);
+ assertEquals(1, listener2.get);
- assertEquals(1, listener1.get);
- assertEquals(1, listener2.get);
+ MyKey key2 = new MyKey(b);
+ cache2.put(key2, "c");
+ assertEquals(2, cache1.getCacheSize());
+ assertEquals(2, cache2.getCacheSize());
+ assertEquals("c", cache1.get(new MyKey(b)));
- cache2.put(key = new MyKey("a"), "a");
- assertEquals(2, cache1.getCacheSize());
- assertEquals(2, cache2.getCacheSize());
- assertEquals("a", cache1.get(new MyKey("a")));
-
-// put1 += dm.getLocality(key).isLocal() ? 1 : 0;
-// put2++;
-//
-// assertEquals(put1, listener1.put);
-// assertEquals(put2, listener2.put);
+ put1 += isBLocal ? 1 : 0;
+ put2++;
- assertEquals(2, listener1.get);
- assertEquals(1, listener2.get);
+ assertEquals(put1, listener1.put);
+ assertEquals(put2, listener2.put);
- cache2.remove(key = new MyKey("a"));
- assertEquals(1, cache1.getCacheSize());
- assertEquals(1, cache2.getCacheSize());
-
-// assertEquals(put1, listener1.put);
-// assertEquals(put2, listener2.put);
+ assertEquals(1, listener1.get);
+ assertEquals(1, listener2.get);
- assertEquals(2, listener1.get);
- assertEquals(1, listener2.get);
-
-// int remove1 = dm.getLocality(key).isLocal() ? 1 : 0;
-// int remove2 = 1;
-//
-// assertEquals(remove1, listener1.remove);
-// assertEquals(remove2, listener2.remove);
-
- cache1.put(key = new MyKey("c"), "c");
- cache1.clearCache();
- assertEquals(0, cache1.getCacheSize());
- assertNull(cache1.get(new MyKey("b")));
- assertNull(cache2.get(new MyKey("b")));
- assertNull(cache2.get(new MyKey("c")));
- assertEquals(0, cache2.getCacheSize());
-
-// put1++;
-// put2 += dm.getLocality(key).isLocal() ? 0 : 1;
+ assertEquals(2, cache1.getCacheSize());
+ assertEquals(2, cache2.getCacheSize());
-// assertEquals(put1, listener1.put);
-// assertEquals(put2, listener2.put);
+ assertEquals(put1, listener1.put);
+ assertEquals(put2, listener2.put);
- assertEquals(3, listener1.get);
- assertEquals(3, listener2.get);
+ assertEquals(1, listener1.get);
+ assertEquals(1, listener2.get);
-// assertEquals(remove1, listener1.remove);
-// assertEquals(remove2, listener2.remove);
+ key = new MyKey(a);
+ cache2.put(key, "a");
+ assertEquals(2, cache1.getCacheSize());
+ assertEquals(2, cache2.getCacheSize());
+ assertEquals("a", cache1.get(new MyKey(a)));
- assertEquals(1, listener1.clearCache);
- assertEquals(0, listener2.clearCache);
+ put1 += isALocal ? 1 : 0;
+ put2++;
- Map<Serializable, Object> values = new HashMap<Serializable, Object>();
- values.put(key = new MyKey("a"), "a");
- values.put(key2 = new MyKey("b"), "b");
- cache1.putMap(values);
- assertEquals(2, cache1.getCacheSize());
- Thread.sleep(40);
- assertEquals("a", cache2.get(new MyKey("a")));
- assertEquals("b", cache2.get(new MyKey("b")));
- assertEquals(2, cache2.getCacheSize());
+ assertEquals(put1, listener1.put);
+ assertEquals(put2, listener2.put);
-// put1 += 2;
-// put2 += (dm.getLocality(key).isLocal() ? 0 : 1) + (dm.getLocality(key2).isLocal() ? 0 : 1);
-//
-// assertEquals(put1, listener1.put);
-// assertEquals(put2, listener2.put);
+ assertEquals(2, listener1.get);
+ assertEquals(1, listener2.get);
- assertEquals(3, listener1.get);
- assertEquals(5, listener2.get);
+ key = new MyKey(a);
+ cache2.remove(key);
+ assertEquals(1, cache1.getCacheSize());
+ assertEquals(1, cache2.getCacheSize());
-// assertEquals(remove1, listener1.remove);
-// assertEquals(remove2, listener2.remove);
+ assertEquals(put1, listener1.put);
+ assertEquals(put2, listener2.put);
- assertEquals(1, listener1.clearCache);
- assertEquals(0, listener2.clearCache);
+ assertEquals(2, listener1.get);
+ assertEquals(1, listener2.get);
- values = new HashMap<Serializable, Object>()
+ int remove1 = isALocal ? 1 : 0;
+ int remove2 = 1;
+
+ assertEquals(remove1, listener1.remove);
+ assertEquals(remove2, listener2.remove);
+
+ key = new MyKey(c);
+ cache1.put(key, "c");
+ assertEquals(2, cache1.getCacheSize());
+ assertEquals(2, cache2.getCacheSize());
+ assertEquals("c", cache2.get(new MyKey(c)));
+
+ put1++;
+ put2 += isCLocal ? 0 : 1;
+
+ assertEquals(put1, listener1.put);
+ assertEquals(put2, listener2.put);
+
+ assertEquals(2, listener1.get);
+ assertEquals(2, listener2.get);
+
+ assertEquals(remove1, listener1.remove);
+ assertEquals(remove2, listener2.remove);
+
+ assertEquals(0, listener1.clearCache);
+ assertEquals(0, listener2.clearCache);
+
+ cache1.clearCache();
+ assertEquals(0, cache1.getCacheSize());
+ assertNull(cache1.get(new MyKey(b)));
+ assertNull(cache1.get(new MyKey(c)));
+ assertNull(cache2.get(new MyKey(b)));
+ assertNull(cache2.get(new MyKey(c)));
+ assertEquals(0, cache2.getCacheSize());
+
+ assertEquals(put1, listener1.put);
+ assertEquals(put2, listener2.put);
+
+ assertEquals(4, listener1.get);
+ assertEquals(4, listener2.get);
+
+ // Since the clear cache map/reduce can only find cache1,
+ // the remove calls will be applied to cache1 so cache2
+ // will be notified on its entries, this is due to the
+ // hack used to apply modifications within a map/reduce
+ remove2 += (isBLocal ? 0 : 1) + (isCLocal ? 0 : 1);
+
+ assertEquals(remove1, listener1.remove);
+ assertEquals(remove2, listener2.remove);
+
+ assertEquals(1, listener1.clearCache);
+ assertEquals(0, listener2.clearCache);
+
+ Map<Serializable, Object> values = new HashMap<Serializable, Object>();
+ key = new MyKey(a);
+ key2 = new MyKey(b);
+ values.put(key, "a");
+ values.put(key2, "b");
+ cache1.putMap(values);
+ assertEquals(2, cache1.getCacheSize());
+ Thread.sleep(40);
+ assertEquals("a", cache1.get(new MyKey(a)));
+ assertEquals("b", cache1.get(new MyKey(b)));
+ assertEquals("a", cache2.get(new MyKey(a)));
+ assertEquals("b", cache2.get(new MyKey(b)));
+ assertEquals(2, cache2.getCacheSize());
+
+ put1 += 2;
+ put2 += (isALocal ? 0 : 1) + (isBLocal ? 0 : 1);
+
+ assertEquals(put1, listener1.put);
+ assertEquals(put2, listener2.put);
+
+ assertEquals(6, listener1.get);
+ assertEquals(6, listener2.get);
+
+ assertEquals(remove1, listener1.remove);
+ assertEquals(remove2, listener2.remove);
+
+ assertEquals(1, listener1.clearCache);
+ assertEquals(0, listener2.clearCache);
+
+ values = new HashMap<Serializable, Object>()
+ {
+ private static final long serialVersionUID = 1L;
+
+ public Set<Entry<Serializable, Object>> entrySet()
{
- private static final long serialVersionUID = 1L;
+ Set<Entry<Serializable, Object>> set = new LinkedHashSet<Entry<Serializable, Object>>(super.entrySet());
+ set.add(new Entry<Serializable, Object>()
+ {
- public Set<Entry<Serializable, Object>> entrySet()
- {
- Set<Entry<Serializable, Object>> set = new LinkedHashSet<Entry<Serializable, Object>>(super.entrySet());
- set.add(new Entry<Serializable, Object>()
+ public Object setValue(Object paramV)
{
+ return null;
+ }
- public Object setValue(Object paramV)
- {
- return null;
- }
+ public Object getValue()
+ {
+ throw new RuntimeException("An exception");
+ }
- public Object getValue()
- {
- throw new RuntimeException("An exception");
- }
+ public Serializable getKey()
+ {
+ return "c";
+ }
+ });
+ return set;
+ }
+ };
+ values.put(new MyKey("e"), "e");
+ values.put(new MyKey("d"), "d");
+ cache1.putMap(values);
+ assertEquals(2, cache1.getCacheSize());
+ assertEquals(2, cache2.getCacheSize());
- public Serializable getKey()
- {
- return "c";
- }
- });
- return set;
- }
- };
- values.put(new MyKey("e"), "e");
- values.put(new MyKey("d"), "d");
- cache1.putMap(values);
- assertEquals(2, cache1.getCacheSize());
- assertEquals(2, cache2.getCacheSize());
+ assertEquals(put1, listener1.put);
+ assertEquals(put2, listener2.put);
-// assertEquals(put1, listener1.put);
-// assertEquals(put2, listener2.put);
+ assertEquals(6, listener1.get);
+ assertEquals(6, listener2.get);
- assertEquals(3, listener1.get);
- assertEquals(5, listener2.get);
+ assertEquals(remove1, listener1.remove);
+ assertEquals(remove2, listener2.remove);
-// assertEquals(remove1, listener1.remove);
-// assertEquals(remove2, listener2.remove);
+ assertEquals(1, listener1.clearCache);
+ assertEquals(0, listener2.clearCache);
- assertEquals(1, listener1.clearCache);
- assertEquals(0, listener2.clearCache);
+ assertEquals(0, listener1.expire);
+ assertEquals(0, listener2.expire);
- assertEquals(0, listener1.expire);
- assertEquals(0, listener2.expire);
+ cache2.clearCache();
+ assertEquals(0, cache1.getCacheSize());
+ assertEquals(0, cache2.getCacheSize());
- }
- finally
- {
- dcm2.stop();
- }
+ assertEquals(put1, listener1.put);
+ assertEquals(put2, listener2.put);
+
+ assertEquals(6, listener1.get);
+ assertEquals(6, listener2.get);
+
+ // Since the clear cache map/reduce can only find cache1,
+ // the remove calls will be applied to cache1 so cache2
+ // will be notified on its entries, this is due to the
+ // hack used to apply modifications within a map/reduce
+ remove2 += (isALocal ? 0 : 1) + (isBLocal ? 0 : 1);
+
+ assertEquals(remove1, listener1.remove);
+ assertEquals(remove2, listener2.remove);
+
+ assertEquals(1, listener1.clearCache);
+ assertEquals(1, listener2.clearCache);
+
+ assertEquals(0, listener1.expire);
+ assertEquals(0, listener2.expire);
}
}
Modified: kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/resources/conf/portal/cache-configuration-template.xml
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/resources/conf/portal/cache-configuration-template.xml 2012-03-20 11:47:42 UTC (rev 5921)
+++ kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/resources/conf/portal/cache-configuration-template.xml 2012-03-20 13:45:55 UTC (rev 5922)
@@ -53,12 +53,13 @@
<shutdown hookBehavior="DEFAULT"/>
</global>
<default>
- <locking isolationLevel="READ_COMMITTED" lockAcquisitionTimeout="10000" writeSkewCheck="false" concurrencyLevel="500"/>
- <transaction transactionManagerLookupClass="org.infinispan.transaction.lookup.GenericTransactionManagerLookup" syncRollbackPhase="true" syncCommitPhase="true"/>
+ <locking isolationLevel="READ_COMMITTED" lockAcquisitionTimeout="10000" writeSkewCheck="false" concurrencyLevel="500" useLockStriping="true"/>
+ <transaction transactionManagerLookupClass="org.infinispan.transaction.lookup.GenericTransactionManagerLookup" syncRollbackPhase="true" syncCommitPhase="true" transactionMode="TRANSACTIONAL"/>
<jmxStatistics enabled="true"/>
<clustering mode="replication">
<stateRetrieval timeout="20000" fetchInMemoryState="false"/>
<sync replTimeout="20000"/>
</clustering>
+ <invocationBatching enabled="true"/>
</default>
</infinispan>
\ No newline at end of file
Modified: kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/resources/conf/portal/distributed-cache-configuration-template.xml
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/resources/conf/portal/distributed-cache-configuration-template.xml 2012-03-20 11:47:42 UTC (rev 5921)
+++ kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/resources/conf/portal/distributed-cache-configuration-template.xml 2012-03-20 13:45:55 UTC (rev 5922)
@@ -54,11 +54,12 @@
</global>
<default>
<locking isolationLevel="READ_COMMITTED" lockAcquisitionTimeout="20000" writeSkewCheck="false" concurrencyLevel="500" useLockStriping="true"/>
- <transaction transactionManagerLookupClass="org.infinispan.transaction.lookup.GenericTransactionManagerLookup" syncRollbackPhase="true" syncCommitPhase="true"/>
+ <transaction transactionManagerLookupClass="org.infinispan.transaction.lookup.GenericTransactionManagerLookup" syncRollbackPhase="true" syncCommitPhase="true" transactionMode="TRANSACTIONAL"/>
<jmxStatistics enabled="true"/>
<clustering mode="replication">
<stateRetrieval timeout="20000" fetchInMemoryState="false"/>
<sync replTimeout="20000"/>
</clustering>
+ <invocationBatching enabled="true"/>
</default>
</infinispan>
\ No newline at end of file
Modified: kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/resources/conf/portal/distributed-cache-configuration.xml
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/resources/conf/portal/distributed-cache-configuration.xml 2012-03-20 11:47:42 UTC (rev 5921)
+++ kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/resources/conf/portal/distributed-cache-configuration.xml 2012-03-20 13:45:55 UTC (rev 5922)
@@ -54,10 +54,9 @@
</global>
<namedCache name="eXoCache">
<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"/>
+ <transaction transactionManagerLookupClass="org.infinispan.transaction.lookup.GenericTransactionManagerLookup" syncRollbackPhase="true" syncCommitPhase="true" eagerLockSingleNode="true" transactionMode="TRANSACTIONAL"/>
<jmxStatistics enabled="true"/>
<clustering mode="distribution">
- <l1 enabled="false"/>
<hash numOwners="${infinispan-num-owners}" rehashRpcTimeout="120000" />
<sync/>
</clustering>
Modified: kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/resources/conf/portal/test-configuration.xml
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/resources/conf/portal/test-configuration.xml 2012-03-20 11:47:42 UTC (rev 5921)
+++ kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v5/src/test/resources/conf/portal/test-configuration.xml 2012-03-20 13:45:55 UTC (rev 5922)
@@ -32,7 +32,7 @@
<description>The default cache configuration</description>
<object type="org.exoplatform.services.cache.ExoCacheConfig">
<field name="name"><string>default</string></field>
- <field name="maxSize"><int>5</int></field>
+ <field name="maxSize"><int>10</int></field>
<field name="liveTime"><long>2</long></field>
</object>
</object-param>
@@ -223,9 +223,6 @@
<string>LRU</string>
</value>
<value>
- <string>LRU_OLD</string>
- </value>
- <value>
<string>UNORDERED</string>
</value>
<value>
Modified: kernel/trunk/exo.kernel.component.ext.rpc.impl.jgroups.v3/pom.xml
===================================================================
--- kernel/trunk/exo.kernel.component.ext.rpc.impl.jgroups.v3/pom.xml 2012-03-20 11:47:42 UTC (rev 5921)
+++ kernel/trunk/exo.kernel.component.ext.rpc.impl.jgroups.v3/pom.xml 2012-03-20 13:45:55 UTC (rev 5922)
@@ -44,7 +44,7 @@
<dependency>
<groupId>org.jgroups</groupId>
<artifactId>jgroups</artifactId>
- <version>3.0.0.Final</version>
+ <version>3.0.6.Final</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
Modified: kernel/trunk/pom.xml
===================================================================
--- kernel/trunk/pom.xml 2012-03-20 11:47:42 UTC (rev 5921)
+++ kernel/trunk/pom.xml 2012-03-20 13:45:55 UTC (rev 5922)
@@ -203,7 +203,7 @@
<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.jibx</groupId>
12 years, 2 months