jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1461532 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/ oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ oak-run/src/main/java/org/apache/jackrabbit/oak/fixture/ oak-run/src/main/resources/org...
Date Wed, 27 Mar 2013 11:31:14 GMT
Author: jukka
Date: Wed Mar 27 11:31:14 2013
New Revision: 1461532

URL: http://svn.apache.org/r1461532
Log:
OAK-641: Improved benchmark tooling

Uniform cache size settings (bundle cache for Jackrabbit, KernelNodeState cache for the MicroKernel
and segment cache for SegmentMK)

Added:
    jackrabbit/oak/trunk/oak-run/src/main/resources/org/
    jackrabbit/oak/trunk/oak-run/src/main/resources/org/apache/
    jackrabbit/oak/trunk/oak-run/src/main/resources/org/apache/jackrabbit/
    jackrabbit/oak/trunk/oak-run/src/main/resources/org/apache/jackrabbit/oak/
    jackrabbit/oak/trunk/oak-run/src/main/resources/org/apache/jackrabbit/oak/fixture/
    jackrabbit/oak/trunk/oak-run/src/main/resources/org/apache/jackrabbit/oak/fixture/repository.xml
Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStore.java
    jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/BenchmarkRunner.java
    jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/fixture/JackrabbitRepositoryFixture.java
    jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/fixture/OakRepositoryFixture.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStore.java?rev=1461532&r1=1461531&r2=1461532&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStore.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStore.java
Wed Mar 27 11:31:14 2013
@@ -44,6 +44,8 @@ import static com.google.common.base.Pre
  */
 public class KernelNodeStore implements NodeStore {
 
+    private static final long DEFAULT_CACHE_SIZE = 16 * 1024 * 1024;
+
     /**
      * The {@link MicroKernel} instance used to store the content tree.
      */
@@ -55,42 +57,43 @@ public class KernelNodeStore implements 
     @Nonnull
     private volatile Observer observer = EmptyObserver.INSTANCE;
 
-    private final LoadingCache<String, KernelNodeState> cache =
-            CacheBuilder.newBuilder().maximumWeight(16 * 1024 * 1024).weigher(
-                    new Weigher<String, KernelNodeState>() {
-                @Override
-                public int weigh(String key, KernelNodeState state) {
-                    return state.getMemory();
-                }
-            }).build(new CacheLoader<String, KernelNodeState>() {
-                @Override
-                public KernelNodeState load(String key) {
-                    int slash = key.indexOf('/');
-                    String revision = key.substring(0, slash);
-                    String path = key.substring(slash);
-                    return new KernelNodeState(kernel, path, revision, cache);
-                }
-
-                @Override
-                public ListenableFuture<KernelNodeState> reload(String key,
-                                                                KernelNodeState oldValue)
-                        throws Exception {
-                    // LoadingCache.reload() is only used to re-calculate the
-                    // memory usage on KernelNodeState.init(). Therefore
-                    // we simply return the old value as is (OAK-643)
-                    SettableFuture<KernelNodeState> future = SettableFuture.create();
-                    future.set(oldValue);
-                    return future;
-                }
-            });
+    private final LoadingCache<String, KernelNodeState> cache;
 
     /**
      * State of the current root node.
      */
     private KernelNodeState root;
 
-    public KernelNodeStore(MicroKernel kernel) {
+
+    public KernelNodeStore(final MicroKernel kernel, long cacheSize) {
         this.kernel = checkNotNull(kernel);
+        this.cache = CacheBuilder.newBuilder()
+                .maximumWeight(cacheSize)
+                .weigher(new Weigher<String, KernelNodeState>() {
+                    @Override
+                    public int weigh(String key, KernelNodeState state) {
+                        return state.getMemory();
+                    }
+                }).build(new CacheLoader<String, KernelNodeState>() {
+                    @Override
+                    public KernelNodeState load(String key) {
+                        int slash = key.indexOf('/');
+                        String revision = key.substring(0, slash);
+                        String path = key.substring(slash);
+                        return new KernelNodeState(kernel, path, revision, cache);
+                    }
+                    @Override
+                    public ListenableFuture<KernelNodeState> reload(
+                            String key, KernelNodeState oldValue) {
+                        // LoadingCache.reload() is only used to re-calculate the
+                        // memory usage on KernelNodeState.init(). Therefore
+                        // we simply return the old value as is (OAK-643)
+                        SettableFuture<KernelNodeState> future = SettableFuture.create();
+                        future.set(oldValue);
+                        return future;
+                    }
+                });
+
         try {
             this.root = cache.get(kernel.getHeadRevision() + '/');
         } catch (Exception e) {
@@ -98,6 +101,10 @@ public class KernelNodeStore implements 
         }
     }
 
+    public KernelNodeStore(MicroKernel kernel) {
+        this(kernel, DEFAULT_CACHE_SIZE);
+    }
+
     @Nonnull
     public Observer getObserver() {
         return observer;

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=1461532&r1=1461531&r2=1461532&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 27 11:31:14 2013
@@ -49,14 +49,15 @@ public class BenchmarkRunner {
                 .withRequiredArg().ofType(File.class);
 
         OptionSet options = parser.parse(args);
+        int cacheSize = cache.value(options);
         RepositoryFixture[] allFixtures = new RepositoryFixture[] {
-                new JackrabbitRepositoryFixture(),
-                OakRepositoryFixture.getMemory(),
-                OakRepositoryFixture.getDefault(),
-                OakRepositoryFixture.getMongo(host.value(options), port.value(options)),
+                new JackrabbitRepositoryFixture(cacheSize),
+                OakRepositoryFixture.getMemory(cacheSize * MB),
+                OakRepositoryFixture.getDefault(cacheSize * MB),
+                OakRepositoryFixture.getMongo(
+                        host.value(options), port.value(options), cacheSize * MB),
                 OakRepositoryFixture.getSegment(
-                        host.value(options), port.value(options),
-                        cache.value(options) * MB)
+                        host.value(options), port.value(options), cacheSize * MB)
         };
         Benchmark[] allBenchmarks = new Benchmark[] {
             new LoginTest(),

Modified: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/fixture/JackrabbitRepositoryFixture.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/fixture/JackrabbitRepositoryFixture.java?rev=1461532&r1=1461531&r2=1461532&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/fixture/JackrabbitRepositoryFixture.java
(original)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/fixture/JackrabbitRepositoryFixture.java
Wed Mar 27 11:31:14 2013
@@ -16,18 +16,31 @@
  */
 package org.apache.jackrabbit.oak.fixture;
 
+import static org.apache.jackrabbit.core.config.RepositoryConfigurationParser.REPOSITORY_HOME_VARIABLE;
+
 import java.io.File;
+import java.io.InputStream;
+import java.util.Properties;
 
 import javax.jcr.Repository;
+import javax.xml.transform.stream.StreamSource;
 
 import org.apache.commons.io.FileUtils;
 import org.apache.jackrabbit.core.RepositoryImpl;
 import org.apache.jackrabbit.core.config.RepositoryConfig;
+import org.apache.jackrabbit.core.config.RepositoryConfigurationParser;
+import org.xml.sax.InputSource;
 
 public class JackrabbitRepositoryFixture implements RepositoryFixture {
 
+    private final int bundleCacheSize;
+
     private RepositoryImpl[] cluster;
 
+    public JackrabbitRepositoryFixture(int bundleCacheSize) {
+        this.bundleCacheSize = bundleCacheSize;
+    }
+
     @Override
     public boolean isAvailable(int n) {
         return n == 1;
@@ -38,7 +51,16 @@ public class JackrabbitRepositoryFixture
         if (n == 1) {
             String name = "Jackrabbit-" + System.currentTimeMillis();
             File directory = new File(name);
-            RepositoryConfig config = RepositoryConfig.install(directory);
+
+            Properties variables = new Properties(System.getProperties());
+            variables.setProperty(
+                    REPOSITORY_HOME_VARIABLE, directory.getPath());
+            variables.setProperty(
+                    "bundleCacheSize", Integer.toString(bundleCacheSize));
+            InputStream xml = getClass().getResourceAsStream("repository.xml");
+            RepositoryConfig config = RepositoryConfig.create(
+                    new InputSource(xml), variables);
+
             RepositoryImpl repository = RepositoryImpl.create(config);
             this.cluster = new RepositoryImpl[] { repository };
             return new Repository[] { repository };

Modified: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/fixture/OakRepositoryFixture.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/fixture/OakRepositoryFixture.java?rev=1461532&r1=1461531&r2=1461532&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/fixture/OakRepositoryFixture.java
(original)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/fixture/OakRepositoryFixture.java
Wed Mar 27 11:31:14 2013
@@ -27,6 +27,7 @@ import org.apache.jackrabbit.mongomk.imp
 import org.apache.jackrabbit.mongomk.prototype.MongoMK;
 import org.apache.jackrabbit.oak.Oak;
 import org.apache.jackrabbit.oak.jcr.Jcr;
+import org.apache.jackrabbit.oak.kernel.KernelNodeStore;
 import org.apache.jackrabbit.oak.plugins.segment.MongoStore;
 import org.apache.jackrabbit.oak.plugins.segment.SegmentNodeStore;
 import org.apache.jackrabbit.oak.plugins.segment.SegmentStore;
@@ -35,14 +36,14 @@ import com.mongodb.Mongo;
 
 public abstract class OakRepositoryFixture implements RepositoryFixture {
 
-    public static RepositoryFixture getMemory() {
+    public static RepositoryFixture getMemory(final long cacheSize) {
         return new OakRepositoryFixture("Oak-Memory") {
             @Override
             public Repository[] setUpCluster(int n) throws Exception {
                 Repository[] cluster = new Repository[n];
                 MicroKernel kernel = new MicroKernelImpl();
                 for (int i = 0; i < cluster.length; i++) {
-                    Oak oak = new Oak(kernel);
+                    Oak oak = new Oak(new KernelNodeStore(kernel, cacheSize));
                     cluster[i] = new Jcr(oak).createRepository();
                 }
                 return cluster;
@@ -50,7 +51,7 @@ public abstract class OakRepositoryFixtu
         };
     }
 
-    public static RepositoryFixture getDefault() {
+    public static RepositoryFixture getDefault(final long cacheSize) {
         return new OakRepositoryFixture("Oak-Default") {
             private MicroKernelImpl[] kernels;
             @Override
@@ -59,7 +60,8 @@ public abstract class OakRepositoryFixtu
                 kernels = new MicroKernelImpl[cluster.length];
                 for (int i = 0; i < cluster.length; i++) {
                     kernels[i] = new MicroKernelImpl(unique);
-                    cluster[i] = new Jcr(kernels[i]).createRepository();
+                    Oak oak = new Oak(new KernelNodeStore(kernels[i], cacheSize));
+                    cluster[i] = new Jcr(oak).createRepository();
                 }
                 return cluster;
             }
@@ -73,7 +75,8 @@ public abstract class OakRepositoryFixtu
         };
     }
 
-    public static RepositoryFixture getMongo(final String host, final int port) {
+    public static RepositoryFixture getMongo(
+            final String host, final int port, final long cacheSize) {
         return new OakRepositoryFixture("Oak-Mongo") {
             private MongoMK[] kernels;
             @Override
@@ -84,7 +87,8 @@ public abstract class OakRepositoryFixtu
                     MongoConnection mongo =
                             new MongoConnection(host, port, unique);
                     kernels[i] = new MongoMK(mongo.getDB(), i);
-                    cluster[i] = new Jcr(kernels[i]).createRepository();
+                    Oak oak = new Oak(new KernelNodeStore(kernels[i], cacheSize));
+                    cluster[i] = new Jcr(oak).createRepository();
                 }
                 return cluster;
             }

Added: jackrabbit/oak/trunk/oak-run/src/main/resources/org/apache/jackrabbit/oak/fixture/repository.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/resources/org/apache/jackrabbit/oak/fixture/repository.xml?rev=1461532&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/resources/org/apache/jackrabbit/oak/fixture/repository.xml
(added)
+++ jackrabbit/oak/trunk/oak-run/src/main/resources/org/apache/jackrabbit/oak/fixture/repository.xml
Wed Mar 27 11:31:14 2013
@@ -0,0 +1,153 @@
+<?xml version="1.0"?>
+<!--
+   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.
+-->
+
+<!DOCTYPE Repository
+          PUBLIC "-//The Apache Software Foundation//DTD Jackrabbit 2.0//EN"
+          "http://jackrabbit.apache.org/dtd/repository-2.0.dtd">
+
+<!-- Example Repository Configuration File
+     Used by
+     - org.apache.jackrabbit.core.config.RepositoryConfigTest.java
+     -
+-->
+<Repository>
+    <!--
+        virtual file system where the repository stores global state
+        (e.g. registered namespaces, custom node types, etc.)
+    -->
+    <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+        <param name="path" value="${rep.home}/repository"/>
+    </FileSystem>
+
+    <!--
+        data store configuration
+    -->
+    <DataStore class="org.apache.jackrabbit.core.data.FileDataStore"/>
+
+    <!--
+        security configuration
+    -->
+    <Security appName="Jackrabbit">
+        <!--
+            security manager:
+            class: FQN of class implementing the JackrabbitSecurityManager interface
+        -->
+        <SecurityManager class="org.apache.jackrabbit.core.DefaultSecurityManager" workspaceName="security">
+            <!--
+            workspace access:
+            class: FQN of class implementing the WorkspaceAccessManager interface
+            -->
+            <!-- <WorkspaceAccessManager class="..."/> -->
+            <!-- <param name="config" value="${rep.home}/security.xml"/> -->
+        </SecurityManager>
+
+        <!--
+            access manager:
+            class: FQN of class implementing the AccessManager interface
+        -->
+        <AccessManager class="org.apache.jackrabbit.core.security.DefaultAccessManager">
+            <!-- <param name="config" value="${rep.home}/access.xml"/> -->
+        </AccessManager>
+
+        <LoginModule class="org.apache.jackrabbit.core.security.authentication.DefaultLoginModule">
+           <!-- 
+              anonymous user name ('anonymous' is the default value)
+            -->
+           <param name="anonymousId" value="anonymous"/>
+           <!--
+              administrator user id (default value if param is missing is 'admin')
+            -->
+           <param name="adminId" value="admin"/>
+        </LoginModule>
+    </Security>
+
+    <!--
+        location of workspaces root directory and name of default workspace
+    -->
+    <Workspaces rootPath="${rep.home}/workspaces" defaultWorkspace="default"/>
+    <!--
+        workspace configuration template:
+        used to create the initial workspace if there's no workspace yet
+    -->
+    <Workspace name="${wsp.name}">
+        <!--
+            virtual file system of the workspace:
+            class: FQN of class implementing the FileSystem interface
+        -->
+        <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+            <param name="path" value="${wsp.home}"/>
+        </FileSystem>
+        <!--
+            persistence manager of the workspace:
+            class: FQN of class implementing the PersistenceManager interface
+        -->
+        <PersistenceManager class="org.apache.jackrabbit.core.persistence.pool.DerbyPersistenceManager">
+          <param name="url" value="jdbc:derby:${wsp.home}/db;create=true"/>
+          <param name="schemaObjectPrefix" value="${wsp.name}_"/>
+          <param name="bundleCacheSize" value="${bundleCacheSize}"/>
+        </PersistenceManager>
+        <!--
+            Search index and the file system it uses.
+            class: FQN of class implementing the QueryHandler interface
+        -->
+        <SearchIndex class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
+            <param name="path" value="${wsp.home}/index"/>
+            <param name="supportHighlighting" value="true"/>
+        </SearchIndex>
+    </Workspace>
+
+    <!--
+        Configures the versioning
+    -->
+    <Versioning rootPath="${rep.home}/version">
+        <!--
+            Configures the filesystem to use for versioning for the respective
+            persistence manager
+        -->
+        <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+            <param name="path" value="${rep.home}/version" />
+        </FileSystem>
+
+        <!--
+            Configures the persistence manager to be used for persisting version state.
+            Please note that the current versioning implementation is based on
+            a 'normal' persistence manager, but this could change in future
+            implementations.
+        -->
+        <PersistenceManager class="org.apache.jackrabbit.core.persistence.pool.DerbyPersistenceManager">
+          <param name="url" value="jdbc:derby:${rep.home}/version/db;create=true"/>
+          <param name="schemaObjectPrefix" value="version_"/>
+        </PersistenceManager>
+    </Versioning>
+
+    <!--
+        Search index for content that is shared repository wide
+        (/jcr:system tree, contains mainly versions)
+    -->
+    <SearchIndex class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
+        <param name="path" value="${rep.home}/repository/index"/>
+        <param name="supportHighlighting" value="true"/>
+    </SearchIndex>
+
+    <!--
+        Run with a cluster journal
+    -->
+    <Cluster id="node1">
+        <Journal class="org.apache.jackrabbit.core.journal.MemoryJournal"/>
+    </Cluster>
+</Repository>



Mime
View raw message