jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1243833 - in /jackrabbit/sandbox/microkernel/src: main/java/org/apache/jackrabbit/mk/mem/ test/java/org/apache/jackrabbit/mk/hash/ test/java/org/apache/jackrabbit/mk/large/
Date Tue, 14 Feb 2012 09:02:36 GMT
Author: thomasm
Date: Tue Feb 14 09:02:36 2012
New Revision: 1243833

URL: http://svn.apache.org/viewvc?rev=1243833&view=rev
Log:
Pseudo-property nodeVersion ; bugfix

Added:
    jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/large/NodeVersionTest.java
Modified:
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/NodeImpl.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/NodeMap.java
    jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/hash/HashTest.java

Modified: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/NodeImpl.java?rev=1243833&r1=1243832&r2=1243833&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/NodeImpl.java
(original)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/NodeImpl.java
Tue Feb 14 09:02:36 2012
@@ -60,6 +60,11 @@ public class NodeImpl implements Cache.V
     public static final String HASH = ":hash";
 
     /**
+     * The node version.
+     */
+    public static final String NODE_VERSION = ":nodeVersion";
+
+    /**
      * Used when there are many child nodes.
      * The id of an internal node.
      */
@@ -91,8 +96,8 @@ public class NodeImpl implements Cache.V
     private long descendantCount;
     private int descendantInlineCount;
     private boolean hasMoreChildNodes;
-
     private byte[] hash;
+    private String nodeVersion;
 
     public NodeImpl(NodeMap map, long revId) {
         this.map = map;
@@ -295,6 +300,9 @@ public class NodeImpl implements Cache.V
         if (map.hash) {
             json.key(HASH).value(StringUtils.convertBytesToHex(getHash()));
         }
+        if (map.nodeVersion) {
+            json.key(NODE_VERSION).value(id.toString());
+        }
         if (childNodes == null) {
             if (childNodeCount) {
                 json.key(CHILREN_COUNT).value(0);
@@ -467,6 +475,9 @@ public class NodeImpl implements Cache.V
                         } else if (key.equals(HASH)) {
                             value = JsopTokenizer.decodeQuoted(value);
                             node.hash = StringUtils.convertHexToBytes(value);
+                        } else if (key.equals(NODE_VERSION)) {
+                            value = JsopTokenizer.decodeQuoted(value);
+                            node.nodeVersion = value;
                         } else if (key.equals(DESCENDANT_COUNT)) {
                             node.descendantCount = Long.parseLong(value);
                         } else {
@@ -727,4 +738,8 @@ public class NodeImpl implements Cache.V
         return hasMoreChildNodes;
     }
 
+    public String getNodeVersion() {
+        return nodeVersion;
+    }
+
 }

Modified: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/NodeMap.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/NodeMap.java?rev=1243833&r1=1243832&r2=1243833&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/NodeMap.java
(original)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/NodeMap.java
Tue Feb 14 09:02:36 2012
@@ -29,6 +29,7 @@ public class NodeMap {
     public static final String DESCENDANT_COUNT = "descendantCount";
     public static final String DESCENDANT_INLINE_COUNT = "descendantInlineCount";
     public static final String HASH = "hash";
+    public static final String NODE_VERSION = "nodeVersion";
 
     private static final int DEFAULT_MAX_MEMORY_CHILDREN = Integer.MAX_VALUE;
 
@@ -38,6 +39,8 @@ public class NodeMap {
 
     protected boolean hash;
 
+    protected boolean nodeVersion;
+
     final HashMap<Long, NodeImpl> temp = new HashMap<Long, NodeImpl>();
     private Map<Long, NodeImpl> nodes = Collections.synchronizedMap(new HashMap<Long,
NodeImpl>());
     private AtomicLong nextId = new AtomicLong();
@@ -78,6 +81,8 @@ public class NodeMap {
             descendantInlineCount = Integer.parseInt(value);
         } else if (key.equals(HASH)) {
             hash = Boolean.parseBoolean(value);
+        } else if (key.equals(NODE_VERSION)) {
+            nodeVersion = Boolean.parseBoolean(value);
         } else {
             throw ExceptionFactory.get("Unknown setting: " + key);
         }
@@ -179,4 +184,8 @@ public class NodeMap {
         return hash;
     }
 
+    public boolean getNodeVersion() {
+        return nodeVersion;
+    }
+
 }

Modified: jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/hash/HashTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/hash/HashTest.java?rev=1243833&r1=1243832&r2=1243833&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/hash/HashTest.java
(original)
+++ jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/hash/HashTest.java
Tue Feb 14 09:02:36 2012
@@ -62,8 +62,8 @@ public class HashTest extends MultiMkTes
         head = mk.commit("/", "+ \"test2\": { \"id\": 1 }", mk.getHeadRevision(), "");
         NodeImpl r = NodeImpl.parse(mk.getNodes("/", head));
         assertTrue(r.getHash() != null);
-        NodeImpl t1 = NodeImpl.parse(mk.getNodes("/", head));
-        NodeImpl t2 = NodeImpl.parse(mk.getNodes("/", head));
+        NodeImpl t1 = NodeImpl.parse(mk.getNodes("/test1", head));
+        NodeImpl t2 = NodeImpl.parse(mk.getNodes("/test2", head));
         IOUtilsTest.assertEquals(t1.getHash(), t2.getHash());
         assertFalse(Arrays.equals(t1.getHash(), r.getHash()));
     }

Added: jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/large/NodeVersionTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/large/NodeVersionTest.java?rev=1243833&view=auto
==============================================================================
--- jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/large/NodeVersionTest.java
(added)
+++ jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/large/NodeVersionTest.java
Tue Feb 14 09:02:36 2012
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.mk.large;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import org.apache.jackrabbit.mk.MultiMkTestBase;
+import org.apache.jackrabbit.mk.mem.NodeImpl;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+/**
+ * Test moving nodes.
+ */
+@RunWith(Parameterized.class)
+public class NodeVersionTest extends MultiMkTestBase {
+
+    private String head;
+
+    public NodeVersionTest(String url) {
+        super(url);
+    }
+
+    @Before
+    public void setUp() throws Exception {
+        super.setUp();
+    }
+
+    @After
+    public void tearDown() throws InterruptedException {
+        if (isSimpleKernel(mk)) {
+            head = mk.commit("/:root/head/config", "^ \"nodeVersion\": false", head, "");
+            head = mk.commit("/:root/head/config", "^ \"nodeVersion\": null", head, "");
+        }
+        super.tearDown();
+    }
+
+    @Test
+    public void nodeVersion() {
+        if (!isSimpleKernel(mk)) {
+            return;
+        }
+        String head = mk.getHeadRevision();
+        head = mk.commit("/:root/head/config", "^ \"nodeVersion\": true", head, "");
+
+        head = mk.commit("/", "+ \"test1\": { \"id\": 1 }", head, "");
+        head = mk.commit("/", "+ \"test2\": { \"id\": 1 }", head, "");
+
+        NodeImpl n = NodeImpl.parse(mk.getNodes("/", head));
+        String vra = n.getNodeVersion();
+        String v1a = n.getNode("test1").getNodeVersion();
+        String v2a = n.getNode("test2").getNodeVersion();
+
+        // changes the node version
+        head = mk.commit("/", "^ \"test2/id\": 2", head, "");
+
+        n = NodeImpl.parse(mk.getNodes("/", head));
+        String vrb = n.getNodeVersion();
+        String v1b = n.getNode("test1").getNodeVersion();
+        String v2b = n.getNode("test2").getNodeVersion();
+
+        assertFalse(vra.equals(vrb));
+        assertEquals(v1a, v1b);
+        assertFalse(v2a.equals(v2b));
+    }
+
+}



Mime
View raw message