use of org.apache.hadoop.hive.metastore.api.UnlockRequest in project hive by apache.
the class TestTxnHandler method testMultipleLock.
@Test
public void testMultipleLock() throws Exception {
// Test more than one lock can be handled in a lock request
LockComponent comp = new LockComponent(LockType.EXCLUSIVE, LockLevel.DB, "mydb");
comp.setTablename("mytable");
comp.setPartitionname("mypartition=myvalue");
comp.setOperationType(DataOperationType.NO_TXN);
List<LockComponent> components = new ArrayList<LockComponent>(2);
components.add(comp);
comp = new LockComponent(LockType.EXCLUSIVE, LockLevel.DB, "mydb");
comp.setTablename("mytable");
comp.setPartitionname("anotherpartition=anothervalue");
comp.setOperationType(DataOperationType.NO_TXN);
components.add(comp);
LockRequest req = new LockRequest(components, "me", "localhost");
LockResponse res = txnHandler.lock(req);
long lockid = res.getLockid();
assertTrue(res.getState() == LockState.ACQUIRED);
res = txnHandler.checkLock(new CheckLockRequest(lockid));
assertTrue(res.getState() == LockState.ACQUIRED);
txnHandler.unlock(new UnlockRequest(lockid));
assertEquals(0, txnHandler.numLocksInLockTable());
}
Aggregations