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 mr...@apache.org on 2017/03/22 10:51:57 UTC
svn commit: r1788088 - in /jackrabbit/oak/trunk/oak-core/src:
main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java
test/java/org/apache/jackrabbit/oak/plugins/document/VersionGCInitTest.java
Author: mreutegg
Date: Wed Mar 22 10:51:56 2017
New Revision: 1788088
URL: http://svn.apache.org/viewvc?rev=1788088&view=rev
Log:
OAK-5966: Not able to connect in read only mode with old DocumentNodeStore repo
Added:
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGCInitTest.java (with props)
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java?rev=1788088&r1=1788087&r2=1788088&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java Wed Mar 22 10:51:56 2017
@@ -19,6 +19,7 @@ package org.apache.jackrabbit.oak.plugin
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
+import static com.google.common.base.Suppliers.memoize;
import static com.google.common.collect.Iterables.filter;
import static com.google.common.collect.Iterables.toArray;
import static com.google.common.collect.Iterables.transform;
@@ -440,7 +441,7 @@ public final class DocumentNodeStore
private final Checkpoints checkpoints;
- private final VersionGarbageCollector versionGarbageCollector;
+ private final Supplier<VersionGarbageCollector> versionGarbageCollectorSupplier;
private final JournalGarbageCollector journalGarbageCollector;
@@ -526,7 +527,7 @@ public final class DocumentNodeStore
this.clusterId = cid;
this.branches = new UnmergedBranches();
this.asyncDelay = builder.getAsyncDelay();
- this.versionGarbageCollector = new VersionGarbageCollector(
+ this.versionGarbageCollectorSupplier = createVersionGCSupplier(
this, builder.createVersionGCSupport());
this.journalGarbageCollector = new JournalGarbageCollector(this);
this.referencedBlobs = builder.createReferencedBlobs(this);
@@ -2184,6 +2185,16 @@ public final class DocumentNodeStore
//-----------------------------< internal >---------------------------------
+ private static Supplier<VersionGarbageCollector> createVersionGCSupplier(
+ final DocumentNodeStore ns, final VersionGCSupport gcSupport) {
+ return memoize(new Supplier<VersionGarbageCollector>() {
+ @Override
+ public VersionGarbageCollector get() {
+ return new VersionGarbageCollector(ns, gcSupport);
+ }
+ });
+ }
+
/**
* Checks if this node store can operate on the data in the given document
* store.
@@ -2942,7 +2953,7 @@ public final class DocumentNodeStore
@Nonnull
public VersionGarbageCollector getVersionGarbageCollector() {
- return versionGarbageCollector;
+ return versionGarbageCollectorSupplier.get();
}
@Nonnull
Added: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGCInitTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGCInitTest.java?rev=1788088&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGCInitTest.java (added)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGCInitTest.java Wed Mar 22 10:51:56 2017
@@ -0,0 +1,52 @@
+/*
+ * 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.plugins.document;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+public class VersionGCInitTest {
+
+ @Rule
+ public final DocumentMKBuilderProvider builderProvider = new DocumentMKBuilderProvider();
+
+ private DocumentNodeStore ns;
+
+ @Before
+ public void before() {
+ ns = builderProvider.newBuilder().getNodeStore();
+ }
+
+ @Test
+ public void lazyInitialize() throws Exception {
+ DocumentStore store = ns.getDocumentStore();
+ Document vgc = store.find(Collection.SETTINGS, "versionGC");
+ assertNull(vgc);
+
+ ns.getVersionGarbageCollector();
+
+ vgc = store.find(Collection.SETTINGS, "versionGC");
+ assertNotNull(vgc);
+ }
+
+}
Propchange: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGCInitTest.java
------------------------------------------------------------------------------
svn:eol-style = native