Author: chetanm
Date: Tue Jul 11 05:16:12 2017
New Revision: 1801560

URL: http://svn.apache.org/viewvc?rev=1801560&view=rev
Log:
OAK-6271 - Support for importing index files

Store a boolean property indicating that lane is locked for indexing

Modified:
    
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/importer/ClusterNodeStoreLock.java
    
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/importer/ClusterNodeStoreLockTest.java

Modified: 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/importer/ClusterNodeStoreLock.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/importer/ClusterNodeStoreLock.java?rev=1801560&r1=1801559&r2=1801560&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/importer/ClusterNodeStoreLock.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/importer/ClusterNodeStoreLock.java
 Tue Jul 11 05:16:12 2017
@@ -69,6 +69,7 @@ public class ClusterNodeStoreLock implem
 
         //TODO Attempt few times if merge failure due to current running 
indexer cycle
         async.setProperty(leaseName, leaseEndTime);
+        async.setProperty(lockName(asyncIndexerLane), true);
         NodeStoreUtils.mergeWithConcurrentCheck(nodeStore, builder);
 
         log.info("Acquired the lock for async indexer lane [{}]", 
asyncIndexerLane);
@@ -83,15 +84,20 @@ public class ClusterNodeStoreLock implem
         NodeBuilder builder = nodeStore.getRoot().builder();
         NodeBuilder async = builder.child(":async");
         async.removeProperty(leaseName);
+        async.removeProperty(lockName(token.laneName));
         NodeStoreUtils.mergeWithConcurrentCheck(nodeStore, builder);
         log.info("Remove the lock for async indexer lane [{}]", 
token.laneName);
     }
 
     public boolean isLocked(String asyncIndexerLane) {
         NodeState async = nodeStore.getRoot().getChildNode(":async");
-        String leaseName = AsyncIndexUpdate.leasify(asyncIndexerLane);
+        String leaseName = lockName(asyncIndexerLane);
         return async.hasProperty(leaseName);
     }
+
+    private static String lockName(String asyncIndexerLane) {
+        return asyncIndexerLane + "-lock";
+    }
 }
 
 class ClusteredLockToken implements AsyncIndexerLock.LockToken {

Modified: 
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/importer/ClusterNodeStoreLockTest.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/importer/ClusterNodeStoreLockTest.java?rev=1801560&r1=1801559&r2=1801560&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/importer/ClusterNodeStoreLockTest.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/importer/ClusterNodeStoreLockTest.java
 Tue Jul 11 05:16:12 2017
@@ -68,6 +68,7 @@ public class ClusterNodeStoreLockTest {
 
         lock.unlock(token);
         assertFalse(getAsync().hasProperty(AsyncIndexUpdate.leasify(name)));
+        assertFalse(lock.isLocked(name));
     }
 
     private NodeState getAsync() {


Reply via email to