Author: catholicon
Date: Tue Sep 12 18:58:35 2017
New Revision: 1808142
URL: http://svn.apache.org/viewvc?rev=1808142&view=rev
Log:
OAK-6656: OrderedPropertyIndexEditorProvider does not return Editor to
IndexUpdate leading to "ordered" being marked as missing type
Treat type="ordered" similar to disabled "disabled". Also, warn message from
Index provider would have index path which has type="ordered".
Also, fix tests along with making hit count non-static (as that made test
execution depend on each other)
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexUpdate.java
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/OrderedIndex.java
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/OrderedPropertyIndexEditorProvider.java
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/OrderedPropertyIndexEditorProviderTest.java
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexUpdate.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexUpdate.java?rev=1808142&r1=1808141&r2=1808142&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexUpdate.java
(original)
+++
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexUpdate.java
Tue Sep 12 18:58:35 2017
@@ -472,7 +472,7 @@ public class IndexUpdate implements Edit
private boolean failOnMissingIndexProvider = Boolean
.getBoolean("oak.indexUpdate.failOnMissingIndexProvider");
- private final Set<String> ignore = newHashSet("disabled");
+ private final Set<String> ignore = newHashSet("disabled", "ordered");
public void onMissingIndex(String type, NodeBuilder definition, String
indexPath)
throws CommitFailedException {
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/OrderedIndex.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/OrderedIndex.java?rev=1808142&r1=1808141&r2=1808142&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/OrderedIndex.java
(original)
+++
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/OrderedIndex.java
Tue Sep 12 18:58:35 2017
@@ -31,12 +31,11 @@ public interface OrderedIndex {
/**
* Deprecation message tracked when using the ordered index.
*/
- String DEPRECATION_MESSAGE =
+ String DEPRECATION_MESSAGE =
"Ordered Index has been deprecated since Oak 1.1.8. " +
- "Please replace the index definitions with Lucene Property index " +
- "and remove the index providers from the repository. " +
+ "Please replace the index definition ({}) with Lucene Property index "
+
+ "and remove the index providers from the repository. " +
"See docs at http://jackrabbit.apache.org/oak/docs";
-
/**
* the deprecation message will be tracked every N times
*/
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/OrderedPropertyIndexEditorProvider.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/OrderedPropertyIndexEditorProvider.java?rev=1808142&r1=1808141&r2=1808142&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/OrderedPropertyIndexEditorProvider.java
(original)
+++
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/OrderedPropertyIndexEditorProvider.java
Tue Sep 12 18:58:35 2017
@@ -23,6 +23,7 @@ import javax.annotation.Nonnull;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Service;
import org.apache.jackrabbit.oak.api.CommitFailedException;
+import org.apache.jackrabbit.oak.plugins.index.ContextAwareCallback;
import org.apache.jackrabbit.oak.plugins.index.IndexEditorProvider;
import org.apache.jackrabbit.oak.plugins.index.IndexUpdateCallback;
import org.apache.jackrabbit.oak.spi.commit.Editor;
@@ -35,7 +36,7 @@ import org.slf4j.LoggerFactory;
@Service(IndexEditorProvider.class)
public class OrderedPropertyIndexEditorProvider implements
IndexEditorProvider, OrderedIndex {
private static final Logger LOG =
LoggerFactory.getLogger(OrderedPropertyIndexEditorProvider.class);
- private static int hits;
+ private int hits;
private static int threshold = OrderedIndex.TRACK_DEPRECATION_EVERY;
@Override
@@ -46,11 +47,15 @@ public class OrderedPropertyIndexEditorP
@Nonnull IndexUpdateCallback callback) throws
CommitFailedException {
if (OrderedIndex.TYPE.equals(type)) {
if (hit() % threshold == 0) {
- LOG.warn(OrderedIndex.DEPRECATION_MESSAGE);
+ if (callback instanceof ContextAwareCallback) {
+ LOG.warn(DEPRECATION_MESSAGE,
((ContextAwareCallback)callback).getIndexingContext().getIndexPath());
+ } else {
+ LOG.warn(OrderedIndex.DEPRECATION_MESSAGE, definition);
+ }
}
}
return null;
- }
+ }
private synchronized int hit() {
return hits++;
Modified:
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/OrderedPropertyIndexEditorProviderTest.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/OrderedPropertyIndexEditorProviderTest.java?rev=1808142&r1=1808141&r2=1808142&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/OrderedPropertyIndexEditorProviderTest.java
(original)
+++
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/OrderedPropertyIndexEditorProviderTest.java
Tue Sep 12 18:58:35 2017
@@ -18,6 +18,7 @@ package org.apache.jackrabbit.oak.plugin
import static
org.apache.jackrabbit.oak.plugins.index.IndexConstants.INDEX_CONTENT_NODE_NAME;
import static
org.apache.jackrabbit.oak.plugins.index.IndexConstants.INDEX_DEFINITIONS_NAME;
+import static
org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE;
import static org.hamcrest.CoreMatchers.hasItem;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
@@ -36,15 +37,12 @@ import org.apache.jackrabbit.oak.commons
import org.apache.jackrabbit.oak.plugins.index.IndexConstants;
import org.apache.jackrabbit.oak.plugins.index.IndexUpdateProvider;
import org.apache.jackrabbit.oak.plugins.index.IndexUtils;
-import org.apache.jackrabbit.oak.InitialContent;
-import org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState;
import org.apache.jackrabbit.oak.plugins.tree.TreeFactory;
import org.apache.jackrabbit.oak.spi.commit.CommitHook;
import org.apache.jackrabbit.oak.spi.commit.CommitInfo;
import org.apache.jackrabbit.oak.spi.commit.EditorHook;
import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
import org.apache.jackrabbit.oak.spi.state.NodeState;
-import org.junit.Ignore;
import org.junit.Test;
import ch.qos.logback.classic.Level;
@@ -57,6 +55,9 @@ public class OrderedPropertyIndexEditorP
private final String indexName = "mickey";
private final String indexedProperty = "mouse";
+
+ private final String DEPRECATION_MESSAGE =
OrderedIndex.DEPRECATION_MESSAGE.replace("{}",
+ "/" + INDEX_DEFINITIONS_NAME + "/" + indexName);
private Tree createIndexDef(NodeBuilder root) throws RepositoryException {
return IndexUtils
@@ -68,7 +69,7 @@ public class OrderedPropertyIndexEditorP
@Test
public void withIndexDefSingleNode() throws RepositoryException,
CommitFailedException {
- NodeBuilder root = InitialContent.INITIAL_CONTENT.builder();
+ NodeBuilder root = EMPTY_NODE.builder();
createIndexDef(root);
@@ -79,7 +80,7 @@ public class OrderedPropertyIndexEditorP
custom.starting();
root = hook.processCommit(before, after, CommitInfo.EMPTY).builder();
assertEquals(1, custom.getLogs().size());
- assertThat(custom.getLogs(),
hasItem(OrderedIndex.DEPRECATION_MESSAGE));
+ assertThat(custom.getLogs(), hasItem(DEPRECATION_MESSAGE));
custom.finished();
NodeBuilder b =
root.getChildNode(IndexConstants.INDEX_DEFINITIONS_NODE_TYPE)
@@ -91,10 +92,10 @@ public class OrderedPropertyIndexEditorP
public void withIndexMultipleNodes() throws RepositoryException,
CommitFailedException {
final int threshold = 5;
final int nodes = 16;
- final int traces = nodes / threshold;
+ final int traces = 1 + (nodes - 1) / threshold;
OrderedPropertyIndexEditorProvider.setThreshold(threshold);
- final List<String> expected = Collections.nCopies(traces,
OrderedIndex.DEPRECATION_MESSAGE);
- NodeBuilder root = InitialContent.INITIAL_CONTENT.builder();
+ final List<String> expected = Collections.nCopies(traces,
DEPRECATION_MESSAGE);
+ NodeBuilder root = EMPTY_NODE.builder();
createIndexDef(root);
custom.starting();
@@ -111,13 +112,12 @@ public class OrderedPropertyIndexEditorP
.getChildNode(INDEX_CONTENT_NODE_NAME).exists());
}
- @Ignore("OAK-6656")
@Test
public void providerShouldBeAvailable() throws Exception {
CommitHook hook = new EditorHook(new IndexUpdateProvider(
new OrderedPropertyIndexEditorProvider(), null, true));
- NodeBuilder root = EmptyNodeState.EMPTY_NODE.builder();
+ NodeBuilder root = EMPTY_NODE.builder();
createIndexDef(root).setProperty("reindex", false);