jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chet...@apache.org
Subject svn commit: r1594159 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document: NodeDocument.java PropertyHistory.java
Date Tue, 13 May 2014 09:16:17 GMT
Author: chetanm
Date: Tue May 13 09:16:17 2014
New Revision: 1594159

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

Refactor access to previous doc to find previous doc with maxAge set to max value so as to
enable reads of previous documents from secondaries

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/NodeDocument.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/PropertyHistory.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/NodeDocument.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/NodeDocument.java?rev=1594159&r1=1594158&r2=1594159&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/NodeDocument.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/NodeDocument.java
Tue May 13 09:16:17 2014
@@ -1065,7 +1065,7 @@ public final class NodeDocument extends 
             return Collections.emptyList();
         }
         if (revision == null) {
-            return new PropertyHistory(store, this, property);
+            return new PropertyHistory(this, property);
         } else {
             final String mainPath = getMainPath();
             // first try to lookup revision directly
@@ -1074,7 +1074,7 @@ public final class NodeDocument extends 
                 Revision r = entry.getKey();
                 int h = entry.getValue().height;
                 String prevId = Utils.getPreviousIdFor(mainPath, r, h);
-                NodeDocument prev = store.find(Collection.NODES, prevId);
+                NodeDocument prev = getPreviousDocument(prevId);
                 if (prev != null) {
                     if (prev.getValueMap(property).containsKey(revision)) {
                         return Collections.singleton(prev);
@@ -1103,6 +1103,12 @@ public final class NodeDocument extends 
         }
     }
 
+    NodeDocument getPreviousDocument(String prevId){
+        //Use the maxAge variant such that in case of Mongo call for
+        //previous doc are directed towards replicas first
+        return store.find(Collection.NODES, prevId, Integer.MAX_VALUE);
+    }
+
     @Nonnull
     Iterator<NodeDocument> getAllPreviousDocs() {
         if (getPreviousRanges().isEmpty()) {
@@ -1132,9 +1138,7 @@ public final class NodeDocument extends 
     private NodeDocument getPreviousDoc(Revision rev, Range range){
         int h = range.height;
         String prevId = Utils.getPreviousIdFor(getMainPath(), rev, h);
-        //TODO Use the maxAge variant such that in case of Mongo call for
-        //previous doc are directed towards replicas first
-        NodeDocument prev = store.find(Collection.NODES, prevId);
+        NodeDocument prev = getPreviousDocument(prevId);
         if (prev != null) {
             return prev;
         } else {

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/PropertyHistory.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/PropertyHistory.java?rev=1594159&r1=1594158&r2=1594159&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/PropertyHistory.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/PropertyHistory.java
Tue May 13 09:16:17 2014
@@ -45,16 +45,13 @@ class PropertyHistory implements Iterabl
 
     private static final Logger LOG = LoggerFactory.getLogger(PropertyHistory.class);
 
-    private final DocumentStore store;
     private final NodeDocument doc;
     private final String property;
     // path of the main document
     private final String mainPath;
 
-    public PropertyHistory(@Nonnull DocumentStore store,
-                           @Nonnull NodeDocument doc,
+    public PropertyHistory(@Nonnull NodeDocument doc,
                            @Nonnull String property) {
-        this.store = checkNotNull(store);
         this.doc = checkNotNull(doc);
         this.property = checkNotNull(property);
         this.mainPath = doc.getMainPath();
@@ -70,7 +67,7 @@ class PropertyHistory implements Iterabl
                 Revision r = input.getKey();
                 int h = input.getValue().height;
                 String prevId = Utils.getPreviousIdFor(mainPath, r, h);
-                NodeDocument prev = store.find(Collection.NODES, prevId);
+                NodeDocument prev = doc.getPreviousDocument(prevId);
                 if (prev == null) {
                     LOG.warn("Document with previous revisions not found: " + prevId);
                     return null;



Mime
View raw message