Author: chetanm
Date: Thu Aug 10 04:20:56 2017
New Revision: 1804631

URL: http://svn.apache.org/viewvc?rev=1804631&view=rev
Log:
OAK-6541 - While importing new index property indexes are getting marked for 
reindex

Configure all required index editors for import flow

Modified:
    
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/importer/NodeStoreUtils.java
    
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/index/IndexCommand.java
    
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/index/IndexImporterSupport.java
    
jackrabbit/oak/trunk/oak-run/src/test/java/org/apache/jackrabbit/oak/index/ReindexIT.java

Modified: 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/importer/NodeStoreUtils.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/importer/NodeStoreUtils.java?rev=1804631&r1=1804630&r2=1804631&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/importer/NodeStoreUtils.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/importer/NodeStoreUtils.java
 Thu Aug 10 04:20:56 2017
@@ -58,7 +58,7 @@ final class NodeStoreUtils {
                                          IndexEditorProvider 
indexEditorProvider) throws CommitFailedException {
         CompositeHook hooks = new CompositeHook(
                 ResetCommitAttributeHook.INSTANCE,
-                new EditorHook(new IndexUpdateProvider(indexEditorProvider)),
+                new EditorHook(new IndexUpdateProvider(indexEditorProvider, 
null, true)),
                 new ConflictHook(new AnnotatingConflictHandler()),
                 new 
EditorHook(CompositeEditorProvider.compose(singletonList(new 
ConflictValidatorProvider())))
         );

Modified: 
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/index/IndexCommand.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/index/IndexCommand.java?rev=1804631&r1=1804630&r2=1804631&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/index/IndexCommand.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/index/IndexCommand.java
 Thu Aug 10 04:20:56 2017
@@ -58,6 +58,7 @@ public class IndexCommand implements Com
     private File consistencyCheckReport;
     private Options opts;
     private IndexOptions indexOpts;
+    private static boolean disableExitOnError;
 
     @Override
     public void execute(String... args) throws Exception {
@@ -93,6 +94,9 @@ public class IndexCommand implements Com
         } catch (Throwable e) {
             log.error("Error occurred while performing index tasks", e);
             e.printStackTrace(System.err);
+            if (disableExitOnError) {
+                throw e;
+            }
         } finally {
             shutdownLogging();
         }
@@ -102,6 +106,10 @@ public class IndexCommand implements Com
         }
     }
 
+    public static void setDisableExitOnError(boolean disableExitOnError) {
+        IndexCommand.disableExitOnError = disableExitOnError;
+    }
+
     private void tellReportPaths() {
         if (info != null) {
             System.out.printf("Index stats stored at %s%n", getPath(info));

Modified: 
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/index/IndexImporterSupport.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/index/IndexImporterSupport.java?rev=1804631&r1=1804630&r2=1804631&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/index/IndexImporterSupport.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/index/IndexImporterSupport.java
 Thu Aug 10 04:20:56 2017
@@ -29,10 +29,12 @@ import org.apache.jackrabbit.oak.plugins
 import org.apache.jackrabbit.oak.plugins.index.importer.ClusterNodeStoreLock;
 import org.apache.jackrabbit.oak.plugins.index.importer.IndexImporter;
 import 
org.apache.jackrabbit.oak.plugins.index.lucene.directory.LuceneIndexImporter;
+import 
org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider;
+import 
org.apache.jackrabbit.oak.plugins.index.reference.ReferenceEditorProvider;
+import org.apache.jackrabbit.oak.spi.mount.MountInfoProvider;
 import org.apache.jackrabbit.oak.spi.state.Clusterable;
 import org.apache.jackrabbit.oak.spi.state.NodeStore;
 
-import static java.util.Collections.singletonList;
 
 class IndexImporterSupport {
     private final IndexHelper indexHelper;
@@ -63,9 +65,13 @@ class IndexImporterSupport {
     }
 
     private IndexEditorProvider createIndexEditorProvider() throws IOException 
{
-        IndexEditorProvider lucene = createLuceneEditorProvider();
+        MountInfoProvider mip = indexHelper.getMountInfoProvider();
         //Later we can add support for property index and other indexes here
-        return CompositeIndexEditorProvider.compose(singletonList(lucene));
+        return new CompositeIndexEditorProvider(
+                createLuceneEditorProvider(),
+                new PropertyIndexEditorProvider().with(mip),
+                new ReferenceEditorProvider().with(mip)
+        );
     }
 
     private IndexEditorProvider createLuceneEditorProvider() throws 
IOException {

Modified: 
jackrabbit/oak/trunk/oak-run/src/test/java/org/apache/jackrabbit/oak/index/ReindexIT.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/test/java/org/apache/jackrabbit/oak/index/ReindexIT.java?rev=1804631&r1=1804630&r2=1804631&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-run/src/test/java/org/apache/jackrabbit/oak/index/ReindexIT.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-run/src/test/java/org/apache/jackrabbit/oak/index/ReindexIT.java
 Thu Aug 10 04:20:56 2017
@@ -49,6 +49,7 @@ import org.apache.jackrabbit.oak.plugins
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 import org.apache.jackrabbit.oak.spi.state.NodeStateUtils;
 import org.apache.jackrabbit.oak.spi.state.NodeStore;
+import org.junit.Before;
 import org.junit.Test;
 
 import static com.google.common.base.Charsets.UTF_8;
@@ -65,6 +66,11 @@ import static org.junit.Assert.assertTru
 
 public class ReindexIT extends AbstractIndexCommandTest {
 
+    @Before
+    public void setUp() {
+        IndexCommand.setDisableExitOnError(true);
+    }
+
     @Test
     public void reindexOutOfBand() throws Exception{
         createTestData(true);


Reply via email to