@Test public void cleanupAfterMinorPartitionCompaction() throws Exception { Table t = newTable("default", "camipc", true); Partition p = newPartition(t, "today");
@Test public void cleanupAfterMajorPartitionCompaction() throws Exception { Table t = newTable("default", "campc", true); Partition p = newPartition(t, "today"); addBaseFile(t, p, 20L, 20); addDeltaFile(t, p, 21L, 22L, 2); addDeltaFile(t, p, 23L, 24L, 2); addBaseFile(t, p, 25L, 25); burnThroughTransactions("default", "campc", 25); CompactionRequest rqst = new CompactionRequest("default", "campc", CompactionType.MAJOR); rqst.setPartitionname("ds=today"); txnHandler.compact(rqst); CompactionInfo ci = txnHandler.findNextToCompact("fred"); ci.runAs = System.getProperty("user.name"); txnHandler.updateCompactorState(ci, openTxn()); txnHandler.markCompacted(ci); startCleaner(); // Check there are no compactions requests left. ShowCompactResponse rsp = txnHandler.showCompact(new ShowCompactRequest()); Assert.assertEquals(1, rsp.getCompactsSize()); Assert.assertTrue(TxnStore.SUCCEEDED_RESPONSE.equals(rsp.getCompacts().get(0).getState())); // Check that the files are removed List<Path> paths = getDirectories(conf, t, p); Assert.assertEquals(1, paths.size()); Assert.assertEquals("base_25", paths.get(0).getName()); }
@Test public void cleanupAfterMajorPartitionCompactionNoBase() throws Exception { Table t = newTable("default", "campcnb", true); Partition p = newPartition(t, "today"); addDeltaFile(t, p, 1L, 22L, 22); addDeltaFile(t, p, 23L, 24L, 2); addBaseFile(t, p, 25L, 25); burnThroughTransactions("default", "campcnb", 25); CompactionRequest rqst = new CompactionRequest("default", "campcnb", CompactionType.MAJOR); rqst.setPartitionname("ds=today"); txnHandler.compact(rqst); CompactionInfo ci = txnHandler.findNextToCompact("fred"); txnHandler.markCompacted(ci); ci.runAs = System.getProperty("user.name"); txnHandler.updateCompactorState(ci, openTxn()); startCleaner(); // Check there are no compactions requests left. ShowCompactResponse rsp = txnHandler.showCompact(new ShowCompactRequest()); Assert.assertEquals(1, rsp.getCompactsSize()); Assert.assertTrue(TxnStore.SUCCEEDED_RESPONSE.equals(rsp.getCompacts().get(0).getState())); // Check that the files are removed List<Path> paths = getDirectories(conf, t, p); Assert.assertEquals(1, paths.size()); Assert.assertEquals("base_25", paths.get(0).getName()); }
@Test public void droppedPartition() throws Exception { Table t = newTable("default", "dp", true); Partition p = newPartition(t, "today"); addDeltaFile(t, p, 1L, 22L, 22); addDeltaFile(t, p, 23L, 24L, 2); addBaseFile(t, p, 25L, 25); burnThroughTransactions("default", "dp", 25); CompactionRequest rqst = new CompactionRequest("default", "dp", CompactionType.MAJOR); rqst.setPartitionname("ds=today"); txnHandler.compact(rqst); CompactionInfo ci = txnHandler.findNextToCompact("fred"); ci.runAs = System.getProperty("user.name"); txnHandler.updateCompactorState(ci, openTxn()); txnHandler.markCompacted(ci); // Drop partition will clean the partition entry from the compaction queue and hence cleaner have no effect ms.dropPartition("default", "dp", Collections.singletonList("today"), true); startCleaner(); // Check there are no compactions requests left. ShowCompactResponse rsp = txnHandler.showCompact(new ShowCompactRequest()); Assert.assertEquals(0, rsp.getCompactsSize()); } @Override