jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1482750 - in /jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk: Commit.java MongoMK.java
Date Wed, 15 May 2013 10:29:41 GMT
Author: thomasm
Date: Wed May 15 10:29:41 2013
New Revision: 1482750

URL: http://svn.apache.org/r1482750
Log:
OAK-619 MongoMK: improved logging and exception messages

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

Modified: jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/Commit.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/Commit.java?rev=1482750&r1=1482749&r2=1482750&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/Commit.java
(original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/Commit.java
Wed May 15 10:29:41 2013
@@ -275,28 +275,30 @@ public class Commit {
                     collisions.get().add(uncommitted);
                 }
             });
-            MicroKernelException conflict = null;
+            String conflictMessage = null;
             if (newestRev == null) {
                 if (op.isDelete || !op.isNew) {
-                    conflict = new MicroKernelException("The node " + 
-                            op.path + " does not exist or is already deleted " + 
-                            "before " + revision + "; document " + map);
+                    conflictMessage = "The node " + 
+                            op.path + " does not exist or is already deleted";
                 }
             } else {
                 if (op.isNew) {
-                    conflict = new MicroKernelException("The node " + 
-                            op.path + " was already added in revision " + 
-                            newestRev + "; before " + revision + "; document " + map);
+                    conflictMessage = "The node " + 
+                            op.path + " was already added in revision\n" + 
+                            newestRev;
                 } else if (mk.isRevisionNewer(newestRev, baseRevision)
                         && (op.isDelete || isConflicting(map, op))) {
-                    conflict = new MicroKernelException("The node " + 
-                            op.path + " was changed in revision " + newestRev +
-                            ", which was applied after the base revision " + 
-                            baseRevision + "; before " + revision + "; document " + map);
+                    conflictMessage = "The node " + 
+                            op.path + " was changed in revision\n" + newestRev +
+                            ", which was applied after the base revision\n" + 
+                            baseRevision;
                 }
             }
-            if (conflict != null) {
-                throw conflict;
+            if (conflictMessage != null) {
+                conflictMessage += ", before\n" + revision + 
+                        "; document:\n" + map.toString().replaceAll(", _", ",\n_").replaceAll("},
", "},\n") + 
+                        ",\nrevision order:\n" + mk.getRevisionComparator();
+                throw new MicroKernelException(conflictMessage);
             }
             // if we get here the modification was successful
             // -> check for collisions and conflict (concurrent updates

Modified: jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/MongoMK.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/MongoMK.java?rev=1482750&r1=1482749&r2=1482750&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/MongoMK.java
(original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/MongoMK.java
Wed May 15 10:29:41 2013
@@ -169,6 +169,11 @@ public class MongoMK implements MicroKer
     private Thread backgroundThread;
     
     private AtomicInteger simpleRevisionCounter;
+    
+    /**
+     * The comparator for revisions.
+     */
+    private final RevisionComparator revisionComparator;
 
     /**
      * Unmerged branches of this MongoMK instance.
@@ -177,11 +182,6 @@ public class MongoMK implements MicroKer
     // need to be garbage collected (in-memory and on disk)
     private final UnmergedBranches branches = new UnmergedBranches();
 
-    /**
-     * The comparator for revisions.
-     */
-    private final RevisionComparator revisionComparator;
-    
     private boolean stopBackground;
     
     MongoMK(Builder builder) {
@@ -416,11 +416,11 @@ public class MongoMK implements MicroKer
     }
     
     private void checkRevisionAge(Revision r, String path) {
-        if (headRevision.getTimestamp() - r.getTimestamp() > WARN_REVISION_AGE) {
-            LOG.warn("Requesting an old revision for path " + path + ", " + 
+        // TODO only log if there are new revisions available for the given node
+        if (LOG.isDebugEnabled()) {
+            if (headRevision.getTimestamp() - r.getTimestamp() > WARN_REVISION_AGE) {
+                LOG.debug("Requesting an old revision for path " + path + ", " + 
                     ((headRevision.getTimestamp() - r.getTimestamp()) / 1000) + " seconds
old");
-            if (LOG.isDebugEnabled()) {
-                LOG.warn("Requesting an old revision", new Exception());
             }
         }
     }
@@ -1513,8 +1513,13 @@ public class MongoMK implements MicroKer
     public boolean isCached(String path) {
         return store.isCached(Collection.NODES, Utils.getIdFromPath(path));
     }
+    
     public void stopBackground() {
         stopBackground = true;
     }
+    
+    RevisionComparator getRevisionComparator() {
+        return revisionComparator;
+    }
 
 }



Mime
View raw message