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 al...@apache.org on 2014/06/16 16:18:44 UTC
svn commit: r1602872 - in /jackrabbit/oak/trunk/oak-core/src:
main/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdate.java
test/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdateTest.java
Author: alexparvulescu
Date: Mon Jun 16 14:18:43 2014
New Revision: 1602872
URL: http://svn.apache.org/r1602872
Log:
OAK-1877 Hourly async reindexing on an idle instance
- fixed the problem where the reference to the latest cp would not get updated
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdate.java
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdateTest.java
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdate.java?rev=1602872&r1=1602871&r2=1602872&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdate.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdate.java Mon Jun 16 14:18:43 2014
@@ -62,7 +62,7 @@ public class AsyncIndexUpdate implements
* Name of the hidden node under which information about the checkpoints
* seen and indexed by each async indexer is kept.
*/
- private static final String ASYNC = ":async";
+ static final String ASYNC = ":async";
private static final long DEFAULT_LIFETIME = TimeUnit.DAYS.toMillis(1000);
@@ -275,11 +275,8 @@ public class AsyncIndexUpdate implements
throw exception;
}
+ builder.child(ASYNC).setProperty(name, afterCheckpoint);
if (callback.isDirty() || before == MISSING_NODE) {
- builder.child(ASYNC).setProperty(name, afterCheckpoint);
- mergeWithConcurrencyCheck(
- builder, beforeCheckpoint, callback.lease);
-
if (switchOnSync) {
reindexedDefinitions.addAll(
indexUpdate.getReindexedDefinitions());
@@ -301,11 +298,9 @@ public class AsyncIndexUpdate implements
c.removeProperty(ASYNC_PROPERTY_NAME);
}
}
-
- mergeWithConcurrencyCheck(
- builder, beforeCheckpoint, callback.lease);
reindexedDefinitions.clear();
}
+ mergeWithConcurrencyCheck(builder, beforeCheckpoint, callback.lease);
} finally {
callback.close();
}
Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdateTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdateTest.java?rev=1602872&r1=1602871&r2=1602872&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdateTest.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdateTest.java Mon Jun 16 14:18:43 2014
@@ -381,6 +381,8 @@ public class AsyncIndexUpdateTest {
Set<String> checkpoints = newHashSet(store.listCheckpoints());
assertTrue("Expecting the initial checkpoint",
checkpoints.size() == 1);
+ assertEquals(store.getRoot().getChildNode(AsyncIndexUpdate.ASYNC)
+ .getString("async"), checkpoints.iterator().next());
async.run();
assertEquals("Expecting no checkpoint changes",
@@ -418,6 +420,48 @@ public class AsyncIndexUpdateTest {
String secondCp = store.listCheckpoints().iterator().next();
assertFalse("Store should keep only second checkpoint",
secondCp.equals(firstCp));
+ assertEquals(
+ secondCp,
+ store.getRoot().getChildNode(AsyncIndexUpdate.ASYNC)
+ .getString("async"));
+ }
+
+ @Test
+ public void cpCleanupWUnrelatedChanges() throws Exception {
+ MemoryNodeStore store = new MemoryNodeStore();
+ IndexEditorProvider provider = new PropertyIndexEditorProvider();
+
+ NodeBuilder builder = store.getRoot().builder();
+ createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME),
+ "rootIndex", true, false, ImmutableSet.of("foo"), null)
+ .setProperty(ASYNC_PROPERTY_NAME, "async");
+ builder.child("testRoot").setProperty("foo", "abc");
+ store.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
+
+ assertTrue("Expecting no checkpoints",
+ store.listCheckpoints().size() == 0);
+
+ AsyncIndexUpdate async = new AsyncIndexUpdate("async", store, provider);
+ async.run();
+ assertTrue("Expecting one checkpoint",
+ store.listCheckpoints().size() == 1);
+ String firstCp = store.listCheckpoints().iterator().next();
+
+ // add content that's hidden from indexing
+ builder = store.getRoot().builder();
+ builder.child("testRoot").child(":hidden");
+ store.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
+ async.run();
+
+ assertTrue("Expecting one checkpoint",
+ store.listCheckpoints().size() == 1);
+ String secondCp = store.listCheckpoints().iterator().next();
+ assertFalse("Store should keep only second checkpoint",
+ secondCp.equals(firstCp));
+ assertEquals(
+ secondCp,
+ store.getRoot().getChildNode(AsyncIndexUpdate.ASYNC)
+ .getString("async"));
}
@Test