private void compactStoreFiles(final Path tableDir, final TableDescriptor htd,
      final RegionInfo hri, final String familyName, final boolean compactOnce, final boolean major)
      throws IOException {
      HStore store = getStore(conf, fs, tableDir, htd, hri, familyName);
      LOG.info("Compact table=" + htd.getTableName() + " region=" + hri.getRegionNameAsString()
        + " family=" + familyName);
      if (major) {
        store.triggerMajorCompaction();
      }
      do {
        Optional<CompactionContext> compaction =
          store.requestCompaction(PRIORITY_USER, CompactionLifeCycleTracker.DUMMY, null);
        if (!compaction.isPresent()) {
          break;
        }
        List<HStoreFile> storeFiles =
          store.compact(compaction.get(), NoLimitThroughputController.INSTANCE, null);
        if (storeFiles != null && !storeFiles.isEmpty()) {
          if (deleteCompacted) {
            for (HStoreFile storeFile : storeFiles) {
              fs.delete(storeFile.getPath(), false);
            }
          }
        }
      } while (store.needsCompaction() && !compactOnce);
      // We need to close the store properly, to make sure it will archive compacted files
      store.close();
    }
Execute the actual compaction job. If the compact once flag is not specified, execute the
compaction until no more compactions are needed. Uses the Configuration settings provided.
hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/regionserver/CompactionTool.java