use of org.apache.hadoop.hive.ql.QueryPlan in project hive by apache.
the class TestDbTxnManager method testRollback.
@Test
public void testRollback() throws Exception {
WriteEntity we = addTableOutput(WriteEntity.WriteType.DELETE);
QueryPlan qp = new MockQueryPlan(this, HiveOperation.QUERY);
txnMgr.openTxn(ctx, "fred");
txnMgr.acquireLocks(qp, ctx, "fred");
List<HiveLock> locks = ctx.getHiveLocks();
Assert.assertEquals(1, locks.size());
Assert.assertEquals(1, TxnDbUtil.countLockComponents(conf, ((DbLockManager.DbHiveLock) locks.get(0)).lockId));
txnMgr.rollbackTxn();
locks = txnMgr.getLockManager().getLocks(false, false);
Assert.assertEquals(0, locks.size());
}
use of org.apache.hadoop.hive.ql.QueryPlan in project hive by apache.
the class TestDbTxnManager method testLockAcquisitionAndRelease.
@Test
public void testLockAcquisitionAndRelease() throws Exception {
addTableInput();
QueryPlan qp = new MockQueryPlan(this, HiveOperation.QUERY);
txnMgr.openTxn(ctx, "fred");
txnMgr.acquireLocks(qp, ctx, "fred");
List<HiveLock> locks = ctx.getHiveLocks();
Assert.assertEquals(1, locks.size());
txnMgr.commitTxn();
locks = txnMgr.getLockManager().getLocks(false, false);
Assert.assertEquals(0, locks.size());
}
use of org.apache.hadoop.hive.ql.QueryPlan in project hive by apache.
the class TestDbTxnManager method testDelete.
@Test
public void testDelete() throws Exception {
WriteEntity we = addTableOutput(WriteEntity.WriteType.DELETE);
QueryPlan qp = new MockQueryPlan(this, HiveOperation.QUERY);
txnMgr.openTxn(ctx, "fred");
txnMgr.acquireLocks(qp, ctx, "fred");
List<HiveLock> locks = ctx.getHiveLocks();
Assert.assertEquals(1, locks.size());
Assert.assertEquals(1, TxnDbUtil.countLockComponents(conf, ((DbLockManager.DbHiveLock) locks.get(0)).lockId));
txnMgr.commitTxn();
locks = txnMgr.getLockManager().getLocks(false, false);
Assert.assertEquals(0, locks.size());
}
use of org.apache.hadoop.hive.ql.QueryPlan in project hive by apache.
the class TestDbTxnManager method testDDLNoLock.
@Test
public void testDDLNoLock() throws Exception {
WriteEntity we = addTableOutput(WriteEntity.WriteType.DDL_NO_LOCK);
QueryPlan qp = new MockQueryPlan(this, HiveOperation.CREATEDATABASE);
txnMgr.openTxn(ctx, "fred");
txnMgr.acquireLocks(qp, ctx, "fred");
List<HiveLock> locks = ctx.getHiveLocks();
Assert.assertNull(locks);
txnMgr.rollbackTxn();
}
use of org.apache.hadoop.hive.ql.QueryPlan in project hive by apache.
the class TestDbTxnManager method testSingleReadMultiPartition.
@Test
public void testSingleReadMultiPartition() throws Exception {
Table t = newTable(true);
addPartitionInput(t);
addPartitionInput(t);
addPartitionInput(t);
QueryPlan qp = new MockQueryPlan(this, HiveOperation.QUERY);
txnMgr.openTxn(ctx, "fred");
txnMgr.acquireLocks(qp, ctx, "fred");
List<HiveLock> locks = ctx.getHiveLocks();
Assert.assertEquals(1, locks.size());
Assert.assertEquals(3, TxnDbUtil.countLockComponents(conf, ((DbLockManager.DbHiveLock) locks.get(0)).lockId));
txnMgr.commitTxn();
locks = txnMgr.getLockManager().getLocks(false, false);
Assert.assertEquals(0, locks.size());
}
Aggregations