jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1470512 - in /jackrabbit/oak/trunk/oak-mongomk/src: main/java/org/apache/jackrabbit/mongomk/ test/java/org/apache/jackrabbit/mongomk/ test/java/org/apache/jackrabbit/mongomk/impl/
Date Mon, 22 Apr 2013 13:51:41 GMT
Author: thomasm
Date: Mon Apr 22 13:51:41 2013
New Revision: 1470512

URL: http://svn.apache.org/r1470512
Log:
OAK-780 Revision.fromString() only parses two counter digits - changed revision id format

Modified:
    jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/LoggingDocumentStoreWrapper.java
    jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/MongoMK.java
    jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/Revision.java
    jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/RandomizedClusterTest.java
    jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/SimpleTest.java
    jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/impl/MongoMKWaitForCommitTest.java

Modified: jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/LoggingDocumentStoreWrapper.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/LoggingDocumentStoreWrapper.java?rev=1470512&r1=1470511&r2=1470512&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/LoggingDocumentStoreWrapper.java
(original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/LoggingDocumentStoreWrapper.java
Mon Apr 22 13:51:41 2013
@@ -149,7 +149,7 @@ public class LoggingDocumentStoreWrapper
         }
     }
 
-    private void logMethod(String methodName, Object... args) {
+    private static void logMethod(String methodName, Object... args) {
         StringBuilder buff = new StringBuilder("ds");
         buff.append('.').append(methodName).append('(');
         for (int i = 0; i < args.length; i++) {

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=1470512&r1=1470511&r2=1470512&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
Mon Apr 22 13:51:41 2013
@@ -276,7 +276,7 @@ public class MongoMK implements MicroKer
         clusterNodeInfo.renewLease(asyncDelay);
     }
     
-    private void backgroundRead() {
+    void backgroundRead() {
         String id = Utils.getIdFromPath("/");
         Map<String, Object> map = store.find(DocumentStore.Collection.NODES, id, asyncDelay);
         @SuppressWarnings("unchecked")
@@ -302,7 +302,7 @@ public class MongoMK implements MicroKer
         }
     }
     
-    private void backgroundWrite() {
+    void backgroundWrite() {
         if (unsavedLastRevisions.size() == 0) {
             return;
         }
@@ -1047,6 +1047,7 @@ public class MongoMK implements MicroKer
      * @param onlyCommitted whether only committed changes should be considered
      * @return the revision, or null if deleted
      */
+    @SuppressWarnings("unchecked")
     @Nullable Revision getNewestRevision(Map<String, Object> nodeMap,
                                          Revision before, boolean onlyCommitted) {
         if (nodeMap == null) {
@@ -1054,10 +1055,8 @@ public class MongoMK implements MicroKer
         }
         Map<String, String> revisions = Maps.newHashMap();
         if (nodeMap.containsKey(UpdateOp.REVISIONS)) {
-            //noinspection unchecked
             revisions.putAll((Map<String, String>) nodeMap.get(UpdateOp.REVISIONS));
         }
-        @SuppressWarnings("unchecked")
         Map<String, String> deletedMap = (Map<String, String>) nodeMap
                 .get(UpdateOp.DELETED);
         if (deletedMap != null) {

Modified: jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/Revision.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/Revision.java?rev=1470512&r1=1470511&r2=1470512&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/Revision.java
(original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/Revision.java
Mon Apr 22 13:51:41 2013
@@ -113,27 +113,32 @@ public class Revision {
         if (!rev.startsWith("r")) {
             throw new IllegalArgumentException(rev);
         }
-        String t = rev.substring(1, 8);
-        long timestamp = Long.parseLong(t, 16);
-        int idx = rev.indexOf('-');
-        int c = 0;
-        if (idx > 8) {
-            t = rev.substring(8, 11);
-            c = Integer.parseInt(t, 16);
+        int idxCount = rev.indexOf('-');
+        if (idxCount < 0) {
+            throw new IllegalArgumentException(rev);
         }
-        t = rev.substring(idx + 1);
+        int idxClusterId = rev.indexOf('-', idxCount + 1);
+        if (idxClusterId < 0) {
+            throw new IllegalArgumentException(rev);
+        }
+        String t = rev.substring(1, idxCount);
+        long timestamp = Long.parseLong(t, 16);
+        t = rev.substring(idxCount + 1, idxClusterId);
+        int c = Integer.parseInt(t, 16);
+        t = rev.substring(idxClusterId + 1);
         int clusterId = Integer.parseInt(t, 16);
         Revision r = new Revision(timestamp, c, clusterId);
         return r;
     }
     
     public String toString() {
-        StringBuilder buff = new StringBuilder("r");
-        buff.append(Long.toHexString(0x10000000L + timestamp).substring(1));
-        buff.append(Integer.toHexString(0x1000 + counter).substring(1));
-        buff.append('-');
-        buff.append(Integer.toHexString(clusterId));
-        return buff.toString();
+        return new StringBuilder("r").
+                append(Long.toHexString(timestamp)).
+                append('-').
+                append(Integer.toHexString(counter)).
+                append('-').
+                append(Integer.toHexString(clusterId)).
+                toString();
     }
     
     public long getTimestamp() {

Modified: jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/RandomizedClusterTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/RandomizedClusterTest.java?rev=1470512&r1=1470511&r2=1470512&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/RandomizedClusterTest.java
(original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/RandomizedClusterTest.java
Mon Apr 22 13:51:41 2013
@@ -136,9 +136,10 @@ public class RandomizedClusterTest {
                 } else {
                     maskFail |= 1 << op;
                 }
-int todo;                
-//                get(node);
-//                get(node2);
+                log("get " + node);
+                get(node);
+                log("get " + node2);
+                get(node2);
                 MongoMK mk = mkList[mkId];
                 MicroKernelImpl mkGold = mkListGold[mkId];
                 ClusterRev cr = new ClusterRev();
@@ -150,8 +151,7 @@ int todo;                
                 int revId = i - r.nextInt(maxBackRev);
                 cr = revs.get(revId);
                 if (cr != null) {
-int todo2;                
-//                    get(node, cr.revGold, cr.rev);
+                    get(node, cr.revGold, cr.rev);
                 }
             }
             if (Integer.bitCount(maskOk) != opCount) {
@@ -180,7 +180,13 @@ int todo2;                
     
     private void get(String node) {
         String headGold = mkListGold[mkId].getHeadRevision();
-        String head = mkList[mkId].getHeadRevision();
+        for (int i = 0; i < mkList.length; i++) {
+            MongoMK mk = mkList[i];
+            mk.backgroundWrite();
+        }
+        MongoMK mk = mkList[mkId];
+        mk.backgroundRead();
+        String head = mk.getHeadRevision();
         get(node, headGold, head);
     }
         
@@ -192,7 +198,9 @@ int todo2;                
             assertFalse(mk.nodeExists(p, head));
             return;
         }
-        assertTrue("path: " + p, mk.nodeExists(p, head));
+        if (!mk.nodeExists(p, head)) {
+            assertTrue("path: " + p, mk.nodeExists(p, head));
+        }
         String resultGold = mkGold.getNodes(p, headGold, 0, 0, Integer.MAX_VALUE, null);
         String result = mk.getNodes(p, head, 0, 0, Integer.MAX_VALUE, null);
         resultGold = normalize(resultGold);
@@ -248,7 +256,7 @@ int todo2;                
             }
             builder.setDocumentStore(ds).setBlobStore(bs);
         }
-        return builder.setClusterId(clusterId).open();
+        return builder.setClusterId(clusterId + 1).open();
     }
     
     /**

Modified: jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/SimpleTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/SimpleTest.java?rev=1470512&r1=1470511&r2=1470512&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/SimpleTest.java
(original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/SimpleTest.java
Mon Apr 22 13:51:41 2013
@@ -108,25 +108,25 @@ public class SimpleTest {
         String rev4 = mk.commit("/test", "^\"a/x\":1", null, null);
         
         String r0 = mk.getNodes("/", rev0, 0, 0, Integer.MAX_VALUE, ":id");
-        assertEquals("{\":id\":\"/@r0000001000-1\",\":childNodeCount\":0}", r0);
+        assertEquals("{\":id\":\"/@r1-0-1\",\":childNodeCount\":0}", r0);
         String r1 = mk.getNodes("/", rev1, 0, 0, Integer.MAX_VALUE, ":id");
-        assertEquals("{\":id\":\"/@r0000002000-1\",\"test\":{},\":childNodeCount\":1}", r1);
+        assertEquals("{\":id\":\"/@r2-0-1\",\"test\":{},\":childNodeCount\":1}", r1);
         String r2 = mk.getNodes("/", rev2, 0, 0, Integer.MAX_VALUE, ":id");
-        assertEquals("{\":id\":\"/@r0000003000-1\",\"test\":{},\":childNodeCount\":1}", r2);
+        assertEquals("{\":id\":\"/@r3-0-1\",\"test\":{},\":childNodeCount\":1}", r2);
         String r3;
         r3 = mk.getNodes("/", rev3, 0, 0, Integer.MAX_VALUE, ":id");
-        assertEquals("{\":id\":\"/@r0000004000-1\",\"test\":{},\":childNodeCount\":1}", r3);
+        assertEquals("{\":id\":\"/@r4-0-1\",\"test\":{},\":childNodeCount\":1}", r3);
         r3 = mk.getNodes("/test", rev3, 0, 0, Integer.MAX_VALUE, ":id");
-        assertEquals("{\":id\":\"/test@r0000004000-1\",\"a\":{},\"b\":{},\":childNodeCount\":2}",
r3);
+        assertEquals("{\":id\":\"/test@r4-0-1\",\"a\":{},\"b\":{},\":childNodeCount\":2}",
r3);
         String r4;
         r4 = mk.getNodes("/", rev4, 0, 0, Integer.MAX_VALUE, ":id");
-        assertEquals("{\":id\":\"/@r0000005000-1\",\"test\":{},\":childNodeCount\":1}", r4);
+        assertEquals("{\":id\":\"/@r5-0-1\",\"test\":{},\":childNodeCount\":1}", r4);
         r4 = mk.getNodes("/test", rev4, 0, 0, Integer.MAX_VALUE, ":id");
-        assertEquals("{\":id\":\"/test@r0000005000-1\",\"a\":{},\"b\":{},\":childNodeCount\":2}",
r4);
+        assertEquals("{\":id\":\"/test@r5-0-1\",\"a\":{},\"b\":{},\":childNodeCount\":2}",
r4);
         r4 = mk.getNodes("/test/a", rev4, 0, 0, Integer.MAX_VALUE, ":id");
-        assertEquals("{\":id\":\"/test/a@r0000005000-1\",\"x\":1,\":childNodeCount\":0}",
r4);
+        assertEquals("{\":id\":\"/test/a@r5-0-1\",\"x\":1,\":childNodeCount\":0}", r4);
         r4 = mk.getNodes("/test/b", rev4, 0, 0, Integer.MAX_VALUE, ":id");
-        assertEquals("{\":id\":\"/test/b@r0000004000-1\",\":childNodeCount\":0}", r4);
+        assertEquals("{\":id\":\"/test/b@r4-0-1\",\":childNodeCount\":0}", r4);
         
         mk.dispose();        
     }

Modified: jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/impl/MongoMKWaitForCommitTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/impl/MongoMKWaitForCommitTest.java?rev=1470512&r1=1470511&r2=1470512&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/impl/MongoMKWaitForCommitTest.java
(original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/impl/MongoMKWaitForCommitTest.java
Mon Apr 22 13:51:41 2013
@@ -127,6 +127,7 @@ public class MongoMKWaitForCommitTest ex
 
     private ScheduledFuture<String> scheduleCommit(long delay, final String revisionId)
{
         ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
+        final MicroKernel mk = this.mk;
         ScheduledFuture<String> future = executorService.schedule(new Callable<String>(){
             @Override
             public String call() throws Exception {



Mime
View raw message