[exo-jcr-commits] exo-jcr SVN: r1320 - in jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src: main/java/org/exoplatform/services/jcr/impl/dataflow/persistent and 2 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Fri Jan 8 05:30:56 EST 2010
Author: skabashnyuk
Date: 2010-01-08 05:30:56 -0500 (Fri, 08 Jan 2010)
New Revision: 1320
Modified:
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/persistent/WorkspaceStorageCache.java
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/LinkedWorkspaceStorageCacheImpl.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/WorkspaceStorageCacheBaseCase.java
Log:
EXOJCR-371 : enabled BufferedJbossCache in main code. TCK ok. exo test 1015 7 0 expected
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/persistent/WorkspaceStorageCache.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/persistent/WorkspaceStorageCache.java 2010-01-08 09:53:53 UTC (rev 1319)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/persistent/WorkspaceStorageCache.java 2010-01-08 10:30:56 UTC (rev 1320)
@@ -136,5 +136,23 @@
* @return long value
*/
long getSize();
+
+ /**
+ * Start buffering process.
+ */
+ public void beginTransaction();
+
+ /**
+ * Sort changes and commit data to the cache.
+ */
+ public void commitTransaction();
+
+
+ /**
+ * Forget about changes
+ */
+ public void rollbackTransaction();
+
+
}
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-08 09:53:53 UTC (rev 1319)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java 2010-01-08 10:30:56 UTC (rev 1320)
@@ -198,8 +198,12 @@
{
try
{
+
transactionManager.begin();
+ transactionManager.setTransactionTimeout(900000);
+ cache.beginTransaction();
super.save(changesLog);
+ cache.commitTransaction();
transactionManager.commit();
}
catch (RollbackException e)
@@ -211,6 +215,7 @@
{
try
{
+ cache.rollbackTransaction();
transactionManager.rollback();
}
catch (Exception e1)
@@ -224,6 +229,7 @@
{
try
{
+ cache.rollbackTransaction();
transactionManager.rollback();
}
catch (Exception e1)
@@ -231,12 +237,35 @@
// Treat the exception
throw new RepositoryException(e1.getLocalizedMessage(), e1.getCause());
}
+ e.printStackTrace();
throw new RepositoryException(e.getLocalizedMessage(), e.getCause());
}
}
}
+ /**
+ * Start buffering process.
+ */
+ public void beginTransaction()
+ {
+ }
+
/**
+ * Sort changes and commit data to the cache.
+ */
+ public void commitTransaction()
+ {
+
+ }
+
+ /**
+ * Forget about changes
+ */
+ public void rollbackTransaction()
+ {
+
+ }
+ /**
* Get cached ItemData.
*
* @param parentData
@@ -322,7 +351,9 @@
else
{
transactionManager.begin();
+ cache.beginTransaction();
cache.addChildNodes(parentData, childNodes);
+ cache.commitTransaction();
transactionManager.commit();
}
}
@@ -335,6 +366,7 @@
{
try
{
+ cache.rollbackTransaction();
transactionManager.rollback();
}
catch (Exception e1)
@@ -411,7 +443,9 @@
else
{
transactionManager.begin();
+ cache.beginTransaction();
cache.addChildProperties(parentData, childProperties);
+ cache.commitTransaction();
transactionManager.commit();
}
}
@@ -424,6 +458,7 @@
{
try
{
+ cache.rollbackTransaction();
transactionManager.rollback();
}
catch (Exception e1)
@@ -476,7 +511,9 @@
else
{
transactionManager.begin();
+ cache.beginTransaction();
cache.put(data);
+ cache.commitTransaction();
transactionManager.commit();
}
}
@@ -489,6 +526,7 @@
{
try
{
+ cache.rollbackTransaction();
transactionManager.rollback();
}
catch (Exception e1)
@@ -530,7 +568,9 @@
else
{
transactionManager.begin();
+ cache.beginTransaction();
cache.put(data);
+ cache.commitTransaction();
transactionManager.commit();
}
}
@@ -543,6 +583,7 @@
{
try
{
+ cache.rollbackTransaction();
transactionManager.rollback();
}
catch (Exception e1)
@@ -610,7 +651,9 @@
else
{
transactionManager.begin();
+ cache.beginTransaction();
cache.addChildPropertiesList(parentData, propertiesList);
+ cache.commitTransaction();
transactionManager.commit();
}
}
@@ -623,6 +666,7 @@
{
try
{
+ cache.rollbackTransaction();
transactionManager.rollback();
}
catch (Exception e1)
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/LinkedWorkspaceStorageCacheImpl.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/LinkedWorkspaceStorageCacheImpl.java 2010-01-08 09:53:53 UTC (rev 1319)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/LinkedWorkspaceStorageCacheImpl.java 2010-01-08 10:30:56 UTC (rev 1320)
@@ -1877,4 +1877,22 @@
return res.toString();
}
+
+ public void beginTransaction()
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void commitTransaction()
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void rollbackTransaction()
+ {
+ // TODO Auto-generated method stub
+
+ }
}
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-08 09:53:53 UTC (rev 1319)
+++ 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-08 10:30:56 UTC (rev 1320)
@@ -120,7 +120,7 @@
public static final Set<String> NO_CHILDS = Collections.emptySet();
- protected final Cache<Serializable, Object> cache;
+ protected final BufferedJbossCache cache;
protected final Fqn<String> itemsRoot;
@@ -270,7 +270,7 @@
{
CacheFactory<Serializable, Object> factory = new DefaultCacheFactory<Serializable, Object>();
LOG.info("JBoss Cache configuration used: " + jbcConfig);
- this.cache = factory.createCache(jbcConfig, false);
+ this.cache = new BufferedJbossCache(factory.createCache(jbcConfig, false));
this.cache.create();
this.cache.start();
@@ -347,7 +347,7 @@
*/
public TransactionManager getTransactionManager()
{
- return ((CacheSPI<Serializable, Object>)cache).getTransactionManager();
+ return cache.getTransactionManager();
}
/**
@@ -822,7 +822,7 @@
if (prevData != null)
{
// do update ACL if needed
- if (!prevData.getACL().equals(node.getACL()))
+ if (prevData.getACL() == null || !prevData.getACL().equals(node.getACL()))
{
updateChildsACL(node.getIdentifier(), node.getACL());
}
@@ -959,4 +959,22 @@
}
}
+ public void beginTransaction()
+ {
+ cache.beginTransaction();
+
+ }
+
+ public void commitTransaction()
+ {
+ cache.commitTransaction();
+
+ }
+
+ public void rollbackTransaction()
+ {
+ cache.rollbackTransaction();
+
+ }
+
}
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspaceStorageCacheBaseCase.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspaceStorageCacheBaseCase.java 2010-01-08 09:53:53 UTC (rev 1319)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspaceStorageCacheBaseCase.java 2010-01-08 10:30:56 UTC (rev 1320)
@@ -289,10 +289,19 @@
initNodesData();
initDataAsPersisted();
- cache.put(nodeData1);
- cache.put(nodeData2);
- cache.put(propertyData12);
-
+ try
+ {
+ cache.beginTransaction();
+ cache.put(nodeData1);
+ cache.put(nodeData2);
+ cache.put(propertyData12);
+ cache.commitTransaction();
+ }
+ catch (Exception e)
+ {
+ cache.rollbackTransaction();
+ throw e;
+ }
assertEquals("Cached node " + nodeData1.getQPath().getAsString() + " is not equals", cache.get(rootUuid,
nodePath1.getEntries()[nodePath1.getEntries().length - 1]), nodeData1);
assertEquals("Cached node " + nodeData2.getQPath().getAsString() + " is not equals", cache.get(rootUuid,
@@ -316,22 +325,30 @@
List<NodeData> nodes = new ArrayList<NodeData>();
nodes.add(nodeData31);
nodes.add(nodeData32);
- cache.addChildNodes(nodeData3, nodes);
+ try
+ {
+ cache.beginTransaction();
+ cache.addChildNodes(nodeData3, nodes);
- cache.put(nodeData1);
- cache.put(nodeData2);
- cache.put(propertyData12);
+ cache.put(nodeData1);
+ cache.put(nodeData2);
+ cache.put(propertyData12);
- List<PropertyData> properties2 = new ArrayList<PropertyData>();
- properties2.add(propertyData21);
- properties2.add(propertyData22);
- cache.addChildProperties(nodeData2, properties2);
+ List<PropertyData> properties2 = new ArrayList<PropertyData>();
+ properties2.add(propertyData21);
+ properties2.add(propertyData22);
+ cache.addChildProperties(nodeData2, properties2);
- List<PropertyData> properties1 = new ArrayList<PropertyData>();
- properties1.add(propertyData11);
- properties1.add(propertyData12);
- cache.addChildProperties(nodeData1, properties1);
-
+ List<PropertyData> properties1 = new ArrayList<PropertyData>();
+ properties1.add(propertyData11);
+ properties1.add(propertyData12);
+ cache.addChildProperties(nodeData1, properties1);
+ }
+ catch (Exception e)
+ {
+ cache.rollbackTransaction();
+ throw e;
+ }
// prev stuff
assertEquals("Cached " + nodeData1.getQPath().getAsString() + " is not equals", cache.get(rootUuid, nodePath1
.getEntries()[nodePath1.getEntries().length - 1]), nodeData1);
@@ -400,22 +417,30 @@
List<NodeData> nodes = new ArrayList<NodeData>();
nodes.add(nodeData31);
nodes.add(nodeData32);
- cache.addChildNodes(nodeData3, nodes);
+ try
+ {
+ cache.beginTransaction();
+ cache.addChildNodes(nodeData3, nodes);
- cache.put(nodeData1);
- cache.put(nodeData2);
- cache.put(propertyData12);
+ cache.put(nodeData1);
+ cache.put(nodeData2);
+ cache.put(propertyData12);
- List<PropertyData> properties2 = new ArrayList<PropertyData>();
- properties2.add(propertyData21);
- properties2.add(propertyData22);
- cache.addChildProperties(nodeData2, properties2);
+ List<PropertyData> properties2 = new ArrayList<PropertyData>();
+ properties2.add(propertyData21);
+ properties2.add(propertyData22);
+ cache.addChildProperties(nodeData2, properties2);
- List<PropertyData> properties1 = new ArrayList<PropertyData>();
- properties1.add(propertyData11);
- properties1.add(propertyData12);
- cache.addChildProperties(nodeData1, properties1);
-
+ List<PropertyData> properties1 = new ArrayList<PropertyData>();
+ properties1.add(propertyData11);
+ properties1.add(propertyData12);
+ cache.addChildProperties(nodeData1, properties1);
+ }
+ catch (Exception e)
+ {
+ cache.rollbackTransaction();
+ throw e;
+ }
// props, prev stuff
assertEquals("Cached child property " + propertyData11.getQPath().getAsString() + " is not equals", cache.get(
nodeUuid1, propertyPath11.getEntries()[propertyPath11.getEntries().length - 1]), propertyData11);
@@ -494,32 +519,39 @@
initNodesData();
initDataAsPersisted();
+ try
+ {
+ cache.beginTransaction();
+ // the case here
+ cache.put(nodeData3);
+ List<NodeData> n3childNodes = new ArrayList<NodeData>();
+ n3childNodes.add(nodeData31);
+ n3childNodes.add(nodeData32);
+ cache.addChildNodes(nodeData3, n3childNodes);
- // the case here
- cache.put(nodeData3);
- List<NodeData> n3childNodes = new ArrayList<NodeData>();
- n3childNodes.add(nodeData31);
- n3childNodes.add(nodeData32);
- cache.addChildNodes(nodeData3, n3childNodes);
+ // any stuff
+ cache.put(nodeData1);
+ cache.put(nodeData2);
+ cache.put(propertyData12);
- // any stuff
- cache.put(nodeData1);
- cache.put(nodeData2);
- cache.put(propertyData12);
+ List<PropertyData> properties2 = new ArrayList<PropertyData>();
+ properties2.add(propertyData21);
+ properties2.add(propertyData22);
+ cache.addChildProperties(nodeData2, properties2);
- List<PropertyData> properties2 = new ArrayList<PropertyData>();
- properties2.add(propertyData21);
- properties2.add(propertyData22);
- cache.addChildProperties(nodeData2, properties2);
+ List<PropertyData> properties1 = new ArrayList<PropertyData>();
+ properties1.add(propertyData11);
+ properties1.add(propertyData12);
+ cache.addChildProperties(nodeData1, properties1);
- List<PropertyData> properties1 = new ArrayList<PropertyData>();
- properties1.add(propertyData11);
- properties1.add(propertyData12);
- cache.addChildProperties(nodeData1, properties1);
-
- // remove
- cache.remove(nodeData3); // remove node3 and its childs (31, 32)
-
+ // remove
+ cache.remove(nodeData3); // remove node3 and its childs (31, 32)
+ }
+ catch (Exception e)
+ {
+ cache.rollbackTransaction();
+ throw e;
+ }
// check
assertNull("Node " + nodeData3.getQPath().getAsString() + " in the cache", cache.get(nodeUuid3));
assertNull("Node " + nodeData3.getQPath().getAsString() + " childs in the cache", cache.getChildNodes(nodeData3));
@@ -535,20 +567,28 @@
List<PropertyData> properties2 = new ArrayList<PropertyData>();
properties2.add(propertyData21);
properties2.add(propertyData22);
- cache.addChildProperties(nodeData2, properties2);
+ try
+ {
+ cache.beginTransaction();
+ cache.addChildProperties(nodeData2, properties2);
- // any stuff
- cache.put(nodeData3);
- cache.put(nodeData31);
+ // any stuff
+ cache.put(nodeData3);
+ cache.put(nodeData31);
- List<PropertyData> properties1 = new ArrayList<PropertyData>();
- properties1.add(propertyData11);
- properties1.add(propertyData12);
- cache.addChildProperties(nodeData1, properties1);
+ List<PropertyData> properties1 = new ArrayList<PropertyData>();
+ properties1.add(propertyData11);
+ properties1.add(propertyData12);
+ cache.addChildProperties(nodeData1, properties1);
- // remove
- cache.remove(nodeData2); // remove node2 and its childs (21, 22)
-
+ // remove
+ cache.remove(nodeData2); // remove node2 and its childs (21, 22)
+ }
+ catch (Exception e)
+ {
+ cache.rollbackTransaction();
+ throw e;
+ }
// check
assertNull("Node " + nodeData2.getQPath().getAsString() + " in the cache", cache.get(nodeUuid2));
assertNull("Node " + nodeData2.getQPath().getAsString() + " properties in the cache", cache
@@ -565,33 +605,41 @@
List<PropertyData> properties2 = new ArrayList<PropertyData>();
properties2.add(propertyData21);
properties2.add(propertyData22);
- cache.addChildProperties(nodeData2, properties2);
+ try
+ {
+ cache.beginTransaction();
+ cache.addChildProperties(nodeData2, properties2);
- List<NodeData> nodes2 = new ArrayList<NodeData>();
- nodes2.add(nodeData21);
- nodes2.add(nodeData22);
- cache.addChildNodes(nodeData2, nodes2);
+ List<NodeData> nodes2 = new ArrayList<NodeData>();
+ nodes2.add(nodeData21);
+ nodes2.add(nodeData22);
+ cache.addChildNodes(nodeData2, nodes2);
- // any stuff
- cache.put(nodeData3);
- cache.put(nodeData31);
- cache.put(nodeData32);
+ // any stuff
+ cache.put(nodeData3);
+ cache.put(nodeData31);
+ cache.put(nodeData32);
- List<PropertyData> properties1 = new ArrayList<PropertyData>();
- properties1.add(propertyData11);
- properties1.add(propertyData12);
- cache.addChildProperties(nodeData1, properties1);
+ List<PropertyData> properties1 = new ArrayList<PropertyData>();
+ properties1.add(propertyData11);
+ properties1.add(propertyData12);
+ cache.addChildProperties(nodeData1, properties1);
- // remove
- PlainChangesLog chlog = new PlainChangesLogImpl();
- chlog.add(ItemState.createDeletedState(propertyData21));
- chlog.add(ItemState.createDeletedState(propertyData22));
- chlog.add(ItemState.createDeletedState(nodeData21));
- chlog.add(ItemState.createDeletedState(nodeData22));
- chlog.add(ItemState.createDeletedState(nodeData2));
- // cache.remove(nodeData2); // remove node2 and its childs and properties (21, 22)
- cache.onSaveItems(chlog);
-
+ // remove
+ PlainChangesLog chlog = new PlainChangesLogImpl();
+ chlog.add(ItemState.createDeletedState(propertyData21));
+ chlog.add(ItemState.createDeletedState(propertyData22));
+ chlog.add(ItemState.createDeletedState(nodeData21));
+ chlog.add(ItemState.createDeletedState(nodeData22));
+ chlog.add(ItemState.createDeletedState(nodeData2));
+ // cache.remove(nodeData2); // remove node2 and its childs and properties (21, 22)
+ cache.onSaveItems(chlog);
+ }
+ catch (Exception e)
+ {
+ cache.rollbackTransaction();
+ throw e;
+ }
// check
assertNull("Node " + nodeData2.getQPath().getAsString() + " in the cache", cache.get(nodeUuid2));
More information about the exo-jcr-commits
mailing list