use of org.apache.hadoop.hive.ql.txn.compactor.Cleaner in project hive by apache.
the class TestTxnCommands2 method runCleaner.
public static void runCleaner(HiveConf hiveConf) throws MetaException {
AtomicBoolean stop = new AtomicBoolean(true);
Cleaner t = new Cleaner();
t.setThreadId((int) t.getId());
t.setHiveConf(hiveConf);
AtomicBoolean looped = new AtomicBoolean();
t.init(stop, looped);
t.run();
}
use of org.apache.hadoop.hive.ql.txn.compactor.Cleaner in project hive by apache.
the class TestTxnCommands2 method writeBetweenWorkerAndCleanerForVariousTblProperties.
protected void writeBetweenWorkerAndCleanerForVariousTblProperties(String tblProperties) throws Exception {
String tblName = "hive12352";
runStatementOnDriver("drop table if exists " + tblName);
runStatementOnDriver("CREATE TABLE " + tblName + "(a INT, b STRING) " + //currently ACID requires table to be bucketed
" CLUSTERED BY(a) INTO 1 BUCKETS" + " STORED AS ORC TBLPROPERTIES ( " + tblProperties + " )");
//create some data
runStatementOnDriver("insert into " + tblName + " values(1, 'foo'),(2, 'bar'),(3, 'baz')");
runStatementOnDriver("update " + tblName + " set b = 'blah' where a = 3");
//run Worker to execute compaction
TxnStore txnHandler = TxnUtils.getTxnStore(hiveConf);
txnHandler.compact(new CompactionRequest("default", tblName, CompactionType.MINOR));
Worker t = new Worker();
t.setThreadId((int) t.getId());
t.setHiveConf(hiveConf);
AtomicBoolean stop = new AtomicBoolean(true);
AtomicBoolean looped = new AtomicBoolean();
t.init(stop, looped);
t.run();
//delete something, but make sure txn is rolled back
hiveConf.setBoolVar(HiveConf.ConfVars.HIVETESTMODEROLLBACKTXN, true);
runStatementOnDriver("delete from " + tblName + " where a = 1");
hiveConf.setBoolVar(HiveConf.ConfVars.HIVETESTMODEROLLBACKTXN, false);
List<String> expected = new ArrayList<>();
expected.add("1\tfoo");
expected.add("2\tbar");
expected.add("3\tblah");
Assert.assertEquals("", expected, runStatementOnDriver("select a,b from " + tblName + " order by a"));
//run Cleaner
Cleaner c = new Cleaner();
c.setThreadId((int) c.getId());
c.setHiveConf(hiveConf);
c.init(stop, new AtomicBoolean());
c.run();
//this seems odd, but we wan to make sure that to run CompactionTxnHandler.cleanEmptyAbortedTxns()
Initiator i = new Initiator();
i.setThreadId((int) i.getId());
i.setHiveConf(hiveConf);
i.init(stop, new AtomicBoolean());
i.run();
//check that aborted operation didn't become committed
Assert.assertEquals("", expected, runStatementOnDriver("select a,b from " + tblName + " order by a"));
}
Aggregations