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 ch...@apache.org on 2017/05/22 11:51:49 UTC

svn commit: r1795795 - in /jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/index: IndexOptions.java OutOfBandIndexer.java

Author: chetanm
Date: Mon May 22 11:51:49 2017
New Revision: 1795795

URL: http://svn.apache.org/viewvc?rev=1795795&view=rev
Log:
OAK-6246 - Support for out of band indexing with read only access to NodeStore

Allow using 'head' as a possible value for '--checkpoint' argument

Modified:
    jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/index/IndexOptions.java
    jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/index/OutOfBandIndexer.java

Modified: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/index/IndexOptions.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/index/IndexOptions.java?rev=1795795&r1=1795794&r2=1795795&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/index/IndexOptions.java (original)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/index/IndexOptions.java Mon May 22 11:51:49 2017
@@ -73,7 +73,8 @@ public class IndexOptions implements Opt
                 .withRequiredArg().ofType(String.class).withValuesSeparatedBy(",");
 
         checkpoint = parser.accepts("checkpoint", "Checkpoint value upto which index would be updated when " +
-                "indexing is performed in read only mode")
+                "indexing is performed in read only mode. For testing purpose it can be set to 'head' to indicate that head " +
+                "state should be used.")
                 .withRequiredArg().ofType(String.class);
 
         consistencyCheck = parser.accepts("index-consistency-check", "Performs consistency check " +

Modified: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/index/OutOfBandIndexer.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/index/OutOfBandIndexer.java?rev=1795795&r1=1795794&r2=1795795&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/index/OutOfBandIndexer.java (original)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/index/OutOfBandIndexer.java Mon May 22 11:51:49 2017
@@ -87,6 +87,12 @@ public class OutOfBandIndexer implements
      */
     private static final String INDEXER_META = "indexer-info.txt";
 
+    /**
+     * Checkpoint value which indicate that head state needs to be used
+     * This would be mostly used for testing purpose
+     */
+    private static final String HEAD_AS_CHECKPOINT = "head";
+
     private final Closer closer = Closer.create();
     private final IndexHelper indexHelper;
     private final String checkpoint;
@@ -107,6 +113,11 @@ public class OutOfBandIndexer implements
         Stopwatch w = Stopwatch.createStarted();
         NodeState checkpointedState = indexHelper.getNodeStore().retrieve(checkpoint);
 
+        if (checkpointedState == null && HEAD_AS_CHECKPOINT.equals(checkpoint)) {
+            checkpointedState = indexHelper.getNodeStore().getRoot();
+            log.warn("Using head state for indexing. Such an index cannot be imported back");
+        }
+
         checkNotNull(checkpointedState, "Not able to retrieve revision referred via checkpoint [%s]", checkpoint);
         copyOnWriteStore = new MemoryNodeStore(checkpointedState);
         checkpointInfo = indexHelper.getNodeStore().checkpointInfo(checkpoint);
@@ -192,6 +203,7 @@ public class OutOfBandIndexer implements
         NodeBuilder builder = copyOnWriteStore.getRoot().builder();
 
         for (String indexPath : indexHelper.getIndexPaths()) {
+            //TODO Do it only for lucene indexes for now
             NodeBuilder idxBuilder = NodeStoreUtils.childBuilder(builder, indexPath);
             idxBuilder.setProperty(IndexConstants.REINDEX_PROPERTY_NAME, true);
             switchLane(idxBuilder);