You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by GitBox <gi...@apache.org> on 2021/02/24 12:17:56 UTC

[GitHub] [jackrabbit-oak] Joscorbe commented on a change in pull request #274: OAK-9305: Create checkpoint with given revision

Joscorbe commented on a change in pull request #274:
URL: https://github.com/apache/jackrabbit-oak/pull/274#discussion_r581910273



##########
File path: oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreMBeanImpl.java
##########
@@ -264,4 +268,28 @@ public String cleanIndividualCache(String name) {
                 return "ERROR: Invalid cache name received.";
         }
     }
+
+    @Override
+    public String createCheckpoint(String revision, long lifetime, boolean force) {
+        Revision rev = Revision.fromString(revision);
+        long oldestTimestamp = nodeStore.getClock().getTime() - revisionGCMaxAgeMillis;
+        Revision oldestCheckpoint = nodeStore.getCheckpoints().getOldestRevisionToKeep();
+        if (oldestCheckpoint != null) {
+            oldestTimestamp = Math.min(oldestTimestamp, oldestCheckpoint.getTimestamp());
+        }
+        if (force || oldestTimestamp < rev.getTimestamp()) {
+            Map<String, String> info = new HashMap<>();
+            info.put(COMPOSITE_INFO + "created", Long.toString(rev.getTimestamp()));
+            info.put(COMPOSITE_INFO + "expires", Long.toString(Utils.sum(rev.getTimestamp() + lifetime)));
+
+            String cp = nodeStore.getCheckpoints().create(lifetime, info, rev).toString();
+            log.info("Created checkpoint [{}] with lifetime {} for Revision {}", cp, lifetime, revision);
+            return cp;

Review comment:
       I was thinking about returning here the string inside the log.info, instead of the "cp" variable that just returns the revision string (which is the first argument you send to this method, so not really useful).
   But that would be less machine readable, and I'm not sure if that would be needed.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org