Author: nzamosenchuk
Date: 2009-11-18 11:16:19 -0500 (Wed, 18 Nov 2009)
New Revision: 754
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/JBossCacheWorkspaceDataManager.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java
Log:
EXOJCR-242: small updates of locking code
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/JBossCacheWorkspaceDataManager.java
===================================================================
---
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/JBossCacheWorkspaceDataManager.java 2009-11-18
16:03:40 UTC (rev 753)
+++
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/JBossCacheWorkspaceDataManager.java 2009-11-18
16:16:19 UTC (rev 754)
@@ -25,7 +25,6 @@
import org.exoplatform.services.jcr.dataflow.LockPlainChangesLogImpl;
import org.exoplatform.services.jcr.dataflow.PlainChangesLog;
import org.exoplatform.services.jcr.dataflow.ReadOnlyThroughChanges;
-import org.exoplatform.services.jcr.dataflow.TransactionChangesLog;
import org.exoplatform.services.jcr.datamodel.QPath;
import org.exoplatform.services.jcr.impl.Constants;
import org.exoplatform.services.jcr.impl.core.lock.LockData;
@@ -96,7 +95,7 @@
{
for (PlainChangesLog curChangesLog : chengesLogList)
{
- // if this is LOCK or UNLOCK changes log, then put or remove lock data from
cache
+ // if this is LOCK or UNLOCK changes log, then put or remove lock data to or
from cache
if (curChangesLog.getEventType() == ExtendedEvent.LOCK
|| curChangesLog.getEventType() == ExtendedEvent.UNLOCK)
{
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java
===================================================================
---
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java 2009-11-18
16:03:40 UTC (rev 753)
+++
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java 2009-11-18
16:16:19 UTC (rev 754)
@@ -703,22 +703,32 @@
throw new RepositoryException("Lock data to write can't be
null!");
}
// check that there is no lock data for given node
- Node<Serializable, Object> oldNode =
locksRoot.getChild(makeNodeFqn(lockData.getNodeIdentifier()));
- if (oldNode.get(JBossCacheStorage.LOCK_DATA) != null)
+ Node<Serializable, Object> node =
locksRoot.getChild(makeNodeFqn(lockData.getNodeIdentifier()));
+ // node is not null: check if lockData exists
+ if (node != null)
{
- throw new LockException("Unable to write lock data. Node [" +
lockData.getNodeIdentifier()
- + "] already has LockData!");
+ LockData oldLockData = (LockData)node.get(JBossCacheStorage.LOCK_DATA);
+ // if old data exists and hash differs, then it was newly locked! Exception,
can't lock
+ // already locked node.
+ if (oldLockData != null && oldLockData.getTokenHash() !=
lockData.getTokenHash())
+ {
+ throw new LockException("Unable to write lock data. Node [" +
lockData.getNodeIdentifier()
+ + "] already has LockData!");
+ }
}
+ else
+ {
+ // JBoss node doesn't exists, create it
+ node = locksRoot.addChild(makeNodeFqn(lockData.getNodeIdentifier()));
+ node.setResident(true);
+ }
// try to write LockData
- Node<Serializable, Object> node =
locksRoot.addChild(makeNodeFqn(lockData.getNodeIdentifier()));
if (node == null)
{
throw new RepositoryException("Unable to write to cache!");
}
// this will prevent from deleting it by eviction.
- node.setResident(true);
node.put(JBossCacheStorage.LOCK_DATA, lockData);
-
}
/**
Show replies by date