jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r1466037 - /jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/prototype/MongoMK.java
Date Tue, 09 Apr 2013 14:04:00 GMT
Author: mreutegg
Date: Tue Apr  9 14:04:00 2013
New Revision: 1466037

URL: http://svn.apache.org/r1466037
Log:
OAK-619 Lock-free MongoMK implementation
- make sure background write does not interfere with regular commits
- introduce feature flag for background operations 

Modified:
    jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/prototype/MongoMK.java

Modified: jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/prototype/MongoMK.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/prototype/MongoMK.java?rev=1466037&r1=1466036&r2=1466037&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/prototype/MongoMK.java
(original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/prototype/MongoMK.java
Tue Apr  9 14:04:00 2013
@@ -78,6 +78,11 @@ public class MongoMK implements MicroKer
      * When trying to access revisions that are older than this many milliseconds, a warning
is logged.
      */
     private static final int WARN_REVISION_AGE = Integer.getInteger("oak.mongoMK.revisionAge",
10000);
+
+    /**
+     * Enable background operations
+     */
+    private static final boolean ENABLE_BACKGROUND_OPS = Boolean.getBoolean("oak.mongoMK.backgroundOps");
     
     /**
      * The delay for asynchronous operations (delayed commit propagation and
@@ -261,14 +266,16 @@ public class MongoMK implements MicroKer
             // only when using timestamp
             return;
         }
-        try {
-            // backgroundWrite();
-            // backgroundRead();
-        } catch (RuntimeException e) {
-            if (isDisposed.get()) {
-                return;
+        synchronized (this) {
+            try {
+                backgroundWrite();
+                backgroundRead();
+            } catch (RuntimeException e) {
+                if (isDisposed.get()) {
+                    return;
+                }
+                LOG.warn("Background operation failed: " + e.toString(), e);
             }
-            LOG.warn("Background operation failed: " + e.toString(), e);
         }
     }
     
@@ -323,9 +330,13 @@ public class MongoMK implements MicroKer
             if (r == null) {
                 continue;
             }
-            if (Revision.getTimestampDifference(now, r.getTimestamp()) < asyncDelay) {
-                continue;
-            }
+            // FIXME: with below code fragment the root (and other nodes
+            // 'close' to the root will not be updated in MongoDB when there
+            // are frequent changes. Uncommenting the lines below also
+            // leads to test failures because reads seem to become inconsistent
+//            if (Revision.getTimestampDifference(now, r.getTimestamp()) < asyncDelay)
{
+//                continue;
+//            }
             
             Commit commit = new Commit(this, null, r);
             commit.touchNode(p);
@@ -1235,7 +1246,7 @@ public class MongoMK implements MicroKer
                     }
                 }
                 MongoMK mk = ref.get();
-                if (mk != null) {
+                if (mk != null && ENABLE_BACKGROUND_OPS) {
                     mk.runBackgroundOperations();
                     delay = mk.getAsyncDelay();
                 }



Mime
View raw message