exo-jcr SVN: r2188 - in jcr/trunk/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: nzamosenchuk
Date: 2010-03-30 06:54:11 -0400 (Tue, 30 Mar 2010)
New Revision: 2188
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java
Log:
EXOJCR-609: 1. In JbossCacheWSC - if property list is empty - notify with the warning. This is abnormal situation. At least "jcr:primaryType" should exists.
2. In CacheableWorkspaceDM - use equals(), instead of "==" when checking if nodeData in cache is null-stub-nodeData. Cause "==" will not work in cluster.
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java 2010-03-30 09:38:54 UTC (rev 2187)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java 2010-03-30 10:54:11 UTC (rev 2188)
@@ -44,7 +44,7 @@
import javax.transaction.TransactionManager;
/**
- * Created by The eXo Platform SAS.
+ * Created by The eXo Platform SAS.
*
* <br/>
* Author : Peter Nedonosko peter.nedonosko(a)exoplatform.com.ua
@@ -58,7 +58,7 @@
* The identifier of the <code>null</code> value
*/
protected static final String ITEM_DATA_NULL_VALUE_ID = "$";
-
+
/**
* The name of the <code>null</code> value
*/
@@ -121,6 +121,26 @@
return null;
}
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (obj == this)
+ {
+ return true;
+ }
+
+ if (obj == null)
+ {
+ return false;
+ }
+
+ if (obj instanceof NodeData)
+ {
+ return getIdentifier().equals(((ItemData)obj).getIdentifier());
+ }
+
+ return false;
+ }
};
/**
@@ -353,7 +373,7 @@
* Items cache
* @param systemDataContainerHolder
* System Workspace data container (persistent level)
- * @param transactionService TransactionService
+ * @param transactionService TransactionService
*/
public CacheableWorkspaceDataManager(WorkspaceDataContainer dataContainer, WorkspaceStorageCache cache,
SystemDataContainerHolder systemDataContainerHolder, TransactionService transactionService)
@@ -409,6 +429,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public int getChildNodesCount(NodeData parent) throws RepositoryException
{
if (cache.isEnabled())
@@ -426,6 +447,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public List<NodeData> getChildNodesData(NodeData nodeData) throws RepositoryException
{
return getChildNodesData(nodeData, false);
@@ -434,6 +456,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public List<PropertyData> getChildPropertiesData(NodeData nodeData) throws RepositoryException
{
List<PropertyData> childs = getChildPropertiesData(nodeData, false);
@@ -448,6 +471,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ItemData getItemData(NodeData parentData, QPathEntry name) throws RepositoryException
{
@@ -472,7 +496,7 @@
else if (!data.isNode())
{
fixPropertyValues((PropertyData)data);
- }
+ }
}
finally
{
@@ -484,12 +508,13 @@
fixPropertyValues((PropertyData)data);
}
- return data == ITEM_DATA_NULL_VALUE ? null : data;
+ return ITEM_DATA_NULL_VALUE.equals(data) ? null : data;
}
/**
* {@inheritDoc}
*/
+ @Override
public ItemData getItemData(String identifier) throws RepositoryException
{
// 2. Try from cache
@@ -525,14 +550,15 @@
fixPropertyValues((PropertyData)data);
}
- return data == ITEM_DATA_NULL_VALUE ? null : data;
+ return ITEM_DATA_NULL_VALUE.equals(data) ? null : data;
}
/**
* {@inheritDoc}
*/
+ @Override
public List<PropertyData> getReferencesData(String identifier, boolean skipVersionStorage)
- throws RepositoryException
+ throws RepositoryException
{
return super.getReferencesData(identifier, skipVersionStorage);
}
@@ -540,6 +566,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public List<PropertyData> listChildPropertiesData(NodeData nodeData) throws RepositoryException
{
return listChildPropertiesData(nodeData, false);
@@ -558,7 +585,7 @@
}
else
{
- // save normaly
+ // save normaly
super.save(changesLog);
// notify listeners after storage commit
@@ -608,7 +635,7 @@
* Repository error
*/
protected List<NodeData> getChildNodesData(NodeData nodeData, boolean forcePersistentRead)
- throws RepositoryException
+ throws RepositoryException
{
List<NodeData> childNodes = null;
@@ -665,7 +692,7 @@
* Repository error
*/
protected List<PropertyData> getChildPropertiesData(NodeData nodeData, boolean forcePersistentRead)
- throws RepositoryException
+ throws RepositoryException
{
List<PropertyData> childProperties = null;
@@ -761,7 +788,7 @@
* Repository error
*/
protected List<PropertyData> listChildPropertiesData(NodeData nodeData, boolean forcePersistentRead)
- throws RepositoryException
+ throws RepositoryException
{
List<PropertyData> propertiesList;
@@ -852,10 +879,10 @@
* @param prop PropertyData, original Property data
* @return PropertyData
* @throws IllegalStateException
- * @throws RepositoryException
+ * @throws RepositoryException
*/
protected ValueData getPropertyValue(String propertyId, int orderNumb, int persistedVersion)
- throws IllegalStateException, RepositoryException
+ throws IllegalStateException, RepositoryException
{
// TODO use interface not JDBC
JDBCStorageConnection conn = (JDBCStorageConnection)dataContainer.openConnection();
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java 2010-03-30 09:38:54 UTC (rev 2187)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java 2010-03-30 10:54:11 UTC (rev 2188)
@@ -65,24 +65,24 @@
* <ul>
* <li>/$ITEMS - stores items by Id (i.e. /$ITEMS/itemId)</li>
* <li>/$CHILD_NODES, /$CHILD_PROPS - stores items by parentId and name (i.e. /$CHILD_NODES/parentId/childName.$ITEM_ID)</li>
- * <li>/$CHILD_NODES_LIST, /$CHILD_PROPS_LIST - stores child list by parentId and child Id
+ * <li>/$CHILD_NODES_LIST, /$CHILD_PROPS_LIST - stores child list by parentId and child Id
* (i.e. /$CHILD_NODES_LIST/parentId.lists = serialized Set<Object>)</li>
* </ul>
- * </li>
+ * </li>
* <li>all child properties/nodes lists should be evicted from parent at same time
* i.e. for /$CHILD_NODES_LIST, /$CHILD_PROPS_LIST we need customized eviction policy (EvictionActionPolicy) to evict
* whole list on one of childs eviction
- * </li>
+ * </li>
* </ul>
*
- * <p/>
- * Current state notes (subject of change):
+ * <p/>
+ * Current state notes (subject of change):
* <ul>
* <li>cache implements WorkspaceStorageCache, without any stuff about references and locks</li>
* <li>transaction style implemented via JBC barches, do with JTA (i.e. via exo's TransactionService + JBoss TM)</li>
* <li>we need customized eviction policy (EvictionActionPolicy) for /$CHILD_NODES_LIST, /$CHILD_PROPS_LIST</li>
* </ul>
- *
+ *
* @author <a href="mailto:peter.nedonosko@exoplatform.com">Peter Nedonosko</a>
* @version $Id: JBossCacheWorkspaceStorageCache.java 13869 2008-05-05 08:40:10Z pnedonosko $
*/
@@ -253,7 +253,7 @@
*/
public JBossCacheWorkspaceStorageCache(WorkspaceEntry wsConfig, TransactionService transactionService,
ConfigurationManager cfm) throws RepositoryException, RepositoryConfigurationException
- {
+ {
if (wsConfig.getCache() == null)
{
throw new RepositoryConfigurationException("Cache configuration not found");
@@ -287,17 +287,17 @@
createResidentNode(childProps);
createResidentNode(childPropsList);
createResidentNode(itemsRoot);
- }
+ }
/**
* Cache constructor with JBossCache JTA transaction support.
*
- * @param wsConfig WorkspaceEntry workspace config
+ * @param wsConfig WorkspaceEntry workspace config
* @throws RepositoryException if error of initialization
* @throws RepositoryConfigurationException if error of configuration
*/
public JBossCacheWorkspaceStorageCache(WorkspaceEntry wsConfig, ConfigurationManager cfm)
- throws RepositoryException, RepositoryConfigurationException
+ throws RepositoryException, RepositoryConfigurationException
{
this(wsConfig, null, cfm);
}
@@ -336,7 +336,7 @@
/**
* Return TransactionManager used by JBossCache backing the JCR cache.
*
- * @return TransactionManager
+ * @return TransactionManager
*/
public TransactionManager getTransactionManager()
{
@@ -406,8 +406,8 @@
{
if (state.isPersisted())
{
- // There was a problem with removing a list of samename siblings in on transaction,
- // so putItemInBufferedCache(..) and updateInBufferedCache(..) used instead put(..) and update (..) methods.
+ // There was a problem with removing a list of samename siblings in on transaction,
+ // so putItemInBufferedCache(..) and updateInBufferedCache(..) used instead put(..) and update (..) methods.
ItemData prevItem = putItemInBufferedCache(state.getData());
if (prevItem != null && state.isNode())
{
@@ -446,8 +446,8 @@
}
/**
- * {@inheritDoc}
- */
+ * {@inheritDoc}
+ */
public void addChildNodes(NodeData parent, List<NodeData> childs)
{
boolean inTransaction = cache.isTransactionActive();
@@ -517,7 +517,9 @@
}
else
{
- cache.put(makeChildListFqn(childPropsList, parent.getIdentifier()), ITEM_LIST, Collections.EMPTY_SET);
+ // This is really critical situation! Anywhere at least jcr:primaryType should be!
+ // At least warn to know is something happens.
+ LOG.warn("Empty properties list cached " + (parent != null ? parent.getQPath().getAsString() : parent));
}
}
finally
@@ -540,7 +542,7 @@
// {
// cache.beginTransaction();
// cache.setLocal(true);
- //
+ //
// }
// finally
// {
@@ -631,7 +633,7 @@
/**
* Internal get child properties.
*
- * @param parentId String
+ * @param parentId String
* @param withValue boolean, if true only "full" Propeties can be returned
* @return List of PropertyData
*/
@@ -776,7 +778,7 @@
{
// add in CHILD_NODES
cache.put(makeChildFqn(childNodes, node.getParentIdentifier(), node.getQPath().getEntries()[node.getQPath()
- .getEntries().length - 1]), ITEM_ID, node.getIdentifier());
+ .getEntries().length - 1]), ITEM_ID, node.getIdentifier());
// if MODIFY and List present OR FORCE_MODIFY, then write
if ((modifyListsOfChild == ModifyChildOption.MODIFY && cache.getNode(makeChildListFqn(childNodesList, node
.getParentIdentifier())) != null)
@@ -797,7 +799,7 @@
{
// add in CHILD_NODES
cache.put(makeChildFqn(childNodes, node.getParentIdentifier(), node.getQPath().getEntries()[node.getQPath()
- .getEntries().length - 1]), ITEM_ID, node.getIdentifier());
+ .getEntries().length - 1]), ITEM_ID, node.getIdentifier());
// if MODIFY and List present OR FORCE_MODIFY, then write
if ((modifyListsOfChild == ModifyChildOption.MODIFY && cache.getNode(makeChildListFqn(childNodesList, node
.getParentIdentifier())) != null)
@@ -821,7 +823,7 @@
{
// add in CHILD_PROPS
cache.put(makeChildFqn(childProps, prop.getParentIdentifier(), prop.getQPath().getEntries()[prop.getQPath()
- .getEntries().length - 1]), ITEM_ID, prop.getIdentifier());
+ .getEntries().length - 1]), ITEM_ID, prop.getIdentifier());
// if MODIFY and List present OR FORCE_MODIFY, then write
if ((modifyListsOfChild == ModifyChildOption.MODIFY && cache.getNode(makeChildListFqn(childPropsList, prop
.getParentIdentifier())) != null)
@@ -843,7 +845,7 @@
// remove from CHILD_NODES of parent
cache.removeNode(makeChildFqn(childNodes, item.getParentIdentifier(), item.getQPath().getEntries()[item
- .getQPath().getEntries().length - 1]));
+ .getQPath().getEntries().length - 1]));
// remove from CHILD_NODES_LIST of parent
cache.removeFromList(makeChildListFqn(childNodesList, item.getParentIdentifier()), ITEM_LIST, item
@@ -866,7 +868,7 @@
{
// remove from CHILD_PROPS
cache.removeNode(makeChildFqn(childProps, item.getParentIdentifier(), item.getQPath().getEntries()[item
- .getQPath().getEntries().length - 1]));
+ .getQPath().getEntries().length - 1]));
// remove from CHILD_PROPS_LIST
cache.removeFromList(makeChildListFqn(childPropsList, item.getParentIdentifier()), ITEM_LIST, item
@@ -899,7 +901,7 @@
}
/**
- * Update Node hierachy in case of same-name siblings reorder.
+ * Update Node hierachy in case of same-name siblings reorder.
* Assumes the new (updated) nodes already putted in the cache. Previous name of updated nodes will be calculated
* and that node will be deleted (if has same id as the new node). Childs paths will be updated to a new node path.
*
@@ -911,7 +913,7 @@
// get previously cached NodeData and using its name remove child on the parent
Fqn<String> prevFqn =
makeChildFqn(childNodes, node.getParentIdentifier(), prevNode.getQPath().getEntries()[prevNode.getQPath()
- .getEntries().length - 1]);
+ .getEntries().length - 1]);
if (node.getIdentifier().equals(cache.get(prevFqn, ITEM_ID)))
{
// it's same-name siblings re-ordering, delete previous child
@@ -941,7 +943,7 @@
// get previously cached NodeData and using its name remove child on the parent
Fqn<String> prevFqn =
makeChildFqn(childNodes, node.getParentIdentifier(), prevNode.getQPath().getEntries()[prevNode.getQPath()
- .getEntries().length - 1]);
+ .getEntries().length - 1]);
if (node.getIdentifier().equals(cache.getFromBuffer(prevFqn, ITEM_ID)))
{
// it's same-name siblings re-ordering, delete previous child
@@ -977,15 +979,15 @@
PropertyData prevProp = iter.next();
if (inheritACL
- && (prevProp.getQPath().getName().equals(Constants.EXO_PERMISSIONS) || prevProp.getQPath().getName()
- .equals(Constants.EXO_OWNER)))
+ && (prevProp.getQPath().getName().equals(Constants.EXO_PERMISSIONS) || prevProp.getQPath().getName()
+ .equals(Constants.EXO_OWNER)))
{
inheritACL = false;
}
// recreate with new path for child Props only
QPath newPath =
QPath
- .makeChildPath(rootPath, prevProp.getQPath().getEntries()[prevProp.getQPath().getEntries().length - 1]);
+ .makeChildPath(rootPath, prevProp.getQPath().getEntries()[prevProp.getQPath().getEntries().length - 1]);
TransientPropertyData newProp =
new TransientPropertyData(newPath, prevProp.getIdentifier(), prevProp.getPersistedVersion(), prevProp
.getType(), prevProp.getParentIdentifier(), prevProp.isMultiValued(), prevProp.getValues());
@@ -999,7 +1001,7 @@
// recreate with new path for child Nodes only
QPath newPath =
QPath
- .makeChildPath(rootPath, prevNode.getQPath().getEntries()[prevNode.getQPath().getEntries().length - 1]);
+ .makeChildPath(rootPath, prevNode.getQPath().getEntries()[prevNode.getQPath().getEntries().length - 1]);
TransientNodeData newNode =
new TransientNodeData(newPath, prevNode.getIdentifier(), prevNode.getPersistedVersion(), prevNode
.getPrimaryTypeName(), prevNode.getMixinTypeNames(), prevNode.getOrderNumber(), prevNode
@@ -1034,7 +1036,7 @@
TransientNodeData newNode =
new TransientNodeData(prevNode.getQPath(), prevNode.getIdentifier(), prevNode.getPersistedVersion(),
prevNode.getPrimaryTypeName(), prevNode.getMixinTypeNames(), prevNode.getOrderNumber(), prevNode
- .getParentIdentifier(), acl);
+ .getParentIdentifier(), acl);
// update this node
cache.put(makeItemFqn(newNode.getIdentifier()), ITEM_DATA, newNode);
// update childs recursive
14 years, 1 month
exo-jcr SVN: r2187 - in jcr/trunk: applications/product-patches/as/tomcat and 2 other directories.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2010-03-30 05:38:54 -0400 (Tue, 30 Mar 2010)
New Revision: 2187
Modified:
jcr/trunk/applications/product-patches/as/jonas/exo-configuration.xml
jcr/trunk/applications/product-patches/as/tomcat/exo-configuration.xml
jcr/trunk/exo.jcr.framework.ftpclient/pom.xml
jcr/trunk/exo.jcr.framework.ftpclient/src/test/java/org/exoplatform/frameworks/ftpclient/multimulti/TestAgent.java
Log:
EXOJCR-150 : The tests fixed. The cause of problem to one of test is configuration FtpService on server.
Modified: jcr/trunk/applications/product-patches/as/jonas/exo-configuration.xml
===================================================================
--- jcr/trunk/applications/product-patches/as/jonas/exo-configuration.xml 2010-03-30 07:52:32 UTC (rev 2186)
+++ jcr/trunk/applications/product-patches/as/jonas/exo-configuration.xml 2010-03-30 09:38:54 UTC (rev 2187)
@@ -258,7 +258,7 @@
</value-param>
<value-param>
<name>cache-folder-name</name>
- <value>target/ftp_cache</value>
+ <value>../temp/ftp_cache</value>
</value-param>
<!-- bytes per second -->
Modified: jcr/trunk/applications/product-patches/as/tomcat/exo-configuration.xml
===================================================================
--- jcr/trunk/applications/product-patches/as/tomcat/exo-configuration.xml 2010-03-30 07:52:32 UTC (rev 2186)
+++ jcr/trunk/applications/product-patches/as/tomcat/exo-configuration.xml 2010-03-30 09:38:54 UTC (rev 2187)
@@ -258,7 +258,7 @@
</value-param>
<value-param>
<name>cache-folder-name</name>
- <value>target/ftp_cache</value>
+ <value>../temp/ftp_cache</value>
</value-param>
<!-- bytes per second -->
Modified: jcr/trunk/exo.jcr.framework.ftpclient/pom.xml
===================================================================
--- jcr/trunk/exo.jcr.framework.ftpclient/pom.xml 2010-03-30 07:52:32 UTC (rev 2186)
+++ jcr/trunk/exo.jcr.framework.ftpclient/pom.xml 2010-03-30 09:38:54 UTC (rev 2187)
@@ -53,11 +53,17 @@
</configuration>
</plugin>
<plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <skipTests>true</skipTests>
- </configuration>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skipTests>true</skipTests>
+ <includes>
+ <include>**/*.java</include>
+ </includes>
+ <excludes>
+ <excluse>**/TestAgent.java</excluse>
+ </excludes>
+ </configuration>
</plugin>
</plugins>
</pluginManagement>
Modified: jcr/trunk/exo.jcr.framework.ftpclient/src/test/java/org/exoplatform/frameworks/ftpclient/multimulti/TestAgent.java
===================================================================
--- jcr/trunk/exo.jcr.framework.ftpclient/src/test/java/org/exoplatform/frameworks/ftpclient/multimulti/TestAgent.java 2010-03-30 07:52:32 UTC (rev 2186)
+++ jcr/trunk/exo.jcr.framework.ftpclient/src/test/java/org/exoplatform/frameworks/ftpclient/multimulti/TestAgent.java 2010-03-30 09:38:54 UTC (rev 2187)
@@ -56,6 +56,15 @@
private ClientThread clientThread;
private boolean successed = false;
+
+ /**
+ * the name of the test case
+ */
+ private String fName;
+
+ public TestAgent(String name) {
+ fName= name;
+ }
public TestAgent(int agentId, int itemsCount)
{
14 years, 1 month
exo-jcr SVN: r2186 - in jcr/trunk/exo.jcr.component.core/src: main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache and 1 other directories.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2010-03-30 03:52:32 -0400 (Tue, 30 Mar 2010)
New Revision: 2186
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestCacheableWorkspaceDataManager.java
Log:
EXOJCR-609: first implementation
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java 2010-03-30 06:32:47 UTC (rev 2185)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java 2010-03-30 07:52:32 UTC (rev 2186)
@@ -18,11 +18,15 @@
*/
package org.exoplatform.services.jcr.impl.dataflow.persistent;
+import org.exoplatform.services.jcr.access.AccessControlList;
+import org.exoplatform.services.jcr.dataflow.ItemDataVisitor;
import org.exoplatform.services.jcr.dataflow.ItemStateChangesLog;
import org.exoplatform.services.jcr.dataflow.persistent.WorkspaceStorageCache;
+import org.exoplatform.services.jcr.datamodel.InternalQName;
import org.exoplatform.services.jcr.datamodel.ItemData;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
+import org.exoplatform.services.jcr.datamodel.QPath;
import org.exoplatform.services.jcr.datamodel.QPathEntry;
import org.exoplatform.services.jcr.datamodel.ValueData;
import org.exoplatform.services.jcr.impl.dataflow.persistent.jbosscache.JBossCacheWorkspaceStorageCache;
@@ -50,8 +54,76 @@
*/
public class CacheableWorkspaceDataManager extends WorkspacePersistentDataManager
{
+ /**
+ * The identifier of the <code>null</code> value
+ */
+ protected static final String ITEM_DATA_NULL_VALUE_ID = "$";
+
+ /**
+ * The name of the <code>null</code> value
+ */
+ protected static final String ITEM_DATA_NULL_VALUE_NAME = null;
/**
+ * The <code>null</code> value for the itemData
+ */
+ protected static final ItemData ITEM_DATA_NULL_VALUE = new NodeData()
+ {
+
+ public void accept(ItemDataVisitor visitor) throws RepositoryException
+ {
+ }
+
+ public String getIdentifier()
+ {
+ return ITEM_DATA_NULL_VALUE_ID;
+ }
+
+ public String getParentIdentifier()
+ {
+ return null;
+ }
+
+ public int getPersistedVersion()
+ {
+ return 0;
+ }
+
+ QPath path = new QPath(new QPathEntry[]{new QPathEntry(null, ITEM_DATA_NULL_VALUE_NAME, 0)});
+
+ public QPath getQPath()
+ {
+ return path;
+ }
+
+ public boolean isNode()
+ {
+ return true;
+ }
+
+ public AccessControlList getACL()
+ {
+ return null;
+ }
+
+ public InternalQName[] getMixinTypeNames()
+ {
+ return null;
+ }
+
+ public int getOrderNumber()
+ {
+ return 0;
+ }
+
+ public InternalQName getPrimaryTypeName()
+ {
+ return null;
+ }
+
+ };
+
+ /**
* Items cache.
*/
protected final WorkspaceStorageCache cache;
@@ -94,7 +166,7 @@
* GET_LIST_PROPERTIES type.
*/
static private final int GET_LIST_PROPERTIES = 5;
-
+
/**
* Request type.
*/
@@ -386,7 +458,7 @@
if (data == null)
{
final DataRequest request = new DataRequest(parentData.getIdentifier(), name);
-
+
try
{
request.start();
@@ -395,7 +467,7 @@
data = getCachedItemData(parentData, name);
if (data == null)
{
- data = getPersistedItemData(parentData, name);
+ data = getPersistedItemData(parentData, name);
}
else if (!data.isNode())
{
@@ -412,7 +484,7 @@
fixPropertyValues((PropertyData)data);
}
- return data;
+ return data == ITEM_DATA_NULL_VALUE ? null : data;
}
/**
@@ -427,7 +499,7 @@
if (data == null)
{
final DataRequest request = new DataRequest(identifier);
-
+
try
{
request.start();
@@ -436,7 +508,7 @@
data = getCachedItemData(identifier);
if (data == null)
{
- data = getPersistedItemData(identifier);
+ data = getPersistedItemData(identifier);
}
else if (!data.isNode())
{
@@ -453,7 +525,7 @@
fixPropertyValues((PropertyData)data);
}
- return data;
+ return data == ITEM_DATA_NULL_VALUE ? null : data;
}
/**
@@ -622,8 +694,7 @@
}
childProperties = super.getChildPropertiesData(nodeData);
- // TODO childProperties.size() > 0 for SDB
- if (childProperties.size() > 0 && cache.isEnabled())
+ if (cache.isEnabled())
{
NodeData parentData = (NodeData)getItemData(nodeData.getIdentifier());
@@ -654,9 +725,9 @@
protected ItemData getPersistedItemData(NodeData parentData, QPathEntry name) throws RepositoryException
{
ItemData data = super.getItemData(parentData, name);
- if (data != null && cache.isEnabled())
+ if (cache.isEnabled())
{
- cache.put(data);
+ cache.put(data == null ? ITEM_DATA_NULL_VALUE : data);
}
return data;
}
@@ -671,9 +742,9 @@
protected ItemData getPersistedItemData(String identifier) throws RepositoryException
{
ItemData data = super.getItemData(identifier);
- if (data != null && cache.isEnabled())
+ if (cache.isEnabled())
{
- cache.put(data);
+ cache.put(data == null ? ITEM_DATA_NULL_VALUE : data);
}
return data;
}
@@ -718,8 +789,7 @@
}
}
propertiesList = super.listChildPropertiesData(nodeData);
- // TODO propertiesList.size() > 0 for SDB
- if (propertiesList.size() > 0 && cache.isEnabled())
+ if (cache.isEnabled())
{
NodeData parentData = (NodeData)getItemData(nodeData.getIdentifier());
@@ -733,7 +803,7 @@
finally
{
request.done();
- }
+ }
}
protected boolean isTxAware()
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java 2010-03-30 06:32:47 UTC (rev 2185)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java 2010-03-30 07:52:32 UTC (rev 2186)
@@ -476,7 +476,7 @@
else
{
// cache fact of empty childs list
- cache.put(makeChildListFqn(childNodesList, parent.getIdentifier()), ITEM_LIST, new HashSet<Object>());
+ cache.put(makeChildListFqn(childNodesList, parent.getIdentifier()), ITEM_LIST, Collections.EMPTY_SET);
}
}
finally
@@ -514,11 +514,10 @@
set.add(child.getIdentifier());
}
cache.put(makeChildListFqn(childPropsList, parent.getIdentifier()), ITEM_LIST, set);
-
}
else
{
- LOG.warn("Empty properties list cached " + (parent != null ? parent.getQPath().getAsString() : parent));
+ cache.put(makeChildListFqn(childPropsList, parent.getIdentifier()), ITEM_LIST, Collections.EMPTY_SET);
}
}
finally
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestCacheableWorkspaceDataManager.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestCacheableWorkspaceDataManager.java 2010-03-30 06:32:47 UTC (rev 2185)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestCacheableWorkspaceDataManager.java 2010-03-30 07:52:32 UTC (rev 2186)
@@ -53,6 +53,7 @@
{
private static final int READER = 100;
+
private static final int TIMES = 20;
private CacheableWorkspaceDataManager cwdm;
@@ -61,6 +62,12 @@
private MyWorkspaceStorageConnection con;
+ private CacheableWorkspaceDataManager cwdmEmpty;
+
+ private WorkspaceDataContainer wdcEmpty;
+
+ private MyWorkspaceStorageConnection conEmpty;
+
@Override
protected void setUp() throws Exception
{
@@ -69,6 +76,11 @@
this.wdc = new MyWorkspaceDataContainer(con);
this.cwdm =
new CacheableWorkspaceDataManager(wdc, new MyWorkspaceStorageCache(), new SystemDataContainerHolder(wdc));
+ this.conEmpty = new MyWorkspaceStorageConnection(true);
+ this.wdcEmpty = new MyWorkspaceDataContainer(conEmpty);
+ this.cwdmEmpty =
+ new CacheableWorkspaceDataManager(wdcEmpty, new MyWorkspaceStorageCache(), new SystemDataContainerHolder(
+ wdcEmpty));
}
@Override
@@ -96,7 +108,7 @@
startSignal.await();
for (int i = 0; i < TIMES; i++)
{
- task.execute();
+ task.execute();
}
}
catch (Exception e)
@@ -120,9 +132,9 @@
e.printStackTrace();
}
throw errors.get(0);
- }
+ }
}
-
+
public void testGetItemById() throws Exception
{
assertEquals(0, con.getItemDataByIdCalls.get());
@@ -132,15 +144,26 @@
{
ItemData item = cwdm.getItemData("getItemData");
assertNotNull(item);
- }
+ }
};
multiThreadingTest(task);
assertEquals(1, con.getItemDataByIdCalls.get());
+ assertEquals(0, conEmpty.getItemDataByIdCalls.get());
+ task = new MyTask()
+ {
+ public void execute() throws Exception
+ {
+ ItemData item = cwdmEmpty.getItemData("getItemData");
+ assertNull(item);
+ }
+ };
+ multiThreadingTest(task);
+ assertEquals(1, conEmpty.getItemDataByIdCalls.get());
}
-
+
public void testGetItemDataByNodeDataNQPathEntry() throws Exception
{
- final NodeData nodeData = new PersistedNodeData("getItemData", null, null, 0, 1, null, null, null);
+ final NodeData nodeData = new PersistedNodeData("getItemData", null, null, 0, 1, null, null, null);
assertEquals(0, con.getItemDataByNodeDataNQPathEntryCalls.get());
MyTask task = new MyTask()
{
@@ -148,15 +171,26 @@
{
ItemData item = cwdm.getItemData(nodeData, new QPathEntry("http://www.foo.com", "foo", 0));
assertNotNull(item);
- }
+ }
};
multiThreadingTest(task);
assertEquals(1, con.getItemDataByNodeDataNQPathEntryCalls.get());
+ assertEquals(0, conEmpty.getItemDataByNodeDataNQPathEntryCalls.get());
+ task = new MyTask()
+ {
+ public void execute() throws Exception
+ {
+ ItemData item = cwdmEmpty.getItemData(nodeData, new QPathEntry("http://www.foo.com", "foo", 0));
+ assertNull(item);
+ }
+ };
+ multiThreadingTest(task);
+ assertEquals(1, conEmpty.getItemDataByNodeDataNQPathEntryCalls.get());
}
-
+
public void testGetChildPropertiesData() throws Exception
{
- final NodeData nodeData = new PersistedNodeData("getChildPropertiesData", null, null, 0, 1, null, null, null);
+ final NodeData nodeData = new PersistedNodeData("getChildPropertiesData", null, null, 0, 1, null, null, null);
assertEquals(0, con.getChildPropertiesDataCalls.get());
MyTask task = new MyTask()
{
@@ -165,7 +199,7 @@
List<PropertyData> properties = cwdm.getChildPropertiesData(nodeData);
assertNotNull(properties);
assertFalse(properties.isEmpty());
- }
+ }
};
multiThreadingTest(task);
assertEquals(1, con.getChildPropertiesDataCalls.get());
@@ -176,15 +210,38 @@
List<PropertyData> properties = cwdm.getChildPropertiesData(nodeData, true);
assertNotNull(properties);
assertFalse(properties.isEmpty());
- }
+ }
};
multiThreadingTest(task);
assertEquals(1 + READER * TIMES, con.getChildPropertiesDataCalls.get());
+ assertEquals(0, conEmpty.getChildPropertiesDataCalls.get());
+ task = new MyTask()
+ {
+ public void execute() throws Exception
+ {
+ List<PropertyData> properties = cwdmEmpty.getChildPropertiesData(nodeData);
+ assertNotNull(properties);
+ assertTrue(properties.isEmpty());
+ }
+ };
+ multiThreadingTest(task);
+ assertEquals(1, conEmpty.getChildPropertiesDataCalls.get());
+ task = new MyTask()
+ {
+ public void execute() throws Exception
+ {
+ List<PropertyData> properties = cwdmEmpty.getChildPropertiesData(nodeData, true);
+ assertNotNull(properties);
+ assertTrue(properties.isEmpty());
+ }
+ };
+ multiThreadingTest(task);
+ assertEquals(1 + READER * TIMES, conEmpty.getChildPropertiesDataCalls.get());
}
-
+
public void testListChildPropertiesData() throws Exception
{
- final NodeData nodeData = new PersistedNodeData("listChildPropertiesData", null, null, 0, 1, null, null, null);
+ final NodeData nodeData = new PersistedNodeData("listChildPropertiesData", null, null, 0, 1, null, null, null);
assertEquals(0, con.listChildPropertiesDataCalls.get());
MyTask task = new MyTask()
{
@@ -193,7 +250,7 @@
List<PropertyData> properties = cwdm.listChildPropertiesData(nodeData);
assertNotNull(properties);
assertFalse(properties.isEmpty());
- }
+ }
};
multiThreadingTest(task);
assertEquals(1, con.listChildPropertiesDataCalls.get());
@@ -204,15 +261,38 @@
List<PropertyData> properties = cwdm.listChildPropertiesData(nodeData, true);
assertNotNull(properties);
assertFalse(properties.isEmpty());
- }
+ }
};
multiThreadingTest(task);
assertEquals(1 + READER * TIMES, con.listChildPropertiesDataCalls.get());
+ assertEquals(0, conEmpty.listChildPropertiesDataCalls.get());
+ task = new MyTask()
+ {
+ public void execute() throws Exception
+ {
+ List<PropertyData> properties = cwdmEmpty.listChildPropertiesData(nodeData);
+ assertNotNull(properties);
+ assertTrue(properties.isEmpty());
+ }
+ };
+ multiThreadingTest(task);
+ assertEquals(1, conEmpty.listChildPropertiesDataCalls.get());
+ task = new MyTask()
+ {
+ public void execute() throws Exception
+ {
+ List<PropertyData> properties = cwdmEmpty.listChildPropertiesData(nodeData, true);
+ assertNotNull(properties);
+ assertTrue(properties.isEmpty());
+ }
+ };
+ multiThreadingTest(task);
+ assertEquals(1 + READER * TIMES, conEmpty.listChildPropertiesDataCalls.get());
}
-
+
public void testGetChildNodes() throws Exception
{
- final NodeData nodeData = new PersistedNodeData("getChildNodes", null, null, 0, 1, null, null, null);
+ final NodeData nodeData = new PersistedNodeData("getChildNodes", null, null, 0, 1, null, null, null);
assertEquals(0, con.getChildNodesDataCalls.get());
MyTask task = new MyTask()
{
@@ -221,7 +301,7 @@
List<NodeData> nodes = cwdm.getChildNodesData(nodeData);
assertNotNull(nodes);
assertFalse(nodes.isEmpty());
- }
+ }
};
multiThreadingTest(task);
assertEquals(1, con.getChildNodesDataCalls.get());
@@ -232,15 +312,38 @@
List<NodeData> nodes = cwdm.getChildNodesData(nodeData, true);
assertNotNull(nodes);
assertFalse(nodes.isEmpty());
- }
+ }
};
multiThreadingTest(task);
assertEquals(1 + READER * TIMES, con.getChildNodesDataCalls.get());
+ assertEquals(0, conEmpty.getChildNodesDataCalls.get());
+ task = new MyTask()
+ {
+ public void execute() throws Exception
+ {
+ List<NodeData> nodes = cwdmEmpty.getChildNodesData(nodeData);
+ assertNotNull(nodes);
+ assertTrue(nodes.isEmpty());
+ }
+ };
+ multiThreadingTest(task);
+ assertEquals(1, conEmpty.getChildNodesDataCalls.get());
+ task = new MyTask()
+ {
+ public void execute() throws Exception
+ {
+ List<NodeData> nodes = cwdmEmpty.getChildNodesData(nodeData, true);
+ assertNotNull(nodes);
+ assertTrue(nodes.isEmpty());
+ }
+ };
+ multiThreadingTest(task);
+ assertEquals(1 + READER * TIMES, conEmpty.getChildNodesDataCalls.get());
}
-
+
public void testGetChildNodesCount() throws Exception
{
- final NodeData nodeData = new PersistedNodeData("getChildNodesCount", null, null, 0, 1, null, null, null);
+ final NodeData nodeData = new PersistedNodeData("getChildNodesCount", null, null, 0, 1, null, null, null);
assertEquals(0, con.getChildNodesCountCalls.get());
MyTask task = new MyTask()
{
@@ -248,7 +351,7 @@
{
int result = cwdm.getChildNodesCount(nodeData);
assertEquals(1, result);
- }
+ }
};
multiThreadingTest(task);
assertEquals(READER * TIMES, con.getChildNodesCountCalls.get());
@@ -260,17 +363,40 @@
{
int result = cwdm.getChildNodesCount(nodeData);
assertEquals(1, result);
- }
+ }
};
multiThreadingTest(task);
assertEquals(READER * TIMES, con.getChildNodesCountCalls.get());
+ assertEquals(0, conEmpty.getChildNodesCountCalls.get());
+ task = new MyTask()
+ {
+ public void execute() throws Exception
+ {
+ int result = cwdmEmpty.getChildNodesCount(nodeData);
+ assertEquals(0, result);
+ }
+ };
+ multiThreadingTest(task);
+ assertEquals(READER * TIMES, conEmpty.getChildNodesCountCalls.get());
+ // Add data to the cache
+ cwdmEmpty.getChildNodesData(nodeData);
+ task = new MyTask()
+ {
+ public void execute() throws Exception
+ {
+ int result = cwdmEmpty.getChildNodesCount(nodeData);
+ assertEquals(0, result);
+ }
+ };
+ multiThreadingTest(task);
+ assertEquals(READER * TIMES, conEmpty.getChildNodesCountCalls.get());
}
private static interface MyTask
{
void execute() throws Exception;
}
-
+
private static class MyWorkspaceStorageCache implements WorkspaceStorageCache
{
@@ -365,9 +491,21 @@
}
- private static class MyWorkspaceStorageConnection implements WorkspaceStorageConnection
+ public static class MyWorkspaceStorageConnection implements WorkspaceStorageConnection
{
+ public final boolean emptyResult;
+
+ public MyWorkspaceStorageConnection()
+ {
+ this(false);
+ }
+
+ public MyWorkspaceStorageConnection(boolean emptyResult)
+ {
+ this.emptyResult = emptyResult;
+ }
+
public void add(NodeData data) throws RepositoryException, UnsupportedOperationException,
InvalidItemStateException, IllegalStateException
{
@@ -401,7 +539,7 @@
public int getChildNodesCount(NodeData parent) throws RepositoryException
{
getChildNodesCountCalls.incrementAndGet();
- return 1;
+ return emptyResult ? 0 : 1;
}
public AtomicInteger getChildNodesDataCalls = new AtomicInteger();
@@ -409,7 +547,8 @@
public List<NodeData> getChildNodesData(NodeData parent) throws RepositoryException, IllegalStateException
{
getChildNodesDataCalls.incrementAndGet();
- return Arrays.asList((NodeData)new PersistedNodeData("getChildNodesData", null, null, 0, 1, null, null, null));
+ return emptyResult ? new ArrayList<NodeData>() : Arrays.asList((NodeData)new PersistedNodeData(
+ "getChildNodesData", null, null, 0, 1, null, null, null));
}
public AtomicInteger getChildPropertiesDataCalls = new AtomicInteger();
@@ -418,10 +557,9 @@
IllegalStateException
{
getChildPropertiesDataCalls.incrementAndGet();
- return Arrays
- .asList((PropertyData)new PersistedPropertyData("getChildPropertiesData", null, null, 0,
- PropertyType.STRING, false, Arrays
- .asList((ValueData)new ByteArrayPersistedValueData(1, "foo".getBytes()))));
+ return emptyResult ? new ArrayList<PropertyData>() : Arrays.asList((PropertyData)new PersistedPropertyData(
+ "getChildPropertiesData", null, null, 0, PropertyType.STRING, false, Arrays
+ .asList((ValueData)new ByteArrayPersistedValueData(1, "foo".getBytes()))));
}
public AtomicInteger getItemDataByNodeDataNQPathEntryCalls = new AtomicInteger();
@@ -430,7 +568,7 @@
IllegalStateException
{
getItemDataByNodeDataNQPathEntryCalls.incrementAndGet();
- return new PersistedNodeData("getItemData", null, null, 0, 1, null, null, null);
+ return emptyResult ? null : new PersistedNodeData("getItemData", null, null, 0, 1, null, null, null);
}
public AtomicInteger getItemDataByIdCalls = new AtomicInteger();
@@ -438,7 +576,8 @@
public ItemData getItemData(String identifier) throws RepositoryException, IllegalStateException
{
getItemDataByIdCalls.incrementAndGet();
- return new PersistedNodeData("getItemData", null, null, 0, 1, null, null, null);
+ return emptyResult && identifier.equals("getItemData") ? null : new PersistedNodeData("getItemData", null,
+ null, 0, 1, null, null, null);
}
public AtomicInteger getReferencesDataCalls = new AtomicInteger();
@@ -463,8 +602,9 @@
IllegalStateException
{
listChildPropertiesDataCalls.incrementAndGet();
- return Arrays.asList((PropertyData)new PersistedPropertyData("listChildPropertiesData", null, null, 0, PropertyType.STRING,
- false, Arrays.asList((ValueData)new ByteArrayPersistedValueData(1, "foo".getBytes()))));
+ return emptyResult ? new ArrayList<PropertyData>() : Arrays.asList((PropertyData)new PersistedPropertyData(
+ "listChildPropertiesData", null, null, 0, PropertyType.STRING, false, Arrays
+ .asList((ValueData)new ByteArrayPersistedValueData(1, "foo".getBytes()))));
}
public void rename(NodeData data) throws RepositoryException, UnsupportedOperationException,
14 years, 1 month
exo-jcr SVN: r2185 - jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2010-03-30 02:32:47 -0400 (Tue, 30 Mar 2010)
New Revision: 2185
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java
Log:
EXOJCR-613: fixPropertyValues calls have been added.
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java 2010-03-29 19:08:11 UTC (rev 2184)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java 2010-03-30 06:32:47 UTC (rev 2185)
@@ -397,6 +397,10 @@
{
data = getPersistedItemData(parentData, name);
}
+ else if (!data.isNode())
+ {
+ fixPropertyValues((PropertyData)data);
+ }
}
finally
{
@@ -434,6 +438,10 @@
{
data = getPersistedItemData(identifier);
}
+ else if (!data.isNode())
+ {
+ fixPropertyValues((PropertyData)data);
+ }
}
finally
{
14 years, 1 month
exo-jcr SVN: r2184 - jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2010-03-29 15:08:11 -0400 (Mon, 29 Mar 2010)
New Revision: 2184
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestCacheableWorkspaceDataManager.java
Log:
EXOJCR-613: Variable time has been removed.
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestCacheableWorkspaceDataManager.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestCacheableWorkspaceDataManager.java 2010-03-29 19:00:19 UTC (rev 2183)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestCacheableWorkspaceDataManager.java 2010-03-29 19:08:11 UTC (rev 2184)
@@ -111,7 +111,6 @@
};
thread.start();
}
- long time = System.currentTimeMillis();
startSignal.countDown();
doneSignal.await();
if (!errors.isEmpty())
14 years, 1 month
exo-jcr SVN: r2183 - jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2010-03-29 15:00:19 -0400 (Mon, 29 Mar 2010)
New Revision: 2183
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestCacheableWorkspaceDataManager.java
Log:
EXOJCR-613: Total Time has been removed and a test for getChildNodesCount has been added.
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestCacheableWorkspaceDataManager.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestCacheableWorkspaceDataManager.java 2010-03-29 18:37:02 UTC (rev 2182)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestCacheableWorkspaceDataManager.java 2010-03-29 19:00:19 UTC (rev 2183)
@@ -114,7 +114,6 @@
long time = System.currentTimeMillis();
startSignal.countDown();
doneSignal.await();
- System.out.println("Total Time = " + (System.currentTimeMillis() - time));
if (!errors.isEmpty())
{
for (Exception e : errors)
@@ -239,6 +238,34 @@
multiThreadingTest(task);
assertEquals(1 + READER * TIMES, con.getChildNodesDataCalls.get());
}
+
+ public void testGetChildNodesCount() throws Exception
+ {
+ final NodeData nodeData = new PersistedNodeData("getChildNodesCount", null, null, 0, 1, null, null, null);
+ assertEquals(0, con.getChildNodesCountCalls.get());
+ MyTask task = new MyTask()
+ {
+ public void execute() throws Exception
+ {
+ int result = cwdm.getChildNodesCount(nodeData);
+ assertEquals(1, result);
+ }
+ };
+ multiThreadingTest(task);
+ assertEquals(READER * TIMES, con.getChildNodesCountCalls.get());
+ // Add data to the cache
+ cwdm.getChildNodesData(nodeData);
+ task = new MyTask()
+ {
+ public void execute() throws Exception
+ {
+ int result = cwdm.getChildNodesCount(nodeData);
+ assertEquals(1, result);
+ }
+ };
+ multiThreadingTest(task);
+ assertEquals(READER * TIMES, con.getChildNodesCountCalls.get());
+ }
private static interface MyTask
{
14 years, 1 month
exo-jcr SVN: r2182 - jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2010-03-29 14:37:02 -0400 (Mon, 29 Mar 2010)
New Revision: 2182
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java
Log:
EXOJCR-613: Recall the method getItemData(String) when it is needed to avoid useless call to the database.
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java 2010-03-29 17:57:07 UTC (rev 2181)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java 2010-03-29 18:37:02 UTC (rev 2182)
@@ -558,11 +558,7 @@
childNodes = super.getChildNodesData(nodeData);
if (cache.isEnabled())
{
- NodeData parentData = (NodeData)cache.get(nodeData.getIdentifier());
- if (parentData == null)
- {
- parentData = (NodeData)super.getItemData(nodeData.getIdentifier());
- }
+ NodeData parentData = (NodeData)getItemData(nodeData.getIdentifier());
if (parentData != null)
{
@@ -621,11 +617,7 @@
// TODO childProperties.size() > 0 for SDB
if (childProperties.size() > 0 && cache.isEnabled())
{
- NodeData parentData = (NodeData)cache.get(nodeData.getIdentifier());
- if (parentData == null)
- {
- parentData = (NodeData)super.getItemData(nodeData.getIdentifier());
- }
+ NodeData parentData = (NodeData)getItemData(nodeData.getIdentifier());
if (parentData != null)
{
@@ -721,11 +713,7 @@
// TODO propertiesList.size() > 0 for SDB
if (propertiesList.size() > 0 && cache.isEnabled())
{
- NodeData parentData = (NodeData)cache.get(nodeData.getIdentifier());
- if (parentData == null)
- {
- parentData = (NodeData)super.getItemData(nodeData.getIdentifier());
- }
+ NodeData parentData = (NodeData)getItemData(nodeData.getIdentifier());
if (parentData != null)
{
14 years, 1 month
exo-jcr SVN: r2181 - jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2010-03-29 13:57:07 -0400 (Mon, 29 Mar 2010)
New Revision: 2181
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java
Log:
EXOJCR-613: Bad DataRequest type for GET_LIST_PROPERTIES.
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java 2010-03-29 17:52:56 UTC (rev 2180)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java 2010-03-29 17:57:07 UTC (rev 2181)
@@ -93,7 +93,7 @@
/**
* GET_LIST_PROPERTIES type.
*/
- static private final int GET_LIST_PROPERTIES = 4;
+ static private final int GET_LIST_PROPERTIES = 5;
/**
* Request type.
14 years, 1 month
exo-jcr SVN: r2180 - in jcr/trunk/exo.jcr.component.core/src: test/java/org/exoplatform/services/jcr/impl/dataflow/persistent and 1 other directory.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2010-03-29 13:52:56 -0400 (Mon, 29 Mar 2010)
New Revision: 2180
Added:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestCacheableWorkspaceDataManager.java
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java
Log:
EXOJCR-613: We ensure that we never access more than once to the database when several concurrent threads try to access to the same data at the same time. We also ensure that we create the object DataRequest only when it is required which means only when we have to access to the database.
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java 2010-03-29 13:25:16 UTC (rev 2179)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java 2010-03-29 17:52:56 UTC (rev 2180)
@@ -31,9 +31,9 @@
import org.exoplatform.services.jcr.storage.WorkspaceDataContainer;
import org.exoplatform.services.transaction.TransactionService;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.CountDownLatch;
import javax.jcr.RepositoryException;
@@ -59,7 +59,7 @@
/**
* Requests cache.
*/
- protected final Map<Integer, DataRequest> requestCache;
+ protected final ConcurrentMap<Integer, DataRequest> requestCache;
private TransactionManager transactionManager;
@@ -91,6 +91,11 @@
static private final int GET_ITEM_NAME = 4;
/**
+ * GET_LIST_PROPERTIES type.
+ */
+ static private final int GET_LIST_PROPERTIES = 4;
+
+ /**
* Request type.
*/
protected final int type;
@@ -173,43 +178,29 @@
this.type = GET_ITEM_ID;
// hashcode
- this.hcode = 31 * (31 + this.type) + this.id.hashCode();
+ this.hcode = 31 * (31 + this.type) + (this.id == null ? 0 : this.id.hashCode());
}
/**
- * Find the same, and if found wait till the one will be finished.
- *
- * WARNING. This method effective with cache use only!!! Without cache the database will control
- * requests performance/chaching process.
- *
- * @return this data request
+ * Start the request, each same will wait till this will be finished
*/
- DataRequest waitSame()
+ void start()
{
- DataRequest prev = requestCache.get(this.hashCode());
- if (prev != null)
+ DataRequest request = requestCache.putIfAbsent(this.hashCode(), this);
+ if (request != null)
{
- prev.await();
+ request.await();
}
- return this;
}
/**
- * Start the request, each same will wait till this will be finished
- */
- void start()
- {
- requestCache.put(this.hashCode(), this);
- }
-
- /**
* Done the request. Must be called after the data request will be finished. This call allow
* another same requests to be performed.
*/
void done()
{
this.ready.countDown();
- requestCache.remove(this.hashCode());
+ requestCache.remove(this.hashCode(), this);
}
/**
@@ -298,7 +289,7 @@
super(dataContainer, systemDataContainerHolder);
this.cache = cache;
- this.requestCache = new HashMap<Integer, DataRequest>();
+ this.requestCache = new ConcurrentHashMap<Integer, DataRequest>();
addItemPersistenceListener(cache);
transactionManager = transactionService.getTransactionManager();
@@ -320,7 +311,7 @@
super(dataContainer, systemDataContainerHolder);
this.cache = cache;
- this.requestCache = new HashMap<Integer, DataRequest>();
+ this.requestCache = new ConcurrentHashMap<Integer, DataRequest>();
addItemPersistenceListener(cache);
if (cache instanceof JBossCacheWorkspaceStorageCache)
@@ -394,7 +385,23 @@
// 2. Try from container
if (data == null)
{
- data = getPersistedItemData(parentData, name);
+ final DataRequest request = new DataRequest(parentData.getIdentifier(), name);
+
+ try
+ {
+ request.start();
+ // Try first to get the value from the cache since a
+ // request could have been launched just before
+ data = getCachedItemData(parentData, name);
+ if (data == null)
+ {
+ data = getPersistedItemData(parentData, name);
+ }
+ }
+ finally
+ {
+ request.done();
+ }
}
else if (!data.isNode())
{
@@ -415,7 +422,23 @@
// 3. Try from container
if (data == null)
{
- return getPersistedItemData(identifier);
+ final DataRequest request = new DataRequest(identifier);
+
+ try
+ {
+ request.start();
+ // Try first to get the value from the cache since a
+ // request could have been launched just before
+ data = getCachedItemData(identifier);
+ if (data == null)
+ {
+ data = getPersistedItemData(identifier);
+ }
+ }
+ finally
+ {
+ request.done();
+ }
}
else if (!data.isNode())
{
@@ -508,22 +531,30 @@
throws RepositoryException
{
- final DataRequest request = new DataRequest(nodeData.getIdentifier(), DataRequest.GET_NODES);
-
List<NodeData> childNodes = null;
if (!forcePersistentRead && cache.isEnabled())
{
- request.waitSame();
childNodes = cache.getChildNodes(nodeData);
if (childNodes != null)
{
return childNodes;
}
}
+ final DataRequest request = new DataRequest(nodeData.getIdentifier(), DataRequest.GET_NODES);
try
{
request.start();
+ if (!forcePersistentRead && cache.isEnabled())
+ {
+ // Try first to get the value from the cache since a
+ // request could have been launched just before
+ childNodes = cache.getChildNodes(nodeData);
+ if (childNodes != null)
+ {
+ return childNodes;
+ }
+ }
childNodes = super.getChildNodesData(nodeData);
if (cache.isEnabled())
{
@@ -535,9 +566,7 @@
if (parentData != null)
{
- {
- cache.addChildNodes(parentData, childNodes);
- }
+ cache.addChildNodes(parentData, childNodes);
}
}
return childNodes;
@@ -563,22 +592,30 @@
throws RepositoryException
{
- final DataRequest request = new DataRequest(nodeData.getIdentifier(), DataRequest.GET_PROPERTIES);
-
List<PropertyData> childProperties = null;
if (!forcePersistentRead && cache.isEnabled())
{
- request.waitSame();
childProperties = cache.getChildProperties(nodeData);
if (childProperties != null)
{
return childProperties;
}
}
+ final DataRequest request = new DataRequest(nodeData.getIdentifier(), DataRequest.GET_PROPERTIES);
try
{
request.start();
+ if (!forcePersistentRead && cache.isEnabled())
+ {
+ // Try first to get the value from the cache since a
+ // request could have been launched just before
+ childProperties = cache.getChildProperties(nodeData);
+ if (childProperties != null)
+ {
+ return childProperties;
+ }
+ }
childProperties = super.getChildPropertiesData(nodeData);
// TODO childProperties.size() > 0 for SDB
@@ -592,9 +629,7 @@
if (parentData != null)
{
- {
- cache.addChildProperties(parentData, childProperties);
- }
+ cache.addChildProperties(parentData, childProperties);
}
}
return childProperties;
@@ -621,9 +656,7 @@
ItemData data = super.getItemData(parentData, name);
if (data != null && cache.isEnabled())
{
- {
- cache.put(data);
- }
+ cache.put(data);
}
return data;
}
@@ -640,9 +673,7 @@
ItemData data = super.getItemData(identifier);
if (data != null && cache.isEnabled())
{
- {
- cache.put(data);
- }
+ cache.put(data);
}
return data;
}
@@ -662,12 +693,9 @@
throws RepositoryException
{
- final DataRequest request = new DataRequest(nodeData.getIdentifier(), DataRequest.GET_PROPERTIES);
-
List<PropertyData> propertiesList;
if (!forcePersistentRead && cache.isEnabled())
{
- request.waitSame(); // wait if getChildProp... working somewhere
propertiesList = cache.listChildProperties(nodeData);
if (propertiesList != null)
{
@@ -675,24 +703,41 @@
}
}
- propertiesList = super.listChildPropertiesData(nodeData);
- // TODO propertiesList.size() > 0 for SDB
- if (propertiesList.size() > 0 && cache.isEnabled())
+ final DataRequest request = new DataRequest(nodeData.getIdentifier(), DataRequest.GET_LIST_PROPERTIES);
+ try
{
- NodeData parentData = (NodeData)cache.get(nodeData.getIdentifier());
- if (parentData == null)
+ request.start();
+ if (!forcePersistentRead && cache.isEnabled())
{
- parentData = (NodeData)super.getItemData(nodeData.getIdentifier());
+ // Try first to get the value from the cache since a
+ // request could have been launched just before
+ propertiesList = cache.listChildProperties(nodeData);
+ if (propertiesList != null)
+ {
+ return propertiesList;
+ }
}
-
- if (parentData != null)
+ propertiesList = super.listChildPropertiesData(nodeData);
+ // TODO propertiesList.size() > 0 for SDB
+ if (propertiesList.size() > 0 && cache.isEnabled())
{
+ NodeData parentData = (NodeData)cache.get(nodeData.getIdentifier());
+ if (parentData == null)
{
+ parentData = (NodeData)super.getItemData(nodeData.getIdentifier());
+ }
+
+ if (parentData != null)
+ {
cache.addChildPropertiesList(parentData, propertiesList);
}
}
+ return propertiesList;
}
- return propertiesList;
+ finally
+ {
+ request.done();
+ }
}
protected boolean isTxAware()
Added: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestCacheableWorkspaceDataManager.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestCacheableWorkspaceDataManager.java (rev 0)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestCacheableWorkspaceDataManager.java 2010-03-29 17:52:56 UTC (rev 2180)
@@ -0,0 +1,517 @@
+/*
+ * Copyright (C) 2003-2010 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.services.jcr.impl.dataflow.persistent;
+
+import junit.framework.TestCase;
+
+import org.exoplatform.services.jcr.dataflow.ItemStateChangesLog;
+import org.exoplatform.services.jcr.dataflow.persistent.PersistedNodeData;
+import org.exoplatform.services.jcr.dataflow.persistent.PersistedPropertyData;
+import org.exoplatform.services.jcr.dataflow.persistent.WorkspaceStorageCache;
+import org.exoplatform.services.jcr.datamodel.ItemData;
+import org.exoplatform.services.jcr.datamodel.NodeData;
+import org.exoplatform.services.jcr.datamodel.PropertyData;
+import org.exoplatform.services.jcr.datamodel.QPathEntry;
+import org.exoplatform.services.jcr.datamodel.ValueData;
+import org.exoplatform.services.jcr.impl.storage.SystemDataContainerHolder;
+import org.exoplatform.services.jcr.impl.storage.WorkspaceDataContainerBase;
+import org.exoplatform.services.jcr.storage.WorkspaceDataContainer;
+import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import javax.jcr.InvalidItemStateException;
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+
+/**
+ * Created by The eXo Platform SAS
+ * Author : Nicolas Filotto
+ * nicolas.filotto(a)exoplatform.com
+ * 29 mars 2010
+ */
+public class TestCacheableWorkspaceDataManager extends TestCase
+{
+
+ private static final int READER = 100;
+ private static final int TIMES = 20;
+
+ private CacheableWorkspaceDataManager cwdm;
+
+ private WorkspaceDataContainer wdc;
+
+ private MyWorkspaceStorageConnection con;
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ this.con = new MyWorkspaceStorageConnection();
+ this.wdc = new MyWorkspaceDataContainer(con);
+ this.cwdm =
+ new CacheableWorkspaceDataManager(wdc, new MyWorkspaceStorageCache(), new SystemDataContainerHolder(wdc));
+ }
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ this.con = null;
+ this.wdc = null;
+ this.cwdm = null;
+ super.tearDown();
+ }
+
+ private void multiThreadingTest(final MyTask task) throws Exception
+ {
+ final CountDownLatch startSignal = new CountDownLatch(1);
+ final CountDownLatch doneSignal = new CountDownLatch(READER);
+ final List<Exception> errors = Collections.synchronizedList(new ArrayList<Exception>());
+ for (int i = 0; i < READER; i++)
+ {
+ Thread thread = new Thread()
+ {
+ public void run()
+ {
+ try
+ {
+ startSignal.await();
+ for (int i = 0; i < TIMES; i++)
+ {
+ task.execute();
+ }
+ }
+ catch (Exception e)
+ {
+ errors.add(e);
+ }
+ finally
+ {
+ doneSignal.countDown();
+ }
+ }
+ };
+ thread.start();
+ }
+ long time = System.currentTimeMillis();
+ startSignal.countDown();
+ doneSignal.await();
+ System.out.println("Total Time = " + (System.currentTimeMillis() - time));
+ if (!errors.isEmpty())
+ {
+ for (Exception e : errors)
+ {
+ e.printStackTrace();
+ }
+ throw errors.get(0);
+ }
+ }
+
+ public void testGetItemById() throws Exception
+ {
+ assertEquals(0, con.getItemDataByIdCalls.get());
+ MyTask task = new MyTask()
+ {
+ public void execute() throws Exception
+ {
+ ItemData item = cwdm.getItemData("getItemData");
+ assertNotNull(item);
+ }
+ };
+ multiThreadingTest(task);
+ assertEquals(1, con.getItemDataByIdCalls.get());
+ }
+
+ public void testGetItemDataByNodeDataNQPathEntry() throws Exception
+ {
+ final NodeData nodeData = new PersistedNodeData("getItemData", null, null, 0, 1, null, null, null);
+ assertEquals(0, con.getItemDataByNodeDataNQPathEntryCalls.get());
+ MyTask task = new MyTask()
+ {
+ public void execute() throws Exception
+ {
+ ItemData item = cwdm.getItemData(nodeData, new QPathEntry("http://www.foo.com", "foo", 0));
+ assertNotNull(item);
+ }
+ };
+ multiThreadingTest(task);
+ assertEquals(1, con.getItemDataByNodeDataNQPathEntryCalls.get());
+ }
+
+ public void testGetChildPropertiesData() throws Exception
+ {
+ final NodeData nodeData = new PersistedNodeData("getChildPropertiesData", null, null, 0, 1, null, null, null);
+ assertEquals(0, con.getChildPropertiesDataCalls.get());
+ MyTask task = new MyTask()
+ {
+ public void execute() throws Exception
+ {
+ List<PropertyData> properties = cwdm.getChildPropertiesData(nodeData);
+ assertNotNull(properties);
+ assertFalse(properties.isEmpty());
+ }
+ };
+ multiThreadingTest(task);
+ assertEquals(1, con.getChildPropertiesDataCalls.get());
+ task = new MyTask()
+ {
+ public void execute() throws Exception
+ {
+ List<PropertyData> properties = cwdm.getChildPropertiesData(nodeData, true);
+ assertNotNull(properties);
+ assertFalse(properties.isEmpty());
+ }
+ };
+ multiThreadingTest(task);
+ assertEquals(1 + READER * TIMES, con.getChildPropertiesDataCalls.get());
+ }
+
+ public void testListChildPropertiesData() throws Exception
+ {
+ final NodeData nodeData = new PersistedNodeData("listChildPropertiesData", null, null, 0, 1, null, null, null);
+ assertEquals(0, con.listChildPropertiesDataCalls.get());
+ MyTask task = new MyTask()
+ {
+ public void execute() throws Exception
+ {
+ List<PropertyData> properties = cwdm.listChildPropertiesData(nodeData);
+ assertNotNull(properties);
+ assertFalse(properties.isEmpty());
+ }
+ };
+ multiThreadingTest(task);
+ assertEquals(1, con.listChildPropertiesDataCalls.get());
+ task = new MyTask()
+ {
+ public void execute() throws Exception
+ {
+ List<PropertyData> properties = cwdm.listChildPropertiesData(nodeData, true);
+ assertNotNull(properties);
+ assertFalse(properties.isEmpty());
+ }
+ };
+ multiThreadingTest(task);
+ assertEquals(1 + READER * TIMES, con.listChildPropertiesDataCalls.get());
+ }
+
+ public void testGetChildNodes() throws Exception
+ {
+ final NodeData nodeData = new PersistedNodeData("getChildNodes", null, null, 0, 1, null, null, null);
+ assertEquals(0, con.getChildNodesDataCalls.get());
+ MyTask task = new MyTask()
+ {
+ public void execute() throws Exception
+ {
+ List<NodeData> nodes = cwdm.getChildNodesData(nodeData);
+ assertNotNull(nodes);
+ assertFalse(nodes.isEmpty());
+ }
+ };
+ multiThreadingTest(task);
+ assertEquals(1, con.getChildNodesDataCalls.get());
+ task = new MyTask()
+ {
+ public void execute() throws Exception
+ {
+ List<NodeData> nodes = cwdm.getChildNodesData(nodeData, true);
+ assertNotNull(nodes);
+ assertFalse(nodes.isEmpty());
+ }
+ };
+ multiThreadingTest(task);
+ assertEquals(1 + READER * TIMES, con.getChildNodesDataCalls.get());
+ }
+
+ private static interface MyTask
+ {
+ void execute() throws Exception;
+ }
+
+ private static class MyWorkspaceStorageCache implements WorkspaceStorageCache
+ {
+
+ private volatile List<NodeData> childNodes;
+
+ public void addChildNodes(NodeData parent, List<NodeData> childNodes)
+ {
+ this.childNodes = childNodes;
+ }
+
+ private volatile List<PropertyData> childProperties;
+
+ public void addChildProperties(NodeData parent, List<PropertyData> childProperties)
+ {
+ this.childProperties = childProperties;
+ }
+
+ private volatile List<PropertyData> childPropertiesList;
+
+ public void addChildPropertiesList(NodeData parent, List<PropertyData> childProperties)
+ {
+ this.childPropertiesList = childProperties;
+ }
+
+ public void beginTransaction()
+ {
+ }
+
+ public void commitTransaction()
+ {
+ }
+
+ private volatile ItemData itemData;
+
+ public ItemData get(String parentIdentifier, QPathEntry name)
+ {
+ return itemData;
+ }
+
+ public ItemData get(String identifier)
+ {
+ return itemData;
+ }
+
+ public List<NodeData> getChildNodes(NodeData parent)
+ {
+ return childNodes;
+ }
+
+ public List<PropertyData> getChildProperties(NodeData parent)
+ {
+ return childProperties;
+ }
+
+ public long getSize()
+ {
+ return 0;
+ }
+
+ public boolean isEnabled()
+ {
+ return true;
+ }
+
+ public List<PropertyData> listChildProperties(NodeData parentData)
+ {
+ return childPropertiesList;
+ }
+
+ public void put(ItemData item)
+ {
+ this.itemData = item;
+ }
+
+ public void remove(ItemData item)
+ {
+ this.itemData = null;
+ }
+
+ public void rollbackTransaction()
+ {
+ }
+
+ public boolean isTXAware()
+ {
+ return true;
+ }
+
+ public void onSaveItems(ItemStateChangesLog itemStates)
+ {
+ }
+
+ }
+
+ private static class MyWorkspaceStorageConnection implements WorkspaceStorageConnection
+ {
+
+ public void add(NodeData data) throws RepositoryException, UnsupportedOperationException,
+ InvalidItemStateException, IllegalStateException
+ {
+ }
+
+ public void add(PropertyData data) throws RepositoryException, UnsupportedOperationException,
+ InvalidItemStateException, IllegalStateException
+ {
+ }
+
+ public void close() throws IllegalStateException, RepositoryException
+ {
+ }
+
+ public void commit() throws IllegalStateException, RepositoryException
+ {
+ }
+
+ public void delete(NodeData data) throws RepositoryException, UnsupportedOperationException,
+ InvalidItemStateException, IllegalStateException
+ {
+ }
+
+ public void delete(PropertyData data) throws RepositoryException, UnsupportedOperationException,
+ InvalidItemStateException, IllegalStateException
+ {
+ }
+
+ public AtomicInteger getChildNodesCountCalls = new AtomicInteger();
+
+ public int getChildNodesCount(NodeData parent) throws RepositoryException
+ {
+ getChildNodesCountCalls.incrementAndGet();
+ return 1;
+ }
+
+ public AtomicInteger getChildNodesDataCalls = new AtomicInteger();
+
+ public List<NodeData> getChildNodesData(NodeData parent) throws RepositoryException, IllegalStateException
+ {
+ getChildNodesDataCalls.incrementAndGet();
+ return Arrays.asList((NodeData)new PersistedNodeData("getChildNodesData", null, null, 0, 1, null, null, null));
+ }
+
+ public AtomicInteger getChildPropertiesDataCalls = new AtomicInteger();
+
+ public List<PropertyData> getChildPropertiesData(NodeData parent) throws RepositoryException,
+ IllegalStateException
+ {
+ getChildPropertiesDataCalls.incrementAndGet();
+ return Arrays
+ .asList((PropertyData)new PersistedPropertyData("getChildPropertiesData", null, null, 0,
+ PropertyType.STRING, false, Arrays
+ .asList((ValueData)new ByteArrayPersistedValueData(1, "foo".getBytes()))));
+ }
+
+ public AtomicInteger getItemDataByNodeDataNQPathEntryCalls = new AtomicInteger();
+
+ public ItemData getItemData(NodeData parentData, QPathEntry name) throws RepositoryException,
+ IllegalStateException
+ {
+ getItemDataByNodeDataNQPathEntryCalls.incrementAndGet();
+ return new PersistedNodeData("getItemData", null, null, 0, 1, null, null, null);
+ }
+
+ public AtomicInteger getItemDataByIdCalls = new AtomicInteger();
+
+ public ItemData getItemData(String identifier) throws RepositoryException, IllegalStateException
+ {
+ getItemDataByIdCalls.incrementAndGet();
+ return new PersistedNodeData("getItemData", null, null, 0, 1, null, null, null);
+ }
+
+ public AtomicInteger getReferencesDataCalls = new AtomicInteger();
+
+ public List<PropertyData> getReferencesData(String nodeIdentifier) throws RepositoryException,
+ IllegalStateException, UnsupportedOperationException
+ {
+ getReferencesDataCalls.incrementAndGet();
+ return Arrays
+ .asList((PropertyData)new PersistedPropertyData("getReferencesData", null, null, 0, PropertyType.STRING,
+ false, Arrays.asList((ValueData)new ByteArrayPersistedValueData(1, "foo".getBytes()))));
+ }
+
+ public boolean isOpened()
+ {
+ return true;
+ }
+
+ public AtomicInteger listChildPropertiesDataCalls = new AtomicInteger();
+
+ public List<PropertyData> listChildPropertiesData(NodeData parent) throws RepositoryException,
+ IllegalStateException
+ {
+ listChildPropertiesDataCalls.incrementAndGet();
+ return Arrays.asList((PropertyData)new PersistedPropertyData("listChildPropertiesData", null, null, 0, PropertyType.STRING,
+ false, Arrays.asList((ValueData)new ByteArrayPersistedValueData(1, "foo".getBytes()))));
+ }
+
+ public void rename(NodeData data) throws RepositoryException, UnsupportedOperationException,
+ InvalidItemStateException, IllegalStateException
+ {
+ }
+
+ public void rollback() throws IllegalStateException, RepositoryException
+ {
+ }
+
+ public void update(NodeData data) throws RepositoryException, UnsupportedOperationException,
+ InvalidItemStateException, IllegalStateException
+ {
+ }
+
+ public void update(PropertyData data) throws RepositoryException, UnsupportedOperationException,
+ InvalidItemStateException, IllegalStateException
+ {
+ }
+
+ };
+
+ private static class MyWorkspaceDataContainer extends WorkspaceDataContainerBase
+ {
+
+ private WorkspaceStorageConnection con;
+
+ public MyWorkspaceDataContainer(WorkspaceStorageConnection con)
+ {
+ this.con = con;
+ }
+
+ public boolean isCheckSNSNewConnection()
+ {
+ return false;
+ }
+
+ public boolean isSame(WorkspaceDataContainer another)
+ {
+ return false;
+ }
+
+ public WorkspaceStorageConnection openConnection() throws RepositoryException
+ {
+ return con;
+ }
+
+ public WorkspaceStorageConnection openConnection(boolean readOnly) throws RepositoryException
+ {
+ return con;
+ }
+
+ public WorkspaceStorageConnection reuseConnection(WorkspaceStorageConnection original) throws RepositoryException
+ {
+ return con;
+ }
+
+ public String getInfo()
+ {
+ return "MyWorkspaceDataContainer";
+ }
+
+ public String getName()
+ {
+ return "MyWorkspaceDataContainer";
+ }
+
+ public String getStorageVersion()
+ {
+ return "0";
+ }
+
+ };
+
+}
14 years, 1 month
exo-jcr SVN: r2179 - jcr/trunk/exo.jcr.component.core/src/main/resources.
by do-not-reply@jboss.org
Author: pnedonosko
Date: 2010-03-29 09:25:16 -0400 (Mon, 29 Mar 2010)
New Revision: 2179
Modified:
jcr/trunk/exo.jcr.component.core/src/main/resources/binding.xml
Log:
EXOJCR-617 Deserializer.resolveString used by default for all String fields in Repository configuration
Modified: jcr/trunk/exo.jcr.component.core/src/main/resources/binding.xml
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/resources/binding.xml 2010-03-29 10:39:11 UTC (rev 2178)
+++ jcr/trunk/exo.jcr.component.core/src/main/resources/binding.xml 2010-03-29 13:25:16 UTC (rev 2179)
@@ -1,6 +1,6 @@
<binding>
<!-- the default deserializer to use for String -->
- <format type="java.lang.String" deserializer="org.exoplatform.container.xml.Deserializer.cleanString"/>
+ <format type="java.lang.String" deserializer="org.exoplatform.container.xml.Deserializer.resolveString"/>
<mapping name="repository-service" class="org.exoplatform.services.jcr.config.RepositoryServiceConfiguration">
<value name="default-repository" field="defaultRepositoryName" style="attribute" />
@@ -85,7 +85,7 @@
<mapping name="property" class="org.exoplatform.services.jcr.config.SimpleParameterEntry">
<value name="name" field="name" style="attribute" />
- <value name="value" field="value" style="attribute" deserializer="org.exoplatform.container.xml.Deserializer.resolveString" />
+ <value name="value" field="value" style="attribute" />
</mapping>
<mapping name="value-storage" class="org.exoplatform.services.jcr.config.ValueStorageEntry">
14 years, 1 month