exo-jcr SVN: r1445 - kernel/trunk/exo.kernel.component.common/src/test/resources/conf/standalone.
by do-not-reply@jboss.org
Author: pnedonosko
Date: 2010-01-17 04:12:54 -0500 (Sun, 17 Jan 2010)
New Revision: 1445
Modified:
kernel/trunk/exo.kernel.component.common/src/test/resources/conf/standalone/test-configuration.xml
Log:
EXOJCR-410 track-without-transaction=true in tests commented
Modified: kernel/trunk/exo.kernel.component.common/src/test/resources/conf/standalone/test-configuration.xml
===================================================================
--- kernel/trunk/exo.kernel.component.common/src/test/resources/conf/standalone/test-configuration.xml 2010-01-17 09:11:16 UTC (rev 1444)
+++ kernel/trunk/exo.kernel.component.common/src/test/resources/conf/standalone/test-configuration.xml 2010-01-17 09:12:54 UTC (rev 1445)
@@ -163,10 +163,10 @@
<name>timeout</name>
<value>5</value>
</value-param>
- <value-param>
+ <!-- value-param>
<name>track-without-transaction</name>
<value>true</value>
- </value-param>
+ </value-param -->
</init-params>
</component>
16 years, 3 months
exo-jcr SVN: r1444 - kernel/trunk/exo.kernel.component.common/src/test/resources/conf/standalone.
by do-not-reply@jboss.org
Author: pnedonosko
Date: 2010-01-17 04:11:16 -0500 (Sun, 17 Jan 2010)
New Revision: 1444
Modified:
kernel/trunk/exo.kernel.component.common/src/test/resources/conf/standalone/test-configuration.xml
Log:
EXOJCR-410 track-without-transaction=true in TS tests (actual for JOTM TS impl only)
Modified: kernel/trunk/exo.kernel.component.common/src/test/resources/conf/standalone/test-configuration.xml
===================================================================
--- kernel/trunk/exo.kernel.component.common/src/test/resources/conf/standalone/test-configuration.xml 2010-01-17 09:01:11 UTC (rev 1443)
+++ kernel/trunk/exo.kernel.component.common/src/test/resources/conf/standalone/test-configuration.xml 2010-01-17 09:11:16 UTC (rev 1444)
@@ -163,6 +163,10 @@
<name>timeout</name>
<value>5</value>
</value-param>
+ <value-param>
+ <name>track-without-transaction</name>
+ <value>true</value>
+ </value-param>
</init-params>
</component>
16 years, 3 months
exo-jcr SVN: r1443 - kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/transaction/impl/jotm.
by do-not-reply@jboss.org
Author: pnedonosko
Date: 2010-01-17 04:01:11 -0500 (Sun, 17 Jan 2010)
New Revision: 1443
Modified:
kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/transaction/impl/jotm/TransactionServiceJotmImpl.java
Log:
EXOJCR-410 track-without-transaction=false by default
Modified: kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/transaction/impl/jotm/TransactionServiceJotmImpl.java
===================================================================
--- kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/transaction/impl/jotm/TransactionServiceJotmImpl.java 2010-01-17 08:56:14 UTC (rev 1442)
+++ kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/transaction/impl/jotm/TransactionServiceJotmImpl.java 2010-01-17 09:01:11 UTC (rev 1443)
@@ -55,7 +55,7 @@
public static final String TRACK_WITHOT_TRANSACTION_PARAM = "track-without-transaction";
- private boolean trackWithoutTransaction = true;
+ private boolean trackWithoutTransaction = false;
private Current current;
16 years, 3 months
exo-jcr SVN: r1442 - jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2010-01-17 03:56:14 -0500 (Sun, 17 Jan 2010)
New Revision: 1442
Modified:
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jcr-config.xml
Log:
EXOJCR-406 : The config to CacheableLockManager was changed to cluster configuraation.
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jcr-config.xml
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jcr-config.xml 2010-01-17 08:40:06 UTC (rev 1441)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jcr-config.xml 2010-01-17 08:56:14 UTC (rev 1442)
@@ -78,12 +78,12 @@
<property name="changesfilter-config-path" value="conf/cluster/test-jbosscache-indexer-config-exoloader_db1_ws.xml" />
</properties>
</query-handler>
- <lock-manager class="org.exoplatform.services.jcr.impl.core.lock.jbosscache.CacheableLockManager">
+ <!-- lock-manager class="org.exoplatform.services.jcr.impl.core.lock.jbosscache.CacheableLockManager">
<properties>
<property name="time-out" value="15m" />
- <property name="jbosscache-configuration" value="conf/cluster/test-jbosscache-lockc-onfig_db1_ws.xml" />
+ <property name="jbosscache-configuration" value="conf/cluster/test-jbosscache-lock-config_db1_ws.xml" />
</properties>
- </lock-manager>
+ </lock-manager -->
</workspace>
<workspace name="ws1">
@@ -119,12 +119,12 @@
<property name="changesfilter-config-path" value="conf/cluster/test-jbosscache-indexer-config-exoloader_db1_ws1.xml" />
</properties>
</query-handler>
- <lock-manager class="org.exoplatform.services.jcr.impl.core.lock.jbosscache.CacheableLockManager">
+ <!-- lock-manager class="org.exoplatform.services.jcr.impl.core.lock.jbosscache.CacheableLockManager">
<properties>
<property name="time-out" value="15m" />
<property name="jbosscache-configuration" value="conf/cluster/test-jbosscache-lock-config_db1_ws1.xml" />
</properties>
- </lock-manager>
+ </lock-manager -->
</workspace>
</workspaces>
</repository>
16 years, 3 months
exo-jcr SVN: r1441 - jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2010-01-17 03:40:06 -0500 (Sun, 17 Jan 2010)
New Revision: 1441
Modified:
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jcr-config.xml
Log:
EXOJCR-406 : The config to CacheableLockManager was adde to cluster configuraation.
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jcr-config.xml
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jcr-config.xml 2010-01-17 08:19:24 UTC (rev 1440)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jcr-config.xml 2010-01-17 08:40:06 UTC (rev 1441)
@@ -81,7 +81,7 @@
<lock-manager class="org.exoplatform.services.jcr.impl.core.lock.jbosscache.CacheableLockManager">
<properties>
<property name="time-out" value="15m" />
- <property name="jbosscache-configuration" value="conf/cluster/test-jbosscache-lockconfig_db1_ws.xml" />
+ <property name="jbosscache-configuration" value="conf/cluster/test-jbosscache-lockc-onfig_db1_ws.xml" />
</properties>
</lock-manager>
</workspace>
@@ -122,7 +122,7 @@
<lock-manager class="org.exoplatform.services.jcr.impl.core.lock.jbosscache.CacheableLockManager">
<properties>
<property name="time-out" value="15m" />
- <property name="jbosscache-configuration" value="conf/cluster/test-jbosscache-lockconfig_db1_ws1.xml" />
+ <property name="jbosscache-configuration" value="conf/cluster/test-jbosscache-lock-config_db1_ws1.xml" />
</properties>
</lock-manager>
</workspace>
16 years, 3 months
exo-jcr SVN: r1440 - in jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent: jbosscache and 1 other directory.
by do-not-reply@jboss.org
Author: pnedonosko
Date: 2010-01-17 03:19:24 -0500 (Sun, 17 Jan 2010)
New Revision: 1440
Added:
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TxIsolatedOperation.java
Modified:
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/BufferedJBossCache.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java
Log:
EXOJCR-405 isolated XA transactions for storage operations (cache now)
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java 2010-01-17 08:09:07 UTC (rev 1439)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java 2010-01-17 08:19:24 UTC (rev 1440)
@@ -25,7 +25,6 @@
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPathEntry;
import org.exoplatform.services.jcr.impl.dataflow.persistent.jbosscache.JBossCacheWorkspaceStorageCache;
-import org.exoplatform.services.jcr.impl.storage.JCRInvalidItemStateException;
import org.exoplatform.services.jcr.impl.storage.SystemDataContainerHolder;
import org.exoplatform.services.jcr.storage.WorkspaceDataContainer;
import org.exoplatform.services.transaction.TransactionService;
@@ -35,14 +34,12 @@
import java.util.Map;
import java.util.concurrent.CountDownLatch;
-import javax.jcr.InvalidItemStateException;
-import javax.jcr.ItemExistsException;
import javax.jcr.RepositoryException;
-import javax.transaction.InvalidTransactionException;
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.HeuristicRollbackException;
+import javax.transaction.NotSupportedException;
import javax.transaction.RollbackException;
-import javax.transaction.Status;
import javax.transaction.SystemException;
-import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
/**
@@ -52,7 +49,7 @@
* Author : Peter Nedonosko peter.nedonosko(a)exoplatform.com.ua
* 13.04.2006
*
- * @version $Id: CacheableWorkspaceDataManager.java 34801 2009-07-31 15:44:50Z dkatayev $
+ * @version $Id$
*/
public class CacheableWorkspaceDataManager extends WorkspacePersistentDataManager
{
@@ -251,6 +248,139 @@
}
}
+ protected abstract class StorageTxIsolatedOperation extends TxIsolatedOperation
+ {
+ StorageTxIsolatedOperation()
+ {
+ super(transactionManager);
+ }
+
+ protected void beginTx() throws NotSupportedException, SystemException
+ {
+ super.beginTx(); // start new global tx
+ cache.beginTransaction(); // TODO keep it into the cache impl
+ }
+
+ protected void commitTx() throws SecurityException, IllegalStateException, RollbackException,
+ HeuristicMixedException, HeuristicRollbackException, SystemException
+ {
+ cache.commitTransaction();
+ super.commitTx(); // commit global tx
+ }
+
+ protected void rollbackTx() throws NotSupportedException, SystemException
+ {
+ cache.rollbackTransaction();
+ super.rollbackTx(); // rollback global tx
+ }
+ }
+
+ protected class SaveInTransaction extends StorageTxIsolatedOperation
+ {
+ final ItemStateChangesLog changes;
+
+ SaveInTransaction(ItemStateChangesLog changes)
+ {
+ this.changes = changes;
+ }
+
+ @Override
+ protected void action() throws RepositoryException
+ {
+ CacheableWorkspaceDataManager.super.save(changes);
+ }
+
+ @Override
+ protected void txAction() throws RepositoryException
+ {
+ super.txAction();
+
+ // notify listeners after transaction commit but before the current resume!
+ try
+ {
+ notifySaveItems(changes, false);
+ }
+ catch (Throwable th)
+ {
+ // TODO XA layer can throws runtime exceptions
+ throw new RepositoryException(th);
+ }
+ }
+ }
+
+ protected class CacheNodesInTransaction extends StorageTxIsolatedOperation
+ {
+ final List<NodeData> childs;
+
+ final NodeData parent;
+
+ CacheNodesInTransaction(NodeData parent, List<NodeData> childs)
+ {
+ this.parent = parent;
+ this.childs = childs;
+ }
+
+ @Override
+ protected void action() throws RepositoryException
+ {
+ cache.addChildNodes(parent, childs);
+ }
+ }
+
+ protected class CachePropertiesInTransaction extends StorageTxIsolatedOperation
+ {
+ final List<PropertyData> childs;
+
+ final NodeData parent;
+
+ CachePropertiesInTransaction(NodeData parent, List<PropertyData> childs)
+ {
+ this.parent = parent;
+ this.childs = childs;
+ }
+
+ @Override
+ protected void action() throws RepositoryException
+ {
+ cache.addChildProperties(parent, childs);
+ }
+ }
+
+ protected class CachePropertiesListInTransaction extends StorageTxIsolatedOperation
+ {
+ final List<PropertyData> childsList;
+
+ final NodeData parent;
+
+ CachePropertiesListInTransaction(NodeData parent, List<PropertyData> childsList)
+ {
+ this.parent = parent;
+ this.childsList = childsList;
+ }
+
+ @Override
+ protected void action() throws RepositoryException
+ {
+ cache.addChildPropertiesList(parent, childsList);
+ }
+ }
+
+ protected class CacheItemInTransaction extends StorageTxIsolatedOperation
+ {
+ final ItemData item;
+
+ CacheItemInTransaction(ItemData item)
+ {
+ this.item = item;
+ }
+
+ @Override
+ protected void action() throws RepositoryException
+ {
+ cache.put(item);
+ }
+ }
+
/**
* CacheableWorkspaceDataManager constructor.
*
@@ -302,7 +432,7 @@
transactionManager = null;
}
}
-
+
/**
* Get Items Cache.
*
@@ -343,7 +473,19 @@
*/
public List<PropertyData> getChildPropertiesData(NodeData nodeData) throws RepositoryException
{
- return getChildPropertiesData(nodeData, false);
+
+ List<PropertyData> childs = getChildPropertiesData(nodeData, false);
+ // for (int i = 0; i < childs.size(); i++)
+ // {
+ // PropertyData data = childs.get(i);
+ // if (data.getValues() == null)
+ // {
+ // // refill the property data if values invalid (null)
+ // childs.set(i, fillPropertyValue(data));
+ // }
+ // }
+
+ return childs;
}
/**
@@ -360,6 +502,11 @@
{
data = getPersistedItemData(parentData, name);
}
+ // else if (!data.isNode() && ((PropertyData)data).getValues() == null)
+ // {
+ // // refill the property data if values invalid (null)
+ // data = fillPropertyValue((PropertyData)data);
+ // }
return data;
}
@@ -377,6 +524,12 @@
{
return getPersistedItemData(identifier);
}
+ // else if (!data.isNode() && ((PropertyData)data).getValues() == null)
+ // {
+ // // refill the property data if values invalid (null)
+ // data = fillPropertyValue((PropertyData)data);
+ // }
+
return data;
}
@@ -403,226 +556,19 @@
@Override
public void save(final ItemStateChangesLog changesLog) throws RepositoryException
{
- if (transactionManager == null)
+ if (isTxAware())
{
- super.save(changesLog);
-
- // notify listeners after storage commit
- notifySaveItems(changesLog, false);
+ // save in dedicated XA transaction
+ new SaveInTransaction(changesLog).perform();
}
else
{
- try
- {
- // Care about dedicated XA transaction for storage save:
- // suspend current ransaction and create one new for the JCR storage (cache etc.)
- // after the new transaction done we'll resume the current.
- Transaction current = transactionManager.suspend();
- try
- {
- saveInTransaction(changesLog);
-
- // notify listeners after transaction commit but before the current resume!
- try
- {
- notifySaveItems(changesLog, false);
- }
- catch (Throwable th)
- {
- // TODO XA layer can throws runtime exceptions
- throw new RepositoryException(th);
- }
- }
- finally
- {
- if (current != null)
- {
- try
- {
- transactionManager.resume(current);
- }
- catch (InvalidTransactionException e)
- {
- throw new RepositoryException(e);
- }
- catch (IllegalStateException e)
- {
- throw new RepositoryException(e);
- }
- }
- }
- }
- catch (SystemException e)
- {
- throw new RepositoryException(e);
- }
-
- // TODO to do not commit in curr thread (i.e. curr tx)
- // try
- // {
- // if (transactionManager.getStatus() == Status.STATUS_COMMITTING)
- // {
- // // The JCR session has been enrolled into a XA Transaction, the method applyChanges must be called in another thread since the operations
- // // that we do into the cache are not allowed within the current Transaction, so to do it in another Transaction we need to call the method
- // // from another Thread
- // final AtomicReference<Exception> exception = new AtomicReference<Exception>();
- // final CountDownLatch doneSignal = new CountDownLatch(1);
- // Thread t = new Thread()
- // {
- // public void run()
- // {
- // try
- // {
- // applyChanges(changesLog);
- // }
- // catch (Exception e)
- // {
- // exception.set(e);
- // }
- // finally
- // {
- // doneSignal.countDown();
- // }
- // }
- // };
- // t.start();
- // doneSignal.await();
- // Exception e = exception.get();
- // if (e != null)
- // {
- // if (e instanceof RepositoryException)
- // {
- // throw (RepositoryException)e;
- // }
- // else
- // {
- // throw new RuntimeException(e);
- // }
- // }
- // }
- // else
- // {
- // // Normal Transaction
- // applyChanges(changesLog);
- // }
- // }
- // catch (RepositoryException e)
- // {
- // throw e;
- // }
- // catch (InterruptedException e)
- // {
- // throw new RepositoryException(e.getLocalizedMessage(), e.getCause());
- // }
- // catch (SystemException e)
- // {
- // throw new RepositoryException(e.getLocalizedMessage(), e.getCause());
- // }
- }
- }
-
- /**
- * Apply all the changes in new XA transaction. This save should run in dedicated XA transaction, i.e. only JCR storage stuff should be involved to.
- */
- private void saveInTransaction(ItemStateChangesLog changesLog) throws RepositoryException
- {
- try
- {
- transactionManager.begin(); // start new global tx
- cache.beginTransaction(); // TODO keep it into the cache impl
+ // save normaly
super.save(changesLog);
- cache.commitTransaction();
- transactionManager.commit(); // commit global tx
- }
- catch (RollbackException e)
- {
- // Indicate that the transaction has been rolled back rather than committed.
- throw new RepositoryException(e);
- }
- catch (JCRInvalidItemStateException e)
- {
- try
- {
- cache.rollbackTransaction();
- transactionManager.rollback(); // rollback global tx
- }
- catch (Exception e1)
- {
- LOG.error("Rollback error ", e1);
- }
- throw new JCRInvalidItemStateException(e.getMessage(), e.getIdentifier(), e.getState(), e);
+ // notify listeners after storage commit
+ notifySaveItems(changesLog, false);
}
- catch (InvalidItemStateException e)
- {
- try
- {
- cache.rollbackTransaction();
- transactionManager.rollback();
- }
- catch (Exception e1)
- {
- LOG.error("Rollback error ", e1);
- }
-
- throw new InvalidItemStateException(e);
- }
- catch (ItemExistsException e)
- {
- try
- {
- cache.rollbackTransaction();
- transactionManager.rollback();
- }
- catch (Exception e1)
- {
- LOG.error("Rollback error ", e1);
- }
-
- throw new ItemExistsException(e);
- }
- catch (ReadOnlyWorkspaceException e)
- {
- try
- {
- cache.rollbackTransaction();
- transactionManager.rollback();
- }
- catch (Exception e1)
- {
- LOG.error("Rollback error ", e1);
- }
-
- throw new ReadOnlyWorkspaceException(e);
- }
- catch (RepositoryException e)
- {
- try
- {
- cache.rollbackTransaction();
- transactionManager.rollback();
- }
- catch (Exception e1)
- {
- LOG.error("Rollback error ", e1);
- }
-
- throw new RepositoryException(e);
- }
- catch (Exception e)
- {
- try
- {
- cache.rollbackTransaction();
- transactionManager.rollback();
- }
- catch (Exception e1)
- {
- LOG.error("Rollback error ", e1);
- }
-
- throw new RepositoryException(e);
- }
}
/**
@@ -697,47 +643,49 @@
if (parentData != null)
{
- if (transactionManager == null)
+ if (isTxAware())
{
- cache.addChildNodes(parentData, childNodes);
+ new CacheNodesInTransaction(parentData, childNodes).perform();
+
+ // TODO
+ // try
+ // {
+ // if (transactionManager.getStatus() == Status.STATUS_ACTIVE)
+ // {
+ // cache.addChildNodes(parentData, childNodes);
+ // }
+ // else
+ // {
+ // transactionManager.begin();
+ // cache.beginTransaction();
+ // cache.addChildNodes(parentData, childNodes);
+ // cache.commitTransaction();
+ // transactionManager.commit();
+ // }
+ // }
+ // catch (RollbackException e)
+ // {
+ // // Indicate that the transaction has been rolled back rather than committed.
+ // throw new RepositoryException(e);
+ // }
+ // catch (Exception e)
+ // {
+ // try
+ // {
+ // cache.rollbackTransaction();
+ // transactionManager.rollback();
+ // }
+ // catch (Exception e1)
+ // {
+ // LOG.error("Rollback error ", e1);
+ // }
+ //
+ // throw new RepositoryException(e);
+ // }
}
else
{
-
- try
- {
- if (transactionManager.getStatus() == Status.STATUS_ACTIVE)
- {
- cache.addChildNodes(parentData, childNodes);
- }
- else
- {
- transactionManager.begin();
- cache.beginTransaction();
- cache.addChildNodes(parentData, childNodes);
- cache.commitTransaction();
- transactionManager.commit();
- }
- }
- catch (RollbackException e)
- {
- // Indicate that the transaction has been rolled back rather than committed.
- throw new RepositoryException(e);
- }
- catch (Exception e)
- {
- try
- {
- cache.rollbackTransaction();
- transactionManager.rollback();
- }
- catch (Exception e1)
- {
- LOG.error("Rollback error ", e1);
- }
-
- throw new RepositoryException(e);
- }
+ cache.addChildNodes(parentData, childNodes);
}
}
}
@@ -793,46 +741,49 @@
if (parentData != null)
{
- if (transactionManager == null)
+ if (isTxAware())
{
- cache.addChildProperties(parentData, childProperties);
+ new CachePropertiesInTransaction(parentData, childProperties).perform();
+
+ // TODO
+ // try
+ // {
+ // if (transactionManager.getStatus() == Status.STATUS_ACTIVE)
+ // {
+ // cache.addChildProperties(parentData, childProperties);
+ // }
+ // else
+ // {
+ // transactionManager.begin();
+ // cache.beginTransaction();
+ // cache.addChildProperties(parentData, childProperties);
+ // cache.commitTransaction();
+ // transactionManager.commit();
+ // }
+ // }
+ // catch (RollbackException e)
+ // {
+ // // Indicate that the transaction has been rolled back rather than committed.
+ // throw new RepositoryException(e);
+ // }
+ // catch (Exception e)
+ // {
+ // try
+ // {
+ // cache.rollbackTransaction();
+ // transactionManager.rollback();
+ // }
+ // catch (Exception e1)
+ // {
+ // LOG.error("Rollback error ", e1);
+ // }
+ //
+ // throw new RepositoryException(e);
+ // }
}
else
{
- try
- {
- if (transactionManager.getStatus() == Status.STATUS_ACTIVE)
- {
- cache.addChildProperties(parentData, childProperties);
- }
- else
- {
- transactionManager.begin();
- cache.beginTransaction();
- cache.addChildProperties(parentData, childProperties);
- cache.commitTransaction();
- transactionManager.commit();
- }
- }
- catch (RollbackException e)
- {
- // Indicate that the transaction has been rolled back rather than committed.
- throw new RepositoryException(e);
- }
- catch (Exception e)
- {
- try
- {
- cache.rollbackTransaction();
- transactionManager.rollback();
- }
- catch (Exception e1)
- {
- LOG.error("Rollback error ", e1);
- }
-
- throw new RepositoryException(e);
- }
+ cache.addChildProperties(parentData, childProperties);
}
}
}
@@ -857,51 +808,52 @@
*/
protected ItemData getPersistedItemData(NodeData parentData, QPathEntry name) throws RepositoryException
{
-
- ItemData data = null;
- data = super.getItemData(parentData, name);
+ ItemData data = super.getItemData(parentData, name);
if (data != null && cache.isEnabled())
{
- if (transactionManager == null)
+ if (isTxAware())
{
- cache.put(data);
+ new CacheItemInTransaction(data).perform();
+
+ // TODO
+ // try
+ // {
+ // if (transactionManager.getStatus() == Status.STATUS_ACTIVE)
+ // {
+ // cache.put(data);
+ // }
+ // else
+ // {
+ // transactionManager.begin();
+ // cache.beginTransaction();
+ // cache.put(data);
+ // cache.commitTransaction();
+ // transactionManager.commit();
+ // }
+ // }
+ // catch (RollbackException e)
+ // {
+ // // Indicate that the transaction has been rolled back rather than committed.
+ // throw new RepositoryException(e);
+ // }
+ // catch (Exception e)
+ // {
+ // try
+ // {
+ // cache.rollbackTransaction();
+ // transactionManager.rollback();
+ // }
+ // catch (Exception e1)
+ // {
+ // LOG.error("Rollback error ", e1);
+ // }
+ //
+ // throw new RepositoryException(e);
+ // }
}
else
{
- try
- {
- if (transactionManager.getStatus() == Status.STATUS_ACTIVE)
- {
- cache.put(data);
- }
- else
- {
- transactionManager.begin();
- cache.beginTransaction();
- cache.put(data);
- cache.commitTransaction();
- transactionManager.commit();
- }
- }
- catch (RollbackException e)
- {
- // Indicate that the transaction has been rolled back rather than committed.
- throw new RepositoryException(e);
- }
- catch (Exception e)
- {
- try
- {
- cache.rollbackTransaction();
- transactionManager.rollback();
- }
- catch (Exception e1)
- {
- LOG.error("Rollback error ", e1);
- }
-
- throw new RepositoryException(e);
- }
+ cache.put(data);
}
}
return data;
@@ -919,46 +871,49 @@
ItemData data = super.getItemData(identifier);
if (data != null && cache.isEnabled())
{
- if (transactionManager == null)
+ if (isTxAware())
{
- cache.put(data);
+ new CacheItemInTransaction(data).perform();
+
+ // TODO
+ // try
+ // {
+ // if (transactionManager.getStatus() == Status.STATUS_ACTIVE)
+ // {
+ // cache.put(data);
+ // }
+ // else
+ // {
+ // transactionManager.begin();
+ // cache.beginTransaction();
+ // cache.put(data);
+ // cache.commitTransaction();
+ // transactionManager.commit();
+ // }
+ // }
+ // catch (RollbackException e)
+ // {
+ // // Indicate that the transaction has been rolled back rather than committed.
+ // throw new RepositoryException(e);
+ // }
+ // catch (Exception e)
+ // {
+ // try
+ // {
+ // cache.rollbackTransaction();
+ // transactionManager.rollback();
+ // }
+ // catch (Exception e1)
+ // {
+ // LOG.error("Rollback error ", e1);
+ // }
+ //
+ // throw new RepositoryException(e);
+ // }
}
else
{
- try
- {
- if (transactionManager.getStatus() == Status.STATUS_ACTIVE)
- {
- cache.put(data);
- }
- else
- {
- transactionManager.begin();
- cache.beginTransaction();
- cache.put(data);
- cache.commitTransaction();
- transactionManager.commit();
- }
- }
- catch (RollbackException e)
- {
- // Indicate that the transaction has been rolled back rather than committed.
- throw new RepositoryException(e);
- }
- catch (Exception e)
- {
- try
- {
- cache.rollbackTransaction();
- transactionManager.rollback();
- }
- catch (Exception e1)
- {
- LOG.error("Rollback error ", e1);
- }
-
- throw new RepositoryException(e);
- }
+ cache.put(data);
}
}
return data;
@@ -1004,49 +959,185 @@
if (parentData != null)
{
- if (transactionManager == null)
+ if (isTxAware())
{
- cache.addChildPropertiesList(parentData, propertiesList);
+ new CachePropertiesListInTransaction(parentData, propertiesList).perform();
+
+ // if (transactionManager.getStatus() == Status.STATUS_ACTIVE)
+ // {
+ // cache.addChildPropertiesList(parentData, propertiesList);
+ // }
+ // else
+ // {
+ // try
+ // {
+ // transactionManager.begin();
+ // cache.beginTransaction();
+ // cache.addChildPropertiesList(parentData, propertiesList);
+ // cache.commitTransaction();
+ // transactionManager.commit();
+ // }
+ // catch (RollbackException e)
+ // {
+ // // Indicate that the transaction has been rolled back rather than committed.
+ // throw new RepositoryException(e);
+ // }
+ // catch (Exception e)
+ // {
+ // try
+ // {
+ // cache.rollbackTransaction();
+ // transactionManager.rollback();
+ // }
+ // catch (Exception e1)
+ // {
+ // LOG.error("Rollback error ", e1);
+ // }
+ //
+ // throw new RepositoryException(e);
+ // }
+ // }
}
else
{
- try
- {
- if (transactionManager.getStatus() == Status.STATUS_ACTIVE)
- {
- cache.addChildPropertiesList(parentData, propertiesList);
- }
- else
- {
- transactionManager.begin();
- cache.beginTransaction();
- cache.addChildPropertiesList(parentData, propertiesList);
- cache.commitTransaction();
- transactionManager.commit();
- }
- }
- catch (RollbackException e)
- {
- // Indicate that the transaction has been rolled back rather than committed.
- throw new RepositoryException(e);
- }
- catch (Exception e)
- {
- try
- {
- cache.rollbackTransaction();
- transactionManager.rollback();
- }
- catch (Exception e1)
- {
- LOG.error("Rollback error ", e1);
- }
-
- throw new RepositoryException(e);
- }
+ cache.addChildPropertiesList(parentData, propertiesList);
}
}
}
return propertiesList;
}
+
+ // /**
+ // * Apply all the changes in new XA transaction. This save should run in dedicated XA transaction,
+ // * i.e. only JCR storage stuff should be involved to.
+ // */
+ // private void saveInTransaction(ItemStateChangesLog changes) throws RepositoryException
+ // {
+ // try
+ // {
+ // transactionManager.begin(); // start new global tx
+ // cache.beginTransaction(); // TODO keep it into the cache impl
+ // CacheableWorkspaceDataManager.super.save(changes);
+ // cache.commitTransaction();
+ // transactionManager.commit(); // commit global tx
+ // }
+ // catch (RollbackException e)
+ // {
+ // // Indicate that the transaction has been rolled back rather than committed.
+ // throw new RepositoryException(e);
+ // }
+ // catch (JCRInvalidItemStateException e)
+ // {
+ // try
+ // {
+ // cache.rollbackTransaction();
+ // transactionManager.rollback(); // rollback global tx
+ // }
+ // catch (Exception e1)
+ // {
+ // LOG.error("Rollback error ", e1);
+ // }
+ //
+ // throw new JCRInvalidItemStateException(e.getMessage(), e.getIdentifier(), e.getState(), e);
+ // }
+ // catch (InvalidItemStateException e)
+ // {
+ // try
+ // {
+ // cache.rollbackTransaction();
+ // transactionManager.rollback();
+ // }
+ // catch (Exception e1)
+ // {
+ // LOG.error("Rollback error ", e1);
+ // }
+ //
+ // throw new InvalidItemStateException(e);
+ // }
+ // catch (ItemExistsException e)
+ // {
+ // try
+ // {
+ // cache.rollbackTransaction();
+ // transactionManager.rollback();
+ // }
+ // catch (Exception e1)
+ // {
+ // LOG.error("Rollback error ", e1);
+ // }
+ //
+ // throw new ItemExistsException(e);
+ // }
+ // catch (ReadOnlyWorkspaceException e)
+ // {
+ // try
+ // {
+ // cache.rollbackTransaction();
+ // transactionManager.rollback();
+ // }
+ // catch (Exception e1)
+ // {
+ // LOG.error("Rollback error ", e1);
+ // }
+ //
+ // throw new ReadOnlyWorkspaceException(e);
+ // }
+ // catch (RepositoryException e)
+ // {
+ // try
+ // {
+ // cache.rollbackTransaction();
+ // transactionManager.rollback();
+ // }
+ // catch (Exception e1)
+ // {
+ // LOG.error("Rollback error ", e1);
+ // }
+ //
+ // throw new RepositoryException(e);
+ // }
+ // catch (Exception e)
+ // {
+ // try
+ // {
+ // cache.rollbackTransaction();
+ // transactionManager.rollback();
+ // }
+ // catch (Exception e1)
+ // {
+ // LOG.error("Rollback error ", e1);
+ // }
+ //
+ // throw new RepositoryException(e);
+ // }
+ // }
+
+ protected boolean isTxAware()
+ {
+ return transactionManager != null;
+ }
+
+ // /**
+ // * Fill Property Value from persistent storage.
+ // *
+ // * @param prop PropertyData, original Property data
+ // * @return PropertyData
+ // * @throws IllegalStateException
+ // * @throws RepositoryException
+ // */
+ // protected PropertyData fillPropertyValue(PropertyData prop) throws IllegalStateException, RepositoryException
+ // {
+ // // TODO use interface not JDBC
+ // JDBCStorageConnection conn = (JDBCStorageConnection)dataContainer.openConnection();
+ // try
+ // {
+ // return new PersistedPropertyData(prop.getIdentifier(), prop.getQPath(), prop.getParentIdentifier(), prop
+ // .getPersistedVersion(), prop.getType(), prop.isMultiValued(), conn.getPropertyValues(prop.getIdentifier(),
+ // prop.getPersistedVersion()));
+ // }
+ // finally
+ // {
+ // conn.close();
+ // }
+ // }
}
Property changes on: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java
___________________________________________________________________
Name: svn:keywords
+ Id
Added: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TxIsolatedOperation.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TxIsolatedOperation.java (rev 0)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TxIsolatedOperation.java 2010-01-17 08:19:24 UTC (rev 1440)
@@ -0,0 +1,264 @@
+package org.exoplatform.services.jcr.impl.dataflow.persistent;
+
+import org.exoplatform.services.jcr.impl.storage.JCRInvalidItemStateException;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+
+import javax.jcr.InvalidItemStateException;
+import javax.jcr.ItemExistsException;
+import javax.jcr.RepositoryException;
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.HeuristicRollbackException;
+import javax.transaction.InvalidTransactionException;
+import javax.transaction.NotSupportedException;
+import javax.transaction.RollbackException;
+import javax.transaction.Status;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+
+/**
+ * Handles XA transactionalyisolated operation. I.e. Action of this operation will be executed in dedicated global transaction.
+ * If another current transaction exists, the one will be suspended and resumed after the execution.
+ * At other hand if nested isolated operations perform they will use same (current, active) transaction.
+ */
+public abstract class TxIsolatedOperation
+{
+ protected static final Log LOG = ExoLogger.getLogger("jcr.TxIsolatedOperation");
+
+ protected final TransactionManager txManager;
+
+ protected final static ThreadLocal<Transaction> currentIsolated = new ThreadLocal<Transaction>();
+
+ public TxIsolatedOperation(TransactionManager txManager)
+ {
+ this.txManager = txManager;
+ }
+
+ /**
+ * Action body for a final implementation.
+ *
+ * @throws RepositoryException
+ */
+ protected abstract void action() throws RepositoryException;
+
+ protected void beginTx() throws NotSupportedException, SystemException
+ {
+ txManager.begin(); // start new global tx
+ }
+
+ protected void commitTx() throws SecurityException, IllegalStateException, RollbackException,
+ HeuristicMixedException, HeuristicRollbackException, SystemException
+ {
+ txManager.commit(); // commit global tx
+ }
+
+ protected void rollbackTx() throws NotSupportedException, SystemException
+ {
+ txManager.rollback(); // rollback global tx
+ }
+
+ /**
+ * Apply action in new XA transaction (begin then commit or rollback).
+ * Action will runs in dedicated (isolated) XA transaction, i.e. only JCR storage stuff will be involved to.
+ * But if it's a nested isolated operation it will run the action assuming the same (current, active) transaction.
+ */
+ protected void txAction() throws RepositoryException
+ {
+ final boolean actInTx = currentIsolated.get() == null;
+ try
+ {
+ if (actInTx)
+ {
+ beginTx();
+
+ // remember current isolated transaction for this thread
+ Transaction current = txManager.getTransaction();
+ if (current != null)
+ {
+ currentIsolated.set(current);
+ }
+ }
+
+ action();
+
+ if (actInTx)
+ {
+ commitTx();
+
+ // remove current isolated transaction from this thread
+ currentIsolated.remove();
+ }
+ }
+ catch (RollbackException e)
+ {
+ if (actInTx)
+ {
+ // remove current isolated transaction from this thread
+ currentIsolated.remove();
+ }
+ // Indicate that the transaction has been rolled back rather than committed.
+ throw new RepositoryException(e);
+ }
+ catch (JCRInvalidItemStateException e)
+ {
+ doRollback(actInTx);
+ throw new JCRInvalidItemStateException(e.getMessage(), e.getIdentifier(), e.getState(), e);
+ }
+ catch (InvalidItemStateException e)
+ {
+ doRollback(actInTx);
+ throw new InvalidItemStateException(e);
+ }
+ catch (ItemExistsException e)
+ {
+ doRollback(actInTx);
+ throw new ItemExistsException(e);
+ }
+ catch (ReadOnlyWorkspaceException e)
+ {
+ doRollback(actInTx);
+ throw new ReadOnlyWorkspaceException(e);
+ }
+ catch (RepositoryException e)
+ {
+ doRollback(actInTx);
+ throw new RepositoryException(e);
+ }
+ catch (Exception e)
+ {
+ doRollback(actInTx);
+ throw new RepositoryException(e);
+ }
+ }
+
+ /**
+ * Performs rollback of the action if it's acts in original isolated transaction.
+ * If it's acts as a nested operation, the actions will be commited in original (rooted) isolated trnsaction.
+ *
+ * @param actInTx boolean, true if it's original isolated transaction
+ */
+ private void doRollback(boolean actInTx)
+ {
+ if (actInTx)
+ {
+ try
+ {
+ rollbackTx();
+ }
+ catch (Exception e1)
+ {
+ LOG.error("Rollback error ", e1);
+ }
+ // remove current isolated transaction from this thread
+ currentIsolated.remove();
+ }
+ }
+
+ /**
+ * Apply the action in new XA transaction. Action should run in dedicated XA transaction,
+ * i.e. only JCR storage stuff should be involved to.
+ */
+ public void perform() throws RepositoryException
+ {
+ try
+ {
+ // Care about dedicated XA transaction for storage save:
+ // suspend current ransaction and create one new for the JCR storage (cache etc.)
+ // after the new transaction done we'll resume the current.
+
+ // TODO if nested in storage, e.g. save causes read, use one tx, e.g. via ThreadLocal
+ //if (txManager.getStatus() == Status.STATUS_ACTIVE)
+
+ Transaction current = txManager.suspend();
+ try
+ {
+ txAction();
+ }
+ finally
+ {
+ if (current != null)
+ {
+ try
+ {
+ txManager.resume(current);
+ }
+ catch (InvalidTransactionException e)
+ {
+ throw new RepositoryException(e);
+ }
+ catch (IllegalStateException e)
+ {
+ throw new RepositoryException(e);
+ }
+ }
+ }
+ }
+ catch (SystemException e)
+ {
+ throw new RepositoryException(e);
+ }
+
+ // TODO to do not commit in curr thread (i.e. curr tx)
+ // try
+ // {
+ // if (transactionManager.getStatus() == Status.STATUS_COMMITTING)
+ // {
+ // // The JCR session has been enrolled into a XA Transaction, the method applyChanges must be called in another thread since the operations
+ // // that we do into the cache are not allowed within the current Transaction, so to do it in another Transaction we need to call the method
+ // // from another Thread
+ // final AtomicReference<Exception> exception = new AtomicReference<Exception>();
+ // final CountDownLatch doneSignal = new CountDownLatch(1);
+ // Thread t = new Thread()
+ // {
+ // public void run()
+ // {
+ // try
+ // {
+ // applyChanges(changesLog);
+ // }
+ // catch (Exception e)
+ // {
+ // exception.set(e);
+ // }
+ // finally
+ // {
+ // doneSignal.countDown();
+ // }
+ // }
+ // };
+ // t.start();
+ // doneSignal.await();
+ // Exception e = exception.get();
+ // if (e != null)
+ // {
+ // if (e instanceof RepositoryException)
+ // {
+ // throw (RepositoryException)e;
+ // }
+ // else
+ // {
+ // throw new RuntimeException(e);
+ // }
+ // }
+ // }
+ // else
+ // {
+ // // Normal Transaction
+ // applyChanges(changesLog);
+ // }
+ // }
+ // catch (RepositoryException e)
+ // {
+ // throw e;
+ // }
+ // catch (InterruptedException e)
+ // {
+ // throw new RepositoryException(e.getLocalizedMessage(), e.getCause());
+ // }
+ // catch (SystemException e)
+ // {
+ // throw new RepositoryException(e.getLocalizedMessage(), e.getCause());
+ // }
+ }
+}
Property changes on: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TxIsolatedOperation.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java 2010-01-17 08:09:07 UTC (rev 1439)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java 2010-01-17 08:19:24 UTC (rev 1440)
@@ -41,8 +41,11 @@
import org.exoplatform.services.jcr.impl.Constants;
import org.exoplatform.services.jcr.impl.dataflow.TransientValueData;
import org.exoplatform.services.jcr.impl.storage.SystemDataContainerHolder;
+import org.exoplatform.services.jcr.impl.storage.value.fs.FileIOChannel;
import org.exoplatform.services.jcr.storage.WorkspaceDataContainer;
import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
+import org.exoplatform.services.jcr.storage.value.ValueIOChannel;
+import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
@@ -56,6 +59,7 @@
import java.util.Set;
import javax.jcr.InvalidItemStateException;
+import javax.jcr.PropertyType;
import javax.jcr.RepositoryException;
/**
@@ -77,14 +81,19 @@
/**
* Workspace data container (persistent storage).
*/
- protected WorkspaceDataContainer dataContainer;
+ protected final WorkspaceDataContainer dataContainer;
/**
* System workspace data container (persistent storage).
*/
- protected WorkspaceDataContainer systemDataContainer;
+ protected final WorkspaceDataContainer systemDataContainer;
/**
+ * Value sorages provider (for dest file suggestion on save).
+ */
+ // TODO protected final ValueStoragePluginProvider valueStorageProvider;
+
+ /**
* Persistent level listeners. This listeners can be filtered by filters from
* <code>liestenerFilters</code> list.
*/
@@ -114,13 +123,16 @@
* holder of system workspace data container
*/
public WorkspacePersistentDataManager(WorkspaceDataContainer dataContainer,
+ //ValueStoragePluginProvider valueStorageProvider,
SystemDataContainerHolder systemDataContainerHolder)
{
this.dataContainer = dataContainer;
+ this.systemDataContainer = systemDataContainerHolder.getContainer();
+ // this.valueStorageProvider = valueStorageProvider;
+
this.listeners = new ArrayList<ItemsPersistenceListener>();
this.mandatoryListeners = new ArrayList<MandatoryItemsPersistenceListener>();
this.liestenerFilters = new ArrayList<ItemsPersistenceListenerFilter>();
- this.systemDataContainer = systemDataContainerHolder.getContainer();
}
/**
@@ -128,18 +140,6 @@
*/
public void save(final ItemStateChangesLog changesLog) throws RepositoryException
{
- doSave(changesLog);
- }
-
- /**
- * Save the list of changes to storage.
- *
- * @param changesLog
- * @throws RepositoryException
- */
- private void doSave(final ItemStateChangesLog changesLog) throws RepositoryException
- {
- //LOG.info(changesLog.dump())
// check if this workspace container is not read-only
if (readOnly && !(changesLog instanceof ReadOnlyThroughChanges))
{
@@ -234,7 +234,7 @@
// if it's different container instances
? systemDataContainer.equals(dataContainer) && thisConnection != null
// but container confugrations are same and non-system connnection open
- // reuse this connection as system
+ // reuse this connection as system
? systemDataContainer.reuseConnection(thisConnection)
// or open one new system
: systemDataContainer.openConnection()
@@ -256,7 +256,7 @@
// if it's different container instances
? dataContainer.equals(systemDataContainer) && systemConnection != null
// but container confugrations are same and system connnection open
- // reuse system connection as this
+ // reuse system connection as this
? dataContainer.reuseConnection(systemConnection)
// or open one new
: dataContainer.openConnection()
@@ -273,7 +273,7 @@
protected PlainChangesLogImpl save(PlainChangesLog changesLog) throws InvalidItemStateException,
RepositoryException, IOException
{ //LOG.info(changesLog.dump())
- // copy state
+ // copy state
PlainChangesLogImpl newLog =
new PlainChangesLogImpl(new ArrayList<ItemState>(), changesLog.getSessionId(), changesLog.getEventType(),
changesLog.getPairId());
@@ -303,7 +303,7 @@
{
PropertyData prevData = (PropertyData)prevState.getData();
- if (prevData.getValues() != null)
+ if (prevData.getValues() != null) // null if it's DELETE state
{
List<ValueData> values = new ArrayList<ValueData>();
for (int i = 0; i < prevData.getValues().size(); i++)
@@ -326,16 +326,15 @@
// TODO for JBC case, the storage connection will evict the replicated Value to read it from the DB
File destFile = null;
- // TODO review TransientValueData logic about spool file and stream
if (tvd.getSpoolFile() != null)
{
// spooled to temp file
- pvd = new StreamPersistedValueData(i, tvd.getSpoolFile());
+ pvd = new StreamPersistedValueData(i, tvd.getSpoolFile(), destFile);
}
else
{
// with original stream
- pvd = new StreamPersistedValueData(i, tvd.getOriginalStream());
+ pvd = new StreamPersistedValueData(i, tvd.getOriginalStream(), destFile);
}
values.add(pvd);
@@ -397,7 +396,7 @@
}
else if (itemState.isDeleted())
{
- doDelete(data, conn);
+ doDelete(data, conn);
}
else if (itemState.isRenamed())
{
@@ -759,13 +758,17 @@
for (MandatoryItemsPersistenceListener mlistener : mandatoryListeners)
{
if (mlistener.isTXAware() == isListenerTXAware)
+ {
mlistener.onSaveItems(changesLog);
+ }
}
for (ItemsPersistenceListener listener : listeners)
{
if (listener.isTXAware() == isListenerTXAware && isListenerAccepted(listener))
+ {
listener.onSaveItems(changesLog);
+ }
}
}
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/BufferedJBossCache.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/BufferedJBossCache.java 2010-01-17 08:09:07 UTC (rev 1439)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/BufferedJBossCache.java 2010-01-17 08:19:24 UTC (rev 1440)
@@ -58,7 +58,7 @@
*/
private final Cache<Serializable, Object> parentCache;
- private ThreadLocal<CompressedChangesBuffer> changesList = new ThreadLocal<CompressedChangesBuffer>();
+ private final ThreadLocal<CompressedChangesBuffer> changesList = new ThreadLocal<CompressedChangesBuffer>();
private ThreadLocal<Boolean> local = new ThreadLocal<Boolean>();
@@ -100,6 +100,7 @@
finally
{
changesList.set(null);
+ changesContainer = null;
}
}
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 2010-01-17 08:09:07 UTC (rev 1439)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java 2010-01-17 08:19:24 UTC (rev 1440)
@@ -33,6 +33,7 @@
import org.exoplatform.services.jcr.impl.Constants;
import org.exoplatform.services.jcr.impl.dataflow.TransientNodeData;
import org.exoplatform.services.jcr.impl.dataflow.TransientPropertyData;
+import org.exoplatform.services.jcr.impl.dataflow.persistent.TxIsolatedOperation;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
import org.exoplatform.services.transaction.TransactionService;
@@ -306,42 +307,23 @@
protected void prepareCache() throws RepositoryException
{
-
TransactionManager txm = cache.getTransactionManager();
- try
+ final Node<Serializable, Object> cacheRoot = cache.getRoot();
+ TxIsolatedOperation prepare = new TxIsolatedOperation(txm)
{
- txm.begin();
-
- Node<Serializable, Object> cacheRoot = cache.getRoot();
-
- cacheRoot.addChild(this.itemsRoot).setResident(true);
- cacheRoot.addChild(this.childNodes).setResident(true);
- cacheRoot.addChild(this.childNodesList).setResident(true);
- cacheRoot.addChild(this.childProps).setResident(true);
- cacheRoot.addChild(this.childPropsList).setResident(true);
- cacheRoot.addChild(refsRoot).setResident(true);
-
- txm.commit();
- }
- catch (RollbackException e)
- {
- // Indicate that the transaction has been rolled back rather than committed.
- throw new RepositoryException(e);
- }
- catch (Exception e)
- {
- try
+ @Override
+ protected void action() throws RepositoryException
{
- txm.rollback();
- throw new RepositoryException("Cannot preare cache", e);
+ cacheRoot.addChild(itemsRoot).setResident(true);
+ cacheRoot.addChild(childNodes).setResident(true);
+ cacheRoot.addChild(childNodesList).setResident(true);
+ cacheRoot.addChild(childProps).setResident(true);
+ cacheRoot.addChild(childPropsList).setResident(true);
+ cacheRoot.addChild(refsRoot).setResident(true);
}
- catch (Exception e1)
- {
- LOG.error("Error of rolback ", e1);
- }
+ };
- throw new RepositoryException(e);
- }
+ prepare.perform();
}
protected static String readJBCConfig(final WorkspaceEntry wsConfig) throws RepositoryConfigurationException
16 years, 3 months
exo-jcr SVN: r1439 - in jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src: test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache and 1 other directory.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2010-01-17 03:09:07 -0500 (Sun, 17 Jan 2010)
New Revision: 1439
Modified:
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/BufferedJBossCache.java
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/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/TestCompressedChangesBuffer.java
Log:
EXOJCR-409: Added and applied option for local cache operations, skipping replication and refactored BufferedJBossCache.
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/BufferedJBossCache.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/BufferedJBossCache.java 2010-01-16 20:04:46 UTC (rev 1438)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/BufferedJBossCache.java 2010-01-17 08:09:07 UTC (rev 1439)
@@ -59,6 +59,8 @@
private final Cache<Serializable, Object> parentCache;
private ThreadLocal<CompressedChangesBuffer> changesList = new ThreadLocal<CompressedChangesBuffer>();
+
+ private ThreadLocal<Boolean> local = new ThreadLocal<Boolean>();
protected static final Log LOG =
ExoLogger.getLogger("org.exoplatform.services.jcr.impl.dataflow.persistent.jbosscache.BufferedJBossCache");
@@ -75,6 +77,7 @@
public void beginTransaction()
{
changesList.set(new CompressedChangesBuffer());
+ local.set(false);
}
/**
@@ -82,11 +85,7 @@
*/
public void commitTransaction()
{
- CompressedChangesBuffer changesContainer = changesList.get();
- if (changesContainer == null)
- {
- throw new IllegalStateException("changesContainer should not be empty");
- }
+ CompressedChangesBuffer changesContainer = getChangesBufferSafe();
try
{
//log.info("Before=" + changesContainer.toString());
@@ -105,6 +104,21 @@
}
/**
+ * Tries to get buffer and if it is null throws an exception otherwise returns buffer.
+ *
+ * @return
+ */
+ private CompressedChangesBuffer getChangesBufferSafe()
+ {
+ CompressedChangesBuffer changesContainer = changesList.get();
+ if (changesContainer == null)
+ {
+ throw new IllegalStateException("changesContainer should not be empty");
+ }
+ return changesContainer;
+ }
+
+ /**
* Forget about changes
*/
public void rollbackTransaction()
@@ -112,6 +126,16 @@
changesList.set(null);
}
+ /**
+ * Creates all ChangesBuffers with given parameter
+ *
+ * @param local
+ */
+ public void setLocal(boolean local)
+ {
+ this.local.set(local);
+ }
+
/* (non-Javadoc)
* @see org.jboss.cache.Cache#addCacheListener(java.lang.Object)
*/
@@ -376,13 +400,8 @@
*/
public void put(Fqn fqn, Map<? extends Serializable, ? extends Object> data)
{
- //parentCache.put(fqn, data);
- CompressedChangesBuffer changesContainer = changesList.get();
- if (changesContainer == null)
- {
- throw new IllegalStateException("changesContainer should not be empty");
- }
- changesContainer.add(new PutObjectContainer(fqn, data, parentCache, changesContainer.getHistoryIndex()));
+ CompressedChangesBuffer changesContainer = getChangesBufferSafe();
+ changesContainer.add(new PutObjectContainer(fqn, data, parentCache, changesContainer.getHistoryIndex(), local.get()));
}
/* (non-Javadoc)
@@ -390,12 +409,8 @@
*/
public Object put(Fqn fqn, Serializable key, Object value)
{
- CompressedChangesBuffer changesContainer = changesList.get();
- if (changesContainer == null)
- {
- throw new IllegalStateException("changesContainer should not be empty");
- }
- changesContainer.add(new PutKeyValueContainer(fqn, key, value, parentCache, changesContainer.getHistoryIndex()));
+ CompressedChangesBuffer changesContainer = getChangesBufferSafe();
+ changesContainer.add(new PutKeyValueContainer(fqn, key, value, parentCache, changesContainer.getHistoryIndex(), local.get()));
return parentCache.get(fqn, key);
}
@@ -430,12 +445,8 @@
*/
public Object remove(Fqn fqn, Serializable key)
{
- CompressedChangesBuffer changesContainer = changesList.get();
- if (changesContainer == null)
- {
- throw new IllegalStateException("changesContainer should not be empty");
- }
- changesContainer.add(new RemoveKeyContainer(fqn, key, parentCache, changesContainer.getHistoryIndex()));
+ CompressedChangesBuffer changesContainer = getChangesBufferSafe();
+ changesContainer.add(new RemoveKeyContainer(fqn, key, parentCache, changesContainer.getHistoryIndex(), local.get()));
return parentCache.get(fqn, key);
}
@@ -476,12 +487,8 @@
*/
public boolean removeNode(Fqn fqn)
{
- CompressedChangesBuffer changesContainer = changesList.get();
- if (changesContainer == null)
- {
- throw new IllegalStateException("changesContainer should not be empty");
- }
- changesContainer.add(new RemoveNodeContainer(fqn, parentCache, changesContainer.getHistoryIndex()));
+ CompressedChangesBuffer changesContainer = getChangesBufferSafe();
+ changesContainer.add(new RemoveNodeContainer(fqn, parentCache, changesContainer.getHistoryIndex(), local.get()));
return true;
}
@@ -548,12 +555,8 @@
*/
public void addToList(Fqn fqn, String key, Object value)
{
- CompressedChangesBuffer changesContainer = changesList.get();
- if (changesContainer == null)
- {
- throw new IllegalStateException("changesContainer should not be empty");
- }
- changesContainer.add(new AddToListContainer(fqn, key, value, parentCache, changesContainer.getHistoryIndex()));
+ CompressedChangesBuffer changesContainer = getChangesBufferSafe();
+ changesContainer.add(new AddToListContainer(fqn, key, value, parentCache, changesContainer.getHistoryIndex(), local.get()));
}
/**
@@ -565,13 +568,9 @@
*/
public void removeFromList(Fqn fqn, String key, Object value)
{
- CompressedChangesBuffer changesContainer = changesList.get();
- if (changesContainer == null)
- {
- throw new IllegalStateException("changesContainer should not be empty");
- }
+ CompressedChangesBuffer changesContainer = getChangesBufferSafe();
changesContainer
- .add(new RemoveFromListContainer(fqn, key, value, parentCache, changesContainer.getHistoryIndex()));
+ .add(new RemoveFromListContainer(fqn, key, value, parentCache, changesContainer.getHistoryIndex(), local.get()));
}
public static enum ChangesType {
@@ -591,13 +590,16 @@
protected final int historicalIndex;
- public ChangesContainer(Fqn fqn, ChangesType changesType, Cache<Serializable, Object> cache, int historicalIndex)
+ protected final boolean localMode;
+
+ public ChangesContainer(Fqn fqn, ChangesType changesType, Cache<Serializable, Object> cache, int historicalIndex, boolean localMode)
{
super();
this.fqn = fqn;
this.changesType = changesType;
this.cache = cache;
this.historicalIndex = historicalIndex;
+ this.localMode = localMode;
}
/**
@@ -639,6 +641,11 @@
return result == 0 ? historicalIndex - o.getHistoricalIndex() : result;
}
+ protected void setCacheLocalMode()
+ {
+ cache.getInvocationContext().getOptionOverrides().setCacheModeLocal(localMode);
+ }
+
public abstract void apply();
}
@@ -650,9 +657,9 @@
private final Map<? extends Serializable, ? extends Object> data;
public PutObjectContainer(Fqn fqn, Map<? extends Serializable, ? extends Object> data,
- Cache<Serializable, Object> cache, int historicalIndex)
+ Cache<Serializable, Object> cache, int historicalIndex, boolean local)
{
- super(fqn, ChangesType.PUT, cache, historicalIndex);
+ super(fqn, ChangesType.PUT, cache, historicalIndex, local);
this.data = data;
}
@@ -660,6 +667,7 @@
@Override
public void apply()
{
+ setCacheLocalMode();
cache.put(fqn, data);
}
}
@@ -674,9 +682,9 @@
private final Object value;
public PutKeyValueContainer(Fqn fqn, Serializable key, Object value, Cache<Serializable, Object> cache,
- int historicalIndex)
+ int historicalIndex, boolean local)
{
- super(fqn, ChangesType.PUT_KEY, cache, historicalIndex);
+ super(fqn, ChangesType.PUT_KEY, cache, historicalIndex, local);
this.key = key;
this.value = value;
}
@@ -684,6 +692,7 @@
@Override
public void apply()
{
+ setCacheLocalMode();
cache.put(fqn, key, value);
}
}
@@ -699,9 +708,9 @@
private final Object value;
public AddToListContainer(Fqn fqn, Serializable key, Object value, Cache<Serializable, Object> cache,
- int historicalIndex)
+ int historicalIndex, boolean local)
{
- super(fqn, ChangesType.PUT_KEY, cache, historicalIndex);
+ super(fqn, ChangesType.PUT_KEY, cache, historicalIndex, local);
this.key = key;
this.value = value;
}
@@ -723,6 +732,7 @@
newSet.addAll((Set<Object>)existingObject);
}
newSet.add(value);
+ setCacheLocalMode();
cache.put(fqn, key, newSet);
}
else
@@ -743,9 +753,9 @@
private final Object value;
public RemoveFromListContainer(Fqn fqn, Serializable key, Object value, Cache<Serializable, Object> cache,
- int historicalIndex)
+ int historicalIndex, boolean local)
{
- super(fqn, ChangesType.REMOVE_KEY, cache, historicalIndex);
+ super(fqn, ChangesType.REMOVE_KEY, cache, historicalIndex, local);
this.key = key;
this.value = value;
}
@@ -756,12 +766,14 @@
// force writeLock on next read
cache.getInvocationContext().getOptionOverrides().setForceWriteLock(true);
// object found by FQN and key;
+ setCacheLocalMode();
Object existingObject = cache.get(getFqn(), key);
// if found value is really set! add to it.
if (existingObject instanceof Set)
{
Set<Object> newSet = new HashSet<Object>((Set<Object>)existingObject);
newSet.remove(value);
+ setCacheLocalMode();
cache.put(fqn, key, newSet);
}
}
@@ -774,17 +786,17 @@
{
private final Serializable key;
- public RemoveKeyContainer(Fqn fqn, Serializable key, Cache<Serializable, Object> cache, int historicalIndex)
+ public RemoveKeyContainer(Fqn fqn, Serializable key, Cache<Serializable, Object> cache, int historicalIndex, boolean local)
{
- super(fqn, ChangesType.REMOVE_KEY, cache, historicalIndex);
+ super(fqn, ChangesType.REMOVE_KEY, cache, historicalIndex, local);
this.key = key;
}
@Override
public void apply()
{
+ setCacheLocalMode();
cache.remove(fqn, key);
-
}
}
@@ -795,14 +807,15 @@
public static class RemoveNodeContainer extends ChangesContainer
{
- public RemoveNodeContainer(Fqn fqn, Cache<Serializable, Object> cache, int historicalIndex)
+ public RemoveNodeContainer(Fqn fqn, Cache<Serializable, Object> cache, int historicalIndex, boolean local)
{
- super(fqn, ChangesType.REMOVE, cache, historicalIndex);
+ super(fqn, ChangesType.REMOVE, cache, historicalIndex, local);
}
@Override
public void apply()
{
+ setCacheLocalMode();
cache.removeNode(fqn);
}
}
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 2010-01-16 20:04:46 UTC (rev 1438)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java 2010-01-17 08:09:07 UTC (rev 1439)
@@ -371,6 +371,7 @@
*/
public void put(ItemData item)
{
+ cache.setLocal(true);
if (item.isNode())
{
putNode((NodeData)item, ModifyChildOption.NOT_MODIFY);
@@ -379,6 +380,7 @@
{
putProperty((PropertyData)item, ModifyChildOption.NOT_MODIFY);
}
+ cache.setLocal(false);
}
/**
@@ -439,6 +441,7 @@
*/
public void addChildNodes(NodeData parent, List<NodeData> childs)
{
+ cache.setLocal(true);
// remove previous all (to be sure about consistency)
cache.removeNode(makeChildListFqn(childNodesList, parent.getIdentifier()));
@@ -455,6 +458,7 @@
// cache fact of empty childs list
cache.put(makeChildListFqn(childNodesList, parent.getIdentifier()), ITEM_LIST, new HashSet<Object>());
}
+ cache.setLocal(false);
}
/**
@@ -462,6 +466,7 @@
*/
public void addChildProperties(NodeData parent, List<PropertyData> childs)
{
+ cache.setLocal(true);
// remove previous all (to be sure about consistency)
cache.removeNode(makeChildListFqn(childPropsList, parent.getIdentifier()));
if (childs.size() > 0)
@@ -476,6 +481,7 @@
{
LOG.warn("Empty properties list cached " + (parent != null ? parent.getQPath().getAsString() : parent));
}
+ cache.setLocal(false);
}
/**
@@ -483,7 +489,9 @@
*/
public void addChildPropertiesList(NodeData parent, List<PropertyData> childProperties)
{
+ cache.setLocal(true);
// TODO not implemented, will force read from DB
+ cache.setLocal(false);
}
/**
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/TestCompressedChangesBuffer.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/TestCompressedChangesBuffer.java 2010-01-16 20:04:46 UTC (rev 1438)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/TestCompressedChangesBuffer.java 2010-01-17 08:09:07 UTC (rev 1439)
@@ -40,13 +40,13 @@
CompressedChangesBuffer buffer = new CompressedChangesBuffer();
ChangesContainer put1 =
new PutObjectContainer(Fqn.fromString("/" + JBossCacheWorkspaceStorageCache.CHILD_NODES + "/b"),
- new HashMap<String, String>(), null, buffer.getHistoryIndex());
+ new HashMap<String, String>(), null, buffer.getHistoryIndex(), false);
ChangesContainer put2 =
new PutObjectContainer(Fqn.fromString("/" + JBossCacheWorkspaceStorageCache.CHILD_NODES + "/b/c"),
- new HashMap<String, String>(), null, buffer.getHistoryIndex());
+ new HashMap<String, String>(), null, buffer.getHistoryIndex(), false);
ChangesContainer rm1 =
new RemoveNodeContainer(Fqn.fromString("/" + JBossCacheWorkspaceStorageCache.CHILD_NODES + "/b"), null, buffer
- .getHistoryIndex());
+ .getHistoryIndex(), false);
buffer.add(put1);
buffer.add(put2);
assertTrue("List MUST contain put container", buffer.getSortedList().contains(put1));
@@ -67,17 +67,17 @@
CompressedChangesBuffer buffer = new CompressedChangesBuffer();
ChangesContainer put1 =
new PutObjectContainer(Fqn.fromString("/" + JBossCacheWorkspaceStorageCache.CHILD_NODES + "/b"),
- new HashMap<String, String>(), null, buffer.getHistoryIndex());
+ new HashMap<String, String>(), null, buffer.getHistoryIndex(), false);
ChangesContainer put2 =
new PutObjectContainer(Fqn.fromString("/" + JBossCacheWorkspaceStorageCache.CHILD_NODES + "/b/c"),
- new HashMap<String, String>(), null, buffer.getHistoryIndex());
+ new HashMap<String, String>(), null, buffer.getHistoryIndex(), false);
ChangesContainer rm1 =
new RemoveNodeContainer(Fqn.fromString("/" + JBossCacheWorkspaceStorageCache.CHILD_NODES + "/b/c"), null,
- buffer.getHistoryIndex());
+ buffer.getHistoryIndex(), false);
ChangesContainer rm2 =
new RemoveNodeContainer(Fqn.fromString("/" + JBossCacheWorkspaceStorageCache.CHILD_NODES + "/b"), null, buffer
- .getHistoryIndex());
+ .getHistoryIndex(), false);
buffer.add(put1);
buffer.add(put2);
assertTrue("List MUST contain put container", buffer.getSortedList().contains(put1));
@@ -97,11 +97,11 @@
CompressedChangesBuffer buffer = new CompressedChangesBuffer();
ChangesContainer put1 =
new PutObjectContainer(Fqn.fromString("/" + JBossCacheWorkspaceStorageCache.CHILD_NODES_LIST + "/b"),
- new HashMap<String, String>(), null, buffer.getHistoryIndex());
+ new HashMap<String, String>(), null, buffer.getHistoryIndex(), false);
ChangesContainer rm1 =
new RemoveNodeContainer(Fqn.fromString("/" + JBossCacheWorkspaceStorageCache.CHILD_NODES_LIST + "/b"), null,
- buffer.getHistoryIndex());
+ buffer.getHistoryIndex(), false);
buffer.add(put1);
assertTrue("List MUST contain put container", buffer.getSortedList().contains(put1));
buffer.add(rm1);
16 years, 3 months
exo-jcr SVN: r1438 - 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: 2010-01-16 15:04:46 -0500 (Sat, 16 Jan 2010)
New Revision: 1438
Modified:
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/XASessionImpl.java
Log:
EXOJCR-405 comment RM add for XASession, exo tests hungs on version restore
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/XASessionImpl.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/XASessionImpl.java 2010-01-16 15:15:51 UTC (rev 1437)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/XASessionImpl.java 2010-01-16 20:04:46 UTC (rev 1438)
@@ -113,11 +113,12 @@
*/
public void delistResource() throws XAException
{
+ // TODO if session is dead? can we delist it?
try
{
if (LOG.isDebugEnabled())
LOG.debug("Delist session: " + getSessionInfo() + ", " + this);
- txResourceManager.remove(this);
+ //txResourceManager.remove(this);
tService.delistResource(this);
}
catch (RollbackException e)
@@ -135,11 +136,13 @@
*/
public void enlistResource() throws XAException
{
+
+ // TODO if session is dead? can we enlist it?
try
{
if (LOG.isDebugEnabled())
LOG.debug("Enlist session: " + getSessionInfo() + ", " + this);
- txResourceManager.add(this);
+ //txResourceManager.add(this);
tService.enlistResource(this);
}
catch (RollbackException e)
16 years, 3 months
exo-jcr SVN: r1437 - kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/transaction/impl/jotm.
by do-not-reply@jboss.org
Author: pnedonosko
Date: 2010-01-16 10:15:51 -0500 (Sat, 16 Jan 2010)
New Revision: 1437
Modified:
kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/transaction/impl/jotm/TransactionServiceJotmImpl.java
Log:
EXOJCR-410: track-without-transaction parameter added
Modified: kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/transaction/impl/jotm/TransactionServiceJotmImpl.java
===================================================================
--- kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/transaction/impl/jotm/TransactionServiceJotmImpl.java 2010-01-16 15:10:12 UTC (rev 1436)
+++ kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/transaction/impl/jotm/TransactionServiceJotmImpl.java 2010-01-16 15:15:51 UTC (rev 1437)
@@ -48,12 +48,15 @@
* Azarenkov</a>
* @version $Id: $
*/
-
public class TransactionServiceJotmImpl implements TransactionService
{
protected static Log log = ExoLogger.getLogger("transaction.TransactionServiceJotmImpl");
+ public static final String TRACK_WITHOT_TRANSACTION_PARAM = "track-without-transaction";
+
+ private boolean trackWithoutTransaction = true;
+
private Current current;
public TransactionServiceJotmImpl(InitialContextInitializer initializer, InitParams params) throws RemoteException
@@ -65,10 +68,20 @@
current = new Current(tm);
// Change the timeout only if JOTM is not initialized yet
- if (params != null && params.getValueParam("timeout") != null)
+ if (params != null)
{
- int t = Integer.parseInt(params.getValueParam("timeout").getValue());
- current.setDefaultTimeout(t);
+ if (params.getValueParam("timeout") != null)
+ {
+
+ int t = Integer.parseInt(params.getValueParam("timeout").getValue());
+ current.setDefaultTimeout(t);
+ }
+
+ if (params.getValueParam(TRACK_WITHOT_TRANSACTION_PARAM) != null)
+ {
+ trackWithoutTransaction =
+ Boolean.parseBoolean(params.getValueParam(TRACK_WITHOT_TRANSACTION_PARAM).getValue());
+ }
}
}
else
@@ -77,33 +90,24 @@
}
}
- /*
- * (non-Javadoc)
- * @see
- * org.exoplatform.services.transaction.TransactionService#getTransactionManager
- * ()
+ /**
+ * {@inheritDoc}
*/
public TransactionManager getTransactionManager()
{
return current;
}
- /*
- * (non-Javadoc)
- * @see
- * org.exoplatform.services.transaction.TransactionService#getUserTransaction
- * ()
+ /**
+ * {@inheritDoc}
*/
public UserTransaction getUserTransaction()
{
return current;
}
- /*
- * (non-Javadoc)
- * @see
- * org.exoplatform.services.transaction.TransactionService#enlistResource(
- * javax.transaction.xa.XAResource)
+ /**
+ * {@inheritDoc}
*/
public void enlistResource(ExoResource exores) throws RollbackException, SystemException
{
@@ -112,20 +116,22 @@
exores.setPayload(entry);
Transaction tx = getTransactionManager().getTransaction();
if (tx != null)
+ {
current.getTransaction().enlistResource(xares);
- else
+ }
+ else if (trackWithoutTransaction)
+ {
current.connectionOpened(entry);
- //
- entry.jotmResourceList = popThreadLocalRMEventList();
- pushThreadLocalRMEventList(entry.jotmResourceList);
+ // actual only if current.connectionOpened(entry);
+ // otherwise NPE inside the JOTM's Current
+ entry.jotmResourceList = popThreadLocalRMEventList();
+ pushThreadLocalRMEventList(entry.jotmResourceList);
+ }
}
- /*
- * (non-Javadoc)
- * @see
- * org.exoplatform.services.transaction.TransactionService#delistResource(
- * javax.transaction.xa.XAResource)
+ /**
+ * {@inheritDoc}
*/
public void delistResource(ExoResource exores) throws RollbackException, SystemException
{
@@ -133,42 +139,41 @@
ResourceEntry entry = (ResourceEntry)exores.getPayload();
Transaction tx = getTransactionManager().getTransaction();
if (tx != null)
+ {
current.getTransaction().delistResource(xares, XAResource.TMNOFLAGS);
- else
+ }
+ else if (trackWithoutTransaction)
+ {
current.connectionClosed(entry);
- //
+ // actual only if current.connectionClosed(entry);
+ if (entry != null && entry.jotmResourceList != null)
+ {
+ entry.jotmResourceList.remove(xares);
+ }
+ }
+
exores.setPayload(null);
- if (entry != null && entry.jotmResourceList != null)
- {
- entry.jotmResourceList.remove(xares);
- }
}
- /*
- * (non-Javadoc)
- * @see org.exoplatform.services.transaction.TransactionService#createXid()
+ /**
+ * {@inheritDoc}
*/
public Xid createXid()
{
return new XidImpl();
}
- /*
- * (non-Javadoc)
- * @see
- * org.exoplatform.services.transaction.TransactionService#getDefaultTimeout()
+ /**
+ * {@inheritDoc}
*/
public int getDefaultTimeout()
{
return current.getDefaultTimeout();
}
- /*
- * (non-Javadoc)
- * @see
- * org.exoplatform.services.transaction.TransactionService#setTransactionTimeout
- * (int)
+ /**
+ * {@inheritDoc}
*/
public void setTransactionTimeout(int seconds) throws SystemException
{
16 years, 3 months
exo-jcr SVN: r1436 - in jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock: jbosscache and 1 other directory.
by do-not-reply@jboss.org
Author: sergiykarpenko
Date: 2010-01-16 10:10:12 -0500 (Sat, 16 Jan 2010)
New Revision: 1436
Modified:
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/LockImpl.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManager.java
Log:
EXOJCR-332: getLockData fixed
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/LockImpl.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/LockImpl.java 2010-01-16 14:49:12 UTC (rev 1435)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/LockImpl.java 2010-01-16 15:10:12 UTC (rev 1436)
@@ -38,7 +38,7 @@
private SessionImpl session;
- // TODO remove this construector, need refactor lock classes ierarchy
+ // TODO remove this constructor, need refactor lock classes ierarchy
public LockImpl()
{
}
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManager.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManager.java 2010-01-16 14:49:12 UTC (rev 1435)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManager.java 2010-01-16 15:10:12 UTC (rev 1436)
@@ -86,9 +86,7 @@
*/
@Managed
@NameTemplate(@Property(key = "service", value = "lockmanager"))
-public class CacheableLockManager
- extends AbstractLockManager
- implements ItemsPersistenceListener, Startable
+public class CacheableLockManager extends AbstractLockManager implements ItemsPersistenceListener, Startable
{
/**
* The name to property time out.
@@ -172,16 +170,16 @@
* @param config
*/
public CacheableLockManager(WorkspacePersistentDataManager dataManager, WorkspaceEntry config)
- throws RepositoryConfigurationException
+ throws RepositoryConfigurationException
{
this(dataManager, config, null);
}
public CacheableLockManager(WorkspacePersistentDataManager dataManager, WorkspaceEntry config,
- LockPersister persister) throws RepositoryConfigurationException
+ LockPersister persister) throws RepositoryConfigurationException
{
- List<SimpleParameterEntry> paramenerts = config.getLockManager().getParameters();
-
+ List<SimpleParameterEntry> paramenerts = config.getLockManager().getParameters();
+
this.dataManager = dataManager;
if (config.getLockManager() != null)
{
@@ -193,8 +191,7 @@
else
{
lockTimeOut =
- config.getLockManager().getTimeout() > 0 ? config.getLockManager().getTimeout()
- : DEFAULT_LOCK_TIMEOUT;
+ config.getLockManager().getTimeout() > 0 ? config.getLockManager().getTimeout() : DEFAULT_LOCK_TIMEOUT;
}
}
@@ -208,11 +205,13 @@
// make cache
if (config.getLockManager() != null
- && (config.getLockManager().getCacheConfig() != null || (paramenerts != null && config
- .getLockManager().getParameterValue(JBOSSCACCHE_CONFIG, null) != null)))
+ && (config.getLockManager().getCacheConfig() != null || (paramenerts != null && config.getLockManager()
+ .getParameterValue(JBOSSCACCHE_CONFIG, null) != null)))
{
- String pathToConfig = (paramenerts != null && config.getLockManager().getParameterValue(JBOSSCACCHE_CONFIG, null) != null) ? config.getLockManager()
- .getParameterValue(JBOSSCACCHE_CONFIG) : config.getLockManager().getCacheConfig();
+ String pathToConfig =
+ (paramenerts != null && config.getLockManager().getParameterValue(JBOSSCACCHE_CONFIG, null) != null)
+ ? config.getLockManager().getParameterValue(JBOSSCACCHE_CONFIG) : config.getLockManager()
+ .getCacheConfig();
CacheFactory<Serializable, Object> factory = new DefaultCacheFactory<Serializable, Object>();
cache = factory.createCache(pathToConfig, false);
cache.create();
@@ -241,9 +240,9 @@
* .jcr.impl.core.NodeImpl, boolean, boolean, long)
*/
public synchronized Lock addPendingLock(NodeImpl node, boolean isDeep, boolean isSessionScoped, long timeOut)
- throws LockException
+ throws LockException
{
- LockData lData = getLockData((NodeData) node.getData(), SEARCH_EXECMATCH | SEARCH_CLOSEDPARENT);
+ LockData lData = getLockData((NodeData)node.getData(), SEARCH_EXECMATCH | SEARCH_CLOSEDPARENT);
if (lData != null)
{
if (lData.getNodeIdentifier().equals(node.getInternalIdentifier()))
@@ -256,7 +255,7 @@
}
}
- if (isDeep && getLockData((NodeData) node.getData(), SEARCH_CLOSEDCHILD) != null)
+ if (isDeep && getLockData((NodeData)node.getData(), SEARCH_CLOSEDCHILD) != null)
{
throw new LockException("Some child node is locked.");
}
@@ -291,7 +290,7 @@
public LockImpl getLock(NodeImpl node) throws LockException, RepositoryException
{
- LockData lData = getLockData((NodeData) node.getData(), SEARCH_EXECMATCH | SEARCH_CLOSEDPARENT);
+ LockData lData = getLockData((NodeData)node.getData(), SEARCH_EXECMATCH | SEARCH_CLOSEDPARENT);
if (lData == null || (!node.getInternalIdentifier().equals(lData.getNodeIdentifier()) && !lData.isDeep()))
{
@@ -363,7 +362,7 @@
*/
public boolean isLockHolder(NodeImpl node) throws RepositoryException
{
- LockData lData = getLockData((NodeData) node.getData(), SEARCH_EXECMATCH | SEARCH_CLOSEDPARENT);
+ LockData lData = getLockData((NodeData)node.getData(), SEARCH_EXECMATCH | SEARCH_CLOSEDPARENT);
return lData != null && isLockHolder(node.getSession().getId(), lData.getTokenHash());
}
@@ -383,7 +382,7 @@
*/
public synchronized void onCloseSession(ExtendedSession session)
{
- SessionImpl sessionImpl = (SessionImpl) session;
+ SessionImpl sessionImpl = (SessionImpl)session;
for (LockData lockData : getLockList())
{
@@ -396,8 +395,8 @@
// if no session currently holds lock except this
try
{
- ((NodeImpl) sessionImpl.getTransientNodesManager().getItemByIdentifier(lockData.getNodeIdentifier(),
- false)).unlock();
+ ((NodeImpl)sessionImpl.getTransientNodesManager().getItemByIdentifier(lockData.getNodeIdentifier(),
+ false)).unlock();
}
catch (UnsupportedRepositoryOperationException e)
{
@@ -435,7 +434,7 @@
List<PlainChangesLog> chengesLogList = new ArrayList<PlainChangesLog>();
if (changesLog instanceof TransactionChangesLog)
{
- ChangesLogIterator logIterator = ((TransactionChangesLog) changesLog).getLogIterator();
+ ChangesLogIterator logIterator = ((TransactionChangesLog)changesLog).getLogIterator();
while (logIterator.hasNextLog())
{
@@ -444,11 +443,11 @@
}
else if (changesLog instanceof PlainChangesLog)
{
- chengesLogList.add((PlainChangesLog) changesLog);
+ chengesLogList.add((PlainChangesLog)changesLog);
}
else if (changesLog instanceof CompositeChangesLog)
{
- for (ChangesLogIterator iter = ((CompositeChangesLog) changesLog).getLogIterator(); iter.hasNextLog();)
+ for (ChangesLogIterator iter = ((CompositeChangesLog)changesLog).getLogIterator(); iter.hasNextLog();)
{
chengesLogList.add(iter.nextLog());
}
@@ -465,7 +464,7 @@
if (currChangesLog.getSize() < 2)
{
log.error("Incorrect changes log of type ExtendedEvent.LOCK size=" + currChangesLog.getSize()
- + "<2 \n" + currChangesLog.dump());
+ + "<2 \n" + currChangesLog.dump());
break;
}
nodeIdentifier = currChangesLog.getAllStates().get(0).getData().getParentIdentifier();
@@ -483,12 +482,12 @@
if (currChangesLog.getSize() < 2)
{
log.error("Incorrect changes log of type ExtendedEvent.UNLOCK size=" + currChangesLog.getSize()
- + "<2 \n" + currChangesLog.dump());
+ + "<2 \n" + currChangesLog.dump());
break;
}
internalUnLock(currChangesLog.getSessionId(), currChangesLog.getAllStates().get(0).getData()
- .getParentIdentifier());
+ .getParentIdentifier());
break;
default :
HashSet<String> removedLock = new HashSet<String>();
@@ -548,7 +547,7 @@
else
{
throw new LockException("Can't refresh lock for node " + newLockData.getNodeIdentifier()
- + " since lock is not exist");
+ + " since lock is not exist");
}
}
}
@@ -652,8 +651,8 @@
// make a copy, value may be null for deleting items
TransientPropertyData newData =
- new TransientPropertyData(prop.getQPath(), prop.getIdentifier(), prop.getPersistedVersion(), prop
- .getType(), prop.getParentIdentifier(), prop.isMultiValued(), prop.getValues());
+ new TransientPropertyData(prop.getQPath(), prop.getIdentifier(), prop.getPersistedVersion(), prop.getType(),
+ prop.getParentIdentifier(), prop.isMultiValued(), prop.getValues());
return newData;
}
@@ -689,7 +688,7 @@
*/
private LockData getLockData(NodeData data, int searchType)
{
- if (data == null || getNumLocks() == 0)
+ if (data == null)
return null;
LockData retval = null;
try
@@ -701,7 +700,7 @@
if (retval == null && (searchType & SEARCH_CLOSEDPARENT) != 0)
{
- NodeData parentData = (NodeData) dataManager.getItemData(data.getParentIdentifier());
+ NodeData parentData = (NodeData)dataManager.getItemData(data.getParentIdentifier());
if (parentData != null)
{
retval = getLockDataById(parentData.getIdentifier());
@@ -772,12 +771,12 @@
node.setResident(true);
// this will return null if success. And old data if something exists...
- LockData oldLockData = (LockData) node.putIfAbsent(LOCK_DATA, lockData);
+ LockData oldLockData = (LockData)node.putIfAbsent(LOCK_DATA, lockData);
if (oldLockData != null)
{
throw new LockException("Unable to write LockData. Node [" + lockData.getNodeIdentifier()
- + "] already has LockData!");
+ + "] already has LockData!");
}
pendingLocks.remove(nodeIdentifier);
}
@@ -864,7 +863,7 @@
Node<Serializable, Object> node = lockRoot.getChild(Fqn.fromString(nodeId));
if (node != null)
{
- lockData = (LockData) node.get(LOCK_DATA);
+ lockData = (LockData)node.get(LOCK_DATA);
}
return lockData;
}
@@ -878,7 +877,7 @@
{
if (node != null)
{
- LockData lockData = (LockData) node.get(LOCK_DATA);
+ LockData lockData = (LockData)node.get(LOCK_DATA);
if (lockData != null)
{
locksData.add(lockData);
@@ -897,19 +896,17 @@
{
try
{
- NodeData nData = (NodeData) dataManager.getItemData(nodeIdentifier);
+ NodeData nData = (NodeData)dataManager.getItemData(nodeIdentifier);
PlainChangesLog changesLog =
- new PlainChangesLogImpl(new ArrayList<ItemState>(), SystemIdentity.SYSTEM, ExtendedEvent.UNLOCK);
+ new PlainChangesLogImpl(new ArrayList<ItemState>(), SystemIdentity.SYSTEM, ExtendedEvent.UNLOCK);
ItemData lockOwner =
- copyItemData((PropertyData) dataManager
- .getItemData(nData, new QPathEntry(Constants.JCR_LOCKOWNER, 1)));
+ copyItemData((PropertyData)dataManager.getItemData(nData, new QPathEntry(Constants.JCR_LOCKOWNER, 1)));
changesLog.add(ItemState.createDeletedState(lockOwner));
ItemData lockIsDeep =
- copyItemData((PropertyData) dataManager.getItemData(nData,
- new QPathEntry(Constants.JCR_LOCKISDEEP, 1)));
+ copyItemData((PropertyData)dataManager.getItemData(nData, new QPathEntry(Constants.JCR_LOCKISDEEP, 1)));
changesLog.add(ItemState.createDeletedState(lockIsDeep));
// lock probably removed by other thread
16 years, 3 months