Author: chetanm
Date: Fri May 19 08:10:28 2017
New Revision: 1795591

URL: http://svn.apache.org/viewvc?rev=1795591&view=rev
Log:
OAK-6192 - Lucene IndexInfoProvider implementation

Move the logic for getting async lane name to IndexUtils

Added:
    
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexUtilsTest.java
   (with props)
Modified:
    
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexUtils.java
    
jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexInfoProvider.java
    
jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexInfoProviderTest.java

Modified: 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexUtils.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexUtils.java?rev=1795591&r1=1795590&r2=1795591&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexUtils.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexUtils.java
 Fri May 19 08:10:28 2017
@@ -16,6 +16,7 @@
  */
 package org.apache.jackrabbit.oak.plugins.index;
 
+import static com.google.common.base.Preconditions.checkArgument;
 import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE;
 import static org.apache.jackrabbit.JcrConstants.NT_UNSTRUCTURED;
 import static org.apache.jackrabbit.oak.api.Type.NAME;
@@ -31,6 +32,7 @@ import static org.apache.jackrabbit.oak.
 
 import java.util.Collection;
 import java.util.Map;
+import java.util.Set;
 
 import javax.annotation.CheckForNull;
 import javax.annotation.Nonnull;
@@ -38,6 +40,8 @@ import javax.annotation.Nullable;
 import javax.jcr.RepositoryException;
 
 import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Sets;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Tree;
 import org.apache.jackrabbit.oak.api.Type;
@@ -220,4 +224,18 @@ public class IndexUtils {
         }
         return entry;
     }
+
+    @CheckForNull
+    public static String getAsyncLaneName(NodeState idxState, String 
indexPath) {
+        PropertyState async = 
idxState.getProperty(IndexConstants.ASYNC_PROPERTY_NAME);
+        if (async != null) {
+            Set<String> asyncNames = 
Sets.newHashSet(async.getValue(Type.STRINGS));
+            asyncNames.remove(IndexConstants.INDEXING_MODE_NRT);
+            asyncNames.remove(IndexConstants.INDEXING_MODE_SYNC);
+            checkArgument(!asyncNames.isEmpty(), "No valid async name found 
for " +
+                    "index [%s], definition %s", indexPath, idxState);
+            return Iterables.getOnlyElement(asyncNames);
+        }
+        return null;
+    }
 }

Added: 
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexUtilsTest.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexUtilsTest.java?rev=1795591&view=auto
==============================================================================
--- 
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexUtilsTest.java
 (added)
+++ 
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexUtilsTest.java
 Fri May 19 08:10:28 2017
@@ -0,0 +1,44 @@
+/*
+ * 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.index;
+
+import org.apache.jackrabbit.oak.api.Type;
+import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
+import org.junit.Test;
+
+import static com.google.common.collect.Lists.newArrayList;
+import static 
org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE;
+import static org.junit.Assert.*;
+
+public class IndexUtilsTest {
+
+    @Test
+    public void asyncName() throws Exception {
+        assertNull(IndexUtils.getAsyncLaneName(EMPTY_NODE, "/fooIndex"));
+
+        NodeBuilder builder = EMPTY_NODE.builder();
+        builder.setProperty("async", newArrayList("async2", "sync"), 
Type.STRINGS);
+        assertEquals("async2", 
IndexUtils.getAsyncLaneName(builder.getNodeState(), "/fooIndex"));
+
+        builder.setProperty("async", newArrayList("async3"), Type.STRINGS);
+        assertEquals("async3", 
IndexUtils.getAsyncLaneName(builder.getNodeState(), "/fooIndex"));
+    }
+
+}
\ No newline at end of file

Propchange: 
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexUtilsTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: 
jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexInfoProvider.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexInfoProvider.java?rev=1795591&r1=1795590&r2=1795591&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexInfoProvider.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexInfoProvider.java
 Fri May 19 08:10:28 2017
@@ -34,6 +34,7 @@ import org.apache.jackrabbit.oak.plugins
 import org.apache.jackrabbit.oak.plugins.index.IndexConstants;
 import org.apache.jackrabbit.oak.plugins.index.IndexInfo;
 import org.apache.jackrabbit.oak.plugins.index.IndexInfoProvider;
+import org.apache.jackrabbit.oak.plugins.index.IndexUtils;
 import org.apache.jackrabbit.oak.plugins.index.lucene.directory.DirectoryUtils;
 import 
org.apache.jackrabbit.oak.plugins.index.lucene.directory.IndexConsistencyChecker;
 import 
org.apache.jackrabbit.oak.plugins.index.lucene.writer.MultiplexersLucene;
@@ -67,19 +68,6 @@ public class LuceneIndexInfoProvider imp
         this.workDir = checkNotNull(workDir);
     }
 
-    static String getAsyncName(NodeState idxState, String indexPath) {
-        PropertyState async = 
idxState.getProperty(IndexConstants.ASYNC_PROPERTY_NAME);
-        if (async != null) {
-            Set<String> asyncNames = 
Sets.newHashSet(async.getValue(Type.STRINGS));
-            asyncNames.remove(IndexConstants.INDEXING_MODE_NRT);
-            asyncNames.remove(IndexConstants.INDEXING_MODE_SYNC);
-            checkArgument(!asyncNames.isEmpty(), "No valid async name found 
for " +
-                    "index [%s], definition %s", indexPath, idxState);
-            return Iterables.getOnlyElement(asyncNames);
-        }
-        return null;
-    }
-
     @Override
     public String getType() {
         return LuceneIndexConstants.TYPE_LUCENE;
@@ -107,7 +95,7 @@ public class LuceneIndexInfoProvider imp
     }
 
     private void computeAsyncIndexInfo(NodeState idxState, String indexPath, 
LuceneIndexInfo info) {
-        String asyncName = getAsyncName(idxState, indexPath);
+        String asyncName = IndexUtils.getAsyncLaneName(idxState, indexPath);
         if (asyncName == null) {
             log.warn("No 'async' value for index definition at [{}]. 
Definition {}", indexPath, idxState);
             return;

Modified: 
jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexInfoProviderTest.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexInfoProviderTest.java?rev=1795591&r1=1795590&r2=1795591&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexInfoProviderTest.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexInfoProviderTest.java
 Fri May 19 08:10:28 2017
@@ -57,18 +57,6 @@ public class LuceneIndexInfoProviderTest
         provider = new LuceneIndexInfoProvider(store, asyncService, 
temporaryFolder.getRoot());
     }
 
-    @Test
-    public void asyncName() throws Exception {
-        assertNull(LuceneIndexInfoProvider.getAsyncName(EMPTY_NODE, 
"/fooIndex"));
-
-        NodeBuilder builder = EMPTY_NODE.builder();
-        builder.setProperty("async", newArrayList("async2", "sync"), 
Type.STRINGS);
-        assertEquals("async2", 
LuceneIndexInfoProvider.getAsyncName(builder.getNodeState(), "/fooIndex"));
-
-        builder.setProperty("async", newArrayList("async3"), Type.STRINGS);
-        assertEquals("async3", 
LuceneIndexInfoProvider.getAsyncName(builder.getNodeState(), "/fooIndex"));
-    }
-
     @Test(expected = IllegalArgumentException.class)
     public void infoNonExisting() throws Exception {
         provider.getInfo("/no/existing/path");


Reply via email to