jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1492194 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/ oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/ oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/ oak-core/src/main...
Date Wed, 12 Jun 2013 13:37:54 GMT
Author: jukka
Date: Wed Jun 12 13:37:53 2013
New Revision: 1492194

URL: http://svn.apache.org/r1492194
Log:
OAK-763: Asynchronous indexing

Introduce a checkpoint mechanism by which an asynchronous indexer can
keep track of which past repository revision has already been indexed.

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStore.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdate.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeStore.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStore.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreBranch.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreService.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeStore.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreCacheTest.java
    jackrabbit/oak/trunk/oak-mk-api/src/main/java/org/apache/jackrabbit/mk/api/MicroKernel.java
    jackrabbit/oak/trunk/oak-mk-remote/src/main/java/org/apache/jackrabbit/mk/client/Client.java
    jackrabbit/oak/trunk/oak-mk-remote/src/main/java/org/apache/jackrabbit/mk/server/MicroKernelServlet.java
    jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/core/MicroKernelImpl.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/util/LogWrapper.java
    jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/util/TimingWrapper.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStore.java?rev=1492194&r1=1492193&r2=1492194&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStore.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStore.java
Wed Jun 12 13:37:53 2013
@@ -20,6 +20,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.util.concurrent.ExecutionException;
 
+import javax.annotation.CheckForNull;
 import javax.annotation.Nonnull;
 
 import com.google.common.cache.CacheBuilder;
@@ -37,6 +38,7 @@ import org.apache.jackrabbit.oak.spi.sta
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 import org.apache.jackrabbit.oak.spi.state.NodeStoreBranch;
 
+import static com.google.common.base.Preconditions.checkArgument;
 import static com.google.common.base.Preconditions.checkNotNull;
 
 /**
@@ -144,6 +146,23 @@ public class KernelNodeStore extends Abs
         }
     }
 
+    @Override @Nonnull
+    public String checkpoint(long lifetime) {
+        checkArgument(lifetime > 0);
+        return kernel.checkpoint(lifetime);
+    }
+
+    @Override @CheckForNull
+    public NodeStoreBranch branch(@Nonnull String checkpoint) {
+        try {
+            return new KernelNodeStoreBranch(
+                    this, getRootState(checkNotNull(checkpoint)));
+        } catch (MicroKernelException e) {
+            // TODO: caused by the checkpoint no longer being available?
+            return null;
+        }
+    }
+
     //-----------------------------------------------------------< internal >---
 
     @Nonnull

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdate.java?rev=1492194&r1=1492193&r2=1492194&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdate.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdate.java
Wed Jun 12 13:37:53 2013
@@ -19,14 +19,19 @@
 package org.apache.jackrabbit.oak.plugins.index;
 
 import static com.google.common.base.Preconditions.checkNotNull;
+import static org.apache.jackrabbit.oak.api.Type.STRING;
+import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.MISSING_NODE;
+
+import java.util.concurrent.TimeUnit;
 
 import javax.annotation.Nonnull;
 
 import org.apache.jackrabbit.oak.api.CommitFailedException;
-import org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState;
+import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.spi.commit.CommitHook;
 import org.apache.jackrabbit.oak.spi.commit.EditorHook;
 import org.apache.jackrabbit.oak.spi.commit.EmptyHook;
+import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 import org.apache.jackrabbit.oak.spi.state.NodeStore;
 import org.apache.jackrabbit.oak.spi.state.NodeStoreBranch;
@@ -38,13 +43,15 @@ public class AsyncIndexUpdate implements
     private static final Logger log = LoggerFactory
             .getLogger(AsyncIndexUpdate.class);
 
+    private static final long DEFAULT_LIFETIME = TimeUnit.HOURS.toMillis(1);
+
     private final String name;
 
     private final NodeStore store;
 
     private final CommitHook hook;
-    
-    private NodeState current = EmptyNodeState.EMPTY_NODE;
+
+    private final long lifetime = DEFAULT_LIFETIME; // TODO: make configurable
 
     public AsyncIndexUpdate(
             @Nonnull String name,
@@ -59,13 +66,26 @@ public class AsyncIndexUpdate implements
     @Override
     public void run() {
         log.debug("Running background index task {}", name);
-        NodeStoreBranch branch = store.branch();
-        NodeState after = branch.getHead();
+        String checkpoint = store.checkpoint(lifetime);
+        NodeStoreBranch branch = store.branch(checkpoint);
         try {
-            NodeState processed = hook.processCommit(current, after);
-            branch.setRoot(processed);
-            branch.merge(EmptyHook.INSTANCE);
-            current = after;
+            NodeState after = branch.getHead();
+
+            NodeState before = null;
+            PropertyState async =
+                    after.getChildNode(":async").getProperty(name);
+            if (async != null && async.getType() == STRING) {
+                before = store.branch(async.getValue(STRING)).getHead();
+            }
+            if (before == null) {
+                before = MISSING_NODE;
+            }
+
+            NodeState processed = hook.processCommit(before, after);
+            NodeBuilder builder = processed.builder();
+            builder.child(":async").setProperty(name, checkpoint);
+            branch.setRoot(builder.getNodeState());
+            branch.merge(EmptyHook.INSTANCE); 
         } catch (CommitFailedException e) {
             log.warn("Background index update " + name + " failed", e);
         }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeStore.java?rev=1492194&r1=1492193&r2=1492194&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeStore.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeStore.java
Wed Jun 12 13:37:53 2013
@@ -18,9 +18,14 @@ package org.apache.jackrabbit.oak.plugin
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.Map;
 import java.util.concurrent.atomic.AtomicReference;
 
+import javax.annotation.CheckForNull;
+import javax.annotation.Nonnull;
+
 import com.google.common.io.ByteStreams;
+
 import org.apache.jackrabbit.oak.api.CommitFailedException;
 import org.apache.jackrabbit.oak.spi.commit.CommitHook;
 import org.apache.jackrabbit.oak.spi.state.AbstractNodeStore;
@@ -28,8 +33,10 @@ import org.apache.jackrabbit.oak.spi.sta
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 import org.apache.jackrabbit.oak.spi.state.NodeStoreBranch;
 
+import static com.google.common.base.Preconditions.checkArgument;
 import static com.google.common.base.Preconditions.checkNotNull;
 import static com.google.common.base.Preconditions.checkState;
+import static com.google.common.collect.Maps.newHashMap;
 import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE;
 
 /**
@@ -41,6 +48,8 @@ public class MemoryNodeStore extends Abs
     private final AtomicReference<NodeState> root =
             new AtomicReference<NodeState>(EMPTY_NODE);
 
+    private final Map<String, NodeState> checkpoints = newHashMap();
+
     @Override
     public NodeState getRoot() {
         return root.get();
@@ -64,6 +73,24 @@ public class MemoryNodeStore extends Abs
         }
     }
 
+    @Override @Nonnull
+    public synchronized String checkpoint(long lifetime) {
+        checkArgument(lifetime > 0);
+        String checkpoint = "checkpoint" + checkpoints.size();
+        checkpoints.put(checkpoint, getRoot());
+        return checkpoint;
+    }
+
+    @Override @CheckForNull
+    public synchronized NodeStoreBranch branch(@Nonnull String checkpoint) {
+        NodeState base = checkpoints.get(checkNotNull(checkpoint));
+        if (base != null) {
+            return new MemoryNodeStoreBranch(this, base);
+        } else {
+            return null;
+        }
+    }
+
     private static class MemoryNodeStoreBranch extends AbstractNodeStoreBranch {
 
         /** The underlying store to which this branch belongs */

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStore.java?rev=1492194&r1=1492193&r2=1492194&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStore.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStore.java
Wed Jun 12 13:37:53 2013
@@ -16,9 +16,13 @@
  */
 package org.apache.jackrabbit.oak.plugins.segment;
 
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+
 import java.io.IOException;
 import java.io.InputStream;
 
+import javax.annotation.CheckForNull;
 import javax.annotation.Nonnull;
 
 import org.apache.jackrabbit.oak.api.Blob;
@@ -66,7 +70,8 @@ public class SegmentNodeStore extends Ab
 
     @Override @Nonnull
     public NodeStoreBranch branch() {
-        return new SegmentNodeStoreBranch(this, new SegmentWriter(store));
+        return new SegmentNodeStoreBranch(
+                this, new SegmentWriter(store), getRoot());
     }
 
     @Override
@@ -77,4 +82,19 @@ public class SegmentNodeStore extends Ab
         return new SegmentBlob(reader, recordId);
     }
 
+    @Override @Nonnull
+    public synchronized String checkpoint(long lifetime) {
+        checkArgument(lifetime > 0);
+        // TODO: Guard the checkpoint from garbage collection
+        return getRoot().getRecordId().toString();
+    }
+
+    @Override @CheckForNull
+    public synchronized NodeStoreBranch branch(@Nonnull String checkpoint) {
+        // TODO: Verify validity of the checkpoint
+        RecordId id = RecordId.fromString(checkNotNull(checkpoint));
+        SegmentNodeState base = new SegmentNodeState(store, id);
+        return new SegmentNodeStoreBranch(this, new SegmentWriter(store), base);
+    }
+
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreBranch.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreBranch.java?rev=1492194&r1=1492193&r2=1492194&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreBranch.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreBranch.java
Wed Jun 12 13:37:53 2013
@@ -40,10 +40,12 @@ class SegmentNodeStoreBranch extends Abs
 
     private SegmentNodeState head;
 
-    SegmentNodeStoreBranch(SegmentNodeStore store, SegmentWriter writer) {
+    SegmentNodeStoreBranch(
+            SegmentNodeStore store, SegmentWriter writer,
+            SegmentNodeState base) {
         this.store = store;
         this.writer = writer;
-        this.base = store.getRoot();
+        this.base = base;
         this.head = base;
     }
 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreService.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreService.java?rev=1492194&r1=1492193&r2=1492194&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreService.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreService.java
Wed Jun 12 13:37:53 2013
@@ -20,6 +20,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.util.Dictionary;
 
+import javax.annotation.CheckForNull;
 import javax.annotation.Nonnull;
 
 import org.apache.felix.scr.annotations.Activate;
@@ -127,6 +128,16 @@ public class SegmentNodeStoreService ext
         return getDelegate().createBlob(stream);
     }
 
+    @Override @Nonnull
+    public String checkpoint(long lifetime) {
+        return getDelegate().checkpoint(lifetime);
+    }
+
+    @Override @CheckForNull
+    public NodeStoreBranch branch(@Nonnull String checkpoint) {
+        return getDelegate().branch(checkpoint);
+    }
+
     //------------------------------------------------------------< Object >--
 
     @Override

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeStore.java?rev=1492194&r1=1492193&r2=1492194&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeStore.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeStore.java
Wed Jun 12 13:37:53 2013
@@ -19,6 +19,7 @@ package org.apache.jackrabbit.oak.spi.st
 import java.io.IOException;
 import java.io.InputStream;
 
+import javax.annotation.CheckForNull;
 import javax.annotation.Nonnull;
 
 import org.apache.jackrabbit.oak.api.Blob;
@@ -57,4 +58,28 @@ public interface NodeStore {
      * @throws IOException  If an error occurs while reading from the stream
      */
     Blob createBlob(InputStream inputStream) throws IOException;
+
+    /**
+     * Creates a new checkpoint of the latest root of the tree. The checkpoint
+     * remains valid for at least as long as requested and allows that state
+     * of the repository to be retrieved using the returned opaque string
+     * reference.
+     *
+     * @param lifetime time (in milliseconds, &gt; 0) that the checkpoint
+     *                 should remain available
+     * @return string reference of this checkpoint
+     */
+    @Nonnull
+    String checkpoint(long lifetime);
+
+    /**
+     * Starts a new branch from a previously created repository checkpoint.
+     *
+     * @param checkpoint string reference of a checkpoint
+     * @return new branch starting from the given checkpoint,
+     *         or {@code null} if the checkpoint is no longer available
+     */
+    @CheckForNull
+    NodeStoreBranch branch(@Nonnull String checkpoint);
+
 }

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreCacheTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreCacheTest.java?rev=1492194&r1=1492193&r2=1492194&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreCacheTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreCacheTest.java
Wed Jun 12 13:37:53 2013
@@ -168,6 +168,11 @@ public class KernelNodeStoreCacheTest {
             return kernel.getHeadRevision();
         }
 
+        @Override @Nonnull
+        public String checkpoint(long lifetime) throws MicroKernelException {
+            return kernel.checkpoint(lifetime);
+        }
+
         @Override
         public String getRevisionHistory(long since,
                                          int maxEntries,
@@ -269,5 +274,6 @@ public class KernelNodeStoreCacheTest {
         public String write(InputStream in) throws MicroKernelException {
             return kernel.write(in);
         }
+
     }
 }

Modified: jackrabbit/oak/trunk/oak-mk-api/src/main/java/org/apache/jackrabbit/mk/api/MicroKernel.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mk-api/src/main/java/org/apache/jackrabbit/mk/api/MicroKernel.java?rev=1492194&r1=1492193&r2=1492194&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mk-api/src/main/java/org/apache/jackrabbit/mk/api/MicroKernel.java
(original)
+++ jackrabbit/oak/trunk/oak-mk-api/src/main/java/org/apache/jackrabbit/mk/api/MicroKernel.java
Wed Jun 12 13:37:53 2013
@@ -83,6 +83,19 @@ public interface MicroKernel {
     String getHeadRevision() throws MicroKernelException;
 
     /**
+     * Creates a new checkpoint of the latest head revision. The checkpoint
+     * guarantees that revision to remain valid and accessible for at least
+     * as long as requested.
+     *
+     * @param lifetime time (in milliseconds) that the checkpoint should
+     *                 remain available
+     * @return revision id of the created checkpoint
+     * @throws MicroKernelException if the checkpoint could not be created
+     */
+    @Nonnull
+    String checkpoint(long lifetime) throws MicroKernelException;
+
+    /**
      * Returns a list of all currently available (historical) head revisions in
      * chronological order since a specific point. <i>Private</i> branch
      * revisions won't be included in the result.

Modified: jackrabbit/oak/trunk/oak-mk-remote/src/main/java/org/apache/jackrabbit/mk/client/Client.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mk-remote/src/main/java/org/apache/jackrabbit/mk/client/Client.java?rev=1492194&r1=1492193&r2=1492194&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mk-remote/src/main/java/org/apache/jackrabbit/mk/client/Client.java
(original)
+++ jackrabbit/oak/trunk/oak-mk-remote/src/main/java/org/apache/jackrabbit/mk/client/Client.java
Wed Jun 12 13:37:53 2013
@@ -110,6 +110,21 @@ public class Client implements MicroKern
         }
     }
 
+    @Override @Nonnull
+    public String checkpoint(long lifetime) throws MicroKernelException {
+        try {
+            Request request = createRequest("checkpoint");
+            try {
+                request.addParameter("lifetime", lifetime);
+                return request.getString();
+            } finally {
+                request.close();
+            }
+        } catch (IOException e) {
+            throw new MicroKernelException(e);
+        }
+    }
+
     @Override
     public String getRevisionHistory(long since, int maxEntries, String path)
             throws MicroKernelException {
@@ -382,5 +397,6 @@ public class Client implements MicroKern
     private Request createRequest(String command) throws IOException, MicroKernelException
{
         return new Request(socketFactory, addr, command);
     }
-    
+
+
 }

Modified: jackrabbit/oak/trunk/oak-mk-remote/src/main/java/org/apache/jackrabbit/mk/server/MicroKernelServlet.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mk-remote/src/main/java/org/apache/jackrabbit/mk/server/MicroKernelServlet.java?rev=1492194&r1=1492193&r2=1492194&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mk-remote/src/main/java/org/apache/jackrabbit/mk/server/MicroKernelServlet.java
(original)
+++ jackrabbit/oak/trunk/oak-mk-remote/src/main/java/org/apache/jackrabbit/mk/server/MicroKernelServlet.java
Wed Jun 12 13:37:53 2013
@@ -74,6 +74,7 @@ class MicroKernelServlet {
 
     static {
         COMMANDS.put("getHeadRevision", new GetHeadRevision());
+        COMMANDS.put("checkpoint", new Checkpoint());
         COMMANDS.put("getRevisionHistory", new GetRevisionHistory());
         COMMANDS.put("waitForCommit", new WaitForCommit());
         COMMANDS.put("getJournal", new GetJournal());
@@ -100,6 +101,17 @@ class MicroKernelServlet {
         }
     }
 
+    static class Checkpoint implements Command {
+
+        @Override
+        public void execute(MicroKernel mk, Request request, Response response)
+                throws IOException, MicroKernelException {
+            long lifetime = request.getParameter("lifetime", 1000L);
+            response.setContentType("text/plain");
+            response.write(mk.checkpoint(lifetime));
+        }
+    }
+
     static class GetRevisionHistory implements Command {
 
         @Override

Modified: jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/core/MicroKernelImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/core/MicroKernelImpl.java?rev=1492194&r1=1492193&r2=1492194&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/core/MicroKernelImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/core/MicroKernelImpl.java
Wed Jun 12 13:37:53 2013
@@ -20,6 +20,8 @@ import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.List;
 
+import javax.annotation.Nonnull;
+
 import org.apache.jackrabbit.mk.api.MicroKernel;
 import org.apache.jackrabbit.mk.api.MicroKernelException;
 import org.apache.jackrabbit.mk.json.JsonObject;
@@ -111,6 +113,13 @@ public class MicroKernelImpl implements 
         return getHeadRevisionId().toString();
     }
 
+    @Override @Nonnull
+    public String checkpoint(long lifetime) throws MicroKernelException {
+        // FIXME: need to signal to the garbage collector that this revision
+        // should not be collected until the requested lifetime is over
+        return getHeadRevision();
+    }
+
     /**
      * Same as {@code getHeadRevisionId}, with typed {@code Id} return value instead of string.
      *

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=1492194&r1=1492193&r2=1492194&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 Jun 12 13:37:53 2013
@@ -750,6 +750,13 @@ public class MongoMK implements MicroKer
         return headRevision.toString();
     }
 
+    @Override @Nonnull
+    public String checkpoint(long lifetime) throws MicroKernelException {
+        // FIXME: need to signal to the garbage collector that this revision
+        // should not be collected until the requested lifetime is over
+        return getHeadRevision();
+    }
+
     @Override
     public String getRevisionHistory(long since, int maxEntries, String path)
             throws MicroKernelException {

Modified: jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/util/LogWrapper.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/util/LogWrapper.java?rev=1492194&r1=1492193&r2=1492194&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/util/LogWrapper.java
(original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/util/LogWrapper.java
Wed Jun 12 13:37:53 2013
@@ -19,6 +19,8 @@ package org.apache.jackrabbit.mongomk.ut
 import java.io.InputStream;
 import java.util.concurrent.atomic.AtomicInteger;
 
+import javax.annotation.Nonnull;
+
 import org.apache.jackrabbit.mk.api.MicroKernel;
 import org.apache.jackrabbit.mk.api.MicroKernelException;
 import org.apache.jackrabbit.mk.json.JsopBuilder;
@@ -74,6 +76,19 @@ public class LogWrapper<T extends MicroK
         }
     }
 
+    @Override @Nonnull
+    public String checkpoint(long lifetime) {
+        try {
+            logMethod("checkpoint", lifetime);
+            String result = mk.checkpoint(lifetime);
+            logResult(result);
+            return result;
+        } catch (Exception e) {
+            logException(e);
+            throw convert(e);
+        }
+    }
+
     @Override
     public String getJournal(String fromRevisionId, String toRevisionId, String path) {
         try {

Modified: jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/util/TimingWrapper.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/util/TimingWrapper.java?rev=1492194&r1=1492193&r2=1492194&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/util/TimingWrapper.java
(original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/util/TimingWrapper.java
Wed Jun 12 13:37:53 2013
@@ -95,6 +95,18 @@ public class TimingWrapper implements Mi
         }
     }
 
+    @Override @Nonnull
+    public String checkpoint(long lifetime) {
+        try {
+            long start = now();
+            String result = mk.checkpoint(lifetime);
+            updateAndLogTimes("checkpoint", start, 0, 0);
+            return result;
+        } catch (Exception e) {
+            throw convert(e);
+        }
+    }
+
     @Override
     public String getJournal(String fromRevisionId, String toRevisionId, String path) {
         try {



Mime
View raw message