You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@bookkeeper.apache.org by GitBox <gi...@apache.org> on 2017/12/27 07:32:48 UTC
[GitHub] sijie commented on a change in pull request #851: Issue 578 : make MajorCompaction controlled by time of the day/day of the week
sijie 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_r158773407
##########
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:
Based on my understanding to this logic, the crons are used for adjusting major compaction thresholds. that means major compaction interval should be smaller than the interval that cron runs, otherwise the logic won't work here, right?
----------------------------------------------------------------
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:
users@infra.apache.org
With regards,
Apache Git Services