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/16 10:18:44 UTC
[GitHub] [jackrabbit-oak] mreutegg opened a new pull request #274: OAK-9305: Create checkpoint with given revision
mreutegg opened a new pull request #274:
URL: https://github.com/apache/jackrabbit-oak/pull/274
Initial patch provided by José Andrés Cordero Benítez
Restructured code and added tests
----------------------------------------------------------------
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
[GitHub] [jackrabbit-oak] Joscorbe commented on a change in pull request #274: OAK-9305: Create checkpoint with given revision
Posted by GitBox <gi...@apache.org>.
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
[GitHub] [jackrabbit-oak] mreutegg commented on a change in pull request #274: OAK-9305: Create checkpoint with given revision
Posted by GitBox <gi...@apache.org>.
mreutegg commented on a change in pull request #274:
URL: https://github.com/apache/jackrabbit-oak/pull/274#discussion_r610558599
##########
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:
Thanks for the suggestion. I merged your PR.
--
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
[GitHub] [jackrabbit-oak] mreutegg closed pull request #274: OAK-9305: Create checkpoint with given revision
Posted by GitBox <gi...@apache.org>.
mreutegg closed pull request #274:
URL: https://github.com/apache/jackrabbit-oak/pull/274
--
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
[GitHub] [jackrabbit-oak] Joscorbe commented on a change in pull request #274: OAK-9305: Create checkpoint with given revision
Posted by GitBox <gi...@apache.org>.
Joscorbe commented on a change in pull request #274:
URL: https://github.com/apache/jackrabbit-oak/pull/274#discussion_r581913853
##########
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:
Something like:
return String.format("Created checkpoint [{}] with lifetime {} for Revision {}", cp, lifetime, revision);
But changing this would mean at least 2 tests would need to be adjusted:
createCheckpointForceWithRevisionTooOld()
createCheckpointBeforeExistingCheckpoint()
----------------------------------------------------------------
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