exo-jcr SVN: r1314 - /.
by do-not-reply@jboss.org
Author: dkatayev
Date: 2010-01-06 08:08:03 -0500 (Wed, 06 Jan 2010)
New Revision: 1314
Added:
exo.jcr.component.core JBCCACHE/
Log:
16 years, 4 months
exo-jcr SVN: r1313 - jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/functional.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2010-01-06 07:19:48 -0500 (Wed, 06 Jan 2010)
New Revision: 1313
Modified:
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavQueryTest.java
Log:
EXOJCR-340: Added timeout between ADD and SEARCH.
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavQueryTest.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavQueryTest.java 2010-01-06 11:11:39 UTC (rev 1312)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavQueryTest.java 2010-01-06 12:19:48 UTC (rev 1313)
@@ -58,6 +58,11 @@
public static final String MIME_TEXT_HTML = "text/html";
/**
+ * Delay between adding nodes and querying repository (in ms)
+ */
+ public static final int SLEEP_BEFORE_QUERY = 6000;
+
+ /**
* Full-text query tests
*/
public void testFullTextSearch() throws Exception
@@ -93,20 +98,22 @@
{
conn.addNode(entry.getKey(), entry.getValue().getBytes(), MIME_TEXT_PLAIN);
}
+ // wait for indexer to flush volatile index
+ sleep();
// map containing test-case: <SQL query> : <expected nodes>
Map<String, String[]> sqlCases = new HashMap<String, String[]>();
sqlCases.put("SELECT * FROM nt:base WHERE CONTAINS(*,'tailored')", new String[]{"JCR_Overview"});
sqlCases.put("SELECT * FROM nt:base WHERE CONTAINS(*,'XPathQuery')", new String[]{"JCR_Queries"});
sqlCases.put("SELECT * FROM nt:resource WHERE CONTAINS(*,'API')", new String[]{"JCR_Structure", "JCR_Overview"});
- assertQuery(conn, sqlCases, Query.SQL);
+ assertQuery(sqlCases, Query.SQL);
// map containing test-case: <XPATH query> : <expected nodes>
Map<String, String[]> xpathCases = new HashMap<String, String[]>();
xpathCases.put("//element(*, nt:base)[jcr:contains(.,'tailored')]", new String[]{"JCR_Overview"});
xpathCases.put("//element(*, nt:base)[jcr:contains(.,'XPathQuery')]", new String[]{"JCR_Queries"});
xpathCases.put("//element(*, nt:resource)[jcr:contains(.,'API')]", new String[]{"JCR_Structure", "JCR_Overview"});
- assertQuery(conn, xpathCases, Query.XPATH);
+ assertQuery(xpathCases, Query.XPATH);
// remove created nodes
for (Entry<String, String> entry : nodes.entrySet())
{
@@ -134,20 +141,23 @@
{
conn.addNode(testLocalRootName + "/" + name, "_data_".getBytes());
}
+ // wait for indexer to flush volatile index
+ sleep();
+
// map containing test-case: <SQL query> : <expected nodes>
Map<String, String[]> sqlCases = new HashMap<String, String[]>();
sqlCases.put("SELECT * FROM nt:base WHERE jcr:path LIKE '/" + testLocalRootName
+ "[%]/%' AND NOT jcr:path LIKE '/" + testLocalRootName + "[%]/%/%' ", expected.toArray(new String[expected
.size()]));
sqlCases.put("SELECT * FROM nt:base WHERE fn:name() = 'exoString'", new String[]{"exoString"});
- assertQuery(conn, sqlCases, Query.SQL);
+ assertQuery(sqlCases, Query.SQL);
// map containing test-case: <XPATH query> : <expected nodes>
Map<String, String[]> xpathCases = new HashMap<String, String[]>();
xpathCases.put("/jcr:root/" + testLocalRootName + "/ element(*, nt:base)", expected.toArray(new String[expected
.size()]));
xpathCases.put("//element(*,nt:file)[fn:name() = 'exoString']", new String[]{"exoString"});
- assertQuery(conn, xpathCases, Query.XPATH);
+ assertQuery(xpathCases, Query.XPATH);
conn.removeNode(testLocalRootName);
}
@@ -181,6 +191,8 @@
{
conn.addNode(entry.getKey(), "content".getBytes(), entry.getValue());
}
+ // wait for indexer to flush volatile index
+ sleep();
// map containing test-case: <SQL query> : <expected nodes>
Map<String, String[]> sqlCases = new HashMap<String, String[]>();
@@ -190,7 +202,7 @@
MIME_TEXT_HTML));
sqlCases.put("SELECT * FROM nt:resource WHERE jcr:mimeType LIKE 'text%'", nodes.keySet().toArray(
new String[nodes.size()]));
- assertQuery(conn, sqlCases, Query.SQL);
+ assertQuery(sqlCases, Query.SQL);
// map containing test-case: <XPATH query> : <expected nodes>
Map<String, String[]> xpathCases = new HashMap<String, String[]>();
@@ -200,7 +212,7 @@
MIME_TEXT_HTML));
xpathCases.put("//element(*,nt:resource)[jcr:like(@jcr:mimeType, 'text%')]", nodes.keySet().toArray(
new String[nodes.size()]));
- assertQuery(conn, xpathCases, Query.XPATH);
+ assertQuery(xpathCases, Query.XPATH);
// remove created nodes
for (Entry<String, String> entry : nodes.entrySet())
@@ -222,21 +234,24 @@
* @throws XMLStreamException
* @throws FactoryConfigurationError
*/
- private void assertQuery(JCRWebdavConnection conn, Map<String, String[]> queryCases, String lang)
- throws IOException, ModuleException, XMLStreamException, FactoryConfigurationError
+ private void assertQuery(Map<String, String[]> queryCases, String lang) throws IOException, ModuleException,
+ XMLStreamException, FactoryConfigurationError
{
if (lang.equals(Query.SQL) || lang.equals(Query.XPATH))
{
- for (Entry<String, String[]> entry : queryCases.entrySet())
+ for (JCRWebdavConnection connection : getConnections())
{
- HTTPResponse response =
- lang.equals(Query.SQL) ? conn.sqlQuery(entry.getKey()) : conn.xpathQuery(entry.getKey());
- assertEquals(207, response.getStatusCode());
- List<String> found;
- assertEquals(207, response.getStatusCode());
- found = parseNodeNames(response.getData());
- assertTrue("Lists are not equals:\n*found:\t" + found + "\n*expected:\t" + entry.getValue(), compareLists(
- Arrays.asList(entry.getValue()), found));
+ for (Entry<String, String[]> entry : queryCases.entrySet())
+ {
+ HTTPResponse response =
+ lang.equals(Query.SQL) ? connection.sqlQuery(entry.getKey()) : connection.xpathQuery(entry.getKey());
+ assertEquals(207, response.getStatusCode());
+ List<String> found;
+ assertEquals(207, response.getStatusCode());
+ found = parseNodeNames(response.getData());
+ assertTrue("Lists are not equals:\n*found:\t" + found + "\n*expected:\t" + entry.getValue(),
+ compareLists(Arrays.asList(entry.getValue()), found));
+ }
}
}
else
@@ -342,4 +357,19 @@
}
return new ArrayList<String>(nodes);
}
+
+ /**
+ * Sleep for SLEEP_BEFORE_QUERY seconds. This is needed because Indexer is asynchronous and
+ * volatile index can be flushed after some time.
+ */
+ private void sleep()
+ {
+ try
+ {
+ Thread.sleep(SLEEP_BEFORE_QUERY);
+ }
+ catch (InterruptedException e)
+ {
+ }
+ }
}
16 years, 4 months
exo-jcr SVN: r1312 - jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2010-01-06 06:11:39 -0500 (Wed, 06 Jan 2010)
New Revision: 1312
Modified:
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/ChildListEvictionActionPolicy.java
Log:
EXOJCR-333 : The ExoEvictionActionPolicy was changed.
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/ChildListEvictionActionPolicy.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/ChildListEvictionActionPolicy.java 2010-01-06 10:44:51 UTC (rev 1311)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/ChildListEvictionActionPolicy.java 2010-01-06 11:11:39 UTC (rev 1312)
@@ -19,6 +19,7 @@
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
import org.jboss.cache.Cache;
+import org.jboss.cache.CacheStatus;
import org.jboss.cache.Fqn;
import org.jboss.cache.eviction.EvictionActionPolicy;
@@ -60,13 +61,19 @@
if (LOG.isDebugEnabled())
LOG.debug("Evicting Fqn " + fqn);
- cache.evict(fqn, recurcive);
- return true;
+ if (cache.getCacheStatus() == CacheStatus.STARTED)
+ {
+ cache.evict(fqn, recurcive);
+ return true;
+ }
+ else
+ {
+ return false;
+ }
}
catch (Exception e)
{
- if (LOG.isDebugEnabled())
- LOG.debug("Unable to evict " + fqn, e);
+ LOG.error("Unable to evict :" + fqn, e);
return false;
}
}
16 years, 4 months
exo-jcr SVN: r1311 - jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core.
by do-not-reply@jboss.org
Author: tolusha
Date: 2010-01-06 05:44:51 -0500 (Wed, 06 Jan 2010)
New Revision: 1311
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java
Log:
EXOJCR-362: Do not create ItemImpl on add of auto-created items
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java 2010-01-06 10:00:11 UTC (rev 1310)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java 2010-01-06 10:44:51 UTC (rev 1311)
@@ -2880,7 +2880,7 @@
itemAutocreator.makeAutoCreatedItems(node.nodeData(), primaryTypeName, dataManager, session.getUserID());
for (ItemState autoCreatedState : changes.getAllStates())
{
- dataManager.update(autoCreatedState, false); // TODO creates ItemImpl (EXOJCR-362)
+ dataManager.updateItemState(autoCreatedState);
}
// addAutoCreatedItems(node.nodeData(), primaryTypeName);
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java 2010-01-06 10:00:11 UTC (rev 1310)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java 2010-01-06 10:44:51 UTC (rev 1311)
@@ -517,7 +517,7 @@
return false;
}
-
+
/**
* Returns true if the item with <code>itemPath</code> was deleted in this session. Within a transaction,
* isDelete on an Item may return false (because the item has been saved) even if that Item is not in
@@ -1116,7 +1116,7 @@
// We can't remove this VH now.
return;
} // else -- if we has a references in workspace where the VH is being
- // deleted we can remove VH now.
+ // deleted we can remove VH now.
}
}
finally
@@ -1192,7 +1192,7 @@
}
/**
- * Updates (adds or modifies) item state in the session transient storage
+ * Updates (adds or modifies) item state in the session transient storage.
*
* @param itemState
* - the state
@@ -1206,7 +1206,6 @@
*/
public ItemImpl update(ItemState itemState, boolean pool) throws RepositoryException
{
-
if (itemState.isDeleted())
throw new RepositoryException("Illegal state DELETED. Use delete(...) method");
@@ -1216,6 +1215,27 @@
}
/**
+ * Updates (adds or modifies) item state in the session transient storage without creation ItemImpl.
+ *
+ * @param itemState
+ * - the state
+ * @param pool
+ * - if true Manager force pooling this State so next calling will returna the same
+ * object Common rule: use pool = true if the Item supposed to be returned by JCR API
+ * (Node.addNode(), Node.setProperty() for ex) (NOTE: independently of pooling the
+ * Manager always return actual Item state)
+ * @return
+ * @throws RepositoryException
+ */
+ public void updateItemState(ItemState itemState) throws RepositoryException
+ {
+ if (itemState.isDeleted())
+ throw new RepositoryException("Illegal state DELETED. Use delete(...) method");
+
+ changesLog.add(itemState);
+ }
+
+ /**
* Commit changes
*
* @param path
16 years, 4 months
exo-jcr SVN: r1310 - jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/functional.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2010-01-06 05:00:11 -0500 (Wed, 06 Jan 2010)
New Revision: 1310
Modified:
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavQueryTest.java
Log:
EXOJCR-340: Refactoring of query-test.
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavQueryTest.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavQueryTest.java 2010-01-06 09:53:04 UTC (rev 1309)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavQueryTest.java 2010-01-06 10:00:11 UTC (rev 1310)
@@ -34,6 +34,7 @@
import java.util.Map;
import java.util.Map.Entry;
+import javax.jcr.query.Query;
import javax.xml.namespace.QName;
import javax.xml.stream.FactoryConfigurationError;
import javax.xml.stream.XMLInputFactory;
@@ -59,7 +60,7 @@
/**
* Full-text query tests
*/
- public void _testFullTextSearch() throws Exception
+ public void testFullTextSearch() throws Exception
{
JCRWebdavConnection conn = getConnection();
// Nodes with some text, with unique words in each one in form of <name><content>
@@ -98,26 +99,14 @@
sqlCases.put("SELECT * FROM nt:base WHERE CONTAINS(*,'tailored')", new String[]{"JCR_Overview"});
sqlCases.put("SELECT * FROM nt:base WHERE CONTAINS(*,'XPathQuery')", new String[]{"JCR_Queries"});
sqlCases.put("SELECT * FROM nt:resource WHERE CONTAINS(*,'API')", new String[]{"JCR_Structure", "JCR_Overview"});
- // SQL
- for (Entry<String, String[]> entry : sqlCases.entrySet())
- {
- HTTPResponse response = conn.sqlQuery(entry.getKey());
- assertEquals(207, response.getStatusCode());
- assertResponse(entry.getValue(), response);
- }
+ assertQuery(conn, sqlCases, Query.SQL);
// map containing test-case: <XPATH query> : <expected nodes>
Map<String, String[]> xpathCases = new HashMap<String, String[]>();
xpathCases.put("//element(*, nt:base)[jcr:contains(.,'tailored')]", new String[]{"JCR_Overview"});
xpathCases.put("//element(*, nt:base)[jcr:contains(.,'XPathQuery')]", new String[]{"JCR_Queries"});
xpathCases.put("//element(*, nt:resource)[jcr:contains(.,'API')]", new String[]{"JCR_Structure", "JCR_Overview"});
- // XPATH
- for (Entry<String, String[]> entry : xpathCases.entrySet())
- {
- HTTPResponse response = conn.xpathQuery(entry.getKey());
- assertEquals(207, response.getStatusCode());
- assertResponse(entry.getValue(), response);
- }
+ assertQuery(conn, xpathCases, Query.XPATH);
// remove created nodes
for (Entry<String, String> entry : nodes.entrySet())
{
@@ -128,7 +117,7 @@
/**
* Simple test, searching nodes by given path and concrete name.
*/
- public void _testPathSearch() throws Exception
+ public void testPathSearch() throws Exception
{
String testLocalRootName = "testPathSearch";
JCRWebdavConnection conn = getConnection();
@@ -151,26 +140,14 @@
+ "[%]/%' AND NOT jcr:path LIKE '/" + testLocalRootName + "[%]/%/%' ", expected.toArray(new String[expected
.size()]));
sqlCases.put("SELECT * FROM nt:base WHERE fn:name() = 'exoString'", new String[]{"exoString"});
- // SQL
- for (Entry<String, String[]> entry : sqlCases.entrySet())
- {
- HTTPResponse response = conn.sqlQuery(entry.getKey());
- assertEquals(207, response.getStatusCode());
- assertResponse(entry.getValue(), response);
- }
+ assertQuery(conn, sqlCases, Query.SQL);
// map containing test-case: <XPATH query> : <expected nodes>
Map<String, String[]> xpathCases = new HashMap<String, String[]>();
xpathCases.put("/jcr:root/" + testLocalRootName + "/ element(*, nt:base)", expected.toArray(new String[expected
.size()]));
xpathCases.put("//element(*,nt:file)[fn:name() = 'exoString']", new String[]{"exoString"});
- // XPATH
- for (Entry<String, String[]> entry : xpathCases.entrySet())
- {
- HTTPResponse response = conn.xpathQuery(entry.getKey());
- assertEquals(207, response.getStatusCode());
- assertResponse(entry.getValue(), response);
- }
+ assertQuery(conn, xpathCases, Query.XPATH);
conn.removeNode(testLocalRootName);
}
@@ -213,13 +190,7 @@
MIME_TEXT_HTML));
sqlCases.put("SELECT * FROM nt:resource WHERE jcr:mimeType LIKE 'text%'", nodes.keySet().toArray(
new String[nodes.size()]));
- // SQL
- for (Entry<String, String[]> entry : sqlCases.entrySet())
- {
- HTTPResponse response = conn.sqlQuery(entry.getKey());
- assertEquals(207, response.getStatusCode());
- assertResponse(entry.getValue(), response);
- }
+ assertQuery(conn, sqlCases, Query.SQL);
// map containing test-case: <XPATH query> : <expected nodes>
Map<String, String[]> xpathCases = new HashMap<String, String[]>();
@@ -229,13 +200,7 @@
MIME_TEXT_HTML));
xpathCases.put("//element(*,nt:resource)[jcr:like(@jcr:mimeType, 'text%')]", nodes.keySet().toArray(
new String[nodes.size()]));
- // XPATH
- for (Entry<String, String[]> entry : xpathCases.entrySet())
- {
- HTTPResponse response = conn.xpathQuery(entry.getKey());
- assertEquals(207, response.getStatusCode());
- assertResponse(entry.getValue(), response);
- }
+ assertQuery(conn, xpathCases, Query.XPATH);
// remove created nodes
for (Entry<String, String> entry : nodes.entrySet())
@@ -245,23 +210,39 @@
}
/**
- * Checks that response contains expected nodes.
+ * Performs sequence of queries and asserts received results
*
- * @param expected
- * @param response
+ * @param conn
+ * @param queryCases
+ * map containing test-case: <query> : <expected nodes>
+ * @param lang
+ * Query.SQL or Query.XPATH
* @throws IOException
* @throws ModuleException
* @throws XMLStreamException
* @throws FactoryConfigurationError
*/
- private void assertResponse(String[] expected, HTTPResponse response) throws IOException, ModuleException,
- XMLStreamException, FactoryConfigurationError
+ private void assertQuery(JCRWebdavConnection conn, Map<String, String[]> queryCases, String lang)
+ throws IOException, ModuleException, XMLStreamException, FactoryConfigurationError
{
- List<String> found;
- assertEquals(207, response.getStatusCode());
- found = parseNodeNames(response.getData());
- assertTrue("Lists are not equals:\n*found:\t" + found + "\n*expected:\t" + expected, compareLists(Arrays
- .asList(expected), found));
+ if (lang.equals(Query.SQL) || lang.equals(Query.XPATH))
+ {
+ for (Entry<String, String[]> entry : queryCases.entrySet())
+ {
+ HTTPResponse response =
+ lang.equals(Query.SQL) ? conn.sqlQuery(entry.getKey()) : conn.xpathQuery(entry.getKey());
+ assertEquals(207, response.getStatusCode());
+ List<String> found;
+ assertEquals(207, response.getStatusCode());
+ found = parseNodeNames(response.getData());
+ assertTrue("Lists are not equals:\n*found:\t" + found + "\n*expected:\t" + entry.getValue(), compareLists(
+ Arrays.asList(entry.getValue()), found));
+ }
+ }
+ else
+ {
+ fail("Unsupported query language:" + lang);
+ }
}
/**
16 years, 4 months
exo-jcr SVN: r1309 - jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2010-01-06 04:53:04 -0500 (Wed, 06 Jan 2010)
New Revision: 1309
Modified:
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-indexer-config-exoloader_db1_ws.xml
Log:
EXOJCR-333 : The indexer configuration to cluster was changed (remove the eviction configuration).
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-indexer-config-exoloader_db1_ws.xml
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-indexer-config-exoloader_db1_ws.xml 2010-01-06 09:48:24 UTC (rev 1308)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-indexer-config-exoloader_db1_ws.xml 2010-01-06 09:53:04 UTC (rev 1309)
@@ -70,15 +70,5 @@
<sync />
</clustering>
<invocationBatching enabled="false" />
- <!-- Eviction configuration -->
- <eviction wakeUpInterval="5000">
- <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm">
- <property name="maxNodes" value="5000" />
- <property name="timeToLiveSeconds" value="120" />
- </default>
- <region name="/" algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" actionPolicyClass="org.exoplatform.services.jcr.impl.dataflow.persistent.jbosscache.ChildListEvictionActionPolicy" eventQueueSize="1000000">
- <property name="maxNodes" value="5000" />
- <property name="timeToLiveSeconds" value="120" />
- </region>
- </eviction>
+
</jbosscache>
16 years, 4 months
exo-jcr SVN: r1308 - jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2010-01-06 04:48:24 -0500 (Wed, 06 Jan 2010)
New Revision: 1308
Modified:
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-config-ws.xml
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-config-ws1.xml
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-config-ws2.xml
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-config-ws3.xml
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-config-wstck.xml
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-config-wstck1.xml
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-config-wstck2.xml
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-indexer-config-exoloader_db1_ws.xml
Log:
EXOJCR-333 : The configuration to cluster was changed (rename class ExoEvictionActionPolicy to ChildListEvictionActionPolicy).
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-config-ws.xml
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-config-ws.xml 2010-01-06 09:39:03 UTC (rev 1307)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-config-ws.xml 2010-01-06 09:48:24 UTC (rev 1308)
@@ -89,7 +89,7 @@
<property name="maxNodes" value="5000" />
<property name="timeToLiveSeconds" value="120" />
</default>
- <region name="/" algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" actionPolicyClass="org.exoplatform.services.jcr.impl.dataflow.persistent.jbosscache.ExoEvictionActionPolicy" eventQueueSize="1000000">
+ <region name="/" algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" actionPolicyClass="org.exoplatform.services.jcr.impl.dataflow.persistent.jbosscache.ChildListEvictionActionPolicy" eventQueueSize="1000000">
<property name="maxNodes" value="5000" />
<property name="timeToLiveSeconds" value="120" />
</region>
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-config-ws1.xml
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-config-ws1.xml 2010-01-06 09:39:03 UTC (rev 1307)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-config-ws1.xml 2010-01-06 09:48:24 UTC (rev 1308)
@@ -89,7 +89,7 @@
<property name="maxNodes" value="5000" />
<property name="timeToLiveSeconds" value="120" />
</default>
- <region name="/" algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" actionPolicyClass="org.exoplatform.services.jcr.impl.dataflow.persistent.jbosscache.ExoEvictionActionPolicy" eventQueueSize="1000000">
+ <region name="/" algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" actionPolicyClass="org.exoplatform.services.jcr.impl.dataflow.persistent.jbosscache.ChildListEvictionActionPolicy" eventQueueSize="1000000">
<property name="maxNodes" value="5000" />
<property name="timeToLiveSeconds" value="120" />
</region>
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-config-ws2.xml
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-config-ws2.xml 2010-01-06 09:39:03 UTC (rev 1307)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-config-ws2.xml 2010-01-06 09:48:24 UTC (rev 1308)
@@ -89,7 +89,7 @@
<property name="maxNodes" value="5000" />
<property name="timeToLiveSeconds" value="120" />
</default>
- <region name="/" algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" actionPolicyClass="org.exoplatform.services.jcr.impl.dataflow.persistent.jbosscache.ExoEvictionActionPolicy" eventQueueSize="1000000">
+ <region name="/" algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" actionPolicyClass="org.exoplatform.services.jcr.impl.dataflow.persistent.jbosscache.ChildListEvictionActionPolicy" eventQueueSize="1000000">
<property name="maxNodes" value="5000" />
<property name="timeToLiveSeconds" value="120" />
</region>
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-config-ws3.xml
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-config-ws3.xml 2010-01-06 09:39:03 UTC (rev 1307)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-config-ws3.xml 2010-01-06 09:48:24 UTC (rev 1308)
@@ -89,7 +89,7 @@
<property name="maxNodes" value="5000" />
<property name="timeToLiveSeconds" value="120" />
</default>
- <region name="/" algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" actionPolicyClass="org.exoplatform.services.jcr.impl.dataflow.persistent.jbosscache.ExoEvictionActionPolicy" eventQueueSize="1000000">
+ <region name="/" algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" actionPolicyClass="org.exoplatform.services.jcr.impl.dataflow.persistent.jbosscache.ChildListEvictionActionPolicy" eventQueueSize="1000000">
<property name="maxNodes" value="5000" />
<property name="timeToLiveSeconds" value="120" />
</region>
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-config-wstck.xml
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-config-wstck.xml 2010-01-06 09:39:03 UTC (rev 1307)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-config-wstck.xml 2010-01-06 09:48:24 UTC (rev 1308)
@@ -89,7 +89,7 @@
<property name="maxNodes" value="5000" />
<property name="timeToLiveSeconds" value="120" />
</default>
- <region name="/" algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" actionPolicyClass="org.exoplatform.services.jcr.impl.dataflow.persistent.jbosscache.ExoEvictionActionPolicy" eventQueueSize="1000000">
+ <region name="/" algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" actionPolicyClass="org.exoplatform.services.jcr.impl.dataflow.persistent.jbosscache.ChildListEvictionActionPolicy" eventQueueSize="1000000">
<property name="maxNodes" value="5000" />
<property name="timeToLiveSeconds" value="120" />
</region>
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-config-wstck1.xml
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-config-wstck1.xml 2010-01-06 09:39:03 UTC (rev 1307)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-config-wstck1.xml 2010-01-06 09:48:24 UTC (rev 1308)
@@ -89,7 +89,7 @@
<property name="maxNodes" value="5000" />
<property name="timeToLiveSeconds" value="120" />
</default>
- <region name="/" algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" actionPolicyClass="org.exoplatform.services.jcr.impl.dataflow.persistent.jbosscache.ExoEvictionActionPolicy" eventQueueSize="1000000">
+ <region name="/" algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" actionPolicyClass="org.exoplatform.services.jcr.impl.dataflow.persistent.jbosscache.ChildListEvictionActionPolicy" eventQueueSize="1000000">
<property name="maxNodes" value="5000" />
<property name="timeToLiveSeconds" value="120" />
</region>
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-config-wstck2.xml
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-config-wstck2.xml 2010-01-06 09:39:03 UTC (rev 1307)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-config-wstck2.xml 2010-01-06 09:48:24 UTC (rev 1308)
@@ -89,7 +89,7 @@
<property name="maxNodes" value="5000" />
<property name="timeToLiveSeconds" value="120" />
</default>
- <region name="/" algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" actionPolicyClass="org.exoplatform.services.jcr.impl.dataflow.persistent.jbosscache.ExoEvictionActionPolicy" eventQueueSize="1000000">
+ <region name="/" algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" actionPolicyClass="org.exoplatform.services.jcr.impl.dataflow.persistent.jbosscache.ChildListEvictionActionPolicy" eventQueueSize="1000000">
<property name="maxNodes" value="5000" />
<property name="timeToLiveSeconds" value="120" />
</region>
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-indexer-config-exoloader_db1_ws.xml
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-indexer-config-exoloader_db1_ws.xml 2010-01-06 09:39:03 UTC (rev 1307)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-indexer-config-exoloader_db1_ws.xml 2010-01-06 09:48:24 UTC (rev 1308)
@@ -76,7 +76,7 @@
<property name="maxNodes" value="5000" />
<property name="timeToLiveSeconds" value="120" />
</default>
- <region name="/" algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" actionPolicyClass="org.exoplatform.services.jcr.impl.dataflow.persistent.jbosscache.ExoEvictionActionPolicy" eventQueueSize="1000000">
+ <region name="/" algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" actionPolicyClass="org.exoplatform.services.jcr.impl.dataflow.persistent.jbosscache.ChildListEvictionActionPolicy" eventQueueSize="1000000">
<property name="maxNodes" value="5000" />
<property name="timeToLiveSeconds" value="120" />
</region>
16 years, 4 months
exo-jcr SVN: r1307 - jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/functional.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2010-01-06 04:39:03 -0500 (Wed, 06 Jan 2010)
New Revision: 1307
Modified:
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavQueryTest.java
Log:
EXOJCR-340: Added property-constraint search test.
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavQueryTest.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavQueryTest.java 2010-01-06 09:00:54 UTC (rev 1306)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavQueryTest.java 2010-01-06 09:39:03 UTC (rev 1307)
@@ -50,43 +50,47 @@
*/
public class WebdavQueryTest extends BaseClusteringFunctionalTest
{
+ public static final String MIME_TEXT_PLAIN = "text/plain";
+ public static final String MIME_TEXT_PATCH = "text/x-patch";
+
+ public static final String MIME_TEXT_HTML = "text/html";
+
/**
- * Fulltext queries
+ * Full-text query tests
*/
- public void testFullTextSearch() throws Exception
+ public void _testFullTextSearch() throws Exception
{
JCRWebdavConnection conn = getConnection();
- // Nodes with some text, with unique words in each one.
- Map<String, String> expected = new HashMap<String, String>();
- expected
+ // Nodes with some text, with unique words in each one in form of <name><content>
+ Map<String, String> nodes = new HashMap<String, String>();
+ nodes
.put(
"JCR_Overview",
"A JCR is a type of Object Database tailored to the storage, searching, and retrieval of hierarchical data. The JCR API grew o"
+ "ut of the needs of content management systems, which require storage of documents and other binary objects with associated me"
+ "tadata; however, the API is applicable to many additional types of application. In addition to object storage, the JCR provid"
+ "es: APIs for versioning of data; transactions; observation of changes in data; and import or export of data to XML in a standard way.");
- expected
+ nodes
.put(
"JCR_Structure",
"The data in a JCR consists of a tree of Nodes with associated Properties. Data is stored in the Properties, which may hold simple "
+ "values such as numbers and strings or binary data of arbitrary length. Nodes may optionally have one or more types associated with"
+ " them which dictate the kinds of properties, number and type of child nodes, and certain behavioral characteristics of the nodes. API");
- expected
+ nodes
.put(
"JCR_Queries",
"A JCR can be queried with XPathQuery, can export portions of its tree to XML in two standard formats and can import hierarchies directly"
+ " from XML. A JCR may optionally support a standardized form of SQL for queries. The Apache Jackrabbit reference implementation of "
+ "JCR also supports the integration of the Apache Lucene search engine to give full text searches of data in the repository.");
- expected.put("JCR_Impl",
+ nodes.put("JCR_Impl",
"eXo Platform JCR implementation on the company wiki. eXo Platform 2 article on theserverside");
-
// add nodes
- for (Entry<String, String> entry : expected.entrySet())
+ for (Entry<String, String> entry : nodes.entrySet())
{
- conn.addNode(entry.getKey(), entry.getValue().getBytes(), "text/plain");
+ conn.addNode(entry.getKey(), entry.getValue().getBytes(), MIME_TEXT_PLAIN);
}
// map containing test-case: <SQL query> : <expected nodes>
@@ -94,7 +98,6 @@
sqlCases.put("SELECT * FROM nt:base WHERE CONTAINS(*,'tailored')", new String[]{"JCR_Overview"});
sqlCases.put("SELECT * FROM nt:base WHERE CONTAINS(*,'XPathQuery')", new String[]{"JCR_Queries"});
sqlCases.put("SELECT * FROM nt:resource WHERE CONTAINS(*,'API')", new String[]{"JCR_Structure", "JCR_Overview"});
-
// SQL
for (Entry<String, String[]> entry : sqlCases.entrySet())
{
@@ -108,7 +111,6 @@
xpathCases.put("//element(*, nt:base)[jcr:contains(.,'tailored')]", new String[]{"JCR_Overview"});
xpathCases.put("//element(*, nt:base)[jcr:contains(.,'XPathQuery')]", new String[]{"JCR_Queries"});
xpathCases.put("//element(*, nt:resource)[jcr:contains(.,'API')]", new String[]{"JCR_Structure", "JCR_Overview"});
-
// XPATH
for (Entry<String, String[]> entry : xpathCases.entrySet())
{
@@ -117,18 +119,18 @@
assertResponse(entry.getValue(), response);
}
// remove created nodes
- for (Entry<String, String> entry : expected.entrySet())
+ for (Entry<String, String> entry : nodes.entrySet())
{
conn.removeNode(entry.getKey());
}
}
/**
- * Simple test, searching nodes by given path
+ * Simple test, searching nodes by given path and concrete name.
*/
- public void testPathSearch() throws Exception
+ public void _testPathSearch() throws Exception
{
- String testLocalRootName = "testSimpleGetAll";
+ String testLocalRootName = "testPathSearch";
JCRWebdavConnection conn = getConnection();
conn.addDir(testLocalRootName);
List<String> expected = new ArrayList<String>();
@@ -143,20 +145,108 @@
{
conn.addNode(testLocalRootName + "/" + name, "_data_".getBytes());
}
+ // map containing test-case: <SQL query> : <expected nodes>
+ Map<String, String[]> sqlCases = new HashMap<String, String[]>();
+ sqlCases.put("SELECT * FROM nt:base WHERE jcr:path LIKE '/" + testLocalRootName
+ + "[%]/%' AND NOT jcr:path LIKE '/" + testLocalRootName + "[%]/%/%' ", expected.toArray(new String[expected
+ .size()]));
+ sqlCases.put("SELECT * FROM nt:base WHERE fn:name() = 'exoString'", new String[]{"exoString"});
// SQL
- HTTPResponse response =
- conn.sqlQuery("SELECT * FROM nt:base WHERE jcr:path LIKE '/" + testLocalRootName
- + "[%]/%' AND NOT jcr:path LIKE '/" + testLocalRootName + "[%]/%/%' ");
- assertEquals(207, response.getStatusCode());
- assertResponse(expected, response);
- // XPath
- response = conn.xpathQuery("/jcr:root/" + testLocalRootName + "/ element(*, nt:base)");
- assertEquals(207, response.getStatusCode());
- assertResponse(expected, response);
+ for (Entry<String, String[]> entry : sqlCases.entrySet())
+ {
+ HTTPResponse response = conn.sqlQuery(entry.getKey());
+ assertEquals(207, response.getStatusCode());
+ assertResponse(entry.getValue(), response);
+ }
+
+ // map containing test-case: <XPATH query> : <expected nodes>
+ Map<String, String[]> xpathCases = new HashMap<String, String[]>();
+ xpathCases.put("/jcr:root/" + testLocalRootName + "/ element(*, nt:base)", expected.toArray(new String[expected
+ .size()]));
+ xpathCases.put("//element(*,nt:file)[fn:name() = 'exoString']", new String[]{"exoString"});
+ // XPATH
+ for (Entry<String, String[]> entry : xpathCases.entrySet())
+ {
+ HTTPResponse response = conn.xpathQuery(entry.getKey());
+ assertEquals(207, response.getStatusCode());
+ assertResponse(entry.getValue(), response);
+ }
+
conn.removeNode(testLocalRootName);
}
/**
+ * Test, searching over the repository nodes with concrete value of concrete property.
+ * jcr:mimeType is used for querying purposes.
+ */
+ public void testPropertyValueSearch() throws Exception
+ {
+ JCRWebdavConnection conn = getConnection();
+ // Nodes with concrete mimetype in form of <name><content>
+ Map<String, String> nodes = new HashMap<String, String>();
+ // text/plain
+ nodes.put("TextDescription", MIME_TEXT_PLAIN);
+ nodes.put("SmallNote", MIME_TEXT_PLAIN);
+ nodes.put("CalendarMemo", MIME_TEXT_PLAIN);
+ nodes.put("GetThisDone", MIME_TEXT_PLAIN);
+ // text/patch
+ nodes.put("CriticalPath", MIME_TEXT_PATCH);
+ nodes.put("BrokenPatch", MIME_TEXT_PATCH);
+ // text/html
+ nodes.put("FirstPage", MIME_TEXT_HTML);
+ nodes.put("AboutGateIn", MIME_TEXT_HTML);
+ nodes.put("LicenseAgreement", MIME_TEXT_HTML);
+ nodes.put("HomePage", MIME_TEXT_HTML);
+ nodes.put("StrangePage", MIME_TEXT_HTML);
+
+ // add nodes
+ for (Entry<String, String> entry : nodes.entrySet())
+ {
+ conn.addNode(entry.getKey(), "content".getBytes(), entry.getValue());
+ }
+
+ // map containing test-case: <SQL query> : <expected nodes>
+ Map<String, String[]> sqlCases = new HashMap<String, String[]>();
+ sqlCases.put("SELECT * FROM nt:resource WHERE jcr:mimeType ='" + MIME_TEXT_PLAIN + "'", getNodesByMime(nodes,
+ MIME_TEXT_PLAIN));
+ sqlCases.put("SELECT * FROM nt:resource WHERE jcr:mimeType ='" + MIME_TEXT_HTML + "'", getNodesByMime(nodes,
+ MIME_TEXT_HTML));
+ sqlCases.put("SELECT * FROM nt:resource WHERE jcr:mimeType LIKE 'text%'", nodes.keySet().toArray(
+ new String[nodes.size()]));
+ // SQL
+ for (Entry<String, String[]> entry : sqlCases.entrySet())
+ {
+ HTTPResponse response = conn.sqlQuery(entry.getKey());
+ assertEquals(207, response.getStatusCode());
+ assertResponse(entry.getValue(), response);
+ }
+
+ // map containing test-case: <XPATH query> : <expected nodes>
+ Map<String, String[]> xpathCases = new HashMap<String, String[]>();
+ xpathCases.put("//element(*,nt:resource)[@jcr:mimeType='" + MIME_TEXT_PLAIN + "']", getNodesByMime(nodes,
+ MIME_TEXT_PLAIN));
+ xpathCases.put("//element(*,nt:resource)[@jcr:mimeType='" + MIME_TEXT_HTML + "']", getNodesByMime(nodes,
+ MIME_TEXT_HTML));
+ xpathCases.put("//element(*,nt:resource)[jcr:like(@jcr:mimeType, 'text%')]", nodes.keySet().toArray(
+ new String[nodes.size()]));
+ // XPATH
+ for (Entry<String, String[]> entry : xpathCases.entrySet())
+ {
+ HTTPResponse response = conn.xpathQuery(entry.getKey());
+ assertEquals(207, response.getStatusCode());
+ assertResponse(entry.getValue(), response);
+ }
+
+ // remove created nodes
+ for (Entry<String, String> entry : nodes.entrySet())
+ {
+ conn.removeNode(entry.getKey());
+ }
+ }
+
+ /**
+ * Checks that response contains expected nodes.
+ *
* @param expected
* @param response
* @throws IOException
@@ -164,28 +254,35 @@
* @throws XMLStreamException
* @throws FactoryConfigurationError
*/
- private void assertResponse(Collection<String> expected, HTTPResponse response) throws IOException, ModuleException,
+ private void assertResponse(String[] expected, HTTPResponse response) throws IOException, ModuleException,
XMLStreamException, FactoryConfigurationError
{
List<String> found;
assertEquals(207, response.getStatusCode());
found = parseNodeNames(response.getData());
- assertTrue("Lists are not equals:\n*found:\t" + found + "\n*expected:\t" + expected,
- compareLists(expected, found));
+ assertTrue("Lists are not equals:\n*found:\t" + found + "\n*expected:\t" + expected, compareLists(Arrays
+ .asList(expected), found));
}
/**
- * @param expected
- * @param response
- * @throws IOException
- * @throws ModuleException
- * @throws XMLStreamException
- * @throws FactoryConfigurationError
+ * Given map nodesMap should contain entry: <nodeName>:<mime-type>, this method returns array with names of
+ * nodes that are only of given mime-type.
+ *
+ * @param nodesMap
+ * @param mime
+ * @return
*/
- private void assertResponse(String[] expected, HTTPResponse response) throws IOException, ModuleException,
- XMLStreamException, FactoryConfigurationError
+ private String[] getNodesByMime(Map<String, String> nodesMap, String mime)
{
- assertResponse(Arrays.asList(expected), response);
+ List<String> filteredNodes = new ArrayList<String>();
+ for (Entry<String, String> entry : nodesMap.entrySet())
+ {
+ if (entry.getValue().equals(mime))
+ {
+ filteredNodes.add(entry.getKey());
+ }
+ }
+ return filteredNodes.toArray(new String[filteredNodes.size()]);
}
/**
@@ -207,9 +304,6 @@
/**
* Extracts names of nodes from response XML
*
- * TODO: fix
- * /!\ Method accumulates nodes in SET, because of https://jira.jboss.org/jira/browse/EXOJCR-364 /!\
- *
* @param data
* @return
* @throws XMLStreamException
16 years, 4 months
exo-jcr SVN: r1306 - in jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src: test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache and 1 other directories.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2010-01-06 04:00:54 -0500 (Wed, 06 Jan 2010)
New Revision: 1306
Added:
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/ChildListEvictionActionPolicy.java
Removed:
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/ExoEvictionActionPolicy.java
Modified:
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/TestExoEvictionActionPolicy.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/standalone/test-jbosscache-config.xml
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/standalone/test-jbosscache-exo-config.xml
Log:
EXOJCR-333 : Rename class ExoEvictionActionPolicy to ChildListEvictionActionPolicy..
Added: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/ChildListEvictionActionPolicy.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/ChildListEvictionActionPolicy.java (rev 0)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/ChildListEvictionActionPolicy.java 2010-01-06 09:00:54 UTC (rev 1306)
@@ -0,0 +1,82 @@
+/*
+ * 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.jbosscache;
+
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+import org.jboss.cache.Cache;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.eviction.EvictionActionPolicy;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>Date: 2010
+ *
+ * @author <a href="mailto:alex.reshetnyak@exoplatform.com.ua">Alex Reshetnyak</a>
+ * @version $Id$
+ */
+public class ChildListEvictionActionPolicy
+ implements EvictionActionPolicy
+{
+ private static final Log LOG = ExoLogger.getLogger("jcr.ExoEvictionActionPolicy");
+
+ private Cache<?, ?> cache;
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean evict(Fqn fqn)
+ {
+
+ if (fqn.size() == 3 && (JBossCacheWorkspaceStorageCache.CHILD_NODES_LIST.equals(fqn.get(0)) || JBossCacheWorkspaceStorageCache.CHILD_PROPS_LIST.equals(fqn.get(0))))
+ {
+ return eviction(fqn.getParent(), true);
+ }
+ else
+ {
+ return eviction(fqn, false);
+ }
+ }
+
+ private boolean eviction(Fqn fqn, boolean recurcive)
+ {
+ try
+ {
+ if (LOG.isDebugEnabled())
+ LOG.debug("Evicting Fqn " + fqn);
+
+ cache.evict(fqn, recurcive);
+ return true;
+ }
+ catch (Exception e)
+ {
+ if (LOG.isDebugEnabled())
+ LOG.debug("Unable to evict " + fqn, e);
+ return false;
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setCache(Cache<?, ?> cache)
+ {
+ this.cache = cache;
+ }
+
+}
Property changes on: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/ChildListEvictionActionPolicy.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Deleted: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/ExoEvictionActionPolicy.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/ExoEvictionActionPolicy.java 2010-01-05 22:16:55 UTC (rev 1305)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/ExoEvictionActionPolicy.java 2010-01-06 09:00:54 UTC (rev 1306)
@@ -1,82 +0,0 @@
-/*
- * 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.jbosscache;
-
-import org.exoplatform.services.log.ExoLogger;
-import org.exoplatform.services.log.Log;
-import org.jboss.cache.Cache;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.eviction.EvictionActionPolicy;
-
-/**
- * Created by The eXo Platform SAS.
- *
- * <br/>Date: 2010
- *
- * @author <a href="mailto:alex.reshetnyak@exoplatform.com.ua">Alex Reshetnyak</a>
- * @version $Id$
- */
-public class ExoEvictionActionPolicy
- implements EvictionActionPolicy
-{
- private static final Log LOG = ExoLogger.getLogger("jcr.ExoEvictionActionPolicy");
-
- private Cache<?, ?> cache;
-
- /**
- * {@inheritDoc}
- */
- public boolean evict(Fqn fqn)
- {
-
- if (fqn.size() == 3 && (JBossCacheWorkspaceStorageCache.CHILD_NODES_LIST.equals(fqn.get(0)) || JBossCacheWorkspaceStorageCache.CHILD_PROPS_LIST.equals(fqn.get(0))))
- {
- return eviction(fqn.getParent(), true);
- }
- else
- {
- return eviction(fqn, false);
- }
- }
-
- private boolean eviction(Fqn fqn, boolean recurcive)
- {
- try
- {
- if (LOG.isDebugEnabled())
- LOG.debug("Evicting Fqn " + fqn);
-
- cache.evict(fqn, recurcive);
- return true;
- }
- catch (Exception e)
- {
- if (LOG.isDebugEnabled())
- LOG.debug("Unable to evict " + fqn, e);
- return false;
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void setCache(Cache<?, ?> cache)
- {
- this.cache = cache;
- }
-
-}
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/TestExoEvictionActionPolicy.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/TestExoEvictionActionPolicy.java 2010-01-05 22:16:55 UTC (rev 1305)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/TestExoEvictionActionPolicy.java 2010-01-06 09:00:54 UTC (rev 1306)
@@ -81,6 +81,14 @@
cacheRoot.addChild(this.childPropsList).setResident(true);
}
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+
+ cache.stop();
+ cache.destroy();
+ }
+
protected void initJBCConfig()
{
jbcConfig = "src/test/resources/conf/standalone/test-jbosscache-exo-config.xml";
@@ -156,7 +164,7 @@
@NodeEvicted
public void createdNodeEvent(NodeEvent ne)
{
- System.out.println("Node evicred: " + ne.getFqn());
+ System.out.println("Node evicted: " + ne.getFqn());
}
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/standalone/test-jbosscache-config.xml
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/standalone/test-jbosscache-config.xml 2010-01-05 22:16:55 UTC (rev 1305)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/standalone/test-jbosscache-config.xml 2010-01-06 09:00:54 UTC (rev 1306)
@@ -1,6 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:jboss:jbosscache-core:config:3.1">
+ <locking useLockStriping="false" concurrencyLevel="50000" lockParentForChildInsertRemove="false" lockAcquisitionTimeout="3600000"/>
+
<!-- Configure the TransactionManager -->
<transaction transactionManagerLookupClass="org.jboss.cache.transaction.JBossStandaloneJTAManagerLookup" />
@@ -13,7 +15,7 @@
<property name="maxNodes" value="5000" />
<property name="timeToLiveSeconds" value="120" />
</default>
- <region name="/" algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" actionPolicyClass="org.exoplatform.services.jcr.impl.dataflow.persistent.jbosscache.ExoEvictionActionPolicy" eventQueueSize="1000000">
+ <region name="/" algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" actionPolicyClass="org.exoplatform.services.jcr.impl.dataflow.persistent.jbosscache.ChildListEvictionActionPolicy" eventQueueSize="1000000">
<property name="maxNodes" value="5000" />
<property name="timeToLiveSeconds" value="120" />
</region>
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/standalone/test-jbosscache-exo-config.xml
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/standalone/test-jbosscache-exo-config.xml 2010-01-05 22:16:55 UTC (rev 1305)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/standalone/test-jbosscache-exo-config.xml 2010-01-06 09:00:54 UTC (rev 1306)
@@ -15,7 +15,7 @@
<property name="maxNodes" value="50" />
<property name="timeToLiveSeconds" value="20" />
</default>
- <region name="/" algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" actionPolicyClass="org.exoplatform.services.jcr.impl.dataflow.persistent.jbosscache.ExoEvictionActionPolicy" eventQueueSize="1000000">
+ <region name="/" algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" actionPolicyClass="org.exoplatform.services.jcr.impl.dataflow.persistent.jbosscache.ChildListEvictionActionPolicy" eventQueueSize="1000000">
<property name="maxNodes" value="50" />
<property name="timeToLiveSeconds" value="20" />
</region>
16 years, 4 months
exo-jcr SVN: r1305 - in jcr/branches/1.12.0-OPT/exo.jcr.component.core: src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc and 2 other directories.
by do-not-reply@jboss.org
Author: pnedonosko
Date: 2010-01-05 17:16:55 -0500 (Tue, 05 Jan 2010)
New Revision: 1305
Added:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/jdbc/SQLBenchmarkTest.java
Removed:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/storage/jdbc/
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/pom.xml
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java
Log:
EXOJCR-302 rollback of SQLBenchmarkTest move (due to members visibility); SQLBenchmarkTest excluded in the pom, use dev-tests inclusion for run
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/pom.xml
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/pom.xml 2010-01-05 21:56:12 UTC (rev 1304)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/pom.xml 2010-01-05 22:16:55 UTC (rev 1305)
@@ -207,6 +207,7 @@
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>8.2-504.jdbc3</version>
+ <!-- version>8.3-603.jdbc3</version -->
<scope>test</scope>
</dependency>
@@ -330,6 +331,7 @@
<!-- forking: to run both eXo test and TCK use forkMode=once, to run one of them (only) in Eclipse debug use forkMode=never -->
<configuration>
<argLine>${env.MAVEN_OPTS}</argLine>
+ <forkMode>${exo.test.forkMode}</forkMode>
<systemProperties>
<property>
<name>jcr.test.configuration.file</name>
@@ -368,8 +370,8 @@
<exclude>org/exoplatform/services/jcr/**/usecases/BaseUsecasesTest.java</exclude>
<exclude>org/exoplatform/services/jcr/**/api/**/TestSameNameItems.java</exclude>
<exclude>org/exoplatform/services/jcr/**/api/**/TestVersionRestore.java</exclude>
-
<exclude>org/exoplatform/services/jcr/**/impl/**/TestSessionDataManager.java</exclude>
+ <exclude>org/exoplatform/services/jcr/**/impl/**/SQLBenchmarkTest.java</exclude>
</excludes>
</configuration>
</plugin>
@@ -496,6 +498,7 @@
<configuration>
<argLine>${env.MAVEN_OPTS}</argLine>
<phase>test</phase>
+ <forkMode>${exo.test.forkMode}</forkMode>
<goals>
<goal>test</goal>
</goals>
@@ -557,6 +560,7 @@
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<phase>test</phase>
+ <forkMode>${exo.test.forkMode}</forkMode>
<goals>
<goal>test</goal>
</goals>
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java 2010-01-05 21:56:12 UTC (rev 1304)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java 2010-01-05 22:16:55 UTC (rev 1305)
@@ -218,7 +218,7 @@
* Item id
* @return String with container internal id
*/
- public abstract String getInternalId(String identifier);
+ protected abstract String getInternalId(String identifier);
/**
* Used in loadXYZRecord methods for extract real Identifier from container value.
@@ -849,9 +849,9 @@
* @throws IllegalNameException
* - if name on the path is wrong
*/
- public QPath traverseQPath(String cpid) throws SQLException, InvalidItemStateException, IllegalNameException
+ protected QPath traverseQPath(String cpid) throws SQLException, InvalidItemStateException, IllegalNameException
{
- // get item by Identifier usecase
+ // get item by Identifier usecase
List<QPathEntry> qrpath = new ArrayList<QPathEntry>(); // reverted path
String caid = cpid; // container ancestor id
do
Copied: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/jdbc/SQLBenchmarkTest.java (from rev 1303, jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/storage/jdbc/SQLBenchmarkTest.java)
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/jdbc/SQLBenchmarkTest.java (rev 0)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/jdbc/SQLBenchmarkTest.java 2010-01-05 22:16:55 UTC (rev 1305)
@@ -0,0 +1,705 @@
+package org.exoplatform.services.jcr.impl.storage.jdbc;
+
+import java.sql.SQLException;
+import java.util.Arrays;
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.atomic.AtomicReference;
+
+import javax.jcr.InvalidItemStateException;
+import javax.jcr.RepositoryException;
+
+import org.exoplatform.container.StandaloneContainer;
+import org.exoplatform.services.jcr.BaseStandaloneTest;
+import org.exoplatform.services.jcr.RepositoryService;
+import org.exoplatform.services.jcr.core.WorkspaceContainerFacade;
+import org.exoplatform.services.jcr.dataflow.persistent.PersistedNodeData;
+import org.exoplatform.services.jcr.dataflow.persistent.PersistedPropertyData;
+import org.exoplatform.services.jcr.datamodel.IllegalNameException;
+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.Constants;
+import org.exoplatform.services.jcr.impl.core.RepositoryImpl;
+import org.exoplatform.services.jcr.storage.WorkspaceDataContainer;
+import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
+
+/*
+ * Copyright (C) 2003-2009 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * This benchmark only works with mysql with the dump that you can find in src/test/resources/SQLBenchmark/exodb_data.sql.zip
+ *
+ *
+ * Created by The eXo Platform SAS
+ * Author : Nicolas Filotto
+ * nicolas.filotto(a)exoplatform.com
+ * 18 nov. 2009
+ */
+public class SQLBenchmarkTest
+{
+/*
+ static
+ {
+ try
+ {
+ Class.forName("com.jdbmonitor.MonitorDriver");
+ System.out.println("Driver Loaded");
+ }
+ catch (ClassNotFoundException e)
+ {
+ e.printStackTrace();
+ }
+
+ }
+*/
+ /**
+ * @param args
+ */
+ public static void main(String[] args) throws Exception
+ {
+ String containerConf =
+ BaseStandaloneTest.class.getResource("/conf/standalone/sql-benchmark-configuration.xml").toString();
+ String loginConf = BaseStandaloneTest.class.getResource("/login.conf").toString();
+
+ StandaloneContainer.addConfigurationURL(containerConf);
+
+ StandaloneContainer container = StandaloneContainer.getInstance();
+
+ if (System.getProperty("java.security.auth.login.config") == null)
+ System.setProperty("java.security.auth.login.config", loginConf);
+
+ benchmark(1, container);
+ benchmark(10, container);
+ benchmark(20, container);
+ benchmark(50, container);
+ benchmark(100, container);
+ }
+
+ private static void benchmark(int threads, StandaloneContainer container) throws Exception
+ {
+ RepositoryService repositoryService =
+ (RepositoryService)container.getComponentInstanceOfType(RepositoryService.class);
+ RepositoryImpl repository1 = (RepositoryImpl)repositoryService.getRepository("repository1");
+ WorkspaceContainerFacade wsc1 = repository1.getWorkspaceContainer("collaboration");
+ final WorkspaceDataContainer dataContainer1 =
+ (WorkspaceDataContainer)wsc1.getComponent(WorkspaceDataContainer.class);
+ WorkspaceContainerFacade wsc1s = repository1.getWorkspaceContainer("system");
+ final WorkspaceDataContainer dataContainer1s =
+ (WorkspaceDataContainer)wsc1s.getComponent(WorkspaceDataContainer.class);
+ RepositoryImpl repository2 = (RepositoryImpl)repositoryService.getRepository("repository2");
+ WorkspaceContainerFacade wsc2 = repository2.getWorkspaceContainer("collaboration");
+ final WorkspaceDataContainer dataContainer2 =
+ (WorkspaceDataContainer)wsc2.getComponent(WorkspaceDataContainer.class);
+ WorkspaceContainerFacade wsc2s = repository2.getWorkspaceContainer("system");
+ final WorkspaceDataContainer dataContainer2s =
+ (WorkspaceDataContainer)wsc2s.getComponent(WorkspaceDataContainer.class);
+
+ System.out.println("########################################");
+
+ int totalTimes;
+ long time;
+ NodeData parent;
+
+ totalTimes = 5000 / threads;
+ QPath path1 = null;
+ Task<QPath> traverseQPath = new Task<QPath>()
+ {
+ public QPath execute(Object... args) throws Exception
+ {
+ return traverseQPath((WorkspaceDataContainer)args[0], (String)args[1]);
+ }
+
+ };
+ Result<QPath> rTraverseQPath =
+ executeTask(traverseQPath, totalTimes, threads, dataContainer1, Constants.ROOT_UUID);
+ path1 = rTraverseQPath.getResult();
+ time = rTraverseQPath.getTime();
+ System.out.println("traverseQPath with deep 0, thread " + threads
+ + ": Total time with the old strategy (n queries) = " + time + ", avg = " + (time / (threads * totalTimes)));
+ QPath path2 = null;
+ rTraverseQPath = executeTask(traverseQPath, totalTimes, threads, dataContainer2, Constants.ROOT_UUID);
+ path2 = rTraverseQPath.getResult();
+ time = rTraverseQPath.getTime();
+ System.out.println("traverseQPath with deep 0, thread " + threads + ": Total time with the new strategy 0 = "
+ + time + ", avg = " + (time / (threads * totalTimes)));
+ System.out.println("path1 == path2 = " + equals(path1, path2));
+
+ rTraverseQPath =
+ executeTask(traverseQPath, totalTimes, threads, dataContainer1, "dfcbd34bc0a8010b006357806c7f108d");
+ path1 = rTraverseQPath.getResult();
+ time = rTraverseQPath.getTime();
+ System.out.println("traverseQPath with deep 1, thread " + threads
+ + ": Total time with the old strategy (n queries) = " + time + ", avg = " + (time / (threads * totalTimes)));
+
+ rTraverseQPath =
+ executeTask(traverseQPath, totalTimes, threads, dataContainer2, "dfcbd34bc0a8010b006357806c7f108d");
+ path2 = rTraverseQPath.getResult();
+ time = rTraverseQPath.getTime();
+ System.out.println("traverseQPath with deep 1, thread " + threads
+ + ": Total time with the new strategy (n/2 queries) = " + time + ", avg = " + (time / (threads * totalTimes)));
+ System.out.println("path1 == path2 = " + equals(path1, path2));
+
+ rTraverseQPath =
+ executeTask(traverseQPath, totalTimes, threads, dataContainer1, "dfcbe240c0a8010b00ff024d54e46b9f");
+ path1 = rTraverseQPath.getResult();
+ time = rTraverseQPath.getTime();
+ System.out.println("traverseQPath with deep 2, thread " + threads
+ + ": Total time with the old strategy (n queries) = " + time + ", avg = " + (time / (threads * totalTimes)));
+
+ rTraverseQPath =
+ executeTask(traverseQPath, totalTimes, threads, dataContainer2, "dfcbe240c0a8010b00ff024d54e46b9f");
+ path2 = rTraverseQPath.getResult();
+ time = rTraverseQPath.getTime();
+ System.out.println("traverseQPath with deep 2, thread " + threads
+ + ": Total time with the new strategy (n/2 queries) = " + time + ", avg = " + (time / (threads * totalTimes)));
+ System.out.println("path1 == path2 = " + equals(path1, path2));
+
+ rTraverseQPath =
+ executeTask(traverseQPath, totalTimes, threads, dataContainer1, "dfcbffaec0a8010b00ed7dad7cb43540");
+ path1 = rTraverseQPath.getResult();
+ time = rTraverseQPath.getTime();
+ System.out.println("traverseQPath with deep 5, thread " + threads
+ + ": Total time with the old strategy (n queries) = " + time + ", avg = " + (time / (threads * totalTimes)));
+
+ rTraverseQPath =
+ executeTask(traverseQPath, totalTimes, threads, dataContainer2, "dfcbffaec0a8010b00ed7dad7cb43540");
+ path2 = rTraverseQPath.getResult();
+ time = rTraverseQPath.getTime();
+ System.out.println("traverseQPath with deep 5, thread " + threads
+ + ": Total time with the new strategy (n/2 queries) = " + time + ", avg = " + (time / (threads * totalTimes)));
+ System.out.println("path1 == path2 = " + equals(path1, path2));
+
+ rTraverseQPath =
+ executeTask(traverseQPath, totalTimes, threads, dataContainer1, "83cb7ebeac1b00a400bf3596e43c8f18");
+ path1 = rTraverseQPath.getResult();
+ time = rTraverseQPath.getTime();
+ System.out.println("traverseQPath with deep 9, thread " + threads
+ + ": Total time with the old strategy (n queries) = " + time + ", avg = " + (time / (threads * totalTimes)));
+
+ rTraverseQPath =
+ executeTask(traverseQPath, totalTimes, threads, dataContainer2, "83cb7ebeac1b00a400bf3596e43c8f18");
+ path2 = rTraverseQPath.getResult();
+ time = rTraverseQPath.getTime();
+ System.out.println("traverseQPath with deep 9, thread " + threads
+ + ": Total time with the new strategy (n/2 queries) = " + time + ", avg = " + (time / (threads * totalTimes)));
+ System.out.println("path1 == path2 = " + equals(path1, path2));
+
+ totalTimes = 1;
+ parent =
+ new PersistedNodeData("83cb2a36ac1b00a400bdbe4f3f4f6e0e", Constants.ROOT_PATH, null, 0, 0, null, null, null);
+
+ Task<List<NodeData>> getChildNodesData = new Task<List<NodeData>>()
+ {
+ public List<NodeData> execute(Object... args) throws Exception
+ {
+ return getChildNodesData((WorkspaceDataContainer)args[0], (NodeData)args[1]);
+ }
+
+ };
+ List<NodeData> nodesData1 = null;
+
+ Result<List<NodeData>> rGetChildNodesData =
+ executeTask(getChildNodesData, totalTimes, threads, dataContainer1, parent);
+ nodesData1 = rGetChildNodesData.getResult();
+ time = rGetChildNodesData.getTime();
+ System.out.println("getChildNodesData with 1034 subnodes, thread " + threads
+ + ": Total time with the old strategy (4*n + 1 queries) = " + time + ", avg = "
+ + (time / (threads * totalTimes)));
+ List<NodeData> nodesData2 = null;
+ rGetChildNodesData = executeTask(getChildNodesData, totalTimes, threads, dataContainer2, parent);
+ nodesData2 = rGetChildNodesData.getResult();
+ time = rGetChildNodesData.getTime();
+ System.out.println("getChildNodesData with 1034 subnodes, thread " + threads
+ + ": Total time with the new strategy (1 query) = " + time + ", avg = " + (time / (threads * totalTimes)));
+ try
+ {
+ System.out.println("length = " + nodesData1.size());
+ System.out.println("nodesData1 == nodesData2 = " + equals(nodesData1, nodesData2) + " length = "
+ + nodesData1.size());
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ totalTimes = 100 / threads;
+ parent =
+ new PersistedNodeData("83c6e36cac1b00a400688aeb844539b2", Constants.ROOT_PATH, null, 0, 0, null, null, null);
+ rGetChildNodesData = executeTask(getChildNodesData, totalTimes, threads, dataContainer1, parent);
+ nodesData1 = rGetChildNodesData.getResult();
+ time = rGetChildNodesData.getTime();
+ System.out.println("getChildNodesData with 4 subnodes, thread " + threads
+ + ": Total time with the old strategy (4*n + 1 queries) = " + time + ", avg = "
+ + (time / (threads * totalTimes)));
+
+ rGetChildNodesData = executeTask(getChildNodesData, totalTimes, threads, dataContainer2, parent);
+ nodesData2 = rGetChildNodesData.getResult();
+ time = rGetChildNodesData.getTime();
+ System.out.println("getChildNodesData with 4 subnodes, thread " + threads
+ + ": Total time with the new strategy (1 query) = " + time + ", avg = " + (time / (threads * totalTimes)));
+ System.out.println("nodesData1 == nodesData2 = " + equals(nodesData1, nodesData2) + " length = "
+ + nodesData1.size());
+
+ totalTimes = 1000 / threads;
+
+ Task<ItemData> getItemData = new Task<ItemData>()
+ {
+ public ItemData execute(Object... args) throws Exception
+ {
+ return getItemData((WorkspaceDataContainer)args[0], (String)args[1]);
+ }
+
+ };
+ PersistedNodeData nodeData1 = null;
+ Result<ItemData> rGetItemData =
+ executeTask(getItemData, totalTimes, threads, dataContainer1, "83c6e36cac1b00a400688aeb844539b2");
+ nodeData1 = (PersistedNodeData)rGetItemData.getResult();
+ time = rGetItemData.getTime();
+ System.out.println("getItemData by Id for a node, thread " + threads
+ + ": Total time with the old strategy (5 queries) = " + time + ", avg = " + (time / (threads * totalTimes)));
+
+ PersistedNodeData nodeData2 = null;
+ rGetItemData = executeTask(getItemData, totalTimes, threads, dataContainer2, "83c6e36cac1b00a400688aeb844539b2");
+ nodeData2 = (PersistedNodeData)rGetItemData.getResult();
+ time = rGetItemData.getTime();
+ System.out.println("getItemData by Id for a node, thread " + threads
+ + ": Total time with the new strategy (2 queries) = " + time + ", avg = " + (time / (threads * totalTimes)));
+ System.out.println("nodeData1 == nodeData2 = " + equals(nodeData1, nodeData2));
+
+ PersistedPropertyData propertyData1 = null;
+ rGetItemData = executeTask(getItemData, totalTimes, threads, dataContainer1, "83c6e36cac1b00a40038e9e950ecff39");
+ propertyData1 = (PersistedPropertyData)rGetItemData.getResult();
+ time = rGetItemData.getTime();
+ System.out.println("getItemData by Id for a property, thread " + threads
+ + ": Total time with the old strategy (2 queries) = " + time + ", avg = " + (time / (threads * totalTimes)));
+
+ PersistedPropertyData propertyData2 = null;
+ rGetItemData = executeTask(getItemData, totalTimes, threads, dataContainer2, "83c6e36cac1b00a40038e9e950ecff39");
+ propertyData2 = (PersistedPropertyData)rGetItemData.getResult();
+ time = rGetItemData.getTime();
+ System.out.println("getItemData by Id for a property, thread " + threads
+ + ": Total time with the new strategy (2 queries) (=old strategy) = " + time + ", avg = "
+ + (time / (threads * totalTimes)));
+ System.out.println("propertyData1 == propertyData2 = " + equals(propertyData1, propertyData2));
+
+ NodeData parent2 =
+ new PersistedNodeData("00exo0jcr0root0uuid0000000000000", Constants.ROOT_PATH, null, 0, 0, null, null, null);
+ QPathEntry name2 = new QPathEntry(null, "Documents", 1);
+
+ Task<ItemData> getItemData2 = new Task<ItemData>()
+ {
+ public ItemData execute(Object... args) throws Exception
+ {
+ return getItemData((WorkspaceDataContainer)args[0], (NodeData)args[1], (QPathEntry)args[2]);
+ }
+
+ };
+ rGetItemData = executeTask(getItemData2, totalTimes, threads, dataContainer1, parent2, name2);
+ nodeData1 = (PersistedNodeData)rGetItemData.getResult();
+ time = rGetItemData.getTime();
+ System.out.println("getItemData by QPathEntry for a node, thread " + threads
+ + ": Total time with the old strategy = " + time + ", avg = " + (time / (threads * totalTimes)));
+
+ rGetItemData = executeTask(getItemData2, totalTimes, threads, dataContainer2, parent2, name2);
+ nodeData2 = (PersistedNodeData)rGetItemData.getResult();
+ time = rGetItemData.getTime();
+ System.out.println("getItemData by QPathEntry for a node, thread " + threads
+ + ": Total time with the new strategy = " + time + ", avg = " + (time / (threads * totalTimes)));
+ System.out.println("nodeData1 == nodeData2 = " + equals(nodeData1, nodeData2));
+
+ NodeData parent3 = nodeData1;
+ QPathEntry name3 = new QPathEntry("http://www.exoplatform.com/jcr/exo/1.0", "permissions", 1);
+
+ rGetItemData = executeTask(getItemData2, totalTimes, threads, dataContainer1, parent3, name3);
+ propertyData1 = (PersistedPropertyData)rGetItemData.getResult();
+ time = rGetItemData.getTime();
+ System.out.println("getItemData by QPathEntry for a property, thread " + threads
+ + ": Total time with the old strategy = " + time + ", avg = " + (time / (threads * totalTimes)));
+
+ rGetItemData = executeTask(getItemData2, totalTimes, threads, dataContainer2, parent3, name3);
+ propertyData2 = (PersistedPropertyData)rGetItemData.getResult();
+ time = rGetItemData.getTime();
+ System.out.println("getItemData by QPathEntry for a property, thread " + threads
+ + ": Total time with the new strategy = " + time + ", avg = " + (time / (threads * totalTimes)));
+ System.out.println("propertyData1 == propertyData2 = " + equals(propertyData1, propertyData2));
+
+ parent =
+ new PersistedNodeData("83c7507eac1b00a400cf6d951b948e23", Constants.ROOT_PATH, null, 0, 0, null, null, null);
+
+ totalTimes = 100 / threads;
+ Task<List<PropertyData>> getChildPropertiesData = new Task<List<PropertyData>>()
+ {
+ public List<PropertyData> execute(Object... args) throws Exception
+ {
+ return getChildPropertiesData((WorkspaceDataContainer)args[0], (NodeData)args[1]);
+ }
+
+ };
+ List<PropertyData> propertiesData1 = null;
+ Result<List<PropertyData>> rGetChildPropertiesData =
+ executeTask(getChildPropertiesData, totalTimes, threads, dataContainer1, parent);
+ propertiesData1 = rGetChildPropertiesData.getResult();
+ time = rGetChildPropertiesData.getTime();
+ System.out.println("getChildPropertiesData with 20 properties, thread " + threads
+ + ": Total time with the old strategy (n + 1 queries) = " + time + ", avg = "
+ + (time / (threads * totalTimes)));
+ List<PropertyData> propertiesData2 = null;
+ rGetChildPropertiesData = executeTask(getChildPropertiesData, totalTimes, threads, dataContainer2, parent);
+ propertiesData2 = rGetChildPropertiesData.getResult();
+ time = rGetChildPropertiesData.getTime();
+ System.out.println("getChildPropertiesData with 20 properties, thread " + threads
+ + ": Total time with the new strategy (1 query) = " + time + ", avg = " + (time / (threads * totalTimes)));
+ try
+ {
+ System.out.println("propertiesData1 == propertiesData2 = " + equalsP(propertiesData1, propertiesData2)
+ + " length = " + propertiesData1.size());
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ totalTimes = 100 / threads;
+ parent =
+ new PersistedNodeData("83c6e36cac1b00a400688aeb844539b2", Constants.ROOT_PATH, null, 0, 0, null, null, null);
+ rGetChildPropertiesData = executeTask(getChildPropertiesData, totalTimes, threads, dataContainer1, parent);
+ propertiesData1 = rGetChildPropertiesData.getResult();
+ time = rGetChildPropertiesData.getTime();
+ System.out.println("getChildPropertiesData with 6 properties, thread " + threads
+ + ": Total time with the old strategy (n + 1 queries) = " + time + ", avg = "
+ + (time / (threads * totalTimes)));
+
+ rGetChildPropertiesData = executeTask(getChildPropertiesData, totalTimes, threads, dataContainer2, parent);
+ propertiesData2 = rGetChildPropertiesData.getResult();
+ time = rGetChildPropertiesData.getTime();
+ System.out.println("getChildPropertiesData with 6 properties, thread " + threads
+ + ": Total time with the new strategy (1 query) = " + time + ", avg = " + (time / (threads * totalTimes)));
+ System.out.println("propertiesData1 == propertiesData2 = " + equalsP(propertiesData1, propertiesData2)
+ + " length = " + propertiesData1.size());
+
+ totalTimes = 100 / threads;
+ Task<List<PropertyData>> getReferencesData = new Task<List<PropertyData>>()
+ {
+ public List<PropertyData> execute(Object... args) throws Exception
+ {
+ return getReferencesData((WorkspaceDataContainer)args[0], (String)args[1]);
+ }
+
+ };
+ Result<List<PropertyData>> rGetReferencesData =
+ executeTask(getReferencesData, totalTimes, threads, dataContainer1s, "dfcbf3cfc0a8010b00a3f5f3b962c76a");
+ propertiesData1 = rGetReferencesData.getResult();
+ time = rGetReferencesData.getTime();
+ System.out.println("getReferencesData with 3 properties, thread " + threads
+ + ": Total time with the old strategy (n + 1 queries) = " + time + ", avg = "
+ + (time / (threads * totalTimes)));
+
+ rGetReferencesData =
+ executeTask(getReferencesData, totalTimes, threads, dataContainer2s, "dfcbf3cfc0a8010b00a3f5f3b962c76a");
+ propertiesData2 = rGetReferencesData.getResult();
+ time = rGetReferencesData.getTime();
+ System.out.println("getReferencesData with 3 properties, thread " + threads
+ + ": Total time with the new strategy (1 query) = " + time + ", avg = " + (time / (threads * totalTimes)));
+ try
+ {
+ System.out.println("propertiesData1 == propertiesData2 = " + equalsP(propertiesData1, propertiesData2)
+ + " length = " + propertiesData1.size());
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ totalTimes = 100 / threads;
+ rGetReferencesData =
+ executeTask(getReferencesData, totalTimes, threads, dataContainer1, "dfcbe9d6c0a8010b004ccac41a161c5d");
+ propertiesData1 = rGetReferencesData.getResult();
+ time = rGetReferencesData.getTime();
+ System.out.println("getReferencesData with 1 property, thread " + threads
+ + ": Total time with the old strategy (n + 1 queries) = " + time + ", avg = "
+ + (time / (threads * totalTimes)));
+
+ rGetReferencesData =
+ executeTask(getReferencesData, totalTimes, threads, dataContainer2, "dfcbe9d6c0a8010b004ccac41a161c5d");
+ propertiesData2 = rGetReferencesData.getResult();
+ time = rGetReferencesData.getTime();
+ System.out.println("getReferencesData with 1 property, thread " + threads
+ + ": Total time with the new strategy (1 query) = " + time + ", avg = " + (time / (threads * totalTimes)));
+ System.out.println("propertiesData1 == propertiesData2 = " + equalsP(propertiesData1, propertiesData2)
+ + " length = " + propertiesData1.size());
+ }
+
+ private static boolean equals(PersistedNodeData nodeData1, PersistedNodeData nodeData2)
+ {
+ return nodeData1.getACL().equals(nodeData2.getACL())
+ && nodeData1.getIdentifier().equals(nodeData2.getIdentifier())
+ && Arrays.equals(nodeData1.getMixinTypeNames(), nodeData2.getMixinTypeNames())
+ && nodeData1.getOrderNumber() == nodeData2.getOrderNumber()
+ && nodeData1.getParentIdentifier().equals(nodeData2.getParentIdentifier())
+ && nodeData1.getPersistedVersion() == nodeData2.getPersistedVersion()
+ && nodeData1.getPrimaryTypeName().equals(nodeData2.getPrimaryTypeName())
+ && nodeData1.getQPath().equals(nodeData2.getQPath()) && nodeData1.isNode() == nodeData2.isNode();
+ }
+
+ private static boolean equals(PersistedPropertyData propertyData1, PersistedPropertyData propertyData2)
+ {
+ boolean result =
+ propertyData1.isMultiValued() == propertyData2.isMultiValued()
+ && propertyData1.isNode() == propertyData2.isNode()
+ && propertyData1.getIdentifier().equals(propertyData2.getIdentifier())
+ && propertyData1.getParentIdentifier().equals(propertyData2.getParentIdentifier())
+ && propertyData1.getPersistedVersion() == propertyData2.getPersistedVersion()
+ && propertyData1.getQPath().equals(propertyData2.getQPath())
+ && propertyData1.getType() == propertyData2.getType();
+ if (!result)
+ {
+ return false;
+ }
+ List<ValueData> values1 = propertyData1.getValues();
+ List<ValueData> values2 = propertyData2.getValues();
+ if (values1 == null)
+ {
+ return values2 == null;
+ }
+ else if (values2 == null || values1.size() != values2.size())
+ {
+ return false;
+ }
+ else
+ {
+ for (int i = 0; i < values1.size(); i++)
+ {
+ ValueData value1 = values1.get(i);
+ ValueData value2 = values2.get(i);
+ result =
+ value1.isByteArray() == value2.isByteArray() && value1.getLength() == value2.getLength()
+ && value1.getOrderNumber() == value2.getOrderNumber();
+ if (!result)
+ {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ private static boolean equals(QPath path1, QPath path2)
+ {
+ return path1.equals(path2);
+ }
+
+ private static boolean equalsP(List<PropertyData> propertiesData1, List<PropertyData> propertiesData2)
+ {
+ if (propertiesData1 == null)
+ {
+ return propertiesData2 == null;
+ }
+ else if (propertiesData2 == null || propertiesData1.size() != propertiesData2.size())
+ {
+ return false;
+ }
+ else
+ {
+ for (int i = 0; i < propertiesData1.size(); i++)
+ {
+ PersistedPropertyData propertyData1 = (PersistedPropertyData)propertiesData1.get(i);
+ PersistedPropertyData propertyData2 = (PersistedPropertyData)propertiesData2.get(i);
+ if (!equals(propertyData1, propertyData2))
+ {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ private static boolean equals(List<NodeData> nodesData1, List<NodeData> nodesData2)
+ {
+ if (nodesData1 == null)
+ {
+ return nodesData2 == null;
+ }
+ else if (nodesData2 == null || nodesData1.size() != nodesData2.size())
+ {
+ return false;
+ }
+ else
+ {
+ for (int i = 0; i < nodesData1.size(); i++)
+ {
+ PersistedNodeData nodeData1 = (PersistedNodeData)nodesData1.get(i);
+ PersistedNodeData nodeData2 = (PersistedNodeData)nodesData2.get(i);
+ if (!equals(nodeData1, nodeData2))
+ {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ public static ItemData getItemData(WorkspaceDataContainer dataContainer, NodeData parentData, QPathEntry name)
+ throws RepositoryException, IllegalStateException
+ {
+ final WorkspaceStorageConnection con = dataContainer.openConnection();
+ try
+ {
+ return con.getItemData(parentData, name);
+ }
+ finally
+ {
+ con.close();
+ }
+ }
+
+ private static ItemData getItemData(WorkspaceDataContainer dataContainer, final String identifier)
+ throws RepositoryException
+ {
+ final WorkspaceStorageConnection con = dataContainer.openConnection();
+ try
+ {
+ return con.getItemData(identifier);
+ }
+ finally
+ {
+ con.close();
+ }
+ }
+
+ private static List<NodeData> getChildNodesData(WorkspaceDataContainer dataContainer, final NodeData parent)
+ throws RepositoryException
+ {
+ final WorkspaceStorageConnection con = dataContainer.openConnection();
+ try
+ {
+ return con.getChildNodesData(parent);
+ }
+ finally
+ {
+ con.close();
+ }
+ }
+
+ private static List<PropertyData> getChildPropertiesData(WorkspaceDataContainer dataContainer, final NodeData parent)
+ throws RepositoryException
+ {
+ final WorkspaceStorageConnection con = dataContainer.openConnection();
+ try
+ {
+ return con.getChildPropertiesData(parent);
+ }
+ finally
+ {
+ con.close();
+ }
+ }
+
+ private static List<PropertyData> getReferencesData(WorkspaceDataContainer dataContainer, final String identifier)
+ throws RepositoryException
+ {
+ final WorkspaceStorageConnection con = dataContainer.openConnection();
+ try
+ {
+ return con.getReferencesData(identifier);
+ }
+ finally
+ {
+ con.close();
+ }
+ }
+
+ private static QPath traverseQPath(WorkspaceDataContainer dataContainer, final String identifier)
+ throws RepositoryException, SQLException, InvalidItemStateException, IllegalNameException
+ {
+ final JDBCStorageConnection con = (JDBCStorageConnection)dataContainer.openConnection();
+ try
+ {
+ return con.traverseQPath(con.getInternalId(identifier));
+ }
+ finally
+ {
+ con.close();
+ }
+ }
+
+ private static interface Task<R>
+ {
+ R execute(Object... args) throws Exception;
+ }
+
+ private static class Result<R>
+ {
+ private final R result;
+
+ private final long time;
+
+ public Result(R result, long time)
+ {
+ this.result = result;
+ this.time = time;
+ }
+
+ public R getResult()
+ {
+ return result;
+ }
+
+ public long getTime()
+ {
+ return time;
+ }
+ }
+
+ private static <R> Result<R> executeTask(final Task<R> task, final int totalTimes, int threads, final Object... args)
+ throws InterruptedException
+ {
+ final CountDownLatch startSignal = new CountDownLatch(1);
+ final CountDownLatch doneSignal = new CountDownLatch(threads);
+ final AtomicReference<R> result = new AtomicReference<R>();
+ for (int i = 0; i < threads; i++)
+ {
+ Thread t = new Thread()
+ {
+ public void run()
+ {
+ try
+ {
+ startSignal.await();
+ for (int i = 0; i < totalTimes; i++)
+ {
+ result.set(task.execute(args));
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ finally
+ {
+ doneSignal.countDown();
+ }
+ }
+ };
+ t.start();
+ }
+ long time = System.currentTimeMillis();
+ startSignal.countDown();
+ doneSignal.await();
+ return new Result<R>(result.get(), System.currentTimeMillis() - time);
+ }
+}
16 years, 4 months