Author: chetanm
Date: Wed Jul 12 05:05:37 2017
New Revision: 1801682

URL: http://svn.apache.org/viewvc?rev=1801682&view=rev
Log:
OAK-6271 - Support for importing index files

Increment the reindex count

Modified:
    
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/importer/IndexImporter.java
    
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/importer/IndexImporterTest.java

Modified: 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/importer/IndexImporter.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/importer/IndexImporter.java?rev=1801682&r1=1801681&r2=1801682&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/importer/IndexImporter.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/importer/IndexImporter.java
 Wed Jul 12 05:05:37 2017
@@ -29,6 +29,7 @@ import com.google.common.collect.ArrayLi
 import com.google.common.collect.ListMultimap;
 import org.apache.jackrabbit.oak.api.CommitFailedException;
 import org.apache.jackrabbit.oak.api.PropertyState;
+import org.apache.jackrabbit.oak.api.Type;
 import org.apache.jackrabbit.oak.plugins.index.IndexConstants;
 import org.apache.jackrabbit.oak.plugins.index.IndexEditorProvider;
 import org.apache.jackrabbit.oak.plugins.index.IndexUpdate;
@@ -46,6 +47,7 @@ import org.slf4j.LoggerFactory;
 
 import static com.google.common.base.Preconditions.checkArgument;
 import static com.google.common.base.Preconditions.checkNotNull;
+import static 
org.apache.jackrabbit.oak.plugins.index.IndexConstants.REINDEX_COUNT;
 import static 
org.apache.jackrabbit.oak.plugins.index.importer.NodeStoreUtils.mergeWithConcurrentCheck;
 
 public class IndexImporter {
@@ -121,8 +123,8 @@ public class IndexImporter {
         for (IndexInfo indexInfo : asyncLaneToIndexMapping.values()) {
             log.info("Importing index data for {}", indexInfo.indexPath);
             NodeBuilder idxBuilder = NodeStoreUtils.childBuilder(builder, 
indexInfo.indexPath);
-            //TODO Drop existing hidden folders
-            //Increment reindex count
+            //TODO Drop existing hidden folders. Be careful to not touch read 
only mount paths
+            incrementReIndexCount(idxBuilder);
             getImporter(indexInfo.type).importIndex(root, idxBuilder, 
indexInfo.indexDir);
         }
         mergeWithConcurrentCheck(nodeStore, builder);
@@ -254,6 +256,14 @@ public class IndexImporter {
         log.info("Released the referred checkpoint [{}]", 
indexerInfo.checkpoint);
     }
 
+    private void incrementReIndexCount(NodeBuilder definition) {
+        long count = 0;
+        if(definition.hasProperty(REINDEX_COUNT)){
+            count = definition.getProperty(REINDEX_COUNT).getValue(Type.LONG);
+        }
+        definition.setProperty(REINDEX_COUNT, count + 1);
+    }
+
     private NodeState getAsync() {
         return nodeStore.getRoot().getChildNode(":async");
     }

Modified: 
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/importer/IndexImporterTest.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/importer/IndexImporterTest.java?rev=1801682&r1=1801681&r2=1801682&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/importer/IndexImporterTest.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/importer/IndexImporterTest.java
 Wed Jul 12 05:05:37 2017
@@ -62,12 +62,12 @@ import static java.util.Arrays.asList;
 import static org.apache.jackrabbit.JcrConstants.NT_BASE;
 import static 
org.apache.jackrabbit.oak.plugins.index.IndexConstants.ASYNC_PROPERTY_NAME;
 import static 
org.apache.jackrabbit.oak.plugins.index.IndexConstants.INDEX_DEFINITIONS_NAME;
+import static 
org.apache.jackrabbit.oak.plugins.index.IndexConstants.REINDEX_COUNT;
 import static 
org.apache.jackrabbit.oak.plugins.index.IndexUtils.createIndexDefinition;
 import static 
org.apache.jackrabbit.oak.plugins.index.importer.AsyncIndexerLock.NOOP_LOCK;
 import static 
org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE;
 import static org.junit.Assert.*;
 import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
 
 public class IndexImporterTest {
 
@@ -186,6 +186,7 @@ public class IndexImporterTest {
             @Override
             public void importIndex(NodeState root, NodeBuilder defn, File 
indexDir) {
                 assertEquals("fooIndex", indexDir.getName());
+                assertEquals(2, 
defn.getProperty(REINDEX_COUNT).getValue(Type.LONG).longValue());
                 
defn.getChildNode(IndexConstants.INDEX_CONTENT_NODE_NAME).remove();
 
                 NodeState cpState = store.retrieve(checkpoint);


Reply via email to