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 2018/01/02 21:37:09 UTC

[GitHub] dlg99 commented on issue #851: Issue 578 : make MajorCompaction controlled by time of the day/day of the week

dlg99 commented on issue #851: Issue 578 : make MajorCompaction controlled by time of the day/day of the week
URL: https://github.com/apache/bookkeeper/pull/851#issuecomment-354881643
 
 
   @sijie I'll take a look at the change.
   
   I did functionally similar change but it ended up being unused due to less than predictable schedule in our pre-prod env and work in progress on having multiple active ledgers to eliminate compaction completely. 
   We are pretty much planning to drop time-based configuration but if you feel that this is helpful to community I can merge/do a pull req for it to the community code.
   
   My approach was slightly different:
   
   abstract config allowed one to specify time ranges and any parameter could be enabled to make use of it:
   ```text
       ## Some settings support configuration override for specific time range.
      ## For example one can set:
      ## gcWaitTime=1800000
      ## gcWaitTime@timerange0=900000
      ## 
      ## Time ranges defined as:
      ## <rangename>.start=<start time>
      ## <rangename>.end=<end time>
      ## Optional:
      ## <rangename>.day=<comma-separated list of days of the week>
      ## <rangename> consists of prefix "timerange" plus numeric id.
      ## Numeric id starts from 0 and incremented by 1. 
      ## Search for ranges stops on the first missing id and/or on the first range that misses 
      ## or has wrong value for the time or day.
      ## 
      ## Start and end time defined in ISO_LOCAL_TIME format (24 hr, local time zone)
      ## 
      ## Time ranges can overlap because different ranges can be applied to different groups of
      ## parameters.
      ## 
      ## Examples:
      ## 
      ## timerange0.start=09:00:00
      ## timerange0.end=17:59:59.999
      ## 
      ## timerange1.start=22:00
      ## timerange1.end=23:00
      ## timerange1.day=Saturday,Sunday
      ## 
      ## minorCompactionThreshold=0.2
      ## minorCompactionThreshold@timerange0=0.1
      ## 
      ## minorCompactionInterval=3600
      ## minorCompactionInterval@timerange0=1800
      ## 
      ## majorCompactionThreshold=0.3
      ## majorCompactionThreshold@timerange0=0.2
      ## majorCompactionThreshold@timerange1=0.5
      ## 
      ## majorCompactionInterval=86400 
      ## majorCompactionInterval@timerange1=1800 
   ```
   
   ```java
       public double getMinorCompactionThreshold(LocalTime now, DayOfWeek day) {
           return getDouble(this.getPropertyNameForFirstActiveTimerange(MINOR_COMPACTION_THRESHOLD, now, day), 0.2f);
       }
   ```
   
   and in compaction thread I had to make sure that parameters are refreshed before each use like:
   
   ```java
       refreshGcConfigParams(conf.getLocalTime(), conf.getDayOfWeek());
       ....
       private void refreshGcConfigParams(LocalTime now, DayOfWeek day) {
           gcWaitTime = conf.getGcWaitTime(now, day);
           minorCompactionThreshold = conf.getMinorCompactionThreshold(now, day);
           minorCompactionInterval = conf.getMinorCompactionInterval(now, day) * SECOND;
           majorCompactionThreshold = conf.getMajorCompactionThreshold(now, day);
           majorCompactionInterval = conf.getMajorCompactionInterval(now, day) * SECOND;
          .....
   ```

----------------------------------------------------------------
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