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 2014/06/11 07:57:22 UTC
svn commit: r1601814 - in /jackrabbit/oak/trunk/oak-core/src:
main/java/org/apache/jackrabbit/oak/plugins/document/MissingLastRevSeeker.java
test/java/org/apache/jackrabbit/oak/plugins/document/LastRevRecoveryAgentTest.java
Author: chetanm
Date: Wed Jun 11 05:57:22 2014
New Revision: 1601814
URL: http://svn.apache.org/r1601814
Log:
OAK-1883 - Unnecessary invocations of LastRevRecovery when recovery already done.
Applied the patch from Amit Jain. Thanks!
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/MissingLastRevSeeker.java
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/LastRevRecoveryAgentTest.java
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/MissingLastRevSeeker.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/MissingLastRevSeeker.java?rev=1601814&r1=1601813&r2=1601814&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/MissingLastRevSeeker.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/MissingLastRevSeeker.java Wed Jun 11 05:57:22 2014
@@ -94,6 +94,7 @@ public class MissingLastRevSeeker {
public void releaseRecoveryLock(int clusterId){
UpdateOp update = new UpdateOp(Integer.toString(clusterId), true);
update.set(ClusterNodeInfo.REV_RECOVERY_LOCK, null);
+ update.set(ClusterNodeInfo.STATE, null);
store.createOrUpdate(Collection.CLUSTER_NODES, update);
}
Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/LastRevRecoveryAgentTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/LastRevRecoveryAgentTest.java?rev=1601814&r1=1601813&r2=1601814&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/LastRevRecoveryAgentTest.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/LastRevRecoveryAgentTest.java Wed Jun 11 05:57:22 2014
@@ -35,6 +35,7 @@ import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@RunWith(Parameterized.class)
@@ -140,6 +141,37 @@ public class LastRevRecoveryAgentTest {
assertEquals(zlastRev2, getDocument(ds1, "/").getLastRev().get(c2Id));
}
+ @Test
+ public void testRepeatedRecovery() throws Exception {
+ //1. Create base structure /x/y
+ NodeBuilder b1 = ds1.getRoot().builder();
+ b1.child("x").child("y");
+ ds1.merge(b1, EmptyHook.INSTANCE, CommitInfo.EMPTY);
+ ds1.runBackgroundOperations();
+
+ ds2.runBackgroundOperations();
+
+ //2. Add a new node /x/y/z in C2
+ NodeBuilder b2 = ds2.getRoot().builder();
+ b2.child("x").child("y").child("z").setProperty("foo", "bar");
+ ds2.merge(b2, EmptyHook.INSTANCE, CommitInfo.EMPTY);
+
+ NodeDocument z1 = getDocument(ds1, "/x/y/z");
+ Revision zlastRev2 = z1.getLastRev().get(c2Id);
+
+ long leaseTime = ds1.getClusterInfo().getLeaseTime();
+ ds1.runBackgroundOperations();
+
+ clock.waitUntil(clock.getTime() + leaseTime + 10);
+
+ //Renew the lease for C1
+ ds1.getClusterInfo().renewLease();
+
+ assertTrue(ds1.getLastRevRecoveryAgent().isRecoveryNeeded());
+ ds1.getLastRevRecoveryAgent().performRecoveryIfNeeded();
+ assertFalse(ds1.getLastRevRecoveryAgent().isRecoveryNeeded());
+ }
+
private NodeDocument getDocument(DocumentNodeStore nodeStore, String path) {
return nodeStore.getDocumentStore().find(Collection.NODES, Utils.getIdFromPath(path));
}