Index: hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/CompactionTool.java =================================================================== --- hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/CompactionTool.java (revision 1482828) +++ hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/CompactionTool.java (working copy) @@ -80,14 +80,12 @@ private final static String CONF_TMP_DIR = "hbase.tmp.dir"; private final static String CONF_COMPACT_ONCE = "hbase.compactiontool.compact.once"; private final static String CONF_DELETE_COMPACTED = "hbase.compactiontool.delete"; - private final static String CONF_COMPLETE_COMPACTION = "hbase.hstore.compaction.complete"; /** * Class responsible to execute the Compaction on the specified path. * The path can be a table, region or family directory. */ private static class CompactionWorker { - private final boolean keepCompactedFiles; private final boolean deleteCompacted; private final Configuration conf; private final FileSystem fs; @@ -95,7 +93,6 @@ public CompactionWorker(final FileSystem fs, final Configuration conf) { this.conf = conf; - this.keepCompactedFiles = !conf.getBoolean(CONF_COMPLETE_COMPACTION, true); this.deleteCompacted = conf.getBoolean(CONF_DELETE_COMPACTED, false); this.tmpDir = new Path(conf.get(CONF_TMP_DIR)); this.fs = fs; @@ -159,7 +156,7 @@ if (compaction == null) break; List storeFiles = store.compact(compaction); if (storeFiles != null && !storeFiles.isEmpty()) { - if (keepCompactedFiles && deleteCompacted) { + if (deleteCompacted) { for (StoreFile storeFile: storeFiles) { fs.delete(storeFile.getPath(), false); } @@ -438,7 +435,6 @@ System.err.println(); System.err.println("Note: -D properties will be applied to the conf used. "); System.err.println("For example: "); - System.err.println(" To preserve input files, pass -D"+CONF_COMPLETE_COMPACTION+"=false"); System.err.println(" To stop delete of compacted file, pass -D"+CONF_DELETE_COMPACTED+"=false"); System.err.println(" To set tmp dir, pass -D"+CONF_TMP_DIR+"=ALTERNATE_DIR"); System.err.println(); Index: hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HStore.java =================================================================== --- hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HStore.java (revision 1482828) +++ hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HStore.java (working copy) @@ -960,17 +960,7 @@ try { // Commence the compaction. List newFiles = compaction.compact(); - // TODO: get rid of this! - if (!this.conf.getBoolean("hbase.hstore.compaction.complete", true)) { - LOG.warn("hbase.hstore.compaction.complete is set to false"); - sfs = new ArrayList(); - for (Path newFile : newFiles) { - // Create storefile around what we wrote with a reader on it. - StoreFile sf = createStoreFileAndReader(newFile); - sfs.add(sf); - } - return sfs; - } + // Do the steps necessary to complete the compaction. sfs = moveCompatedFilesIntoPlace(cr, newFiles); writeCompactionWalRecord(filesToCompact, sfs); Index: hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java =================================================================== --- hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java (revision 1482828) +++ hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java (working copy) @@ -386,99 +386,7 @@ } } - @Test - public void testRecoveredEditsReplayCompaction() throws Exception { - String method = "testRecoveredEditsReplayCompaction"; - byte[] tableName = Bytes.toBytes(method); - byte[] family = Bytes.toBytes("family"); - this.region = initHRegion(tableName, method, conf, family); - try { - Path regiondir = region.getRegionFileSystem().getRegionDir(); - FileSystem fs = region.getRegionFileSystem().getFileSystem(); - byte[] regionName = region.getRegionInfo().getEncodedNameAsBytes(); - - long maxSeqId = 3; - long minSeqId = 0; - - for (long i = minSeqId; i < maxSeqId; i++) { - Put put = new Put(Bytes.toBytes(i)); - put.add(family, Bytes.toBytes(i), Bytes.toBytes(i)); - region.put(put); - region.flushcache(); - } - - //this will create a region with 3 files - assertEquals(3, region.getStore(family).getStorefilesCount()); - List storeFiles = new ArrayList(3); - for (StoreFile sf : region.getStore(family).getStorefiles()) { - storeFiles.add(sf.getPath()); - } - - //disable compaction completion - conf.setBoolean("hbase.hstore.compaction.complete",false); - region.compactStores(); - - //ensure that nothing changed - assertEquals(3, region.getStore(family).getStorefilesCount()); - - //now find the compacted file, and manually add it to the recovered edits - Path tmpDir = region.getRegionFileSystem().getTempDir(); - FileStatus[] files = FSUtils.listStatus(fs, tmpDir); - String errorMsg = "Expected to find 1 file in the region temp directory " + - "from the compaction, could not find any"; - assertNotNull(errorMsg, files); - assertEquals(errorMsg, 1, files.length); - //move the file inside region dir - Path newFile = region.getRegionFileSystem().commitStoreFile(Bytes.toString(family), files[0].getPath()); - - CompactionDescriptor compactionDescriptor = ProtobufUtil.toCompactionDescriptor( - this.region.getRegionInfo(), family, - storeFiles, Lists.newArrayList(newFile), - region.getRegionFileSystem().getStoreDir(Bytes.toString(family))); - - HLogUtil.writeCompactionMarker(region.getLog(), this.region.getTableDesc(), - this.region.getRegionInfo(), compactionDescriptor); - - Path recoveredEditsDir = HLogUtil.getRegionDirRecoveredEditsDir(regiondir); - - Path recoveredEdits = new Path(recoveredEditsDir, String.format("%019d", 1000)); - fs.create(recoveredEdits); - HLog.Writer writer = HLogFactory.createWriter(fs, recoveredEdits, conf); - - long time = System.nanoTime(); - - writer.append(new HLog.Entry(new HLogKey(regionName, tableName, 10, time, HConstants.DEFAULT_CLUSTER_ID), - WALEdit.createCompaction(compactionDescriptor))); - writer.close(); - - //close the region now, and reopen again - HTableDescriptor htd = region.getTableDesc(); - HRegionInfo info = region.getRegionInfo(); - region.close(); - region = HRegion.openHRegion(conf, fs, regiondir.getParent().getParent(), info, htd, null); - - //now check whether we have only one store file, the compacted one - Collection sfs = region.getStore(family).getStorefiles(); - for (StoreFile sf : sfs) { - LOG.info(sf.getPath()); - } - assertEquals(1, region.getStore(family).getStorefilesCount()); - files = FSUtils.listStatus(fs, tmpDir); - assertTrue("Expected to find 0 files inside " + tmpDir, - files == null || files.length == 0); - - for (long i = minSeqId; i < maxSeqId; i++) { - Get get = new Get(Bytes.toBytes(i)); - Result result = region.get(get); - byte[] value = result.getValue(family, Bytes.toBytes(i)); - assertEquals(Bytes.toBytes(i), value); - } - } finally { - HRegion.closeHRegion(this.region); - this.region = null; - } - } - + public void testGetWhileRegionClose() throws IOException { Configuration hc = initSplit(); int numRows = 100;