jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From meteata...@apache.org
Subject svn commit: r1443579 - in /jackrabbit/oak/trunk/oak-mongomk-perf: pom.xml src/main/java/org/apache/jackrabbit/mongomk/perf/BlobStoreFS.java src/main/java/org/apache/jackrabbit/mongomk/perf/RandomJsopGenerator.java
Date Thu, 07 Feb 2013 15:57:04 GMT
Author: meteatamel
Date: Thu Feb  7 15:57:03 2013
New Revision: 1443579

URL: http://svn.apache.org/viewvc?rev=1443579&view=rev
Log:
Made oak-mongomk-perf work with the latest oak-mongomk code

Modified:
    jackrabbit/oak/trunk/oak-mongomk-perf/pom.xml
    jackrabbit/oak/trunk/oak-mongomk-perf/src/main/java/org/apache/jackrabbit/mongomk/perf/BlobStoreFS.java
    jackrabbit/oak/trunk/oak-mongomk-perf/src/main/java/org/apache/jackrabbit/mongomk/perf/RandomJsopGenerator.java

Modified: jackrabbit/oak/trunk/oak-mongomk-perf/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk-perf/pom.xml?rev=1443579&r1=1443578&r2=1443579&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk-perf/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-mongomk-perf/pom.xml Thu Feb  7 15:57:03 2013
@@ -1,14 +1,14 @@
 <?xml version="1.0" encoding="UTF-8"?>
 
-<!-- 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 
+<!-- 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. -->
 
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
@@ -19,7 +19,7 @@
 	<parent>
 		<groupId>org.apache.jackrabbit</groupId>
 		<artifactId>oak-parent</artifactId>
-		<version>0.6-SNAPSHOT</version>
+		<version>0.7-SNAPSHOT</version>
 		<relativePath>../oak-parent/pom.xml</relativePath>
 	</parent>
 
@@ -104,7 +104,7 @@
 		<dependency>
 			<groupId>org.apache.jackrabbit</groupId>
 			<artifactId>oak-mk-perf</artifactId>
-			<version>0.6-SNAPSHOT</version>
+			<version>0.7-SNAPSHOT</version>
 		</dependency>
 	</dependencies>
 

Modified: jackrabbit/oak/trunk/oak-mongomk-perf/src/main/java/org/apache/jackrabbit/mongomk/perf/BlobStoreFS.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk-perf/src/main/java/org/apache/jackrabbit/mongomk/perf/BlobStoreFS.java?rev=1443579&r1=1443578&r2=1443579&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk-perf/src/main/java/org/apache/jackrabbit/mongomk/perf/BlobStoreFS.java
(original)
+++ jackrabbit/oak/trunk/oak-mongomk-perf/src/main/java/org/apache/jackrabbit/mongomk/perf/BlobStoreFS.java
Thu Feb  7 15:57:03 2013
@@ -23,15 +23,11 @@ import org.apache.jackrabbit.mk.blobs.Bl
 
 public class BlobStoreFS implements  BlobStore{
 
-    private final File rootDir;
-
     public BlobStoreFS(String rootPath) {
         File rootDir = new File(rootPath);
         if (!rootDir.isDirectory()) {
             rootDir.mkdirs();
         }
-
-        this.rootDir = rootDir;
     }
 
     @Override

Modified: jackrabbit/oak/trunk/oak-mongomk-perf/src/main/java/org/apache/jackrabbit/mongomk/perf/RandomJsopGenerator.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk-perf/src/main/java/org/apache/jackrabbit/mongomk/perf/RandomJsopGenerator.java?rev=1443579&r1=1443578&r2=1443579&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk-perf/src/main/java/org/apache/jackrabbit/mongomk/perf/RandomJsopGenerator.java
(original)
+++ jackrabbit/oak/trunk/oak-mongomk-perf/src/main/java/org/apache/jackrabbit/mongomk/perf/RandomJsopGenerator.java
Thu Feb  7 15:57:03 2013
@@ -16,6 +16,7 @@
  */
 package org.apache.jackrabbit.mongomk.perf;
 
+import java.util.Iterator;
 import java.util.Random;
 import java.util.UUID;
 
@@ -26,48 +27,11 @@ import org.apache.jackrabbit.oak.commons
 
 public class RandomJsopGenerator {
 
-    public static class RandomJsop {
-        private final String jsop;
-        private final String message;
-        private final String path;
-
-        public RandomJsop(String path, String jsop, String message) {
-            this.path = path;
-            this.jsop = jsop;
-            this.message = message;
-        }
-
-        public String getJsop() {
-            return this.jsop;
-        }
-
-        public String getMessage() {
-            return this.message;
-        }
-
-        public String getPath() {
-            return this.path;
-        }
-    }
-
     private static final int OP_ADD_NODE = 0;
-
-    private static final int OP_ADD_PROP = 1;
-
-    public static void main(String[] args) throws Exception {
-        RandomJsopGenerator gen = new RandomJsopGenerator();
-        for (int i = 0; i < 10; ++i) {
-            RandomJsop rand = gen.nextRandom();
-            System.out.println(rand.path);
-            System.out.println(rand.jsop);
-            System.out.println();
-        }
-    }
+    private static final int OP_SET_PROP = 1;
 
     private Node[] descendants;
-
     private String path;
-
     private Random random;
 
     public RandomJsopGenerator() throws Exception {
@@ -77,7 +41,7 @@ public class RandomJsopGenerator {
     public RandomJsop nextRandom() {
         JsopBuilder jsopBuilder = new JsopBuilder();
 
-        int numOps = this.random.nextInt(10) + 1;
+        int numOps = random.nextInt(10) + 1;
         for (int i = 0; i < numOps; ++i) {
             if (this.createRandomOp(jsopBuilder)) {
                 jsopBuilder.newline();
@@ -86,26 +50,29 @@ public class RandomJsopGenerator {
             }
         }
 
-        return new RandomJsop(this.path, jsopBuilder.toString(), UUID.randomUUID().toString());
+        return new RandomJsop(path, jsopBuilder.toString(), UUID.randomUUID().toString());
     }
 
     public void setSeed(String path, String json) throws Exception {
         this.path = path;
         String all = String.format("{ \"%s\" : %s }", PathUtils.getName(path), json);
         Node node = NodeBuilder.build(all, path);
-        // FIXME - This needs to change to node.getChildNodeEntries(0, -1).
-        //this.descendants = node.getDescendants(false).toArray(new Node[0]);
-        this.random = new Random();
+        descendants = new Node[node.getChildNodeCount()];
+        int i = 0;
+        for (Iterator<Node> it = node.getChildNodeEntries(0, -1); it.hasNext(); ) {
+            descendants[i++] = it.next();
+        }
+        random = new Random();
     }
 
     private boolean createRandomAddNodeOp(JsopBuilder jsopBuilder) {
-        Node random = this.selectRandom();
+        Node random = selectRandom();
 
-        String childName = this.createRandomString();
+        String childName = createRandomString();
         String newPath = PathUtils.concat(random.getPath(), childName);
         String addPath = newPath;
-        if (!"".equals(this.path)) {
-            addPath = PathUtils.relativize(this.path, newPath);
+        if (!"".equals(path)) {
+            addPath = PathUtils.relativize(path, newPath);
         }
 
         jsopBuilder.tag('+');
@@ -116,56 +83,52 @@ public class RandomJsopGenerator {
         return true;
     }
 
-    private boolean createRandomAddPropOp(JsopBuilder jsopBuilder) {
-        int next = this.random.nextInt(this.descendants.length);
-        Node random = this.descendants[next];
-        String addPath = PathUtils.relativize(this.path, random.getPath());
+    private boolean createRandomSetPropOp(JsopBuilder jsopBuilder) {
+        int next = random.nextInt(this.descendants.length);
+        Node node = descendants[next];
+
+        String addPath = PathUtils.relativize(path, node.getPath());
         if ("".equals(addPath)) {
             addPath = "/";
         }
 
-        jsopBuilder.tag('+');
-        jsopBuilder.key(addPath);
-        jsopBuilder.object();
-
-        int numProps = this.random.nextInt(10) + 1;
+        int numProps = random.nextInt(10) + 1;
         for (int i = 0; i < numProps; ++i) {
-            String propName = this.createRandomString();
-            String propValue = this.createRandomString();
+            String propName = createRandomString();
+            String propValue = createRandomString();
 
-            jsopBuilder.key(propName);
+            jsopBuilder.tag('^');
+            jsopBuilder.key(PathUtils.concat(addPath, propName));
             jsopBuilder.value(propValue);
         }
 
-        jsopBuilder.endObject();
-
         return true;
     }
 
     private boolean createRandomOp(JsopBuilder jsopBuilder) {
         boolean performed = false;
 
-        int op = this.random.nextInt(2);
+        int op = random.nextInt(2);
 
         switch (op) {
-        case OP_ADD_NODE: {
-            performed = this.createRandomAddNodeOp(jsopBuilder);
-            break;
-        }
-        case OP_ADD_PROP: {
-            performed = this.createRandomAddPropOp(jsopBuilder);
-            break;
-        }
+            case OP_ADD_NODE: {
+                performed = createRandomAddNodeOp(jsopBuilder);
+                break;
+            }
+            case OP_SET_PROP: {
+                performed = createRandomSetPropOp(jsopBuilder);
+                break;
+            }
         }
 
         return performed;
     }
 
     private String createRandomString() {
-        int length = this.random.nextInt(6) + 5;
+        int length = random.nextInt(6) + 5;
         char[] chars = new char[length];
         for (int i = 0; i < length; ++i) {
-            char rand = (char) (this.random.nextInt(65) + 59);
+            char rand = (char) (random.nextInt(65) + 59);
             if (Character.isLetterOrDigit(rand)) {
                 chars[i] = rand;
             } else {
@@ -177,11 +140,43 @@ public class RandomJsopGenerator {
     }
 
     private Node selectRandom() {
-        Node randomNode = null;
+        int next = random.nextInt(this.descendants.length);
+        Node randomNode = descendants[next];
+        return randomNode;
+    }
 
-        int next = this.random.nextInt(this.descendants.length);
-        randomNode = this.descendants[next];
+    public static void main(String[] args) throws Exception {
+        RandomJsopGenerator gen = new RandomJsopGenerator();
+        for (int i = 0; i < 10; ++i) {
+            RandomJsop rand = gen.nextRandom();
+            System.out.println(rand.path);
+            System.out.println(rand.jsop);
+            System.out.println();
+        }
+    }
 
-        return randomNode;
+    public static class RandomJsop {
+
+        private final String jsop;
+        private final String message;
+        private final String path;
+
+        public RandomJsop(String path, String jsop, String message) {
+            this.path = path;
+            this.jsop = jsop;
+            this.message = message;
+        }
+
+        public String getJsop() {
+            return jsop;
+        }
+
+        public String getMessage() {
+            return message;
+        }
+
+        public String getPath() {
+            return path;
+        }
     }
-}
+}
\ No newline at end of file



Mime
View raw message