Skip to content

Commit

Permalink
OAK-10921 : added javadocs for update settings method
Browse files Browse the repository at this point in the history
  • Loading branch information
Rishabh Kumar committed Aug 5, 2024
1 parent 4479723 commit 4e2009e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -350,12 +350,26 @@ private Map<String, Object> 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<String, Object> propValMap) {
final UpdateOp updateOp = new UpdateOp(SETTINGS_COLLECTION_ID, true);
setUpdateOp(propValMap, updateOp);
Expand All @@ -370,6 +384,12 @@ private void setUpdateOp(final Map<String, Object> 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<String, Object> propValMap) {
final UpdateOp updateOp = new UpdateOp(SETTINGS_COLLECTION_ID, false);
setUpdateOp(propValMap, updateOp);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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));

Expand Down

0 comments on commit 4e2009e

Please sign in to comment.