Author: jukka Date: Tue Aug 3 14:12:38 2010 New Revision: 981892 URL: http://svn.apache.org/viewvc?rev=981892&view=rev Log: JCR-2695: Jackrabbit performance test suite Backport jcr-benchmark to JCR 1.0 so we can use it over both Jackrabbit 1.x and 2.x Modified: jackrabbit/commons/jcr-benchmark/trunk/pom.xml jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/AbstractBenchmarkTest.java jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/BigCollectionTest.java jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/BigFileReadTest.java jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/BigFileWriteTest.java jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/PerformanceTestSuite.java jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/SmallFileReadTest.java jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/SmallFileWriteTest.java Modified: jackrabbit/commons/jcr-benchmark/trunk/pom.xml URL: http://svn.apache.org/viewvc/jackrabbit/commons/jcr-benchmark/trunk/pom.xml?rev=981892&r1=981891&r2=981892&view=diff ============================================================================== --- jackrabbit/commons/jcr-benchmark/trunk/pom.xml (original) +++ jackrabbit/commons/jcr-benchmark/trunk/pom.xml Tue Aug 3 14:12:38 2010 @@ -30,7 +30,7 @@ jackrabbit-jcr-benchmark - 2.0-SNAPSHOT + 1.0-SNAPSHOT Jackrabbit JCR Benchmarks JCR Benchmark is a suite of performance and scalability tests for @@ -51,7 +51,7 @@ javax.jcr jcr - 2.0 + 1.0 org.apache.commons @@ -61,12 +61,12 @@ org.apache.jackrabbit jackrabbit-jcr-tests - 2.1-SNAPSHOT + 1.6.2 org.apache.jackrabbit jackrabbit-core - 2.1-SNAPSHOT + 1.6.2 org.slf4j Modified: jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/AbstractBenchmarkTest.java URL: http://svn.apache.org/viewvc/jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/AbstractBenchmarkTest.java?rev=981892&r1=981891&r2=981892&view=diff ============================================================================== --- jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/AbstractBenchmarkTest.java (original) +++ jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/AbstractBenchmarkTest.java Tue Aug 3 14:12:38 2010 @@ -17,8 +17,6 @@ package org.apache.jackrabbit.benchmark; import org.apache.jackrabbit.test.AbstractJCRTest; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import javax.jcr.Node; import javax.jcr.RepositoryException; @@ -30,12 +28,14 @@ import java.util.Calendar; /** AbstractBenchmarkTest... */ abstract class AbstractBenchmarkTest extends AbstractJCRTest { - private static Logger log = LoggerFactory.getLogger(AbstractBenchmarkTest.class); - protected static final int MEMBERS = 500; + protected static final int MEMBERSIZE = 1024; + protected static final String MIMETYPE = "application/octet-stream"; + protected static final int MINTIME = 1000; + protected static final int MINCOUNT = 5; protected void setUp() throws Exception { Modified: jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/BigCollectionTest.java URL: http://svn.apache.org/viewvc/jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/BigCollectionTest.java?rev=981892&r1=981891&r2=981892&view=diff ============================================================================== --- jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/BigCollectionTest.java (original) +++ jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/BigCollectionTest.java Tue Aug 3 14:12:38 2010 @@ -91,7 +91,7 @@ public class BigCollectionTest extends A long cnt = 0; while (System.currentTimeMillis() - start < MINTIME || cnt < MINCOUNT) { - Session s = getHelper().getReadOnlySession(); + Session s = helper.getReadOnlySession(); try { Node dir = (Node) s.getItem(bigcollPath); int members = 0; Modified: jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/BigFileReadTest.java URL: http://svn.apache.org/viewvc/jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/BigFileReadTest.java?rev=981892&r1=981891&r2=981892&view=diff ============================================================================== --- jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/BigFileReadTest.java (original) +++ jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/BigFileReadTest.java Tue Aug 3 14:12:38 2010 @@ -16,16 +16,14 @@ */ package org.apache.jackrabbit.benchmark; +import java.io.InputStream; import java.util.Calendar; -import javax.jcr.Binary; import javax.jcr.Node; -import javax.jcr.Property; import javax.jcr.RepositoryException; import javax.jcr.Session; -import javax.jcr.nodetype.NodeType; -import org.apache.commons.compress.utils.IOUtils; +import org.apache.commons.io.IOUtils; import org.apache.commons.io.output.NullOutputStream; public class BigFileReadTest extends PerformanceTest { @@ -44,32 +42,26 @@ public class BigFileReadTest extends Per session = getRepository().login(getCredentials()); root = session.getRootNode().addNode( - "BigFileReadTest", NodeType.NT_FOLDER); + "BigFileReadTest", "nt:folder"); for (int i = 0; i < FILE_COUNT; i++) { - Node file = root.addNode("file" + i, NodeType.NT_FILE); - Node content = file.addNode(Node.JCR_CONTENT, NodeType.NT_RESOURCE); - content.setProperty(Property.JCR_MIMETYPE, "application/octet-stream"); - content.setProperty(Property.JCR_LAST_MODIFIED, Calendar.getInstance()); - Binary binary = session.getValueFactory().createBinary( - new TestInputStream(FILE_SIZE * 1024 * 1024)); - try { - content.setProperty(Property.JCR_DATA, binary); - } finally { - binary.dispose(); - } + Node file = root.addNode("file" + i, "nt:file"); + Node content = file.addNode("jcr:content", "nt:resource"); + content.setProperty("jcr:mimeType", "application/octet-stream"); + content.setProperty("jcr:lastModified", Calendar.getInstance()); + content.setProperty( + "jcr:data", new TestInputStream(FILE_SIZE * 1024 * 1024)); } session.save(); } public void runTest() throws Exception { Node file = root.getNode("file" + (i++ % FILE_COUNT)); - Node content = file.getNode(Node.JCR_CONTENT); - Property data = content.getProperty(Property.JCR_DATA); - Binary binary = data.getBinary(); + Node content = file.getNode("jcr:content"); + InputStream stream = content.getProperty("jcr:data").getStream(); try { - IOUtils.copy(binary.getStream(), new NullOutputStream()); + IOUtils.copy(stream, new NullOutputStream()); } finally { - binary.dispose(); + stream.close(); } } Modified: jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/BigFileWriteTest.java URL: http://svn.apache.org/viewvc/jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/BigFileWriteTest.java?rev=981892&r1=981891&r2=981892&view=diff ============================================================================== --- jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/BigFileWriteTest.java (original) +++ jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/BigFileWriteTest.java Tue Aug 3 14:12:38 2010 @@ -18,12 +18,9 @@ package org.apache.jackrabbit.benchmark; import java.util.Calendar; -import javax.jcr.Binary; import javax.jcr.Node; -import javax.jcr.Property; import javax.jcr.RepositoryException; import javax.jcr.Session; -import javax.jcr.nodetype.NodeType; public class BigFileWriteTest extends PerformanceTest { @@ -39,17 +36,12 @@ public class BigFileWriteTest extends Pe public void runTest() throws RepositoryException { file = session.getRootNode().addNode( - "BigFileWriteTest", NodeType.NT_FILE); - Node content = file.addNode(Node.JCR_CONTENT, NodeType.NT_RESOURCE); - content.setProperty(Property.JCR_MIMETYPE, "application/octet-stream"); - content.setProperty(Property.JCR_LAST_MODIFIED, Calendar.getInstance()); - Binary binary = session.getValueFactory().createBinary( - new TestInputStream(FILE_SIZE * 1024 * 1024)); - try { - content.setProperty(Property.JCR_DATA, binary); - } finally { - binary.dispose(); - } + "BigFileWriteTest", "nt:file"); + Node content = file.addNode("jcr:content", "nt:resource"); + content.setProperty("jcr:mimeType", "application/octet-stream"); + content.setProperty("jcr:lastModified", Calendar.getInstance()); + content.setProperty( + "jcr:data", new TestInputStream(FILE_SIZE * 1024 * 1024)); session.save(); } Modified: jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/PerformanceTestSuite.java URL: http://svn.apache.org/viewvc/jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/PerformanceTestSuite.java?rev=981892&r1=981891&r2=981892&view=diff ============================================================================== --- jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/PerformanceTestSuite.java (original) +++ jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/PerformanceTestSuite.java Tue Aug 3 14:12:38 2010 @@ -24,9 +24,7 @@ import javax.jcr.SimpleCredentials; import org.apache.commons.io.FileUtils; import org.apache.commons.math.stat.descriptive.SummaryStatistics; -import org.apache.jackrabbit.api.management.DataStoreGarbageCollector; import org.apache.jackrabbit.core.RepositoryImpl; -import org.apache.jackrabbit.core.SessionImpl; import org.apache.jackrabbit.core.config.RepositoryConfig; public class PerformanceTestSuite { @@ -45,7 +43,7 @@ public class PerformanceTestSuite { this.credentials = credentials; } - private void runTest(PerformanceTest test) throws Exception { + public void runTest(PerformanceTest test) throws Exception { SummaryStatistics statistics = new SummaryStatistics(); test.setRepository(repository); @@ -81,13 +79,6 @@ public class PerformanceTestSuite { statistics.getMin(), statistics.getMax(), statistics.getN()); - - SessionImpl session = (SessionImpl) repository.login(credentials); - DataStoreGarbageCollector collector = - session.createDataStoreGarbageCollector(); - collector.mark(); - collector.sweep(); - collector.close(); } public static void main(String[] args) throws Exception { Modified: jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/SmallFileReadTest.java URL: http://svn.apache.org/viewvc/jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/SmallFileReadTest.java?rev=981892&r1=981891&r2=981892&view=diff ============================================================================== --- jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/SmallFileReadTest.java (original) +++ jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/SmallFileReadTest.java Tue Aug 3 14:12:38 2010 @@ -16,16 +16,14 @@ */ package org.apache.jackrabbit.benchmark; +import java.io.InputStream; import java.util.Calendar; -import javax.jcr.Binary; import javax.jcr.Node; -import javax.jcr.Property; import javax.jcr.RepositoryException; import javax.jcr.Session; -import javax.jcr.nodetype.NodeType; -import org.apache.commons.compress.utils.IOUtils; +import org.apache.commons.io.IOUtils; import org.apache.commons.io.output.NullOutputStream; public class SmallFileReadTest extends PerformanceTest { @@ -42,19 +40,14 @@ public class SmallFileReadTest extends P session = getRepository().login(getCredentials()); root = session.getRootNode().addNode( - "SmallFileReadTest", NodeType.NT_FOLDER); + "SmallFileReadTest", "nt:folder"); for (int i = 0; i < FILE_COUNT; i++) { - Node file = root.addNode("file" + i, NodeType.NT_FILE); - Node content = file.addNode(Node.JCR_CONTENT, NodeType.NT_RESOURCE); - content.setProperty(Property.JCR_MIMETYPE, "application/octet-stream"); - content.setProperty(Property.JCR_LAST_MODIFIED, Calendar.getInstance()); - Binary binary = session.getValueFactory().createBinary( - new TestInputStream(FILE_SIZE * 1024)); - try { - content.setProperty(Property.JCR_DATA, binary); - } finally { - binary.dispose(); - } + Node file = root.addNode("file" + i, "nt:file"); + Node content = file.addNode("jcr:content", "nt:resource"); + content.setProperty("jcr:mimeType", "application/octet-stream"); + content.setProperty("jcr:lastModified", Calendar.getInstance()); + content.setProperty( + "jcr:data", new TestInputStream(FILE_SIZE * 1024)); } session.save(); } @@ -62,13 +55,12 @@ public class SmallFileReadTest extends P public void runTest() throws Exception { for (int i = 0; i < FILE_COUNT; i++) { Node file = root.getNode("file" + i); - Node content = file.getNode(Node.JCR_CONTENT); - Property data = content.getProperty(Property.JCR_DATA); - Binary binary = data.getBinary(); + Node content = file.getNode("jcr:content"); + InputStream stream = content.getProperty("jcr:data").getStream(); try { - IOUtils.copy(binary.getStream(), new NullOutputStream()); + IOUtils.copy(stream, new NullOutputStream()); } finally { - binary.dispose(); + stream.close(); } } } Modified: jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/SmallFileWriteTest.java URL: http://svn.apache.org/viewvc/jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/SmallFileWriteTest.java?rev=981892&r1=981891&r2=981892&view=diff ============================================================================== --- jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/SmallFileWriteTest.java (original) +++ jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/SmallFileWriteTest.java Tue Aug 3 14:12:38 2010 @@ -18,12 +18,9 @@ package org.apache.jackrabbit.benchmark; import java.util.Calendar; -import javax.jcr.Binary; import javax.jcr.Node; -import javax.jcr.Property; import javax.jcr.RepositoryException; import javax.jcr.Session; -import javax.jcr.nodetype.NodeType; public class SmallFileWriteTest extends PerformanceTest { @@ -40,24 +37,18 @@ public class SmallFileWriteTest extends } public void beforeTest() throws RepositoryException { - root = session.getRootNode().addNode( - "SmallFileWriteTest", NodeType.NT_FOLDER); + root = session.getRootNode().addNode("SmallFileWriteTest", "nt:folder"); session.save(); } public void runTest() throws Exception { for (int i = 0; i < FILE_COUNT; i++) { - Node file = root.addNode("file" + i, NodeType.NT_FILE); - Node content = file.addNode(Node.JCR_CONTENT, NodeType.NT_RESOURCE); - content.setProperty(Property.JCR_MIMETYPE, "application/octet-stream"); - content.setProperty(Property.JCR_LAST_MODIFIED, Calendar.getInstance()); - Binary binary = session.getValueFactory().createBinary( - new TestInputStream(FILE_SIZE * 1024)); - try { - content.setProperty(Property.JCR_DATA, binary); - } finally { - binary.dispose(); - } + Node file = root.addNode("file" + i, "nt:file"); + Node content = file.addNode("jcr:content", "nt:resource"); + content.setProperty("jcr:mimeType", "application/octet-stream"); + content.setProperty("jcr:lastModified", Calendar.getInstance()); + content.setProperty( + "jcr:data", new TestInputStream(FILE_SIZE * 1024)); } }