jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1574976 - in /jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark: BenchmarkRunner.java ConcurrentHasPermissionTest.java ConcurrentHasPermissionTest2.java
Date Thu, 06 Mar 2014 17:42:18 GMT
Author: angela
Date: Thu Mar  6 17:42:18 2014
New Revision: 1574976

URL: http://svn.apache.org/r1574976
Log:
OAK-1505 : Benchmark for Session#hasPermission

Added:
    jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentHasPermissionTest.java
  (with props)
    jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentHasPermissionTest2.java
      - copied, changed from r1574840, jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentReadAccessControlledTreeTest2.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=1574976&r1=1574975&r2=1574976&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
Thu Mar  6 17:42:18 2014
@@ -157,6 +157,14 @@ public class BenchmarkRunner {
                     runAsAdmin.value(options),
                     itemsToRead.value(options),
                     report.value(options)),
+            new ConcurrentHasPermissionTest(
+                    runAsAdmin.value(options),
+                    itemsToRead.value(options),
+                    report.value(options)),
+            new ConcurrentHasPermissionTest2(
+                    runAsAdmin.value(options),
+                    itemsToRead.value(options),
+                    report.value(options)),
             new ManyUserReadTest(
                     runAsAdmin.value(options),
                     itemsToRead.value(options),

Added: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentHasPermissionTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentHasPermissionTest.java?rev=1574976&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentHasPermissionTest.java
(added)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentHasPermissionTest.java
Thu Mar  6 17:42:18 2014
@@ -0,0 +1,87 @@
+/*
+ * 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.List;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import com.google.common.collect.ImmutableList;
+
+/**
+ * Concurrently calls Session#hasPermission on the deep tree:
+ * - the path argument a random path out of the deep tree
+ * - the actions are randomly selected from the combinations listed in {@link #ACTIONS}
+ */
+public class ConcurrentHasPermissionTest extends ConcurrentReadDeepTreeTest {
+
+    private static final List<String> ACTIONS = ImmutableList.of(
+            Session.ACTION_READ,
+            Session.ACTION_ADD_NODE,
+            Session.ACTION_SET_PROPERTY,
+            Session.ACTION_REMOVE,
+            Session.ACTION_READ + "," + Session.ACTION_ADD_NODE + "," + Session.ACTION_SET_PROPERTY
+ "," + Session.ACTION_REMOVE,
+            Session.ACTION_ADD_NODE + "," + Session.ACTION_SET_PROPERTY + "," + Session.ACTION_REMOVE,
+            Session.ACTION_ADD_NODE + "," + Session.ACTION_REMOVE,
+            Session.ACTION_SET_PROPERTY + "," + Session.ACTION_REMOVE,
+            Session.ACTION_READ + "," + Session.ACTION_ADD_NODE,
+            Session.ACTION_READ + "," + Session.ACTION_SET_PROPERTY
+    );
+
+    protected ConcurrentHasPermissionTest(boolean runAsAdmin, int itemsToRead, boolean doReport)
{
+        super(runAsAdmin, itemsToRead, doReport);
+    }
+
+    protected void randomRead(Session testSession, List<String> allPaths, int cnt)
throws RepositoryException {
+        boolean logout = false;
+        if (testSession == null) {
+            testSession = getTestSession();
+            logout = true;
+        }
+        try {
+            int allows = 0;
+            int denies = 0;
+            int size = allPaths.size();
+            long start = System.currentTimeMillis();
+            for (int i = 0; i < cnt; i++) {
+                double rand = size * Math.random();
+                int index = (int) Math.floor(rand);
+                String path = allPaths.get(index);
+
+                String actions = getRandomActions();
+                if (testSession.hasPermission(path, actions)) {
+                    allows++;
+                } else {
+                    denies++;
+                }
+            }
+            long end = System.currentTimeMillis();
+            if (doReport) {
+                System.out.println("Session " + testSession.getUserID() + " calling #hasPermission
(Allows: "+ allows +"; Denies: "+ denies +") completed in " + (end - start));
+            }
+        } finally {
+            if (logout) {
+                logout(testSession);
+            }
+        }
+    }
+
+    private static String getRandomActions() {
+        int index = (int) Math.floor(10 * Math.random());
+        return ACTIONS.get(index);
+    }
+}
\ No newline at end of file

Propchange: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentHasPermissionTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentHasPermissionTest2.java
(from r1574840, jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentReadAccessControlledTreeTest2.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentHasPermissionTest2.java?p2=jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentHasPermissionTest2.java&p1=jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentReadAccessControlledTreeTest2.java&r1=1574840&r2=1574976&rev=1574976&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentReadAccessControlledTreeTest2.java
(original)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentHasPermissionTest2.java
Thu Mar  6 17:42:18 2014
@@ -33,16 +33,19 @@ import org.apache.jackrabbit.oak.spi.sec
 import org.apache.jackrabbit.util.Text;
 
 /**
- * Concurrently reads random items from the deep tree where every 100th node
+ * Concurrently calls Session#hasPermission on the deep tree where every 100th node
  * is access controlled and each policy node contains 100 ACEs for different
- * principals.
+ * principals. The hasPermission methods is calles as follows:
+ *
+ * - the path argument a random path out of the deep tree
+ * - the actions are randomly selected from the combinations listed in {@link #ACTIONS}
  */
-public class ConcurrentReadAccessControlledTreeTest2 extends ConcurrentReadDeepTreeTest {
+public class ConcurrentHasPermissionTest2 extends ConcurrentHasPermissionTest {
 
     int counter = 0;
     final List<Principal> principals = new ArrayList<Principal>();
 
-    public ConcurrentReadAccessControlledTreeTest2(boolean runAsAdmin, int itemsToRead, boolean
doReport) {
+    public ConcurrentHasPermissionTest2(boolean runAsAdmin, int itemsToRead, boolean doReport)
{
         super(runAsAdmin, itemsToRead, doReport);
     }
 



Mime
View raw message