jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1581953 - in /jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark: BenchmarkRunner.java GetAuthorizableByIdTest.java GetAuthorizableByPrincipalTest.java GetPrincipalTest.java
Date Wed, 26 Mar 2014 17:26:30 GMT
Author: angela
Date: Wed Mar 26 17:26:30 2014
New Revision: 1581953

URL: http://svn.apache.org/r1581953
Log:
user mgt related benchmarks

Added:
    jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/GetAuthorizableByIdTest.java
    jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/GetAuthorizableByPrincipalTest.java
    jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/GetPrincipalTest.java
Modified:
    jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/BenchmarkRunner.java

Modified: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/BenchmarkRunner.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/BenchmarkRunner.java?rev=1581953&r1=1581952&r2=1581953&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/BenchmarkRunner.java
(original)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/BenchmarkRunner.java
Wed Mar 26 17:26:30 2014
@@ -72,6 +72,10 @@ public class BenchmarkRunner {
                         .defaultsTo(Boolean.FALSE);
         OptionSpec<File> csvFile = parser.accepts("csvFile", "File to write a CSV version
of the benchmark data.")
                 .withOptionalArg().ofType(File.class);
+        OptionSpec<Boolean> flatStructure = parser.accepts("flatStructure", "Whether
user/group should be setup with a flat structure or not.")
+                .withOptionalArg().ofType(Boolean.class).defaultsTo(Boolean.FALSE);
+        OptionSpec<Integer> numberOfUsers = parser.accepts("numberOfUsers")
+                .withOptionalArg().ofType(Integer.class).defaultsTo(10000);
 
         OptionSet options = parser.parse(args);
         int cacheSize = cache.value(options);
@@ -188,6 +192,15 @@ public class BenchmarkRunner {
             new CreateManyIndexedNodesTest(),
             new GetPoliciesTest(),
             new ConcurrentFileWriteTest(),
+            new GetAuthorizableByIdTest(
+                    numberOfUsers.value(options),
+                    flatStructure.value(options)),
+            new GetAuthorizableByPrincipalTest(
+                    numberOfUsers.value(options),
+                    flatStructure.value(options)),
+            new GetPrincipalTest(
+                    numberOfUsers.value(options),
+                    flatStructure.value(options))
         };
 
         Set<String> argset = Sets.newHashSet(options.nonOptionArguments());

Added: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/GetAuthorizableByIdTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/GetAuthorizableByIdTest.java?rev=1581953&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/GetAuthorizableByIdTest.java
(added)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/GetAuthorizableByIdTest.java
Wed Mar 26 17:26:30 2014
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.oak.benchmark;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+import javax.jcr.Session;
+
+import org.apache.jackrabbit.api.JackrabbitSession;
+import org.apache.jackrabbit.api.security.user.Authorizable;
+import org.apache.jackrabbit.api.security.user.User;
+import org.apache.jackrabbit.api.security.user.UserManager;
+import org.apache.jackrabbit.oak.spi.security.user.UserConstants;
+
+public class GetAuthorizableByIdTest extends AbstractTest {
+
+    private final int numberOfUsers;
+    private final boolean flat;
+
+    private final List<String> ids = new ArrayList<String>();
+
+    public GetAuthorizableByIdTest(int numberOfUsers, boolean flatStructure) {
+        this.numberOfUsers = numberOfUsers;
+        this.flat = flatStructure;
+    }
+
+    @Override
+    protected void beforeSuite() throws Exception {
+        Session s = loginWriter();
+        UserManager userManager = ((JackrabbitSession) s).getUserManager();
+        for (int i = 0; i < numberOfUsers; i++) {
+            String id = (flat) ? "user" + i : UUID.randomUUID().toString();
+            User user = userManager.createUser(id, id);
+            ids.add(id);
+        }
+        s.save();
+        System.out.println("Setup "+numberOfUsers+" users");
+    }
+
+    @Override
+    protected void afterSuite() throws Exception {
+        Session session = loginWriter();
+        session.getNode(UserConstants.DEFAULT_USER_PATH + "/u").remove();
+        session.save();
+    }
+
+    @Override
+    protected void runTest() throws Exception {
+        Session s = loginWriter();
+        UserManager userManager = ((JackrabbitSession) s).getUserManager();
+        for (int i = 0; i < 1000; i++) {
+            Authorizable a = userManager.getAuthorizable(getUserId());
+        }
+
+    }
+
+    protected String getUserId() {
+        return ids.get((int) Math.floor(numberOfUsers * Math.random()));
+    }
+}
\ No newline at end of file

Added: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/GetAuthorizableByPrincipalTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/GetAuthorizableByPrincipalTest.java?rev=1581953&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/GetAuthorizableByPrincipalTest.java
(added)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/GetAuthorizableByPrincipalTest.java
Wed Mar 26 17:26:30 2014
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.oak.benchmark;
+
+import javax.jcr.Session;
+
+import org.apache.jackrabbit.api.JackrabbitSession;
+import org.apache.jackrabbit.api.security.user.Authorizable;
+import org.apache.jackrabbit.api.security.user.UserManager;
+import org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl;
+
+public class GetAuthorizableByPrincipalTest extends GetAuthorizableByIdTest {
+
+    public GetAuthorizableByPrincipalTest(int numberOfUsers, boolean flatStructure) {
+        super(numberOfUsers, flatStructure);
+    }
+
+    @Override
+    protected void runTest() throws Exception {
+        Session s = loginWriter();
+        UserManager userManager = ((JackrabbitSession) s).getUserManager();
+        for (int i = 0; i < 1000; i++) {
+            Authorizable a = userManager.getAuthorizable(new PrincipalImpl(getUserId()));
+        }
+    }
+}
\ No newline at end of file

Added: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/GetPrincipalTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/GetPrincipalTest.java?rev=1581953&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/GetPrincipalTest.java
(added)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/GetPrincipalTest.java
Wed Mar 26 17:26:30 2014
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.oak.benchmark;
+
+import java.security.Principal;
+import javax.jcr.Session;
+
+import org.apache.jackrabbit.api.JackrabbitSession;
+import org.apache.jackrabbit.api.security.principal.PrincipalManager;
+
+public class GetPrincipalTest extends GetAuthorizableByIdTest {
+
+    public GetPrincipalTest(int numberOfUsers, boolean flatStructure) {
+        super(numberOfUsers, flatStructure);
+    }
+
+    @Override
+    protected void runTest() throws Exception {
+        Session s = loginWriter();
+        PrincipalManager principalManager = ((JackrabbitSession) s).getPrincipalManager();
+        for (int i = 0; i < 1000; i++) {
+            Principal p = principalManager.getPrincipal(getUserId());
+        }
+    }
+}
\ No newline at end of file



Mime
View raw message