0.95.2, 0.94.9 버전부터 shell에서 major compation 명령을 내릴 수 있다. 


Usage: java org.apache.hadoop.hbase.regionserver.CompactionTool \

[-compactOnce] [-major] [-mapred] [-D<property=value>]* files...


중요 코드

public class CompactionTool extends Configured implements Tool {

 /**

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

     */

    private void compactStoreFiles(final Path tableDir, final HTableDescriptor htd,

        final HRegionInfo hri, final String familyName, final boolean compactOnce,

        final boolean major) throws IOException {

      HStore store = getStore(conf, fs, tableDir, htd, hri, familyName, tmpDir);

      LOG.info("Compact table=" + htd.getNameAsString() +

        " region=" + hri.getRegionNameAsString() +

        " family=" + familyName);

      if (major) {

        store.triggerMajorCompaction();

      }

      do {

        CompactionContext compaction = store.requestCompaction(Store.PRIORITY_USER, null);

        if (compaction == null) break;

        List<StoreFile> storeFiles = store.compact(compaction);

        if (storeFiles != null && !storeFiles.isEmpty()) {

          if (keepCompactedFiles && deleteCompacted) {

            for (StoreFile storeFile: storeFiles) {

              fs.delete(storeFile.getPath(), false);

            }

          }

        }

      } while (store.needsCompaction() && !compactOnce);

    }


더 깊이 보면, 내부소스상 CompactionContext의 select 메소드를 호출한다.



출처 :

Add major compaction support in CompactionTool

https://issues.apache.org/jira/browse/HBASE-8683


'nosql' 카테고리의 다른 글

[hbase] ROOT catalog table 삭제  (0) 2013.06.20
[hbase] 제한적인 트랙잭션  (0) 2013.06.20
hbase - block, block cache 공부  (0) 2013.06.07
hbase 사용사례 발견  (0) 2013.06.07
[hbase] MSLAB (MemStore-Local Allocation Buffer) 공부  (1) 2013.06.05
Posted by '김용환'
,