jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chet...@apache.org
Subject svn commit: r1502485 - in /jackrabbit/oak/trunk/oak-core/src: main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoMK.java test/java/org/apache/jackrabbit/oak/plugins/mongomk/SimpleTest.java
Date Fri, 12 Jul 2013 08:58:10 GMT
Author: chetanm
Date: Fri Jul 12 08:58:09 2013
New Revision: 1502485

URL: http://svn.apache.org/r1502485
Log:
OAK-619 Lock-free MongoMK implementation
- fix using of simple revisions. Setting moved to builder and used in constructor

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoMK.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/mongomk/SimpleTest.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoMK.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoMK.java?rev=1502485&r1=1502484&r2=1502485&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoMK.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoMK.java
Fri Jul 12 08:58:09 2013
@@ -189,7 +189,11 @@ public class MongoMK implements MicroKer
     private volatile Revision headRevision;
     
     private Thread backgroundThread;
-    
+
+    /**
+     * Enable using simple revisions (just a counter). This feature is useful
+     * for testing.
+     */
     private AtomicInteger simpleRevisionCounter;
     
     /**
@@ -207,6 +211,11 @@ public class MongoMK implements MicroKer
     private boolean stopBackground;
 
     MongoMK(Builder builder) {
+
+        if(builder.isUseSimpleRevision()){
+            this.simpleRevisionCounter = new AtomicInteger(0);
+        }
+
         DocumentStore s = builder.getDocumentStore();
         if (builder.getTiming()) {
             s = new TimingDocumentStoreWrapper(s);
@@ -273,15 +282,7 @@ public class MongoMK implements MicroKer
         backgroundThread.start();
     }
     
-    /**
-     * Enable using simple revisions (just a counter). This feature is useful
-     * for testing.
-     */
-    void useSimpleRevisions() {
-        this.simpleRevisionCounter = new AtomicInteger(1);
-        init();
-    }
-    
+
     /**
      * Create a new revision.
      * 
@@ -1669,6 +1670,7 @@ public class MongoMK implements MicroKer
         private long childrenCacheSize;
         private long diffCacheSize;
         private long documentCacheSize;
+        private boolean useSimpleRevision;
 
         public Builder() {
             memoryCacheSize(DEFAULT_MEMORY_CACHE_SIZE);
@@ -1804,6 +1806,15 @@ public class MongoMK implements MicroKer
             return diffCacheSize;
         }
 
+        public Builder setUseSimpleRevision(boolean useSimpleRevision){
+            this.useSimpleRevision = useSimpleRevision;
+            return this;
+        }
+
+        public boolean isUseSimpleRevision(){
+            return useSimpleRevision;
+        }
+
         /**
          * Open the MongoMK instance using the configured options.
          * 

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/mongomk/SimpleTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/mongomk/SimpleTest.java?rev=1502485&r1=1502484&r2=1502485&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/mongomk/SimpleTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/mongomk/SimpleTest.java
Fri Jul 12 08:58:09 2013
@@ -87,9 +87,8 @@ public class SimpleTest {
     
     @Test
     public void nodeIdentifier() {
-        MongoMK mk = createMK();
-        mk.useSimpleRevisions();
-        
+        MongoMK mk = createMK(true);
+
         String rev0 = mk.getHeadRevision();
         String rev1 = mk.commit("/", "+\"test\":{}", null, null);
         String rev2 = mk.commit("/test", "+\"a\":{}", null, null);
@@ -419,12 +418,20 @@ public class SimpleTest {
     }
 
     private static MongoMK createMK() {
+        return createMK(false);
+    }
+
+    private static MongoMK createMK(boolean useSimpleRevision) {
         MongoMK.Builder builder = new MongoMK.Builder();
+
         if (MONGO_DB) {
             DB db = MongoUtils.getConnection().getDB();
             MongoUtils.dropCollections(db);
             builder.setMongoDB(db);
         }
+
+        builder.setUseSimpleRevision(useSimpleRevision);
+
         return builder.open();
     }
 



Mime
View raw message