You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by am...@apache.org on 2019/08/28 07:14:14 UTC

svn commit: r1866023 - in /jackrabbit/oak/trunk: oak-benchmarks/ oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/ oak-run-commons/src/main/java/org/apache/jackrabbit/oak/fixture/

Author: amitj
Date: Wed Aug 28 07:14:14 2019
New Revision: 1866023

URL: http://svn.apache.org/viewvc?rev=1866023&view=rev
Log:
OAK-8578: Introduce API to check whether blob inlined in Id

- Add a micro-benchmark for Binary#getUri

Added:
    jackrabbit/oak/trunk/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/GetURITest.java   (with props)
Modified:
    jackrabbit/oak/trunk/oak-benchmarks/pom.xml
    jackrabbit/oak/trunk/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/BenchmarkRunner.java
    jackrabbit/oak/trunk/oak-run-commons/src/main/java/org/apache/jackrabbit/oak/fixture/OakFixture.java
    jackrabbit/oak/trunk/oak-run-commons/src/main/java/org/apache/jackrabbit/oak/fixture/SegmentTarFixture.java

Modified: jackrabbit/oak/trunk/oak-benchmarks/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-benchmarks/pom.xml?rev=1866023&r1=1866022&r2=1866023&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-benchmarks/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-benchmarks/pom.xml Wed Aug 28 07:14:14 2019
@@ -162,8 +162,14 @@
 
         <dependency>
             <groupId>org.apache.jackrabbit</groupId>
-            <artifactId>jackrabbit-aws-ext</artifactId>
-            <version>${jackrabbit.version}</version>
+            <artifactId>oak-blob-cloud</artifactId>
+            <version>${project.version}</version>
+            <optional>true</optional>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.jackrabbit</groupId>
+            <artifactId>oak-blob-cloud-azure</artifactId>
+            <version>${project.version}</version>
             <optional>true</optional>
         </dependency>
 

Modified: jackrabbit/oak/trunk/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/BenchmarkRunner.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/BenchmarkRunner.java?rev=1866023&r1=1866022&r2=1866023&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/BenchmarkRunner.java (original)
+++ jackrabbit/oak/trunk/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/BenchmarkRunner.java Wed Aug 28 07:14:14 2019
@@ -533,7 +533,8 @@ public class BenchmarkRunner {
             new BasicWriteTest(),
             new CanReadNonExisting(),
             new IsNodeTypeTest(runAsAdmin.value(options)),
-            new SetPropertyTransientTest()
+            new SetPropertyTransientTest(),
+            new GetURITest()
         };
 
         Set<String> argset = Sets.newHashSet(nonOption.values(options));

Added: jackrabbit/oak/trunk/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/GetURITest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/GetURITest.java?rev=1866023&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/GetURITest.java (added)
+++ jackrabbit/oak/trunk/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/GetURITest.java Wed Aug 28 07:14:14 2019
@@ -0,0 +1,90 @@
+/*
+ * 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.net.URI;
+import java.util.Calendar;
+import java.util.List;
+import java.util.Random;
+
+import javax.jcr.Binary;
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.apache.commons.compress.utils.Lists;
+import org.apache.jackrabbit.api.binary.BinaryDownload;
+import org.apache.jackrabbit.api.binary.BinaryDownloadOptions;
+
+public class GetURITest extends AbstractTest {
+
+    private static final int FILE_COUNT = Integer.getInteger("file.count", 100);
+
+    private static final int FILE_SIZE = Integer.getInteger("file.size", 20);
+
+    private static final boolean DEBUG = Boolean.getBoolean("debug");
+
+    private Session session;
+
+    private Node root;
+
+    private List<Binary> binariesAdded = Lists.newArrayList();
+
+    private Random random = new Random(29);
+
+    /**
+     * Iteration counter used to avoid the split document edge case in DocumentMK.
+     */
+    private int iteration = 0;
+
+    @Override @SuppressWarnings("deprecation")
+    public void beforeSuite() throws RepositoryException {
+        session = loginWriter();
+        root = session.getRootNode().addNode(
+            "GetURI" + TEST_ID + iteration++, "nt:folder");
+        session.save();
+        for (int i = 0; i < FILE_COUNT; i++) {
+            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));
+            Binary binary = root.getNode("file" + i).getNode("jcr:content").getProperty("jcr:data").getBinary();
+            binariesAdded.add(binary);
+        }
+        session.save();
+
+    }
+
+    @Override
+    public void runTest() throws Exception {
+        int index = random.nextInt(FILE_COUNT);
+        Binary binary = binariesAdded.get(index);
+        URI uri = ((BinaryDownload) binary).getURI(BinaryDownloadOptions.DEFAULT);
+        if (DEBUG) {
+            System.out.println("URI retrieved=" + uri);
+        }
+    }
+
+    @Override
+    public void afterSuite() throws RepositoryException {
+        root.remove();
+        session.save();
+    }
+
+}

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

Modified: jackrabbit/oak/trunk/oak-run-commons/src/main/java/org/apache/jackrabbit/oak/fixture/OakFixture.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run-commons/src/main/java/org/apache/jackrabbit/oak/fixture/OakFixture.java?rev=1866023&r1=1866022&r2=1866023&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-run-commons/src/main/java/org/apache/jackrabbit/oak/fixture/OakFixture.java (original)
+++ jackrabbit/oak/trunk/oak-run-commons/src/main/java/org/apache/jackrabbit/oak/fixture/OakFixture.java Wed Aug 28 07:14:14 2019
@@ -19,6 +19,7 @@ package org.apache.jackrabbit.oak.fixtur
 import java.io.File;
 import java.lang.management.ManagementFactory;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
@@ -30,6 +31,7 @@ import com.google.common.base.Predicate;
 import com.google.common.base.Splitter;
 import com.google.common.base.Strings;
 import org.apache.jackrabbit.oak.Oak;
+import org.apache.jackrabbit.oak.api.blob.BlobAccessProvider;
 import org.apache.jackrabbit.oak.fixture.SegmentTarFixture.SegmentTarFixtureBuilder;
 import org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore;
 import org.apache.jackrabbit.oak.plugins.document.DocumentNodeStoreBuilder;
@@ -222,7 +224,12 @@ public abstract class OakFixture {
                 if (blobStore != null) {
                     builder.setBlobStore(blobStore);
                 }
-                return newOak(builder.build());
+                Oak oak = newOak(builder.build());
+                if (blobStore != null) {
+                    oak.getWhiteboard()
+                        .register(BlobAccessProvider.class, (BlobAccessProvider) blobStore, Collections.EMPTY_MAP);
+                }
+                return oak;
             }
 
             @Override
@@ -243,6 +250,10 @@ public abstract class OakFixture {
                     }
                     nodeStores[i] = builder.build();
                     cluster[i] = newOak(nodeStores[i]);
+                    if (blobStore != null) {
+                        cluster[i].getWhiteboard()
+                            .register(BlobAccessProvider.class, (BlobAccessProvider) blobStore, Collections.EMPTY_MAP);
+                    }
                 }
                 if (vgcMaxAge > 0 && nodeStores.length >= 1) {
                     versionGarbageCollectionJob = new VersionGarbageCollectionJob(nodeStores[0], vgcMaxAge);
@@ -400,6 +411,7 @@ public abstract class OakFixture {
 
         private List<DocumentNodeStore> nodeStores = new ArrayList<>();
         private BlobStoreFixture blobStoreFixture;
+        private BlobStore blobStore;
 
         public MongoFixture(final String name, final String uri,
                             final boolean dropDBAfterTest, final long cacheSize,
@@ -435,13 +447,22 @@ public abstract class OakFixture {
 
         @Override
         public Oak getOak(int clusterId) throws Exception {
-            return newOak(getBuilder(clusterId).build());
+            Oak oak = newOak(getBuilder(clusterId).build());
+            if (this.blobStore != null) {
+                oak.getWhiteboard()
+                    .register(BlobAccessProvider.class, (BlobAccessProvider) this.blobStore, Collections.EMPTY_MAP);
+            }
+            return oak;
         }
 
         public Oak[] setUpCluster(DocumentNodeStoreBuilder<?>[] builders, StatisticsProvider statsProvider) throws Exception {
             Oak[] cluster = new Oak[builders.length];
             for (int i = 0; i < cluster.length; i++) {
                 cluster[i] = newOak(builders[i].build());
+                if (this.blobStore != null) {
+                    cluster[i].getWhiteboard()
+                        .register(BlobAccessProvider.class, (BlobAccessProvider) this.blobStore, Collections.EMPTY_MAP);
+                }
             }
             return cluster;
         }
@@ -479,7 +500,8 @@ public abstract class OakFixture {
         private void setupBlobStore(DocumentNodeStoreBuilder<?> builder, StatisticsProvider statsProvider) {
             initializeBlobStoreFixture(statsProvider);
             if (blobStoreFixture != null) {
-                builder.setBlobStore(blobStoreFixture.setUp());
+                this.blobStore = blobStoreFixture.setUp();
+                builder.setBlobStore(this.blobStore);
             }
         }
 
@@ -524,4 +546,4 @@ public abstract class OakFixture {
         return new Oak(nodeStore).with(ManagementFactory.getPlatformMBeanServer());
     }
 
-}
\ No newline at end of file
+}

Modified: jackrabbit/oak/trunk/oak-run-commons/src/main/java/org/apache/jackrabbit/oak/fixture/SegmentTarFixture.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run-commons/src/main/java/org/apache/jackrabbit/oak/fixture/SegmentTarFixture.java?rev=1866023&r1=1866022&r2=1866023&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-run-commons/src/main/java/org/apache/jackrabbit/oak/fixture/SegmentTarFixture.java (original)
+++ jackrabbit/oak/trunk/oak-run-commons/src/main/java/org/apache/jackrabbit/oak/fixture/SegmentTarFixture.java Wed Aug 28 07:14:14 2019
@@ -22,6 +22,7 @@ import static org.apache.jackrabbit.oak.
 import java.io.File;
 import java.io.IOException;
 import java.net.ServerSocket;
+import java.util.Collections;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
@@ -35,6 +36,7 @@ import com.microsoft.azure.storage.blob.
 import org.apache.commons.io.FileUtils;
 import org.apache.jackrabbit.core.data.FileDataStore;
 import org.apache.jackrabbit.oak.Oak;
+import org.apache.jackrabbit.oak.api.blob.BlobAccessProvider;
 import org.apache.jackrabbit.oak.plugins.blob.datastore.DataStoreBlobStore;
 import org.apache.jackrabbit.oak.segment.SegmentId;
 import org.apache.jackrabbit.oak.segment.SegmentNodeStoreBuilders;
@@ -199,18 +201,25 @@ public class SegmentTarFixture extends O
             CloudBlobDirectory directory = container.getDirectoryReference(azureRootPath);
             fileStoreBuilder.withCustomPersistence(new AzurePersistence(directory));
         }
-        
+
+        BlobStore blobStore = null;
         if (useBlobStore) {
             FileDataStore fds = new FileDataStore();
             fds.setMinRecordLength(4092);
             fds.init(parentPath.getAbsolutePath());
-            BlobStore blobStore = new DataStoreBlobStore(fds);
+            blobStore = new DataStoreBlobStore(fds);
             
             fileStoreBuilder.withBlobStore(blobStore);
         }
         
         FileStore fs = fileStoreBuilder.build();
-        return newOak(SegmentNodeStoreBuilders.builder(fs).build());
+        Oak oak = newOak(SegmentNodeStoreBuilders.builder(fs).build());
+        if (blobStore != null) {
+            oak.getWhiteboard()
+                .register(BlobAccessProvider.class, (BlobAccessProvider) blobStore, Collections.EMPTY_MAP);
+        }
+
+        return oak;
     }
 
     @Override
@@ -254,6 +263,10 @@ public class SegmentTarFixture extends O
             }
             
             cluster[i] = newOak(SegmentNodeStoreBuilders.builder(stores[i]).build());
+            if (blobStore != null) {
+                cluster[i].getWhiteboard()
+                    .register(BlobAccessProvider.class, (BlobAccessProvider) blobStore, Collections.EMPTY_MAP);
+            }
         }
         return cluster;
     }