diff --git a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/VersionGCRecommendations.java b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/VersionGCRecommendations.java index 370f3b1485a..13126e701d9 100644 --- a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/VersionGCRecommendations.java +++ b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/VersionGCRecommendations.java @@ -350,12 +350,26 @@ private Map getVGCSettings() { return settings; } + /** + * Set the VGC settings with the given property and value. + * If property is not present, it will add the property to versionGC document with given value. + * + * @param propName the property name + * @param val the value + * @see VersionGCRecommendations#setVGCSetting(Map) + */ private void setVGCSetting(final String propName, final Object val) { setVGCSetting(new HashMap<>() {{ put(propName, val); }}); } + /** + * Set the VGC settings with the given properties and values. + * If properties are not present, it will add the properties to versionGC document with given values + * . + * @param propValMap the properties and values to set + */ private void setVGCSetting(final Map propValMap) { final UpdateOp updateOp = new UpdateOp(SETTINGS_COLLECTION_ID, true); setUpdateOp(propValMap, updateOp); @@ -370,6 +384,12 @@ private void setUpdateOp(final Map propValMap, final UpdateOp up }); } + /** + * Update the VGC settings with the given properties and values. + * Properties are only updated if they already exists in the versionGC document. + * + * @param propValMap the properties and values to update + */ private void updateVGCSetting(final Map propValMap) { final UpdateOp updateOp = new UpdateOp(SETTINGS_COLLECTION_ID, false); setUpdateOp(propValMap, updateOp); diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGCInitTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGCInitTest.java index 14833269e97..47afbf2b7e5 100644 --- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGCInitTest.java +++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGCInitTest.java @@ -62,8 +62,10 @@ public void lazyInitialize() throws Exception { vgc = store.find(SETTINGS, SETTINGS_COLLECTION_ID); assertNotNull(vgc); - assertEquals(0L, vgc.get(SETTINGS_COLLECTION_FULL_GC_TIMESTAMP_PROP)); - assertEquals(MIN_ID_VALUE, vgc.get(SETTINGS_COLLECTION_FULL_GC_DOCUMENT_ID_PROP)); + + // fullGC values shouldn't have been updated without fullGC enabled + assertNull(vgc.get(SETTINGS_COLLECTION_FULL_GC_TIMESTAMP_PROP)); + assertNull(vgc.get(SETTINGS_COLLECTION_FULL_GC_DOCUMENT_ID_PROP)); } @Test @@ -124,9 +126,6 @@ public void lazyInitializeWithFullGCDryRun() throws Exception { vgc = store.find(SETTINGS, SETTINGS_COLLECTION_ID); assertNotNull(vgc); // fullGC values shouldn't have been updated in dryRun mode - System.out.println(stats.oldestModifiedDocId); - System.out.println(stats.oldestModifiedDocTimeStamp); - System.out.println(vgc); assertNull(vgc.get(SETTINGS_COLLECTION_FULL_GC_TIMESTAMP_PROP)); assertNull(vgc.get(SETTINGS_COLLECTION_FULL_GC_DOCUMENT_ID_PROP));