jackrabbit-oak-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thomas Mueller (Jira)" <j...@apache.org>
Subject [jira] [Comment Edited] (OAK-8579) Composite Node Store: Allow creating an index in the read-only repo first
Date Tue, 27 Aug 2019 12:38:00 GMT

    [ https://issues.apache.org/jira/browse/OAK-8579?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16916605#comment-16916605
] 

Thomas Mueller edited comment on OAK-8579 at 8/27/19 12:37 PM:
---------------------------------------------------------------

Potential patch (need to run more tests):

{noformat}
Index: oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/NameValidator.java
===================================================================
--- oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/NameValidator.java	(revision
1864607)
+++ oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/NameValidator.java	(working
copy)
@@ -30,6 +30,7 @@
 import org.apache.jackrabbit.oak.spi.commit.Validator;
 import org.apache.jackrabbit.oak.spi.lifecycle.RepositoryInitializer;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
+import org.apache.jackrabbit.oak.spi.state.NodeStateUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -172,7 +173,9 @@
     @Override
     public Validator childNodeAdded(String name, NodeState after)
             throws CommitFailedException {
-        checkValidName(name);
+        if (!NodeStateUtils.isHidden(name)) {
+            checkValidName(name);
+        }
         return this;
     }
 
Index: oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/TypeEditor.java
===================================================================
--- oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/TypeEditor.java	(revision
1864607)
+++ oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/TypeEditor.java	(working
copy)
@@ -475,6 +475,9 @@
         }
         if (!names.isEmpty()) {
             for (String name : names) {
+                if (NodeStateUtils.isHidden(name)) {
+                    continue;
+                }
                 NodeState child = after.getChildNode(name);
                 String primary = child.getName(JCR_PRIMARYTYPE);
                 Iterable<String> mixins = child.getNames(JCR_MIXINTYPES);
Index: oak-lucene/src/test/java/org/apache/jackrabbit/oak/composite/CompositeNodeStoreLuceneIndexTest.java
===================================================================
--- oak-lucene/src/test/java/org/apache/jackrabbit/oak/composite/CompositeNodeStoreLuceneIndexTest.java
(revision 1864609)
+++ oak-lucene/src/test/java/org/apache/jackrabbit/oak/composite/CompositeNodeStoreLuceneIndexTest.java
(working copy)
@@ -103,20 +103,13 @@
     }
 
     /**
-     * Given a composite node store , trying to create an index in read-write part
-     * with the same index node already existing in the read only part already
-     * we should get OakConstraint001 . This is the current behaviour,
-     * but can be worked upon (improved) in the future .
+     * Given a composite node store , create an index in read-write part
+     * with the same index node already existing in the read-only part already.
      */
     @Test
-    public void tryAddIndexInReadWriteWithIndexExistinginReadOnly() {
-        try {
-            repoV1.setupIndexAndContentInRepo("luceneTest", "foo", true, VERSION_1);
-            assertTrue(false);
-        } catch (Exception e) {
-            assert (e.getLocalizedMessage().contains(
-                    "OakConstraint0001: /oak:index/luceneTest/:oak:mount-readOnlyV1-index-data[[]]:
The primary type null does not exist"));
-        }
+    public void addIndexInReadWriteWithIndexExistinginReadOnly() throws Exception {
+        repoV1.setupIndexAndContentInRepo("luceneTest", "foo", true, VERSION_1);
+        repoV1.cleanup();
     }
 
     /**
{noformat}


was (Author: tmueller):
Potential patch (need to run more tests):

{noformat}
Index: oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/NameValidator.java
===================================================================
--- oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/NameValidator.java	(revision
1864607)
+++ oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/NameValidator.java	(working
copy)
@@ -30,6 +30,7 @@
 import org.apache.jackrabbit.oak.spi.commit.Validator;
 import org.apache.jackrabbit.oak.spi.lifecycle.RepositoryInitializer;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
+import org.apache.jackrabbit.oak.spi.state.NodeStateUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -172,7 +173,9 @@
     @Override
     public Validator childNodeAdded(String name, NodeState after)
             throws CommitFailedException {
-        checkValidName(name);
+        if (!NodeStateUtils.isHidden(name)) {
+            checkValidName(name);
+        }
         return this;
     }
 
Index: oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/TypeEditor.java
===================================================================
--- oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/TypeEditor.java	(revision
1864607)
+++ oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/TypeEditor.java	(working
copy)
@@ -475,6 +475,9 @@
         }
         if (!names.isEmpty()) {
             for (String name : names) {
+                if (NodeStateUtils.isHidden(name)) {
+                    continue;
+                }
                 NodeState child = after.getChildNode(name);
                 String primary = child.getName(JCR_PRIMARYTYPE);
                 Iterable<String> mixins = child.getNames(JCR_MIXINTYPES);
Index: oak-lucene/src/test/java/org/apache/jackrabbit/oak/composite/CompositeNodeStoreLuceneIndexTest.java
===================================================================
--- oak-lucene/src/test/java/org/apache/jackrabbit/oak/composite/CompositeNodeStoreLuceneIndexTest.java
(revision 1864609)
+++ oak-lucene/src/test/java/org/apache/jackrabbit/oak/composite/CompositeNodeStoreLuceneIndexTest.java
(working copy)
@@ -109,14 +109,14 @@
      * but can be worked upon (improved) in the future .
      */
     @Test
-    public void tryAddIndexInReadWriteWithIndexExistinginReadOnly() {
-        try {
+    public void tryAddIndexInReadWriteWithIndexExistinginReadOnly() throws Exception {
+//        try {
             repoV1.setupIndexAndContentInRepo("luceneTest", "foo", true, VERSION_1);
-            assertTrue(false);
-        } catch (Exception e) {
-            assert (e.getLocalizedMessage().contains(
-                    "OakConstraint0001: /oak:index/luceneTest/:oak:mount-readOnlyV1-index-data[[]]:
The primary type null does not exist"));
-        }
+//            assertTrue(false);
+//        } catch (Exception e) {
+//            assert (e.getLocalizedMessage().contains(
+//                    "OakConstraint0001: /oak:index/luceneTest/:oak:mount-readOnlyV1-index-data[[]]:
The primary type null does not exist"));
+//        }
     }
{noformat}

> Composite Node Store: Allow creating an index in the read-only repo first
> -------------------------------------------------------------------------
>
>                 Key: OAK-8579
>                 URL: https://issues.apache.org/jira/browse/OAK-8579
>             Project: Jackrabbit Oak
>          Issue Type: Improvement
>          Components: composite, core, indexing, lucene
>            Reporter: Thomas Mueller
>            Priority: Major
>
> Currently, it is not allowed to first create a new index in the read-only repository,
and then in the read-write repository. Trying to do so will fail with "OakConstraint0001:
/oak:index/.../:oak:mount-readOnlyV1-index-data[[]]: The primary type null does not exist"
> See OAK-7917: oak-lucene/src/test/java/org/apache/jackrabbit/oak/composite - CompositeNodeStoreLuceneIndexTest.java
tryAddIndexInReadWriteWithIndexExistinginReadOnly line 112. 
> It would be better to allow this use case, to reduce the possibility of problems.
> We should specially test with lucene indexes, but also with property indexes. (If that's
more complicated, we can concentrate on the lucene case first.)



--
This message was sent by Atlassian Jira
(v8.3.2#803003)

Mime
View raw message