Search in sources :

Example 6 with UnlockRequest

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());
}
Also used : LockComponent(org.apache.hadoop.hive.metastore.api.LockComponent) LockResponse(org.apache.hadoop.hive.metastore.api.LockResponse) ArrayList(java.util.ArrayList) CheckLockRequest(org.apache.hadoop.hive.metastore.api.CheckLockRequest) LockRequest(org.apache.hadoop.hive.metastore.api.LockRequest) CheckLockRequest(org.apache.hadoop.hive.metastore.api.CheckLockRequest) UnlockRequest(org.apache.hadoop.hive.metastore.api.UnlockRequest) Test(org.junit.Test)

Aggregations

LockRequest (org.apache.hadoop.hive.metastore.api.LockRequest)6 LockResponse (org.apache.hadoop.hive.metastore.api.LockResponse)6 UnlockRequest (org.apache.hadoop.hive.metastore.api.UnlockRequest)6 ArrayList (java.util.ArrayList)5 LockComponent (org.apache.hadoop.hive.metastore.api.LockComponent)5 Test (org.junit.Test)5 CheckLockRequest (org.apache.hadoop.hive.metastore.api.CheckLockRequest)3 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 CompactionRequest (org.apache.hadoop.hive.metastore.api.CompactionRequest)2 ShowCompactRequest (org.apache.hadoop.hive.metastore.api.ShowCompactRequest)2 ShowCompactResponse (org.apache.hadoop.hive.metastore.api.ShowCompactResponse)2 ShowCompactResponseElement (org.apache.hadoop.hive.metastore.api.ShowCompactResponseElement)2 Table (org.apache.hadoop.hive.metastore.api.Table)2 TxnOpenException (org.apache.hadoop.hive.metastore.api.TxnOpenException)2 CompactionInfo (org.apache.hadoop.hive.metastore.txn.CompactionInfo)2 ValidReaderWriteIdList (org.apache.hadoop.hive.common.ValidReaderWriteIdList)1 ValidTxnList (org.apache.hadoop.hive.common.ValidTxnList)1 NoSuchLockException (org.apache.hadoop.hive.metastore.api.NoSuchLockException)1 NoSuchTxnException (org.apache.hadoop.hive.metastore.api.NoSuchTxnException)1 Partition (org.apache.hadoop.hive.metastore.api.Partition)1