jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dpfis...@apache.org
Subject svn commit: r1330732 - in /jackrabbit/oak/trunk/oak-mk/src: main/java/org/apache/jackrabbit/mk/store/DefaultRevisionStore.java test/java/org/apache/jackrabbit/mk/store/DefaultRevisionStoreTest.java
Date Thu, 26 Apr 2012 09:32:51 GMT
Author: dpfister
Date: Thu Apr 26 09:32:51 2012
New Revision: 1330732

URL: http://svn.apache.org/viewvc?rev=1330732&view=rev
Log:
GC for revisions
- support branch & merge (WiP)

Modified:
    jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/store/DefaultRevisionStore.java
    jackrabbit/oak/trunk/oak-mk/src/test/java/org/apache/jackrabbit/mk/store/DefaultRevisionStoreTest.java

Modified: jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/store/DefaultRevisionStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/store/DefaultRevisionStore.java?rev=1330732&r1=1330731&r2=1330732&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/store/DefaultRevisionStore.java
(original)
+++ jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/store/DefaultRevisionStore.java
Thu Apr 26 09:32:51 2012
@@ -62,8 +62,8 @@ public class DefaultRevisionStore extend
     private final Persistence pm;
     protected final GCPersistence gcpm;
 
-    /* avoid synthetic accessor */int initialCacheSize;
-    /* avoid synthetic accessor */Map<Id, Object> cache;
+    /* avoid synthetic accessor */ int initialCacheSize;
+    /* avoid synthetic accessor */ Map<Id, Object> cache;
 
     /**
      * GC run state constants.
@@ -467,28 +467,10 @@ public class DefaultRevisionStore extend
             return;
         }
 
-        // Mark all nodes that belong to currently active puts
-        markLock.writeLock().lock();
-
         try {
-            gcpm.start();
-            gcState.set(MARKING);
-
-            for (PutTokenImpl token : putTokens.keySet()) {
-                markNode(token.getLastModified());
-            }
-
-        } catch (Exception e) {
-            /* unable to perform GC */
-            gcState.set(NOT_ACTIVE);
-            e.printStackTrace();
-            return;
-        } finally {
-            markLock.writeLock().unlock();
-        }
-
-        try {
-            doMark();
+            markUncommittedPuts();
+            markBranches();
+            markCommits();
         } catch (Exception e) {
             /* unable to perform GC */
             gcState.set(NOT_ACTIVE);
@@ -506,8 +488,39 @@ public class DefaultRevisionStore extend
             gcState.set(NOT_ACTIVE);
         }
     }
+    
+    /**
+     * Mark uncommitted puts.
+     * 
+     * @throws Exception
+     *             if an error occurs
+     */
+    private void markUncommittedPuts() throws Exception {
+        markLock.writeLock().lock();
+
+        try {
+            gcpm.start();
+            gcState.set(MARKING);
+
+            for (PutTokenImpl token : putTokens.keySet()) {
+                markNode(token.getLastModified());
+            }
+        } finally {
+            markLock.writeLock().unlock();
+        }
+    }
 
     /**
+     * Mark branches.
+     * 
+     * @throws Exception
+     *             if an error occurs
+     */
+    private void markBranches() throws Exception {
+        // TODO
+    }
+    
+    /**
      * Mark all commits and nodes in a garbage collection cycle. Can be
      * customized by subclasses. If this method throws an exception, the cycle
      * will be stopped without sweeping.
@@ -515,7 +528,7 @@ public class DefaultRevisionStore extend
      * @throws Exception
      *             if an error occurs
      */
-    protected void doMark() throws Exception {
+    protected void markCommits() throws Exception {
         StoredCommit commit = getHeadCommit();
         long tsLimit = commit.getCommitTS() - (60 * 60 * 1000);
 

Modified: jackrabbit/oak/trunk/oak-mk/src/test/java/org/apache/jackrabbit/mk/store/DefaultRevisionStoreTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mk/src/test/java/org/apache/jackrabbit/mk/store/DefaultRevisionStoreTest.java?rev=1330732&r1=1330731&r2=1330732&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mk/src/test/java/org/apache/jackrabbit/mk/store/DefaultRevisionStoreTest.java
(original)
+++ jackrabbit/oak/trunk/oak-mk/src/test/java/org/apache/jackrabbit/mk/store/DefaultRevisionStoreTest.java
Thu Apr 26 09:32:51 2012
@@ -34,6 +34,7 @@ import org.apache.jackrabbit.mk.persiste
 import org.apache.jackrabbit.mk.persistence.InMemPersistence;
 import org.junit.After;
 import org.junit.Before;
+import org.junit.Ignore;
 import org.junit.Test;
 
 /**
@@ -48,7 +49,7 @@ public class DefaultRevisionStoreTest {
     public void setup() throws Exception {
         rs = new DefaultRevisionStore(createPersistence()) {
             @Override
-            protected void doMark() throws Exception {
+            protected void markCommits() throws Exception {
                 StoredCommit commit = getHeadCommit();
                 
                 // Keep head commit only
@@ -100,6 +101,26 @@ public class DefaultRevisionStoreTest {
     }
 
     /**
+     * Verify branch and merge works with garbage collection.
+     * 
+     * @throws Exception if an error occurs
+     */
+    @Ignore
+    @Test
+    public void testBranchMerge() throws Exception {
+        mk.commit("/", "+\"a\" : { \"b\":{}, \"c\":{} }", mk.getHeadRevision(), null);
+        String branchRevisionId = mk.branch(mk.getHeadRevision());
+
+        mk.commit("/a", "+\"d\" : {}", mk.getHeadRevision(), null);
+        branchRevisionId = mk.commit("/a", "+\"e\" : {}", branchRevisionId, null);
+        
+        rs.gc();
+
+        branchRevisionId = mk.commit("/a", "+\"f\" : {}", branchRevisionId, null);
+        mk.merge(branchRevisionId, null);
+    }
+    
+    /**
      * Verify garbage collection can run concurrently with commits.
      * 
      * @throws Exception if an error occurs



Mime
View raw message