jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [jackrabbit-oak] stefan-egli commented on a change in pull request #247: OAK-9176 : sweep2 PR for review
Date Thu, 01 Oct 2020 10:11:49 GMT

stefan-egli commented on a change in pull request #247:
URL: https://github.com/apache/jackrabbit-oak/pull/247#discussion_r498133106



##########
File path: oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/Sweep2Helper.java
##########
@@ -0,0 +1,166 @@
+/*
+ * 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 java.util.Map;
+
+import org.apache.jackrabbit.oak.plugins.document.util.Utils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Helper methods for sweep2 functionality introduced with OAK-9176.
+ * Kept separate from DocumentNodeStore to limit its size.
+ */
+public class Sweep2Helper {
+
+    private static final Logger LOG = LoggerFactory.getLogger(Sweep2Helper.class);
+
+    static boolean isSweep2Necessary(DocumentStore store) {
+        NodeDocument rootNodeDoc = store.find(Collection.NODES, Utils.getIdFromPath("/"));
+        if (rootNodeDoc == null) {
+            // that'd be very weird
+            LOG.warn("isSweep2Necessary : cannot get root node - assuming no sweep2 needed");
+            return false;
+        }
+    
+        if (rootNodeDoc.get("_sweepRev") == null) {
+            // this indicates a pre 1.8 repository upgrade (case 1).
+            // no sweep2 is needed as it is embedded in the normal sweep[1].
+            return false;
+        }
+    
+        // in this case we have a post (>=) 1.8 repository
+        // which might or might not have previously been a pre (<) 1.8
+        // and we need to distinguish those 2 cases - which, to repeat, are:
+        // 2) Oak >= 1.8 which never did an Oak <= 1.6 upgrade:
+        //    -> no sweep2 is needed as OAK-9176 doesn't apply (the repository
+        //       never ran <= 1.6)
+        // 3) Oak >= 1.8 which was previously doing an Oak <= 1.6 upgrade:
+        //    -> A (full) sweep2 is needed. This is the main case of OAK-9176.
+        Map<Revision, String> bcValueMap = rootNodeDoc.getValueMap("_bc");
+        Map<Revision, String> valueMap = rootNodeDoc.getValueMap(NodeDocument.REVISIONS);

Review comment:
       Implemented this with https://github.com/apache/jackrabbit-oak/pull/247/commits/1a8c1dca73bef9e8a1e5e95c80f25ab2f2230f7a




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



Mime
View raw message