jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chet...@apache.org
Subject svn commit: r1594164 - in /jackrabbit/oak/trunk/oak-core/src: main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDocumentStore.java test/java/org/apache/jackrabbit/oak/plugins/document/mongo/ReadPreferenceIT.java
Date Tue, 13 May 2014 09:18:21 GMT
Author: chetanm
Date: Tue May 13 09:18:20 2014
New Revision: 1594164

URL: http://svn.apache.org/r1594164
Log:
OAK-1645 - Route find queries to Mongo secondary in MongoDocumentStore

Do not use the clock from builder for now as it causes other testcases to fail as some aspects
of code still use System.currenttime.

Instead one can specify custom clock directly for testing purpose. This localizes clock change
for testing

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDocumentStore.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/ReadPreferenceIT.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDocumentStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDocumentStore.java?rev=1594164&r1=1594163&r2=1594164&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDocumentStore.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDocumentStore.java
Tue May 13 09:18:20 2014
@@ -121,7 +121,7 @@ public class MongoDocumentStore implemen
      */
     private final Comparator<Revision> comparator = StableRevisionComparator.REVERSE;
 
-    private final Clock clock;
+    private Clock clock = Clock.SIMPLE;
 
     private final DB db;
 
@@ -138,7 +138,6 @@ public class MongoDocumentStore implemen
         settings = db.getCollection(
                 Collection.SETTINGS.toString());
 
-        clock = builder.getClock();
         maxReplicationLagMillis = builder.getMaxReplicationLagMillis();
 
         // indexes:
@@ -1046,4 +1045,8 @@ public class MongoDocumentStore implemen
     private long getTime() {
         return clock.getTime();
     }
+
+    void setClock(Clock clock) {
+        this.clock = clock;
+    }
 }
\ No newline at end of file

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/ReadPreferenceIT.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/ReadPreferenceIT.java?rev=1594164&r1=1594163&r2=1594164&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/ReadPreferenceIT.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/ReadPreferenceIT.java
Tue May 13 09:18:20 2014
@@ -66,8 +66,7 @@ public class ReadPreferenceIT {
         replicationLag = TimeUnit.SECONDS.toMillis(10);
         MongoConnection mc = MongoUtils.getConnection();
         documentNodeStore = new DocumentMK.Builder()
-                .clock(clock)
-                .setMaxReplicationLag(replicationLag, TimeUnit.HOURS)
+                .setMaxReplicationLag(replicationLag, TimeUnit.MILLISECONDS)
                 .setMongoDB(mc.getDB())
                 .setClusterId(1)
                 .getNodeStore();
@@ -144,6 +143,7 @@ public class ReadPreferenceIT {
 
         //Going into future to make parent /x old enough
         clock.waitUntil(Revision.getCurrentTimestamp() + replicationLag);
+        mongoDS.setClock(clock);
 
         //For old modified nodes secondaries should be preferred
         assertEquals(testPref,



Mime
View raw message