public void compact(final Path path, final boolean compactOnce, final boolean major)
      throws IOException {
      if (isFamilyDir(fs, path)) {
        Path regionDir = path.getParent();
        Path tableDir = regionDir.getParent();
        TableDescriptor htd = FSTableDescriptors.getTableDescriptorFromFs(fs, tableDir);
        RegionInfo hri = HRegionFileSystem.loadRegionInfoFileContent(fs, regionDir);
        compactStoreFiles(tableDir, htd, hri, path.getName(), compactOnce, major);
      } else if (isRegionDir(fs, path)) {
        Path tableDir = path.getParent();
        TableDescriptor htd = FSTableDescriptors.getTableDescriptorFromFs(fs, tableDir);
        compactRegion(tableDir, htd, path, compactOnce, major);
      } else if (isTableDir(fs, path)) {
        compactTable(path, compactOnce, major);
      } else {
        throw new IOException(
          "Specified path is not a table, region or family directory. path=" + path);
      }
    }
Execute the compaction on the specified path.
@param path        Directory path on which to run compaction.
@param compactOnce Execute just a single step of compaction.
@param major       Request major compaction.
hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/regionserver/CompactionTool.java