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 am...@apache.org on 2015/07/07 07:47:45 UTC

svn commit: r1689576 - in /jackrabbit/oak/branches/1.0/oak-lucene/src: main/java/org/apache/jackrabbit/oak/plugins/index/lucene/ test/java/org/apache/jackrabbit/oak/plugins/index/lucene/

Author: amitj
Date: Tue Jul  7 05:47:45 2015
New Revision: 1689576

URL: http://svn.apache.org/r1689576
Log:
OAK-3020: Async Update fails after IllegalArgumentException

Reverting revision 1689573

Modified:
    jackrabbit/oak/branches/1.0/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/Aggregate.java
    jackrabbit/oak/branches/1.0/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexEditor.java
    jackrabbit/oak/branches/1.0/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/AggregateTest.java

Modified: jackrabbit/oak/branches/1.0/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/Aggregate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.0/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/Aggregate.java?rev=1689576&r1=1689575&r2=1689576&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.0/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/Aggregate.java (original)
+++ jackrabbit/oak/branches/1.0/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/Aggregate.java Tue Jul  7 05:47:45 2015
@@ -78,7 +78,7 @@ class Aggregate {
         return includes;
     }
 
-    public void collectAggregates(NodeState root, ResultCollector collector) {
+    public void collectAggregates(NodeState root, ResultCollector collector) throws CommitFailedException {
         if (nodeTypeName.equals(ConfigUtil.getPrimaryTypeName(root))) {
             List<Matcher> matchers = createMatchers();
             collectAggregates(root, matchers, collector);
@@ -112,7 +112,7 @@ class Aggregate {
     }
 
     private static void collectAggregates(NodeState nodeState, List<Matcher> matchers,
-                                          ResultCollector collector) {
+                                          ResultCollector collector) throws CommitFailedException {
         for (ChildNodeEntry cne : nodeState.getChildNodeEntries()) {
             List<Matcher> nextSet = newArrayListWithCapacity(matchers.size());
             for (Matcher m : matchers) {
@@ -190,12 +190,13 @@ class Aggregate {
         }
 
         public void collectResults(T rootInclude, String rootIncludePath,
-                                   String nodePath, NodeState nodeState,  ResultCollector results) {
+                                   String nodePath, NodeState nodeState,  ResultCollector results)
+                throws CommitFailedException {
             collectResults(nodePath, nodeState, results);
         }
 
         public void collectResults(String nodePath, NodeState nodeState,
-                                            ResultCollector results) {
+                                            ResultCollector results) throws CommitFailedException {
 
         }
 
@@ -239,7 +240,7 @@ class Aggregate {
 
         @Override
         public void collectResults(NodeInclude rootInclude, String rootIncludePath, String nodePath,
-                                   NodeState nodeState, ResultCollector results) {
+                                   NodeState nodeState, ResultCollector results) throws CommitFailedException {
             //For supporting jcr:contains(jcr:content, 'foo')
             if (rootInclude.relativeNode){
                 results.onResult(new NodeIncludeResult(nodePath, rootIncludePath, nodeState));
@@ -308,7 +309,8 @@ class Aggregate {
         }
 
         @Override
-        public void collectResults(String nodePath, NodeState nodeState, ResultCollector results) {
+        public void collectResults(String nodePath, NodeState nodeState, ResultCollector results)
+                throws CommitFailedException {
             if (pattern != null) {
                 for (PropertyState ps : nodeState.getProperties()) {
                     if (pattern.matcher(ps.getName()).matches()) {
@@ -338,9 +340,9 @@ class Aggregate {
     }
 
     public static interface ResultCollector {
-        void onResult(NodeIncludeResult result);
+        void onResult(NodeIncludeResult result) throws CommitFailedException;
 
-        void onResult(PropertyIncludeResult result);
+        void onResult(PropertyIncludeResult result) throws CommitFailedException;
     }
 
     public static class NodeIncludeResult {
@@ -506,7 +508,8 @@ class Aggregate {
                     null, currentPath));
         }
 
-        public void collectResults(ResultCollector results) {
+        public void collectResults(ResultCollector results)
+                throws CommitFailedException {
             checkArgument(status == Status.MATCH_FOUND);
 
             //If result being collected as part of reaggregation then take path

Modified: jackrabbit/oak/branches/1.0/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexEditor.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.0/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexEditor.java?rev=1689576&r1=1689575&r2=1689576&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.0/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexEditor.java (original)
+++ jackrabbit/oak/branches/1.0/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexEditor.java Tue Jul  7 05:47:45 2015
@@ -292,12 +292,13 @@ public class LuceneIndexEditor implement
             throw new CommitFailedException("Lucene", 3,
                     "Failed to index the node " + path, e);
         } catch (IllegalArgumentException ie) {
-            log.warn("Failed to index the node [{}]", path, ie);
+            throw new CommitFailedException("Lucene", 3,
+                "Failed to index the node " + path, ie);
         }
         return false;
     }
 
-    private Document makeDocument(String path, NodeState state, boolean isUpdate) {
+    private Document makeDocument(String path, NodeState state, boolean isUpdate) throws CommitFailedException {
         if (!isIndexable()) {
             return null;
         }
@@ -379,7 +380,7 @@ public class LuceneIndexEditor implement
                                   NodeState state,
                                   PropertyState property,
                                   String pname,
-                                  PropertyDefinition pd) {
+                                  PropertyDefinition pd) throws CommitFailedException {
         boolean includeTypeForFullText = indexingRule.includePropertyType(property.getType().tag());
         if (Type.BINARY.tag() == property.getType().tag()
                 && includeTypeForFullText) {
@@ -426,7 +427,7 @@ public class LuceneIndexEditor implement
         return pname;
     }
 
-    private boolean addTypedFields(List<Field> fields, PropertyState property, String pname) {
+    private boolean addTypedFields(List<Field> fields, PropertyState property, String pname) throws CommitFailedException {
         int tag = property.getType().tag();
         boolean fieldAdded = false;
         for (int i = 0; i < property.count(); i++) {
@@ -453,7 +454,7 @@ public class LuceneIndexEditor implement
     private boolean addTypedOrderedFields(List<Field> fields,
                                           PropertyState property,
                                           String pname,
-                                          PropertyDefinition pd) {
+                                          PropertyDefinition pd) throws CommitFailedException {
         // Ignore and warn if property multi-valued as not supported
         if (property.getType().isArray()) {
             log.warn(
@@ -617,11 +618,11 @@ public class LuceneIndexEditor implement
     }
 
     private boolean indexAggregates(final String path, final List<Field> fields,
-                                    final NodeState state) {
+                                    final NodeState state) throws CommitFailedException {
         final AtomicBoolean dirtyFlag = new AtomicBoolean();
         indexingRule.getAggregate().collectAggregates(state, new Aggregate.ResultCollector() {
             @Override
-            public void onResult(Aggregate.NodeIncludeResult result) {
+            public void onResult(Aggregate.NodeIncludeResult result) throws CommitFailedException {
                 boolean dirty = indexAggregatedNode(path, fields, result);
                 if (dirty) {
                     dirtyFlag.set(true);
@@ -629,7 +630,7 @@ public class LuceneIndexEditor implement
             }
 
             @Override
-            public void onResult(Aggregate.PropertyIncludeResult result) {
+            public void onResult(Aggregate.PropertyIncludeResult result) throws CommitFailedException {
                 boolean dirty = false;
                 if (result.pd.ordered) {
                     dirty |= addTypedOrderedFields(fields, result.propertyState,
@@ -653,8 +654,10 @@ public class LuceneIndexEditor implement
      * @param fields indexed fields
      * @param result aggregate result
      * @return true if a field was created for passed node result
+     * @throws CommitFailedException
      */
-    private boolean indexAggregatedNode(String path, List<Field> fields, Aggregate.NodeIncludeResult result) {
+    private boolean indexAggregatedNode(String path, List<Field> fields, Aggregate.NodeIncludeResult result)
+            throws CommitFailedException {
         //rule for node being aggregated might be null if such nodes
         //are not indexed on there own. In such cases we rely in current
         //rule for some checks

Modified: jackrabbit/oak/branches/1.0/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/AggregateTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.0/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/AggregateTest.java?rev=1689576&r1=1689575&r2=1689576&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.0/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/AggregateTest.java (original)
+++ jackrabbit/oak/branches/1.0/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/AggregateTest.java Tue Jul  7 05:47:45 2015
@@ -386,12 +386,12 @@ public class AggregateTest {
         final ListMultimap<String, NodeIncludeResult> nodeResults = ArrayListMultimap.create();
         final Map<String, PropertyIncludeResult> propResults = newHashMap();
         @Override
-        public void onResult(NodeIncludeResult result) {
+        public void onResult(NodeIncludeResult result) throws CommitFailedException{
             nodeResults.put(result.nodePath, result);
         }
 
         @Override
-        public void onResult(PropertyIncludeResult result) {
+        public void onResult(PropertyIncludeResult result) throws CommitFailedException {
             propResults.put(result.propertyPath, result);
 
         }