exo-jcr SVN: r1183 - jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache.
by do-not-reply@jboss.org
Author: skabashnyuk
Date: 2009-12-25 08:43:32 -0500 (Fri, 25 Dec 2009)
New Revision: 1183
Modified:
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JbossCacheIndexUpdateMonitor.java
Log:
EXOJCR-331 : changes now made in transaction
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JbossCacheIndexUpdateMonitor.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JbossCacheIndexUpdateMonitor.java 2009-12-25 11:46:14 UTC (rev 1182)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JbossCacheIndexUpdateMonitor.java 2009-12-25 13:43:32 UTC (rev 1183)
@@ -19,11 +19,18 @@
package org.exoplatform.services.jcr.impl.core.query.jbosscache;
import org.exoplatform.services.jcr.impl.core.query.lucene.IndexUpdateMonitor;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
import org.jboss.cache.Cache;
+import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
import java.io.Serializable;
+import javax.transaction.RollbackException;
+import javax.transaction.Status;
+import javax.transaction.TransactionManager;
+
/**
* @author <a href="mailto:Sergey.Kabashnyuk@exoplatform.org">Sergey Kabashnyuk</a>
* @version $Id: exo-jboss-codetemplates.xml 34360 2009-07-22 23:58:59Z ksm $
@@ -31,6 +38,10 @@
*/
public class JbossCacheIndexUpdateMonitor implements IndexUpdateMonitor
{
+ /**
+ * Logger instance for this class
+ */
+ private final Log log = ExoLogger.getLogger(JbossCacheIndexUpdateMonitor.class);
private final Cache<Serializable, Object> cache;
@@ -62,7 +73,41 @@
*/
public void setUpdateInProgress(boolean updateInProgress)
{
- cache.put(PARAMETER_ROOT, PARAMETER_NAME, new Boolean(updateInProgress));
+
+ TransactionManager tm = ((CacheSPI<Serializable, Object>)cache).getTransactionManager();
+ try
+ {
+ // if any active transaction, use it
+ if (tm.getStatus() == Status.STATUS_ACTIVE)
+ {
+ cache.put(PARAMETER_ROOT, PARAMETER_NAME, new Boolean(updateInProgress));
+ }
+ else if (tm.getStatus() == Status.STATUS_NO_TRANSACTION)
+ {
+ // no active transaction, creating new one
+ tm.begin();
+ cache.put(PARAMETER_ROOT, PARAMETER_NAME, new Boolean(updateInProgress));
+ tm.commit();
+ }
+ }
+ catch (RollbackException e)
+ {
+ // Indicate that the transaction has been rolled back rather than committed.
+ log.error(e.getMessage(), e.getCause());
+ }
+ catch (Exception e)
+ {
+ try
+ {
+ tm.rollback();
+ }
+ catch (Exception e1)
+ {
+ // Treat the exception
+ log.error(e.getMessage(), e.getCause());
+ }
+ }
+
}
}
16 years, 4 months
exo-jcr SVN: r1182 - in jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query: jbosscache and 1 other directory.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2009-12-25 06:46:14 -0500 (Fri, 25 Dec 2009)
New Revision: 1182
Modified:
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchManager.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/IndexerCacheLoader.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JbossCacheIndexChangesFilter.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JbossCacheIndexInfos.java
Log:
EXOJCR-334: IndexerCacheLoader updates index on prepare and does nothing on commit. JbossCacheIndex filter and index infos pushes to cache only if transaction is present with ACTIVE status or no transaction present. SearchManager doesn't store log before it is started.
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchManager.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchManager.java 2009-12-25 11:14:40 UTC (rev 1181)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchManager.java 2009-12-25 11:46:14 UTC (rev 1182)
@@ -137,11 +137,6 @@
protected IndexerChangesFilter changesFilter;
/**
- * ChangesLog Buffer (used for saves before start).
- */
- private List<ItemStateChangesLog> changesLogBuffer = new ArrayList<ItemStateChangesLog>();
-
- /**
* Creates a new <code>SearchManager</code>.
*
* @param config
@@ -379,12 +374,8 @@
if (itemStates.getSize() > 0)
{
//Check if SearchManager started and filter configured
- if (changesFilter == null)
+ if (changesFilter != null)
{
- changesLogBuffer.add(itemStates);
- }
- else
- {
changesFilter.onSaveItems(itemStates);
}
}
@@ -461,16 +452,6 @@
}
initializeQueryHandler();
- if (changesLogBuffer.size() > 0)
- {
- for (ItemStateChangesLog bufferedChangesLog : changesLogBuffer)
- {
- onSaveItems(bufferedChangesLog);
- }
- changesLogBuffer.clear();
- changesLogBuffer = null;
- }
-
}
catch (RepositoryException e)
{
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/IndexerCacheLoader.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/IndexerCacheLoader.java 2009-12-25 11:14:40 UTC (rev 1181)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/IndexerCacheLoader.java 2009-12-25 11:46:14 UTC (rev 1182)
@@ -23,8 +23,6 @@
import org.exoplatform.services.jcr.impl.storage.jbosscache.AbstractWriteOnlyCacheLoader;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
-import org.jboss.cache.CacheException;
-import org.jboss.cache.Fqn;
import org.jboss.cache.Modification;
import org.jboss.cache.Modification.ModificationType;
@@ -52,6 +50,15 @@
private QueryHandler parentHandler;
/**
+ * @see org.jboss.cache.loader.AbstractCacheLoader#commit(java.lang.Object)
+ */
+ @Override
+ public void commit(Object tx) throws Exception
+ {
+ // do nothing. Everything is done on prepare phase.
+ }
+
+ /**
* Inject dependencies needed for CacheLoader: SearchManagers and QueryHandlers.
*
* @param searchManager
@@ -70,31 +77,64 @@
}
/**
- * @see org.exoplatform.services.jcr.impl.storage.jbosscache.AbstractWriteOnlyCacheLoader#put(org.jboss.cache.Fqn, java.lang.Object, java.lang.Object)
+ * @see org.jboss.cache.loader.AbstractCacheLoader#prepare(java.lang.Object, java.util.List, boolean)
*/
@Override
- public Object put(Fqn arg0, Object key, Object val) throws Exception
+ public void prepare(Object tx, List<Modification> modifications, boolean onePhase) throws Exception
{
- log.info("Entering PUT.");
- try
+ // update index on prepare phase
+ for (Modification m : modifications)
{
- if (key.equals(JbossCacheIndexChangesFilter.LISTWRAPPER) && val instanceof ChangesFilterListsWrapper)
+ // this is put-key-value modification
+ if (m.getType() == ModificationType.PUT_KEY_VALUE)
{
- if (log.isDebugEnabled())
+ if (m.getKey().equals(JbossCacheIndexChangesFilter.LISTWRAPPER)
+ && m.getValue() instanceof ChangesFilterListsWrapper)
{
- log.info("Received list wrapper, start indexing...");
+ if (log.isDebugEnabled())
+ {
+ log.info("Received list wrapper, start indexing...");
+ }
+ // updating index
+ ChangesFilterListsWrapper wrapper = (ChangesFilterListsWrapper)m.getValue();
+ updateIndex(wrapper.getAddedNodes(), wrapper.getRemovedNodes(), wrapper.getParentAddedNodes(), wrapper
+ .getParentRemovedNodes());
}
- ChangesFilterListsWrapper wrapper = (ChangesFilterListsWrapper)val;
- //System.out.println("UPDATE INDEX: "+wrapper.getAddedNodes() + wrapper.getRemovedNodes());
- updateIndex(wrapper.getAddedNodes(), wrapper.getRemovedNodes(), wrapper.getParentAddedNodes(), wrapper
- .getParentRemovedNodes());
}
}
- catch (Exception e)
+ }
+
+ /**
+ * @see org.exoplatform.services.jcr.impl.storage.jbosscache.AbstractWriteOnlyCacheLoader#put(java.util.List)
+ */
+ @Override
+ public void put(List<Modification> modifications) throws Exception
+ {
+ // do nothing. Index is updated on prepare phase.
+ }
+
+ /**
+ * Switches Indexer mode from RO to RW, or from RW to RO
+ *
+ * @param ioMode
+ */
+ public void setMode(IndexerIoMode ioMode)
+ {
+ try
{
- e.printStackTrace();
+ if (handler != null)
+ {
+ handler.setIndexerIoMode(ioMode);
+ }
+ if (parentHandler != null)
+ {
+ parentHandler.setIndexerIoMode(ioMode);
+ }
}
- return null;
+ catch (IOException e)
+ {
+ log.error("Unable to set indexer mode to " + ioMode, e);
+ }
}
/**
@@ -158,48 +198,4 @@
}
}
- /**
- * Switches Indexer mode from RO to RW, or from RW to RO
- *
- * @param ioMode
- */
- public void setMode(IndexerIoMode ioMode)
- {
- try
- {
- if (handler != null)
- {
- handler.setIndexerIoMode(ioMode);
- }
- if (parentHandler != null)
- {
- parentHandler.setIndexerIoMode(ioMode);
- }
- }
- catch (IOException e)
- {
- log.error("Unable to set indexer mode to " + ioMode, e);
- }
- }
-
- /**
- * @see org.exoplatform.services.jcr.impl.storage.jbosscache.AbstractWriteOnlyCacheLoader#put(java.util.List)
- */
- @Override
- public void put(List<Modification> modifications) throws Exception
- {
- }
-
- @Override
- public void prepare(Object tx, List<Modification> modifications, boolean onePhase) throws Exception
- {
- log.info("Entering PREPARE.");
- for (Modification m : modifications)
- {
- if (m.getType() == ModificationType.PUT_KEY_VALUE)
- {
- put(m.getFqn(), m.getKey(), m.getValue());
- }
- }
- }
}
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JbossCacheIndexChangesFilter.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JbossCacheIndexChangesFilter.java 2009-12-25 11:14:40 UTC (rev 1181)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JbossCacheIndexChangesFilter.java 2009-12-25 11:46:14 UTC (rev 1182)
@@ -26,7 +26,6 @@
import org.exoplatform.services.jcr.impl.core.query.IndexingTree;
import org.exoplatform.services.jcr.impl.core.query.QueryHandler;
import org.exoplatform.services.jcr.impl.core.query.SearchManager;
-import org.exoplatform.services.jcr.impl.dataflow.persistent.jbosscache.JBossCacheWorkspaceStorageCache;
import org.exoplatform.services.jcr.util.IdGenerator;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
@@ -155,7 +154,7 @@
cache.put(id, LISTWRAPPER, new ChangesFilterListsWrapper(addedNodes, removedNodes, parentAddedNodes,
parentRemovedNodes));
}
- else
+ else if (tm.getStatus() == Status.STATUS_NO_TRANSACTION)
{
// no active transaction, creating new one
tm.begin();
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JbossCacheIndexInfos.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JbossCacheIndexInfos.java 2009-12-25 11:14:40 UTC (rev 1181)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JbossCacheIndexInfos.java 2009-12-25 11:46:14 UTC (rev 1182)
@@ -154,7 +154,7 @@
{
cache.put(namesFqn, LIST_KEY, getNames());
}
- else
+ else if (tm.getStatus() == Status.STATUS_NO_TRANSACTION)
{
// no active transaction, creating new one
tm.begin();
16 years, 4 months
exo-jcr SVN: r1181 - jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2009-12-25 06:14:40 -0500 (Fri, 25 Dec 2009)
New Revision: 1181
Modified:
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/IndexerCacheLoader.java
Log:
EXOJCR-334: IndexerCacheLoader added log.info().
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/IndexerCacheLoader.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/IndexerCacheLoader.java 2009-12-25 11:00:45 UTC (rev 1180)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/IndexerCacheLoader.java 2009-12-25 11:14:40 UTC (rev 1181)
@@ -75,6 +75,7 @@
@Override
public Object put(Fqn arg0, Object key, Object val) throws Exception
{
+ log.info("Entering PUT.");
try
{
if (key.equals(JbossCacheIndexChangesFilter.LISTWRAPPER) && val instanceof ChangesFilterListsWrapper)
@@ -192,6 +193,7 @@
@Override
public void prepare(Object tx, List<Modification> modifications, boolean onePhase) throws Exception
{
+ log.info("Entering PREPARE.");
for (Modification m : modifications)
{
if (m.getType() == ModificationType.PUT_KEY_VALUE)
16 years, 4 months
exo-jcr SVN: r1180 - jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2009-12-25 06:00:45 -0500 (Fri, 25 Dec 2009)
New Revision: 1180
Modified:
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/IndexerCacheLoader.java
Log:
EXOJCR-334: IndexerCacheLoader updated to handle transactions.
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/IndexerCacheLoader.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/IndexerCacheLoader.java 2009-12-25 10:59:36 UTC (rev 1179)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/IndexerCacheLoader.java 2009-12-25 11:00:45 UTC (rev 1180)
@@ -26,6 +26,7 @@
import org.jboss.cache.CacheException;
import org.jboss.cache.Fqn;
import org.jboss.cache.Modification;
+import org.jboss.cache.Modification.ModificationType;
import java.io.IOException;
import java.util.List;
@@ -186,37 +187,16 @@
@Override
public void put(List<Modification> modifications) throws Exception
{
- // If transactions are used, then list of modifications will be sent to cache loader
- // added code to handle list of modifications.
+ }
+
+ @Override
+ public void prepare(Object tx, List<Modification> modifications, boolean onePhase) throws Exception
+ {
for (Modification m : modifications)
{
- switch (m.getType())
+ if (m.getType() == ModificationType.PUT_KEY_VALUE)
{
- case PUT_DATA :
- put(m.getFqn(), m.getData());
- break;
- case PUT_DATA_ERASE :
- removeData(m.getFqn());
- put(m.getFqn(), m.getData());
- break;
- case PUT_KEY_VALUE :
- put(m.getFqn(), m.getKey(), m.getValue());
- break;
- case REMOVE_DATA :
- removeData(m.getFqn());
- break;
- case REMOVE_KEY_VALUE :
- remove(m.getFqn(), m.getKey());
- break;
- case REMOVE_NODE :
- remove(m.getFqn());
- break;
- case MOVE :
- // involve moving all children too
- move(m.getFqn(), m.getFqn2());
- break;
- default :
- throw new CacheException("Unknown modification " + m.getType());
+ put(m.getFqn(), m.getKey(), m.getValue());
}
}
}
16 years, 4 months
exo-jcr SVN: r1179 - in jcr/branches/1.12.0-JBCCACHE/applications: java/exo.jcr.applications.backupconsole/bin and 1 other directory.
by do-not-reply@jboss.org
Author: dkatayev
Date: 2009-12-25 05:59:36 -0500 (Fri, 25 Dec 2009)
New Revision: 1179
Modified:
jcr/branches/1.12.0-JBCCACHE/applications/java/exo.jcr.applications.backupconsole/bin/jcrbackup.cmd
jcr/branches/1.12.0-JBCCACHE/applications/java/exo.jcr.applications.backupconsole/bin/jcrbackup.sh
jcr/branches/1.12.0-JBCCACHE/applications/product-exo-jcr-as-jboss-ear.xml
jcr/branches/1.12.0-JBCCACHE/applications/product-exo-jcr-as-jonas-ear.xml
jcr/branches/1.12.0-JBCCACHE/applications/product-exo-jcr-as-tomcat6.xml
Log:
EXOJCR-325 Assemblies and scripts updated
Modified: jcr/branches/1.12.0-JBCCACHE/applications/java/exo.jcr.applications.backupconsole/bin/jcrbackup.cmd
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/applications/java/exo.jcr.applications.backupconsole/bin/jcrbackup.cmd 2009-12-25 10:44:26 UTC (rev 1178)
+++ jcr/branches/1.12.0-JBCCACHE/applications/java/exo.jcr.applications.backupconsole/bin/jcrbackup.cmd 2009-12-25 10:59:36 UTC (rev 1179)
@@ -1 +1 @@
-java -jar exo.jcr.applications.backupconsole-1.12.0-JBCCACHE-SNAPHSOT.jar %*
+java -jar exo.jcr.applications.backupconsole-1.12.0-JBCCACHE-SNAPSHOT.jar %*
Modified: jcr/branches/1.12.0-JBCCACHE/applications/java/exo.jcr.applications.backupconsole/bin/jcrbackup.sh
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/applications/java/exo.jcr.applications.backupconsole/bin/jcrbackup.sh 2009-12-25 10:44:26 UTC (rev 1178)
+++ jcr/branches/1.12.0-JBCCACHE/applications/java/exo.jcr.applications.backupconsole/bin/jcrbackup.sh 2009-12-25 10:59:36 UTC (rev 1179)
@@ -1,3 +1,3 @@
#!/bin/sh
-java -jar exo.jcr.applications.backupconsole-1.12.0-JBCCACHE-SNAPHSOT.jar $*
+java -jar exo.jcr.applications.backupconsole-1.12.0-JBCCACHE-SNAPSHOT.jar $*
Modified: jcr/branches/1.12.0-JBCCACHE/applications/product-exo-jcr-as-jboss-ear.xml
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/applications/product-exo-jcr-as-jboss-ear.xml 2009-12-25 10:44:26 UTC (rev 1178)
+++ jcr/branches/1.12.0-JBCCACHE/applications/product-exo-jcr-as-jboss-ear.xml 2009-12-25 10:59:36 UTC (rev 1179)
@@ -22,7 +22,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>exo.jcr.applications.config</artifactId>
- <version>1.12.0-JBCCACHE-SNAPHSOT</version>
+ <version>1.12.0-JBCCACHE-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -36,7 +36,7 @@
<dependency>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>exo.jcr.ear</artifactId>
- <version>1.12.0-JBCCACHE-SNAPHSOT</version>
+ <version>1.12.0-JBCCACHE-SNAPSHOT</version>
<type>ear</type>
<scope>runtime</scope>
</dependency>
Modified: jcr/branches/1.12.0-JBCCACHE/applications/product-exo-jcr-as-jonas-ear.xml
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/applications/product-exo-jcr-as-jonas-ear.xml 2009-12-25 10:44:26 UTC (rev 1178)
+++ jcr/branches/1.12.0-JBCCACHE/applications/product-exo-jcr-as-jonas-ear.xml 2009-12-25 10:59:36 UTC (rev 1179)
@@ -22,7 +22,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>exo.jcr.applications.config</artifactId>
- <version>1.12.0-JBCCACHE-SNAPHSOT</version>
+ <version>1.12.0-JBCCACHE-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -36,7 +36,7 @@
<dependency>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>exo.jcr.ear</artifactId>
- <version>1.12.0-JBCCACHE-SNAPHSOT</version>
+ <version>1.12.0-JBCCACHE-SNAPSHOT</version>
<type>ear</type>
<scope>runtime</scope>
</dependency>
Modified: jcr/branches/1.12.0-JBCCACHE/applications/product-exo-jcr-as-tomcat6.xml
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/applications/product-exo-jcr-as-tomcat6.xml 2009-12-25 10:44:26 UTC (rev 1178)
+++ jcr/branches/1.12.0-JBCCACHE/applications/product-exo-jcr-as-tomcat6.xml 2009-12-25 10:59:36 UTC (rev 1179)
@@ -22,7 +22,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>exo.jcr.applications.config</artifactId>
- <version>1.12.0-JBCCACHE-SNAPHSOT</version>
+ <version>1.12.0-JBCCACHE-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
16 years, 4 months
exo-jcr SVN: r1178 - in jcr/branches/1.12.0-JBCCACHE: applications and 18 other directories.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2009-12-25 05:44:26 -0500 (Fri, 25 Dec 2009)
New Revision: 1178
Added:
jcr/branches/1.12.0-JBCCACHE/applications/cluster.test.client/
jcr/branches/1.12.0-JBCCACHE/applications/cluster.test.client/pom.xml
jcr/branches/1.12.0-JBCCACHE/applications/cluster.test.client/src/
jcr/branches/1.12.0-JBCCACHE/applications/cluster.test.client/src/main/
jcr/branches/1.12.0-JBCCACHE/applications/cluster.test.client/src/main/java/
jcr/branches/1.12.0-JBCCACHE/applications/cluster.test.client/src/main/java/org/
jcr/branches/1.12.0-JBCCACHE/applications/cluster.test.client/src/main/java/org/exoplatform/
jcr/branches/1.12.0-JBCCACHE/applications/cluster.test.client/src/main/java/org/exoplatform/services/
jcr/branches/1.12.0-JBCCACHE/applications/cluster.test.client/src/main/java/org/exoplatform/services/jcr/
jcr/branches/1.12.0-JBCCACHE/applications/cluster.test.client/src/main/java/org/exoplatform/services/jcr/cluster/
jcr/branches/1.12.0-JBCCACHE/applications/cluster.test.client/src/main/java/org/exoplatform/services/jcr/cluster/JCRWebdavConnection.java
jcr/branches/1.12.0-JBCCACHE/applications/cluster.test.client/src/test/
jcr/branches/1.12.0-JBCCACHE/applications/cluster.test.client/src/test/java/
jcr/branches/1.12.0-JBCCACHE/applications/cluster.test.client/src/test/java/org/
jcr/branches/1.12.0-JBCCACHE/applications/cluster.test.client/src/test/java/org/exoplatform/
jcr/branches/1.12.0-JBCCACHE/applications/cluster.test.client/src/test/java/org/exoplatform/services/
jcr/branches/1.12.0-JBCCACHE/applications/cluster.test.client/src/test/java/org/exoplatform/services/jcr/
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/BaseClusteringFunctionalTest.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/functional/
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavAddBLOBTest.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavAddNodeTest.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavMoveNodeTest.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavRemoveNodeTest.java
Modified:
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/pom.xml
jcr/branches/1.12.0-JBCCACHE/pom.xml
Log:
EXOJCR-330 : Add cluster.test.client and use it. Add functional cluster tests form branche 1.12.0-JBC.
Added: jcr/branches/1.12.0-JBCCACHE/applications/cluster.test.client/pom.xml
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/applications/cluster.test.client/pom.xml (rev 0)
+++ jcr/branches/1.12.0-JBCCACHE/applications/cluster.test.client/pom.xml 2009-12-25 10:44:26 UTC (rev 1178)
@@ -0,0 +1,68 @@
+<!--
+
+ Copyright (C) 2009 eXo Platform SAS.
+
+ This is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.exoplatform.jcr</groupId>
+ <artifactId>jcr-parent</artifactId>
+ <version>1.12.0-JBCCACHE-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>exo.jcr.component.cluster.test.client</artifactId>
+
+ <name>eXo JCR :: Cluster :: Test Client</name>
+ <description>Cluster test client</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.exoplatform.ws</groupId>
+ <artifactId>exo.ws.rest.core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.ws</groupId>
+ <artifactId>exo.ws.rest.ext</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.ws</groupId>
+ <artifactId>exo.ws.commons</artifactId>
+ </dependency>
+ </dependencies>
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifest>
+ <addClasspath>true</addClasspath>
+ </manifest>
+ </archive>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+
+</project>
Added: jcr/branches/1.12.0-JBCCACHE/applications/cluster.test.client/src/main/java/org/exoplatform/services/jcr/cluster/JCRWebdavConnection.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/applications/cluster.test.client/src/main/java/org/exoplatform/services/jcr/cluster/JCRWebdavConnection.java (rev 0)
+++ jcr/branches/1.12.0-JBCCACHE/applications/cluster.test.client/src/main/java/org/exoplatform/services/jcr/cluster/JCRWebdavConnection.java 2009-12-25 10:44:26 UTC (rev 1178)
@@ -0,0 +1,214 @@
+/*
+ * Copyright (C) 2003-2009 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.cluster;
+
+import java.io.IOException;
+
+import javax.ws.rs.core.HttpHeaders;
+
+import org.exoplatform.common.http.client.HTTPConnection;
+import org.exoplatform.common.http.client.HTTPResponse;
+import org.exoplatform.common.http.client.HttpHeaderElement;
+import org.exoplatform.common.http.client.HttpOutputStream;
+import org.exoplatform.common.http.client.ModuleException;
+import org.exoplatform.common.http.client.NVPair;
+import org.exoplatform.services.rest.ExtHttpHeaders;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>Date: 2009
+ *
+ * @author <a href="mailto:alex.reshetnyak@exoplatform.com.ua">Alex Reshetnyak</a>
+ * @version $Id$
+ */
+public class JCRWebdavConnection extends HTTPConnection
+{
+ private String realm;
+
+ private String user;
+
+ private String pass;
+
+ private String workspacePath;
+
+ public JCRWebdavConnection(String host, int port, String user, String password, String realm, String workspacePath)
+ {
+ super(host, port);
+
+ this.user = user;
+ this.pass = password;
+ this.realm = realm;
+ this.workspacePath = workspacePath;
+
+ addBasicAuthorization(this.realm, this.user, this.pass);
+ }
+
+ public void addNode(String name, byte[] data) throws IOException, ModuleException
+ {
+ Put(workspacePath + name, data).getStatusCode();
+ }
+
+ public void addNode(String name, String nodeType, byte[] data) throws IOException, ModuleException
+ {
+ NVPair[] headers = new NVPair[1];
+ headers[0] = new NVPair("File-NodeType", nodeType);
+ Put(workspacePath + name, data).getStatusCode();
+ }
+
+ public HTTPResponse addNode(String name, HttpOutputStream stream) throws IOException, ModuleException
+ {
+ return Put(workspacePath + name, stream);
+ }
+
+ public void removeNode(String name) throws IOException, ModuleException
+ {
+ Delete(workspacePath + name).getStatusCode();
+ }
+
+ /*public void getNode(String name) throws IOException, ModuleException
+ {
+ Get(workspacePath + name).getStatusCode();
+ }*/
+
+ public HTTPResponse getNode(String name) throws IOException, ModuleException
+ {
+ HTTPResponse response = Get(workspacePath + name);
+ response.getStatusCode();
+ return response;
+ }
+
+
+ public void addProperty(String nodeName, String property) throws IOException, ModuleException
+ {
+ String xmlBody =
+ "<?xml version='1.0' encoding='utf-8' ?>" + "<D:propertyupdate xmlns:D='DAV:'>" + "<D:set>" + "<D:prop>" + "<"
+ + property + ">value</" + property + ">" + "</D:prop>" + "</D:set>" + "</D:propertyupdate>";
+
+ NVPair[] headers = new NVPair[2];
+ headers[0] = new NVPair(HttpHeaders.CONTENT_TYPE, "text/xml; charset='utf-8'");
+ headers[1] = new NVPair(HttpHeaders.CONTENT_LENGTH, Integer.toString(xmlBody.length()));
+
+ ExtensionMethod("PROPPATCH", workspacePath + nodeName, xmlBody.getBytes(), headers).getStatusCode();
+ }
+
+ public void setProperty(String nodeName, String property, String value) throws IOException, ModuleException
+ {
+ String xmlBody =
+ "<?xml version='1.0' encoding='utf-8' ?>" + "<D:propertyupdate xmlns:D='DAV:'>" + "<D:set>" + "<D:prop>" + "<"
+ + property + ">" + value + "</" + property + ">" + "</D:prop>" + "</D:set>" + "</D:propertyupdate>";
+
+ NVPair[] headers = new NVPair[2];
+ headers[0] = new NVPair(HttpHeaders.CONTENT_TYPE, "text/xml; charset='utf-8'");
+ headers[1] = new NVPair(HttpHeaders.CONTENT_LENGTH, Integer.toString(xmlBody.length()));
+
+ HTTPResponse response = ExtensionMethod("PROPPATCH", workspacePath + nodeName, xmlBody.getBytes(), headers);
+ response.getStatusCode();
+
+ }
+
+ public void removeProperty(String nodeName, String property) throws IOException, ModuleException
+ {
+ String xmlBody =
+ "<?xml version='1.0' encoding='utf-8' ?>"
+ + "<D:propertyupdate xmlns:D='DAV:' xmlns:Z='http://www.w3.com/standards/z39.50/'>" + "<D:remove>"
+ + "<D:prop><" + property + "/></D:prop>" + "</D:remove>" + "</D:propertyupdate>";
+
+ NVPair[] headers = new NVPair[2];
+ headers[0] = new NVPair(HttpHeaders.CONTENT_TYPE, "text/xml; charset='utf-8'");
+ headers[1] = new NVPair(HttpHeaders.CONTENT_LENGTH, Integer.toString(xmlBody.length()));
+
+ ExtensionMethod("PROPPATCH", workspacePath + nodeName, xmlBody.getBytes(), headers).getStatusCode();
+ }
+
+ public String lock(String nodeName) throws IOException, ModuleException
+ {
+ String xmlBody =
+ "<?xml version='1.0' encoding='utf-8' ?>" + "<D:lockinfo xmlns:D='DAV:'>" + "<D:lockscope>" + "<D:exclusive/>"
+ + "</D:lockscope>" + "<D:locktype>" + "<D:write/>" + "</D:locktype>" + "<D:owner>owner</D:owner>"
+ + "</D:lockinfo>";
+
+ NVPair[] headers = new NVPair[2];
+ headers[0] = new NVPair(HttpHeaders.CONTENT_TYPE, "text/xml; charset='utf-8'");
+ headers[1] = new NVPair(HttpHeaders.CONTENT_LENGTH, Integer.toString(xmlBody.length()));
+
+ HTTPResponse response = ExtensionMethod("LOCK", workspacePath + nodeName, xmlBody.getBytes(), headers);
+
+ response.getStatusCode();
+ StringBuffer resp = new StringBuffer(new String(response.getData(), "UTF-8"));
+
+ final String lockPrffix = "opaquelocktoken:";
+
+ int pos = resp.lastIndexOf(lockPrffix);
+
+ String lockToken = resp.substring(pos + lockPrffix.length(), pos + lockPrffix.length() + 32);
+
+ return lockToken;
+ }
+
+ public void unlock(String nodeName, String lockToken) throws IOException, ModuleException
+ {
+ NVPair[] headers = new NVPair[3];
+ headers[0] = new NVPair(HttpHeaders.CONTENT_TYPE, "text/xml; charset='utf-8'");
+ headers[1] = new NVPair(HttpHeaders.CONTENT_LENGTH, Integer.toString("".length()));
+ headers[2] = new NVPair(ExtHttpHeaders.LOCKTOKEN, "<" + lockToken + ">");
+
+ HTTPResponse response = ExtensionMethod("UNLOCK", workspacePath + nodeName, "".getBytes(), headers);
+ response.getStatusCode();
+ }
+
+ public void addVersionControl(String nodeName) throws IOException, ModuleException
+ {
+ NVPair[] headers = new NVPair[1];
+ // headers[0] = new NVPair(HttpHeaders.CONTENT_TYPE, "text/xml; charset='utf-8'");
+ headers[0] = new NVPair(HttpHeaders.CONTENT_LENGTH, Integer.toString("".length()));
+
+ HTTPResponse response = ExtensionMethod("VERSION-CONTROL", workspacePath + nodeName, "".getBytes(), headers);
+ response.getStatusCode();
+ }
+
+ public void checkIn(String nodeName) throws IOException, ModuleException
+ {
+ NVPair[] headers = new NVPair[1];
+ headers[0] = new NVPair(HttpHeaders.CONTENT_LENGTH, Integer.toString("".length()));
+
+ HTTPResponse response = ExtensionMethod("CHECKIN", workspacePath + nodeName, "".getBytes(), headers);
+ response.getStatusCode();
+ }
+
+ public void checkOut(String nodeName) throws IOException, ModuleException
+ {
+ NVPair[] headers = new NVPair[1];
+ headers[0] = new NVPair(HttpHeaders.CONTENT_LENGTH, Integer.toString("".length()));
+
+ HTTPResponse response = ExtensionMethod("CHECKOUT", workspacePath + nodeName, "".getBytes(), headers);
+ response.getStatusCode();
+ }
+
+ public void addDir(String path) throws IOException, ModuleException
+ {
+ MkCol(workspacePath + path).getStatusCode();
+ }
+
+ public void restore(String node, String version) throws IOException, ModuleException
+ {
+ NVPair[] query = new NVPair[1];
+ query[0] = new NVPair("version", version);
+ Get(workspacePath + node, query).getStatusCode();
+ }
+
+}
\ No newline at end of file
Property changes on: jcr/branches/1.12.0-JBCCACHE/applications/cluster.test.client/src/main/java/org/exoplatform/services/jcr/cluster/JCRWebdavConnection.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/pom.xml
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/pom.xml 2009-12-25 09:13:17 UTC (rev 1177)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/pom.xml 2009-12-25 10:44:26 UTC (rev 1178)
@@ -167,6 +167,11 @@
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>org.exoplatform.jcr</groupId>
+ <artifactId>exo.jcr.component.cluster.test.client</artifactId>
+ <scope>test</scope>
+ </dependency>
<!-- TCK binaries and deps for repo stub, some eXo API test -->
<dependency>
<groupId>org.jboss.cache</groupId>
Added: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/BaseClusteringFunctionalTest.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/BaseClusteringFunctionalTest.java (rev 0)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/BaseClusteringFunctionalTest.java 2009-12-25 10:44:26 UTC (rev 1178)
@@ -0,0 +1,117 @@
+/*
+ * Copyright (C) 2003-2009 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.cluster;
+
+import junit.framework.TestCase;
+
+import org.exoplatform.common.http.client.CookieModule;
+import org.exoplatform.services.jcr.cluster.JCRWebdavConnection;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.Random;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>Date: 2009
+ *
+ * @author <a href="mailto:alex.reshetnyak@exoplatform.com.ua">Alex Reshetnyak</a>
+ * @version $Id$
+ */
+public abstract class BaseClusteringFunctionalTest extends TestCase
+{
+ protected JCRWebdavConnection connection1;
+
+ protected JCRWebdavConnection connection2;
+
+ protected JCRWebdavConnection connection3;
+
+ protected JCRWebdavConnection connection4;
+
+ private String host = "localhost";
+
+ private int port1 = 8081;//8080;
+
+ private int port2 = 8082;
+
+ private int port3 = 8083;
+
+ private int port4 = 8084;
+
+ private String realm = "eXo REST services";
+
+ private String user = "root";
+
+ private String password = "exo";
+
+ private String workspacePath = "/rest/jcr/repository/production/";
+
+ protected String nodeName;
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ CookieModule.setCookiePolicyHandler(null);
+ connection1 = new JCRWebdavConnection(host, port1, user, password, realm, workspacePath);
+ connection2 = new JCRWebdavConnection(host, port2, user, password, realm, workspacePath);
+ connection3 = new JCRWebdavConnection(host, port3, user, password, realm, workspacePath);
+ connection4 = new JCRWebdavConnection(host, port4, user, password, realm, workspacePath);
+
+ nodeName = generateUniqueName("removed_node_over_webdav");
+ }
+
+ public String generateUniqueName(String prefix)
+ {
+ return prefix + "-" + Math.random();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+
+ connection1.removeNode(nodeName);
+ connection1.stop();
+ }
+
+ protected File createBLOBTempFile(String prefix, int sizeInKb) throws IOException
+ {
+ // create test file
+ byte[] data = new byte[1024]; // 1Kb
+
+ File testFile = File.createTempFile(prefix, ".tmp");
+ FileOutputStream tempOut = new FileOutputStream(testFile);
+ Random random = new Random();
+
+ for (int i = 0; i < sizeInKb; i++)
+ {
+ random.nextBytes(data);
+ tempOut.write(data);
+ }
+ tempOut.close();
+ testFile.deleteOnExit(); // delete on test exit
+ return testFile;
+ }
+}
Property changes on: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/BaseClusteringFunctionalTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavAddBLOBTest.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavAddBLOBTest.java (rev 0)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavAddBLOBTest.java 2009-12-25 10:44:26 UTC (rev 1178)
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2003-2009 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.cluster.functional;
+
+import org.exoplatform.common.http.client.HTTPResponse;
+import org.exoplatform.common.http.client.HttpOutputStream;
+import org.exoplatform.services.jcr.cluster.BaseClusteringFunctionalTest;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Random;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>Date:
+ *
+ * @author <a href="karpenko.sergiy(a)gmail.com">Karpenko Sergiy</a>
+ * @version $Id$
+ */
+public class WebdavAddBLOBTest extends BaseClusteringFunctionalTest
+{
+
+ /**
+ * Since blob stored in memory we can not use really big data.
+ */
+ private int sizeInMb = 5;
+
+ public void testAddBLOB() throws Exception
+ {
+ // make a test blob
+ byte[] data = new byte[sizeInMb * 1024 * 1024];
+ Random random = new Random();
+ random.nextBytes(data);
+
+ // add node with blob data
+ HttpOutputStream stream = new HttpOutputStream();
+ HTTPResponse response = connection1.addNode(nodeName, stream);
+ loadStream(stream, new ByteArrayInputStream(data));
+ stream.close();
+ response.getStatusCode();
+
+ // check results
+ // cluster-node1
+ response = connection1.getNode(nodeName);
+ assertEquals(200, response.getStatusCode());
+ byte[] respData = response.getData();
+ assertEquals(data.length, respData.length);
+ assertTrue(java.util.Arrays.equals(data, respData));
+
+ // cluster-node2
+ response = connection2.getNode(nodeName);
+ assertEquals(200, response.getStatusCode());
+ respData = response.getData();
+ assertEquals(data.length, respData.length);
+ assertTrue(java.util.Arrays.equals(data, respData));
+
+ // cluster-node3
+ response = connection3.getNode(nodeName);
+ assertEquals(200, response.getStatusCode());
+ respData = response.getData();
+ assertEquals(data.length, respData.length);
+ assertTrue(java.util.Arrays.equals(data, respData));
+
+ // cluster-node4
+ response = connection4.getNode(nodeName);
+ assertEquals(200, response.getStatusCode());
+ respData = response.getData();
+ assertEquals(data.length, respData.length);
+ assertTrue(java.util.Arrays.equals(data, respData));
+
+ }
+
+ protected void loadStream(HttpOutputStream stream, InputStream in) throws IOException
+ {
+ byte[] buf = new byte[1024]; // 1Kb
+
+ int readed = 0;
+ while ((readed = in.read(buf)) != -1)
+ {
+ stream.write(buf, 0, readed);
+ }
+ }
+}
Property changes on: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavAddBLOBTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavAddNodeTest.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavAddNodeTest.java (rev 0)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavAddNodeTest.java 2009-12-25 10:44:26 UTC (rev 1178)
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2003-2009 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.cluster.functional;
+
+import org.exoplatform.common.http.client.HTTPResponse;
+import org.exoplatform.services.jcr.cluster.BaseClusteringFunctionalTest;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>Date: 2009
+ *
+ * @author <a href="mailto:alex.reshetnyak@exoplatform.com.ua">Alex Reshetnyak</a>
+ * @version $Id$
+ */
+public class WebdavAddNodeTest extends BaseClusteringFunctionalTest
+{
+
+ public void testAddNode() throws Exception
+ {
+ // add node
+ connection1.addNode(nodeName, "_data_".getBytes());
+
+ // check is node exist
+ // cluster-node1
+ HTTPResponse response = connection1.getNode(nodeName);
+ assertEquals(200, response.getStatusCode());
+ assertTrue("_data_".equals(new String(response.getData())));
+
+ // cluster-node2
+ HTTPResponse response2 = connection2.getNode(nodeName);
+ assertEquals(200, response2.getStatusCode());
+ assertTrue("_data_".equals(new String(response2.getData())));
+
+ // cluster-node3
+ HTTPResponse response3 = connection3.getNode(nodeName);
+ assertEquals(200, response3.getStatusCode());
+ assertTrue("_data_".equals(new String(response3.getData())));
+
+ // cluster-node4
+ HTTPResponse response4 = connection4.getNode(nodeName);
+ assertEquals(200, response4.getStatusCode());
+ assertTrue("_data_".equals(new String(response4.getData())));
+
+ }
+
+}
Property changes on: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavAddNodeTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavMoveNodeTest.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavMoveNodeTest.java (rev 0)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavMoveNodeTest.java 2009-12-25 10:44:26 UTC (rev 1178)
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2003-2009 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.cluster.functional;
+
+import org.exoplatform.common.http.client.HTTPResponse;
+import org.exoplatform.services.jcr.cluster.BaseClusteringFunctionalTest;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>Date:
+ *
+ * @author <a href="karpenko.sergiy(a)gmail.com">Karpenko Sergiy</a>
+ * @version $Id$
+ */
+public class WebdavMoveNodeTest extends BaseClusteringFunctionalTest
+{
+ public void testMoveNode() throws Exception
+ {
+ String newNodeName = nodeName + "new";
+
+ // add node
+ connection1.addNode(nodeName, "".getBytes());
+ // check is node exist
+ // cluster-node1
+ HTTPResponse response = connection1.getNode(nodeName);
+ assertEquals(200, response.getStatusCode());
+
+ // cluster-node2
+ HTTPResponse response2 = connection2.getNode(nodeName);
+ assertEquals(200, response2.getStatusCode());
+
+ // cluster-node3
+ HTTPResponse response3 = connection3.getNode(nodeName);
+ assertEquals(200, response3.getStatusCode());
+
+ // cluster-node4
+ HTTPResponse response4 = connection4.getNode(nodeName);
+ assertEquals(200, response4.getStatusCode());
+
+ // move node on cluster-node3
+
+ response = connection3.Move(nodeName, newNodeName);
+ response.getStatusCode();
+
+ // check is node not exist
+ // cluster-node1
+ response = connection1.getNode(nodeName);
+ assertEquals(404, response.getStatusCode());
+
+ // cluster-node2
+ response2 = connection2.getNode(nodeName);
+ assertEquals(404, response2.getStatusCode());
+
+ // cluster-node3
+ response3 = connection3.getNode(nodeName);
+ assertEquals(404, response3.getStatusCode());
+
+ // cluster-node4
+ response4 = connection4.getNode(nodeName);
+ assertEquals(404, response4.getStatusCode());
+
+ // check is node exist
+ // cluster-node1
+ response = connection1.getNode(newNodeName);
+ assertEquals(200, response.getStatusCode());
+
+ // cluster-node2
+ response2 = connection2.getNode(newNodeName);
+ assertEquals(200, response2.getStatusCode());
+
+ // cluster-node3
+ response3 = connection3.getNode(newNodeName);
+ assertEquals(200, response3.getStatusCode());
+
+ // cluster-node4
+ response4 = connection4.getNode(newNodeName);
+ assertEquals(200, response4.getStatusCode());
+ }
+}
Property changes on: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavMoveNodeTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavRemoveNodeTest.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavRemoveNodeTest.java (rev 0)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavRemoveNodeTest.java 2009-12-25 10:44:26 UTC (rev 1178)
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2003-2009 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.cluster.functional;
+
+import org.exoplatform.common.http.client.HTTPResponse;
+import org.exoplatform.services.jcr.cluster.BaseClusteringFunctionalTest;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>Date: 2009
+ *
+ * @author <a href="mailto:alex.reshetnyak@exoplatform.com.ua">Alex Reshetnyak</a>
+ * @version $Id$
+ */
+public class WebdavRemoveNodeTest extends BaseClusteringFunctionalTest
+{
+ public void testRemoveNode() throws Exception
+ {
+ // add test node
+ connection1.addNode(nodeName, "".getBytes());
+
+ // check is exist cluster-node1
+ HTTPResponse response = connection1.getNode(nodeName);
+ assertEquals(200, response.getStatusCode());
+ //cluster-node2
+ response = connection2.getNode(nodeName);
+ assertEquals(200, response.getStatusCode());
+ //cluster-node3
+ response = connection3.getNode(nodeName);
+ assertEquals(200, response.getStatusCode());
+ //cluster-node4
+ response = connection4.getNode(nodeName);
+ assertEquals(200, response.getStatusCode());
+
+ // remove node on cluster-node2
+ connection2.removeNode(nodeName);
+
+ // check cluster-node1
+ response = connection1.getNode(nodeName);
+ assertEquals(404, response.getStatusCode());
+
+ // cluster-node2
+ response = connection2.getNode(nodeName);
+ assertEquals(404, response.getStatusCode());
+
+ // cluster-node3
+ response = connection3.getNode(nodeName);
+ assertEquals(404, response.getStatusCode());
+
+ // cluster-node4
+ response = connection4.getNode(nodeName);
+ assertEquals(404, response.getStatusCode());
+
+ }
+
+}
Property changes on: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavRemoveNodeTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified: jcr/branches/1.12.0-JBCCACHE/pom.xml
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/pom.xml 2009-12-25 09:13:17 UTC (rev 1177)
+++ jcr/branches/1.12.0-JBCCACHE/pom.xml 2009-12-25 10:44:26 UTC (rev 1178)
@@ -67,6 +67,7 @@
<module>applications/java/exo.jcr.applications.rest</module>
<module>applications/java/exo.jcr.ear</module>
<module>applications/java/exo.jcr.applications.backupconsole</module>
+ <module>applications/cluster.test.client</module>
<module>packaging/module</module>
</modules>
@@ -178,6 +179,11 @@
<artifactId>exo.jcr.framework.ftpclient</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.exoplatform.jcr</groupId>
+ <artifactId>exo.jcr.component.cluster.test.client</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>exo.jcr.applications.fckeditor</artifactId>
16 years, 4 months
exo-jcr SVN: r1177 - jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache.
by do-not-reply@jboss.org
Author: pnedonosko
Date: 2009-12-25 04:13:17 -0500 (Fri, 25 Dec 2009)
New Revision: 1177
Modified:
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java
Log:
EOXJCR-333 cleanup and members original sort
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java 2009-12-25 09:12:27 UTC (rev 1176)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java 2009-12-25 09:13:17 UTC (rev 1177)
@@ -134,8 +134,134 @@
protected final Fqn<String> refsRoot;
- protected boolean txStarted = false;
+ /**
+ * Node order comparator for getChildNodes().
+ */
+ class NodesOrderComparator<N extends NodeData> implements Comparator<NodeData>
+ {
+ /**
+ * {@inheritDoc}
+ */
+ public int compare(NodeData n1, NodeData n2)
+ {
+ return n1.getOrderNumber() - n2.getOrderNumber();
+ }
+ }
+
+ class ChildItemsIterator<T extends ItemData> implements Iterator<T>
+ {
+
+ final Iterator<Object> childs;
+
+ final String parentId;
+
+ final Fqn<String> root;
+
+ T next;
+
+ ChildItemsIterator(Fqn<String> root, String parentId)
+ {
+ this.parentId = parentId;
+ this.root = root;
+
+ Fqn<String> parentFqn = makeChildListFqn(root, parentId);
+ // TODO replace getNode with get attr -> use ITEMS with CHILDS etc
+ Node<Serializable, Object> parent = cache.getNode(parentFqn);
+ if (parent != null)
+ {
+ this.childs = cache.getChildrenNames(parentFqn).iterator();
+ fetchNext();
+ }
+ else
+ {
+ this.childs = null;
+ this.next = null;
+ }
+ }
+
+ protected void fetchNext()
+ {
+ if (childs.hasNext())
+ {
+ // traverse to the first existing or the end of childs
+ T n = null;
+ do
+ {
+ String itemId = (String)cache.get(makeChildListFqn(root, parentId, (String)childs.next()), ITEM_ID);
+ if (itemId != null)
+ {
+ n = (T)cache.get(makeItemFqn(itemId), ITEM_DATA);
+ }
+ }
+ while (n == null && childs.hasNext());
+ next = n;
+ }
+ else
+ {
+ next = null;
+ }
+ }
+
+ public boolean hasNext()
+ {
+ return next != null;
+ }
+
+ public T next()
+ {
+ if (next == null)
+ {
+ throw new NoSuchElementException();
+ }
+
+ final T current = next;
+ fetchNext();
+ return current;
+ }
+
+ public void remove()
+ {
+ throw new IllegalArgumentException("Not implemented");
+ }
+ }
+
+ class ChildNodesIterator<N extends NodeData> extends ChildItemsIterator<N>
+ {
+
+ ChildNodesIterator(String parentId)
+ {
+ super(childNodes, parentId);
+ }
+
+ @Override
+ public N next()
+ {
+ return super.next();
+ }
+ }
+
+ class ChildPropertiesIterator<P extends PropertyData> extends ChildItemsIterator<P>
+ {
+
+ ChildPropertiesIterator(String parentId)
+ {
+ super(childProps, parentId);
+ }
+
+ @Override
+ public P next()
+ {
+ return super.next();
+ }
+ }
+
+ public JBossCacheWorkspaceStorageCache(WorkspaceEntry wsConfig) throws RepositoryException,
+ RepositoryConfigurationException
+ {
+ this(readJBCConfig(wsConfig));
+ }
+
/**
* JBossCacheWorkspaceStorageCache constructor.
*
@@ -148,19 +274,19 @@
this.cache.create();
this.cache.start();
- //this.cache.addInterceptor(indexInterceptor, CacheStoreInterceptor.class);
+ // TODO this.cache.addInterceptor(indexInterceptor, CacheStoreInterceptor.class);
Node<Serializable, Object> cacheRoot = cache.getRoot();
- // TODO transaction
-
// prepare cache structures
+ // TODO transaction
TransactionManager tm = getTransactionManager();
try
{
tm.begin();
+
this.itemsRoot = Fqn.fromElements(ITEMS);
cacheRoot.addChild(this.itemsRoot).setResident(true);
@@ -201,21 +327,104 @@
throw new RepositoryException(e.getLocalizedMessage(), e.getCause());
}
}
+ }
+ protected static String readJBCConfig(final WorkspaceEntry wsConfig) throws RepositoryConfigurationException
+ {
+ if (wsConfig.getCache() != null)
+ {
+ return wsConfig.getCache().getParameterValue(JBOSSCACHE_CONFIG);
+ }
+ else
+ {
+ throw new RepositoryConfigurationException("Cache configuration not found");
+ }
}
- public JBossCacheWorkspaceStorageCache(WorkspaceEntry wsConfig) throws RepositoryException,
- RepositoryConfigurationException
+ /**
+ * Return TransactionManager.
+ * @return TransactionManager.
+ */
+ public TransactionManager getTransactionManager()
{
- this(readJBCConfig(wsConfig));
+ return ((CacheSPI<Serializable, Object>)cache).getTransactionManager();
}
/**
* {@inheritDoc}
*/
- public void addChildNodes(NodeData parent, List<NodeData> childs)
+ public void put(ItemData item)
{
+ putItem(item);
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public void remove(ItemData item)
+ {
+ removeItem(item);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void onSaveItems(final ItemStateChangesLog itemStates)
+ {
+ for (ItemState state : itemStates.getAllStates())
+ {
+ if (state.isAdded())
+ {
+ if (state.isPersisted())
+ {
+ putItem(state.getData());
+ }
+ }
+ else if (state.isUpdated())
+ {
+ if (state.isPersisted())
+ {
+ ItemData prevItem = putItem(state.getData());
+ if (prevItem != null && state.isNode())
+ {
+ // nodes reordered, if prev is null it's InvalidItemState case
+ update((NodeData)state.getData(), (NodeData)prevItem);
+ }
+ }
+ }
+ else if (state.isDeleted())
+ {
+ removeItem(state.getData());
+ }
+ else if (state.isRenamed())
+ {
+ // TODO cleanup: update subtree paths
+ // if (prevState.isDeleted() && prevState.isNode())
+ // {
+ // renameNode((NodeData)prevState.getData(), (NodeData)state.getData());
+ // }
+ putItem(state.getData());
+ }
+ else if (state.isMixinChanged())
+ {
+ if (state.isPersisted())
+ {
+ // update subtree ACLs
+ updateMixin((NodeData)state.getData());
+ }
+ }
+ else
+ {
+ // TODO warn it?
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addChildNodes(NodeData parent, List<NodeData> childs)
+ {
// remove previous all (to be sure about consistency)
cache.removeNode(makeChildListFqn(childNodesList, parent.getIdentifier()));
@@ -232,7 +441,6 @@
// cache fact of empty childs list
cache.put(makeChildListFqn(childNodesList, parent.getIdentifier()), NULL_DATA);
}
-
}
/**
@@ -240,7 +448,6 @@
*/
public void addChildProperties(NodeData parent, List<PropertyData> childs)
{
-
// remove previous all (to be sure about consistency)
cache.removeNode(makeChildListFqn(childPropsList, parent.getIdentifier()));
@@ -256,7 +463,6 @@
{
LOG.warn("Empty properties list cached " + (parent != null ? parent.getQPath().getAsString() : parent));
}
-
}
/**
@@ -281,14 +487,6 @@
/**
* {@inheritDoc}
*/
- public ItemData get(String id)
- {
- return (ItemData)cache.get(makeItemFqn(id), ITEM_DATA);
- }
-
- /**
- * {@inheritDoc}
- */
public ItemData get(String parentId, QPathEntry name)
{
@@ -311,6 +509,14 @@
/**
* {@inheritDoc}
*/
+ public ItemData get(String id)
+ {
+ return (ItemData)cache.get(makeItemFqn(id), ITEM_DATA);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public List<NodeData> getChildNodes(final NodeData parent)
{
final List<NodeData> childs = new ArrayList<NodeData>();
@@ -351,120 +557,12 @@
/**
* {@inheritDoc}
*/
- public long getSize()
- {
- // TODO
- return -1;
- }
-
- /**
- * Return TransactionManager.
- * @return TransactionManager.
- */
- public TransactionManager getTransactionManager()
- {
- return ((CacheSPI<Serializable, Object>)cache).getTransactionManager();
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isEnabled()
- {
- // TODO
- return true;
- }
-
- /**
- * {@inheritDoc}
- */
public List<PropertyData> listChildProperties(NodeData parent)
{
return getChildProps(parent.getIdentifier(), false);
}
/**
- * {@inheritDoc}
- */
- public void onSaveItems(final ItemStateChangesLog itemStates)
- {
-
- ItemState prevState = null;
-
- for (ItemState state : itemStates.getAllStates())
- {
-
- if (state.isAdded())
- {
- if (state.isPersisted())
- {
- putItem(state.getData());
- }
- }
- else if (state.isUpdated())
- {
- if (state.isPersisted())
- {
- ItemData prevItem = putItem(state.getData());
- if (prevItem != null && state.isNode())
- {
- // nodes reordered, if prev is null it's InvalidItemState case
- update((NodeData)state.getData(), (NodeData)prevItem);
- }
- }
- }
- else if (state.isDeleted())
- {
- removeItem(state.getData());
- }
- else if (state.isRenamed())
- {
- // TODO cleanup: update subtree paths
- // if (prevState.isDeleted() && prevState.isNode())
- // {
- // renameNode((NodeData)prevState.getData(), (NodeData)state.getData());
- // }
- putItem(state.getData());
- }
- else if (state.isMixinChanged())
- {
- if (state.isPersisted())
- {
- // update subtree ACLs
- updateMixin((NodeData)state.getData());
- }
- }
- else
- {
- // TODO warn it?
- }
-
- prevState = state;
- }
-
- }
-
- /**
- * {@inheritDoc}
- */
- public void put(ItemData item)
- {
-
- putItem(item);
-
- }
-
- /**
- * {@inheritDoc}
- */
- public void remove(ItemData item)
- {
-
- removeItem(item);
-
- }
-
- /**
* Internal get child properties.
*
* @param parentId String
@@ -503,28 +601,47 @@
}
/**
- * Make child Item absolute Fqn, i.e. /root/parentId/childName.
+ * {@inheritDoc}
+ */
+ public long getSize()
+ {
+ // TODO
+ return -1;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isEnabled()
+ {
+ // TODO
+ return true;
+ }
+
+ // ****************
+
+ /**
+ * Make Item absolute Fqn, i.e. /$ITEMS/itemID.
*
- * @param root Fqn
- * @param parentId String
- * @param childName QPathEntry
+ * @param itemId String
* @return Fqn
*/
- protected Fqn<String> makeChildFqn(Fqn<String> root, String parentId, QPathEntry childName)
+ protected Fqn<String> makeItemFqn(String itemId)
{
- return Fqn.fromRelativeElements(root, parentId, childName.getAsString(true));
+ return Fqn.fromRelativeElements(itemsRoot, itemId);
}
/**
- * Make child node parent absolute Fqn, i.e. /root/itemId.
+ * Make child Item absolute Fqn, i.e. /root/parentId/childName.
*
* @param root Fqn
* @param parentId String
+ * @param childName QPathEntry
* @return Fqn
*/
- protected Fqn<String> makeChildListFqn(Fqn<String> root, String parentId)
+ protected Fqn<String> makeChildFqn(Fqn<String> root, String parentId, QPathEntry childName)
{
- return Fqn.fromRelativeElements(root, parentId);
+ return Fqn.fromRelativeElements(root, parentId, childName.getAsString(true));
}
/**
@@ -541,18 +658,17 @@
}
/**
- * Make Item absolute Fqn, i.e. /$ITEMS/itemID.
+ * Make child node parent absolute Fqn, i.e. /root/itemId.
*
- * @param itemId String
+ * @param root Fqn
+ * @param parentId String
* @return Fqn
*/
- protected Fqn<String> makeItemFqn(String itemId)
+ protected Fqn<String> makeChildListFqn(Fqn<String> root, String parentId)
{
- return Fqn.fromRelativeElements(itemsRoot, itemId);
+ return Fqn.fromRelativeElements(root, parentId);
}
- // ****************
-
/**
* Internal put Item.
*
@@ -696,6 +812,28 @@
}
/**
+ * Update Node's mixin and ACL.
+ *
+ * @param node NodeData
+ */
+ protected void updateMixin(NodeData node)
+ {
+ NodeData prevData = (NodeData)cache.put(makeItemFqn(node.getIdentifier()), ITEM_DATA, node);
+ if (prevData != null)
+ {
+ // do update ACL if needed
+ if (!prevData.getACL().equals(node.getACL()))
+ {
+ updateChildsACL(node.getIdentifier(), node.getACL());
+ }
+ }
+ else if (LOG.isDebugEnabled())
+ {
+ LOG.debug("Previous NodeData not found for mixin update " + node.getQPath().getAsString());
+ }
+ }
+
+ /**
* Update Node hierachy in case of same-name siblings reorder.
* Assumes the new (updated) nodes already putted in the cache. Previous name of updated nodes will be calculated
* and that node will be deleted (if has same id as the new node). Childs paths will be updated to a new node path.
@@ -728,63 +866,6 @@
}
/**
- * Update child Nodes ACLs.
- *
- * @param parentId String - root node id of JCR subtree.
- * @param acl AccessControlList
- */
- protected void updateChildsACL(final String parentId, final AccessControlList acl)
- {
- 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;
- }
- }
-
- // 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(makeItemFqn(newNode.getIdentifier()), ITEM_DATA, newNode);
-
- // update childs recursive
- updateChildsACL(newNode.getIdentifier(), acl);
- }
- }
-
- /**
- * Update Node's mixin and ACL.
- *
- * @param node NodeData
- */
- protected void updateMixin(NodeData node)
- {
- NodeData prevData = (NodeData)cache.put(makeItemFqn(node.getIdentifier()), ITEM_DATA, node);
- if (prevData != null)
- {
- // do update ACL if needed
- if (!prevData.getACL().equals(node.getACL()))
- {
- updateChildsACL(node.getIdentifier(), node.getACL());
- }
- }
- else if (LOG.isDebugEnabled())
- {
- LOG.debug("Previous NodeData not found for mixin update " + node.getQPath().getAsString());
- }
- }
-
- /**
* Update Nodes tree with new path.
*
* @param parentId String - root node id of JCR subtree.
@@ -843,138 +924,39 @@
}
}
- class ChildItemsIterator<T extends ItemData> implements Iterator<T>
+ /**
+ * Update child Nodes ACLs.
+ *
+ * @param parentId String - root node id of JCR subtree.
+ * @param acl AccessControlList
+ */
+ protected void updateChildsACL(final String parentId, final AccessControlList acl)
{
-
- final Iterator<Object> childs;
-
- final String parentId;
-
- final Fqn<String> root;
-
- T next;
-
- ChildItemsIterator(Fqn<String> root, String parentId)
+ for (Iterator<NodeData> iter = new ChildNodesIterator<NodeData>(parentId); iter.hasNext();)
{
- this.parentId = parentId;
- this.root = root;
+ NodeData prevNode = iter.next();
- Fqn<String> parentFqn = makeChildListFqn(root, parentId);
- // TODO replace getNode with get attr -> use ITEMS with CHILDS etc
- Node<Serializable, Object> parent = cache.getNode(parentFqn);
- if (parent != null)
+ // is ACL changes on this node (i.e. ACL inheritance brokes)
+ for (InternalQName mixin : prevNode.getMixinTypeNames())
{
- this.childs = cache.getChildrenNames(parentFqn).iterator();
- fetchNext();
- }
- else
- {
- this.childs = null;
- this.next = null;
- }
- }
-
- public boolean hasNext()
- {
- return next != null;
- }
-
- public T next()
- {
- if (next == null)
- {
- throw new NoSuchElementException();
- }
-
- final T current = next;
- fetchNext();
- return current;
- }
-
- public void remove()
- {
- throw new IllegalArgumentException("Not implemented");
- }
-
- protected void fetchNext()
- {
- if (childs.hasNext())
- {
- // traverse to the first existing or the end of childs
- T n = null;
- do
+ if (mixin.equals(Constants.EXO_PRIVILEGEABLE) || mixin.equals(Constants.EXO_OWNEABLE))
{
- String itemId = (String)cache.get(makeChildListFqn(root, parentId, (String)childs.next()), ITEM_ID);
- if (itemId != null)
- {
- n = (T)cache.get(makeItemFqn(itemId), ITEM_DATA);
- }
+ continue;
}
- while (n == null && childs.hasNext());
- next = n;
}
- else
- {
- next = null;
- }
- }
- }
- class ChildNodesIterator<N extends NodeData> extends ChildItemsIterator<N>
- {
+ // 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);
- ChildNodesIterator(String parentId)
- {
- super(childNodes, parentId);
- }
+ // update this node
+ cache.put(makeItemFqn(newNode.getIdentifier()), ITEM_DATA, newNode);
- @Override
- public N next()
- {
- return super.next();
+ // update childs recursive
+ updateChildsACL(newNode.getIdentifier(), acl);
}
}
- class ChildPropertiesIterator<P extends PropertyData> extends ChildItemsIterator<P>
- {
-
- ChildPropertiesIterator(String parentId)
- {
- super(childProps, parentId);
- }
-
- @Override
- public P next()
- {
- return super.next();
- }
- }
-
- /**
- * Node order comparator for getChildNodes().
- */
- class NodesOrderComparator<N extends NodeData> implements Comparator<NodeData>
- {
-
- /**
- * {@inheritDoc}
- */
- public int compare(NodeData n1, NodeData n2)
- {
- return n1.getOrderNumber() - n2.getOrderNumber();
- }
- }
-
- protected static String readJBCConfig(final WorkspaceEntry wsConfig) throws RepositoryConfigurationException
- {
- if (wsConfig.getCache() != null)
- {
- return wsConfig.getCache().getParameterValue(JBOSSCACHE_CONFIG);
- }
- else
- {
- throw new RepositoryConfigurationException("Cache configuration not found");
- }
- }
-
}
16 years, 4 months
exo-jcr SVN: r1176 - jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core.
by do-not-reply@jboss.org
Author: pnedonosko
Date: 2009-12-25 04:12:27 -0500 (Fri, 25 Dec 2009)
New Revision: 1176
Modified:
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SysViewWorkspaceInitializer.java
Log:
EOXJCR-325 SysView initializer fix for null mixins
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SysViewWorkspaceInitializer.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SysViewWorkspaceInitializer.java 2009-12-25 09:09:39 UTC (rev 1175)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SysViewWorkspaceInitializer.java 2009-12-25 09:12:27 UTC (rev 1176)
@@ -56,8 +56,6 @@
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
import java.util.Stack;
import javax.jcr.NamespaceException;
@@ -77,7 +75,7 @@
* Should be configured with restore-path parameter. The path to a backup result file.
*
* @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter Nedonosko</a>
- * @version $Id: SysViewWorkspaceInitializer.java 34801 2009-07-31 15:44:50Z dkatayev $
+ * @version $Id$
*/
public class SysViewWorkspaceInitializer implements WorkspaceInitializer
@@ -300,8 +298,7 @@
}
}
- protected class SVNodeData
- extends TransientNodeData
+ protected class SVNodeData extends TransientNodeData
{
int orderNumber = 0;
@@ -334,7 +331,7 @@
childNodesMap.put(childName, 1);
int index = childNodesMap.get(childName);
- return new int[] {orderNumber++, index};
+ return new int[]{orderNumber++, index};
}
}
@@ -685,8 +682,12 @@
{
// change current context
// - pop parent from the stack
- parents.pop();
-
+ SVNodeData parent = parents.pop();
+ if (parent.getMixinTypeNames() == null)
+ {
+ // mixins cannot be null
+ parent.setMixinTypeNames(new InternalQName[0]);
+ }
}
else if (Constants.SV_PROPERTY.equals(lname))
{
Property changes on: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SysViewWorkspaceInitializer.java
___________________________________________________________________
Name: svn:keywords
+ Id
16 years, 4 months
exo-jcr SVN: r1175 - jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2009-12-25 04:09:39 -0500 (Fri, 25 Dec 2009)
New Revision: 1175
Modified:
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/IndexerCacheLoader.java
Log:
EXOJCR-334: IndexerCacheLoader updated to handle transactions.
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/IndexerCacheLoader.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/IndexerCacheLoader.java 2009-12-24 16:29:21 UTC (rev 1174)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/IndexerCacheLoader.java 2009-12-25 09:09:39 UTC (rev 1175)
@@ -23,6 +23,7 @@
import org.exoplatform.services.jcr.impl.storage.jbosscache.AbstractWriteOnlyCacheLoader;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
+import org.jboss.cache.CacheException;
import org.jboss.cache.Fqn;
import org.jboss.cache.Modification;
@@ -73,16 +74,24 @@
@Override
public Object put(Fqn arg0, Object key, Object val) throws Exception
{
- if (key.equals(JbossCacheIndexChangesFilter.LISTWRAPPER) && val instanceof ChangesFilterListsWrapper)
+ try
{
- if (log.isDebugEnabled())
+ if (key.equals(JbossCacheIndexChangesFilter.LISTWRAPPER) && val instanceof ChangesFilterListsWrapper)
{
- log.info("Received list wrapper, start indexing...");
+ if (log.isDebugEnabled())
+ {
+ log.info("Received list wrapper, start indexing...");
+ }
+ ChangesFilterListsWrapper wrapper = (ChangesFilterListsWrapper)val;
+ //System.out.println("UPDATE INDEX: "+wrapper.getAddedNodes() + wrapper.getRemovedNodes());
+ updateIndex(wrapper.getAddedNodes(), wrapper.getRemovedNodes(), wrapper.getParentAddedNodes(), wrapper
+ .getParentRemovedNodes());
}
- ChangesFilterListsWrapper wrapper = (ChangesFilterListsWrapper)val;
- updateIndex(wrapper.getAddedNodes(), wrapper.getRemovedNodes(), wrapper.getParentAddedNodes(), wrapper
- .getParentRemovedNodes());
}
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
return null;
}
@@ -177,6 +186,38 @@
@Override
public void put(List<Modification> modifications) throws Exception
{
- // batching is not used
+ // If transactions are used, then list of modifications will be sent to cache loader
+ // added code to handle list of modifications.
+ for (Modification m : modifications)
+ {
+ switch (m.getType())
+ {
+ case PUT_DATA :
+ put(m.getFqn(), m.getData());
+ break;
+ case PUT_DATA_ERASE :
+ removeData(m.getFqn());
+ put(m.getFqn(), m.getData());
+ break;
+ case PUT_KEY_VALUE :
+ put(m.getFqn(), m.getKey(), m.getValue());
+ break;
+ case REMOVE_DATA :
+ removeData(m.getFqn());
+ break;
+ case REMOVE_KEY_VALUE :
+ remove(m.getFqn(), m.getKey());
+ break;
+ case REMOVE_NODE :
+ remove(m.getFqn());
+ break;
+ case MOVE :
+ // involve moving all children too
+ move(m.getFqn(), m.getFqn2());
+ break;
+ default :
+ throw new CacheException("Unknown modification " + m.getType());
+ }
+ }
}
}
16 years, 4 months
exo-jcr SVN: r1174 - jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation.
by do-not-reply@jboss.org
Author: sergiykarpenko
Date: 2009-12-24 11:29:21 -0500 (Thu, 24 Dec 2009)
New Revision: 1174
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/NewJDBCStorageConnection.java
Log:
EXOJCR-302: getNodeByName updated
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/NewJDBCStorageConnection.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/NewJDBCStorageConnection.java 2009-12-24 16:11:56 UTC (rev 1173)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/NewJDBCStorageConnection.java 2009-12-24 16:29:21 UTC (rev 1174)
@@ -599,7 +599,17 @@
ResultSet resultSet = findChildNodesByParentIdentifierNew(getInternalId(parent.getIdentifier()));
if (resultSet.next())
{
- return loadChildNodesData(resultSet, parent);
+ Map<String, TempNodeData> tempNodes = loadNodesData(resultSet, parent);
+
+ List<NodeData> childrens = new ArrayList<NodeData>(tempNodes.size());
+ QPath parentQPath = parent.getQPath();
+ AccessControlList parentACL = parent.getACL();
+ for (TempNodeData data : tempNodes.values())
+ {
+ NodeData nodeData = loadNodeRecordFromBuffer(data, parentQPath, parentACL);
+ childrens.add(nodeData);
+ }
+ return childrens;
}
else
{
@@ -617,7 +627,7 @@
}
}
- protected List<NodeData> loadChildNodesData(ResultSet resultSet, NodeData parent) throws RepositoryException,
+ protected Map<String, TempNodeData> loadNodesData(ResultSet resultSet, NodeData parent) throws RepositoryException,
IOException, SQLException
{
@@ -651,15 +661,8 @@
}
while (resultSet.next());
- List<NodeData> childrens = new ArrayList<NodeData>(nodesData.size());
- QPath parentQPath = parent.getQPath();
- AccessControlList parentACL = parent.getACL();
- for (TempNodeData data : nodesData.values())
- {
- NodeData nodeData = loadNodeRecordFromBuffer(data, parentQPath, parentACL);
- childrens.add(nodeData);
- }
- return childrens;
+ return nodesData;
+
}
private static class TempNodeData
@@ -914,7 +917,19 @@
int itemType = resultSet.getInt(COLUMN_CLASS);
if (itemType == I_CLASS_NODE)
{
- return loadNodeRecord(resultSet, parent.getQPath(), parent.getACL());
+ // Remember first node id. If node is not first in result set - it's a bug.
+ String firstNodeId = resultSet.getString(COLUMN_ID);
+
+ // There may be two or more nodes, so load temp NodeDatas and return first one.
+ Map<String, TempNodeData> tempNodes = loadNodesData(resultSet, parent);
+
+ QPath parentQPath = parent.getQPath();
+ AccessControlList parentACL = parent.getACL();
+
+ NodeData nodeData = loadNodeRecordFromBuffer(tempNodes.get(firstNodeId), parentQPath, parentACL);
+ return nodeData;
+
+ //return loadNodeRecord(resultSet, parent.getQPath(), parent.getACL());
}
else
{
16 years, 4 months