ArvinDevel commented on a change in pull request #851: Issue 578 : make
MajorCompaction controlled by time of the day/day of the week
URL: https://github.com/apache/bookkeeper/pull/851#discussion_r158973977
##########
File path:
bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/GarbageCollectorThread.java
##########
@@ -264,12 +278,53 @@ public void safeRun() {
// collection cycle started
forceGarbageCollection.set(false);
}
+
+ }
+
+ /**
+ * increase the threshold when the system in low load status.
+ */
+ private void activateMedianThreshold(){
+ majorCompactionThreshold = medianMajorCompactionThreshold;
+ }
+ /**
+ * increase the threshold when the system in a very low load status.
+ */
+ private void activateHighThreshold(){
+ majorCompactionThreshold = highMajorCompactionThreshold;
+ }
+
+ /**
+ * Check whether the configured cron is met and activate threshold.
+ */
+ private void changeMajorCompactionThreshold(){
+ // next fire time is in the interval
+ if
(medianMajorCron.nextTimeAfter(ZonedDateTime.now()).toInstant().toEpochMilli()
+ <= (majorCompactionInterval + lastChangeThresholdTime)) {
+ activateMedianThreshold();
+ }
+ if
(highMajorCron.nextTimeAfter(ZonedDateTime.now()).toInstant().toEpochMilli()
+ <= (majorCompactionInterval + lastChangeThresholdTime)) {
+ activateHighThreshold();
+ }
+ lastChangeThresholdTime =
ZonedDateTime.now().toInstant().toEpochMilli();
+ }
+
+ /**
+ * restore the threshold to normal value.
+ */
+ private void restoreThreshold(){
+ majorCompactionThreshold = originalMajorCompactionThreshold;
+
}
public void runWithFlags(boolean force, boolean suspendMajor, boolean
suspendMinor) {
if (force) {
LOG.info("Garbage collector thread forced to perform GC before
expiry of wait time.");
}
+
+ changeMajorCompactionThreshold();
Review comment:
There doesn't exists this constraint, as long as the next cron fire time fit
in the next gc period, it will change the threshold. And the next cron fire
time is calculated on `now()`, the `lastChangeThresholdTime` is equal to the
lastGCTime.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services