@Override
    protected void chore() {
      for (HRegion hr : this.instance.onlineRegions.values()) {
        // If region is read only or compaction is disabled at table level, there's no need to
        // iterate through region's stores
        if (hr == null || hr.isReadOnly() || !hr.getTableDescriptor().isCompactionEnabled()) {
          continue;
        }

        for (HStore s : hr.stores.values()) {
          try {
            long multiplier = s.getCompactionCheckMultiplier();
            assert multiplier > 0;
            if (iteration % multiplier != 0) {
              continue;
            }
            if (s.needsCompaction()) {
              // Queue a compaction. Will recognize if major is needed.
              this.instance.compactSplitThread.requestSystemCompaction(hr, s,
                getName() + " requests compaction");
            } else if (s.shouldPerformMajorCompaction()) {
              s.triggerMajorCompaction();
              if (
                majorCompactPriority == DEFAULT_PRIORITY
                  || majorCompactPriority > hr.getCompactPriority()
              ) {
                this.instance.compactSplitThread.requestCompaction(hr, s,
                  getName() + " requests major compaction; use default priority", Store.NO_PRIORITY,
                  CompactionLifeCycleTracker.DUMMY, null);
              } else {
                this.instance.compactSplitThread.requestCompaction(hr, s,
                  getName() + " requests major compaction; use configured priority",
                  this.majorCompactPriority, CompactionLifeCycleTracker.DUMMY, null);
              }
            }
          } catch (IOException e) {
            LOG.warn("Failed major compaction check on " + hr, e);
          }
        }
      }
      iteration = (iteration == Long.MAX_VALUE) ? 0 : (iteration + 1);
    }
Inner class that runs on a long period checking if regions need compaction.
hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java